Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r59087 - in sandbox/numeric_bindings/libs/numeric/bindings/tools: . templates/level1
From: rutger_at_[hidden]
Date: 2010-01-17 05:44:09


Author: rutger
Date: 2010-01-17 05:44:08 EST (Sun, 17 Jan 2010)
New Revision: 59087
URL: http://svn.boost.org/trac/boost/changeset/59087

Log:
added support for overloading some of the generated code to support level1/scal

Text files modified:
   sandbox/numeric_bindings/libs/numeric/bindings/tools/blas_generator.py | 28 ++++++++++++++++++----------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/netlib.py | 27 ++++++++++++++++-----------
   sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level1/scal.hpp | 10 ++++++++++
   3 files changed, 44 insertions(+), 21 deletions(-)

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 2010-01-17 05:44:08 EST (Sun, 17 Jan 2010)
@@ -271,14 +271,17 @@
           arg_A = static_asserts[0]
           for arg_B in static_asserts[1:]:
             print "Adding static assert for argA", arg_A, " argb", arg_B
- assert_line = 'BOOST_STATIC_ASSERT( (is_same< ' + \
- 'typename remove_const< typename value< ' + info_map[ subroutine ][ 'argument_map' ][ arg_A ][ 'code' ][ 'level_1_static_assert' ] + ' >::type >::type, ' + \
- 'typename remove_const< typename value< ' + info_map[ subroutine ][ 'argument_map' ][ arg_B ][ 'code' ][ 'level_1_static_assert' ] + ' >::type >::type' \
- ' >::value) );'
- if not has_comment:
- #level1_static_assert_list += [ '// Here, we assert... ' ]
- has_comment = True
- level1_static_assert_list += [ assert_line ]
+ arg_left = info_map[ subroutine ][ 'argument_map' ][ arg_A ][ 'code' ][ 'level_1_static_assert' ]
+ arg_right = info_map[ subroutine ][ 'argument_map' ][ arg_B ][ 'code' ][ 'level_1_static_assert' ]
+ if arg_left != None and arg_right != None:
+ assert_line = 'BOOST_STATIC_ASSERT( (is_same< ' + \
+ 'typename remove_const< typename value< ' + arg_left + ' >::type >::type, ' + \
+ 'typename remove_const< typename value< ' + arg_right + ' >::type >::type' \
+ ' >::value) );'
+ if not has_comment:
+ #level1_static_assert_list += [ '// Here, we assert... ' ]
+ has_comment = True
+ level1_static_assert_list += [ assert_line ]
 
       # Make sure the mutable stuff is mutable
       if 'output' in info_map[ subroutine ][ 'grouped_arguments' ][ 'by_io' ]:
@@ -357,8 +360,13 @@
       #level2_template = level2_template.replace( "$LEVEL2", ", ".join( level2_arg_list ) )
 
       if len(level1_type_arg_list)>0:
- first_typename = level1_type_arg_list[0].split(" ")[-1]
- first_typename_datatype = first_typename[0:6].lower() # 'matrix' or 'vector'
+ my_key = group_name.lower() + '.' + value_type + '.first_typename'
+ if netlib.my_has_key( my_key, template_map ):
+ first_typename = template_map[ netlib.my_has_key( \
+ my_key, template_map ) ].strip()
+ else:
+ first_typename = level1_type_arg_list[0].split(" ")[-1]
+ first_typename_datatype = first_typename[0:6].lower() # 'matrix' or 'vector' or 'scalar'
       else:
         level1_type_arg_list.insert( 0, 'typename Value' )
         first_typename = 'Value'

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 2010-01-17 05:44:08 EST (Sun, 17 Jan 2010)
@@ -784,7 +784,7 @@
   if template_map.has_key( m_all_key ):
     print "using key ", m_all_key
     return m_all_key
- print "tried keys ", key_name, "and", m_all_key,", no results"
+ #print "tried keys ", key_name, "and", m_all_key,", no results"
   return None
 
 
@@ -1551,11 +1551,6 @@
   #
   argument_map.update( user_defined_arg_map )
 
-
- print "Argument map: "
- pp.pprint( argument_map )
-
-
   #
   # Make a back-reference for
   # * workspace queries
@@ -1610,11 +1605,18 @@
     argument_properties[ 'code' ][ 'user_defined_init' ] = user_defined_type( argument_name, argument_properties, argument_map )
     argument_properties[ 'code' ][ 'typedef' ] = typedef_type( argument_name, argument_properties, argument_map )
 
- print "Argument map: "
- pp.pprint( argument_map )
-
- print "Grouped arguments: "
- pp.pprint( grouped_arguments )
+ # Pass 3
+ # Try to see if a template overrides the code
+ for argument_name, argument_properties in argument_map.iteritems():
+ for call_type in [ 'level_1', 'level_1_type', 'level_1_static_assert', 'level_2' ]:
+ my_key = subroutine_group_name.lower() + '.' + subroutine_value_type + \
+ '.' + argument_name + '.code.' + call_type
+ print "Looking for key ", my_key
+ if my_has_key( my_key, template_map ):
+ user_code = template_map[ my_has_key( my_key, template_map ) ].strip()
+ if user_code == 'None':
+ user_code = None
+ argument_properties[ 'code' ][ call_type ] = user_code
 
   #
   # create a dict object
@@ -1667,6 +1669,9 @@
   
   #subroutine_description.replace( subroutine_name, subroutine_name[ 1: ] )
   #info_map[ 'description' ] = subroutine_description
+
+ print "Value of info_map['" + subroutine_name + "']: "
+ pp.pprint( info_map )
   
   return subroutine_name, info_map
 

Modified: sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level1/scal.hpp
==============================================================================
--- sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level1/scal.hpp (original)
+++ sandbox/numeric_bindings/libs/numeric/bindings/tools/templates/level1/scal.hpp 2010-01-17 05:44:08 EST (Sun, 17 Jan 2010)
@@ -9,6 +9,16 @@
  A (input) DATATYPE
 $TEMPLATE[scal.all.cblas_alias]
 A,ALPHA
+$TEMPLATE[scal.all.first_typename]
+VectorX
+$TEMPLATE[scal.complex.A.code.level_1]
+const ScalarA a
+$TEMPLATE[scal.complex.A.code.level_1_type]
+typename ScalarA
+$TEMPLATE[scal.complex.A.code.level_1_static_assert]
+None
+$TEMPLATE[scal.complex.A.code.level_2]
+const ScalarA a
 $TEMPLATE[scal.friendly_name]
 scale
 $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