Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r58584 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates templates/level1
From: rutger_at_[hidden]
Date: 2009-12-30 10:20:40


Author: rutger
Date: 2009-12-30 10:20:39 EST (Wed, 30 Dec 2009)
New Revision: 58584
URL: http://svn.boost.org/trac/boost/changeset/58584

Log:
added support for post-processing search replace entries to fix cblas' part of dotc

Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/bindings.py | 16 ++++++++++++++++
   sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py | 1 +
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 12 +++++++++---
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp | 2 +-
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level1/dotc.hpp | 6 ++++++
   5 files changed, 33 insertions(+), 4 deletions(-)

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/bindings.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/bindings.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/bindings.py 2009-12-30 10:20:39 EST (Wed, 30 Dec 2009)
@@ -289,4 +289,20 @@
 def value_type( arg ):
     return 'typename value< ' + arg + ' >::type'
 
+#
+# Search replace stuff for handling exceptional cases through the
+# templating system
+#
+
+def search_replace( source, key_name, template_map ):
+ print "Trying key ", key_name
+ if key_name not in template_map:
+ return source
+ result = source
+ for search_replace in template_map[ key_name ].split( "--" ):
+ if "->" in search_replace:
+ splitted = search_replace.split("->")
+ print "Replacing '" + splitted[0] + "' with '" + splitted[1] + "'"
+ result = result.replace( splitted[0], splitted[1] )
+ return result
 

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py 2009-12-30 10:20:39 EST (Wed, 30 Dec 2009)
@@ -130,6 +130,7 @@
         sub_template = sub_template.replace( '$groupname', group_name.lower() )
         sub_template = sub_template.replace( '$RETURN_TYPE', info_map[ subroutine ][ 'return_value_type' ] )
         sub_template = sub_template.replace( '$RETURN_STATEMENT', info_map[ subroutine ][ 'return_statement' ] )
+ sub_template = bindings.search_replace( sub_template, group_name.lower() + '.level0.gsub', template_map )
 
         sub_overloads += bindings.proper_indent( sub_template )
 

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py 2009-12-30 10:20:39 EST (Wed, 30 Dec 2009)
@@ -41,6 +41,12 @@
 
 templates = {}
 
+def return_type( fortran_type ):
+ m_type_map = global_type_map
+ m_type_map[ 'COMPLEX' ] = complex_float_type
+ m_type_map[ 'COMPLEX*16' ] = complex_double_type
+ m_type_map[ 'DOUBLE COMPLEX' ] = complex_double_type
+ return m_type_map[ fortran_type ]
 
 def value_type( fortran_type ):
   m_type_map = global_type_map
@@ -704,9 +710,9 @@
 
 
 
-
+#
 # try different keys, return the one that exists, if any
-
+#
 def my_has_key( key_name, template_map ):
   # try, e.g., gelsd.all.
   m_all_key = key_name.replace( ".complex", ".all" ).replace( ".real", ".all" )
@@ -1435,7 +1441,7 @@
   info_map[ 'argument_map' ] = argument_map
   info_map[ 'grouped_arguments' ] = grouped_arguments
   if subroutine_return_type != None:
- info_map[ 'return_value_type' ] = value_type( subroutine_return_type )
+ info_map[ 'return_value_type' ] = return_type( subroutine_return_type )
     info_map[ 'level1_return_type' ] = 'value_type'
     info_map[ 'return_statement' ] = 'return '
   else:

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/lapack.hpp 2009-12-30 10:20:39 EST (Wed, 30 Dec 2009)
@@ -82,7 +82,7 @@
 // for dispatching to $groupname.
 //
 template< typename Value, typename Enable = void >
-struct $groupname_impl{};
+struct $groupname_impl {};
 
 $TEMPLATE[level1_header1]
 //

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level1/dotc.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level1/dotc.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level1/dotc.hpp 2009-12-30 10:20:39 EST (Wed, 30 Dec 2009)
@@ -11,4 +11,10 @@
  Y (input) DATATYPE
 $TEMPLATE[dotc.friendly_name]
 TODO
+$TEMPLATE[dotc.level0.gsub]
+return cblas_cdotc_sub( n, x, incx, y, incy );->std::complex<float> result;
+ cblas_cdotc_sub( n, x, incx, y, incy, &result );
+ return result;--return cblas_zdotc_sub( n, x, incx, y, incy );->std::complex<double> result;
+ cblas_zdotc_sub( n, x, incx, y, incy, &result );
+ return result;--
 $TEMPLATE[end]


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk