+++ /dev/null
-generate code for Boost.NumPy[1] to accelerate c 1D array handling\r
-\r
-Upstream: https://sourceforge.net/p/pygccxml/patches/2/\r
-\r
-Index: pyplusplus/code_creators/__init__.py\r
-===================================================================\r
---- pyplusplus/code_creators/__init__.py.orig\r
-+++ pyplusplus/code_creators/__init__.py\r
-@@ -110,6 +110,8 @@ from member_variable import bit_field_t\r
- from member_variable import bit_field_wrapper_t\r
- from member_variable import array_mv_t\r
- from member_variable import array_mv_wrapper_t\r
-+from member_variable import array_numpy_t\r
-+from member_variable import array_numpy_wrapper_t\r
- from member_variable import mem_var_ref_t\r
- from member_variable import mem_var_ref_wrapper_t\r
- from member_variable import member_variable_addressof_t\r
-Index: pyplusplus/code_creators/code_creator.py\r
-===================================================================\r
---- pyplusplus/code_creators/code_creator.py.orig\r
-+++ pyplusplus/code_creators/code_creator.py\r
-@@ -126,6 +126,7 @@ class code_creator_t(object):\r
- files = []\r
- if self.code_generator == self.CODE_GENERATOR_TYPES.BOOST_PYTHON:\r
- files.append( "boost/python.hpp" )\r
-+ files.append( "boost/numpy.hpp" )\r
- files.append( code_repository.named_tuple.file_name )\r
- else:\r
- files.append( code_repository.ctypes_utils.file_name )\r
-Index: pyplusplus/code_creators/member_variable.py\r
-===================================================================\r
---- pyplusplus/code_creators/member_variable.py.orig\r
-+++ pyplusplus/code_creators/member_variable.py\r
-@@ -507,7 +507,95 @@ class array_mv_wrapper_t( code_creator.c\r
- def _get_system_files_impl( self ):\r
- return [code_repository.array_1.file_name]\r
- \r
-+class array_numpy_t( member_variable_base_t ):\r
-+ """\r
-+ Creates boost.python code that exposes array member variable via boost.numpy.\r
-+ """\r
-+ def __init__(self, variable, wrapper ):\r
-+ member_variable_base_t.__init__( self, variable=variable, wrapper=wrapper )\r
-+ self.works_on_instance = False\r
-+\r
-+ def _create_body( self ):\r
-+ answer = []\r
-+ doc = ''\r
-+ if self.declaration.type_qualifiers.has_static:\r
-+ answer.append( self.parent.class_var_name + '.add_static_property' )\r
-+ else:\r
-+ if self.documentation:\r
-+ doc = self.documentation\r
-+ answer.append( self.parent.class_var_name + '.add_property' )\r
-+ answer.append('( "%s", &%s );' % (self.declaration.name, self.wrapper.wrapper_creator_full_name ))\r
-+ if doc:\r
-+ answer.append( os.linesep )\r
-+ answer.append( self.PARAM_SEPARATOR )\r
-+ answer.append( doc )\r
-+ return ''.join( answer )\r
-+\r
-+ def _create_impl( self ):\r
-+ answer = []\r
-+ answer.append( '{ //%s, type=%s' % ( self.declaration, self.declaration.type ) )\r
-+ answer.append( os.linesep )\r
-+ answer.append( self.indent( self._create_body() ) )\r
-+ answer.append( os.linesep )\r
-+ answer.append( '}' )\r
-+ return ''.join( answer )\r
-+\r
-+ def _get_system_files_impl( self ):\r
-+ return []\r
- \r
-+class array_numpy_wrapper_t( code_creator.code_creator_t\r
-+ , declaration_based.declaration_based_t ):\r
-+ """registers array class"""\r
-+ def __init__(self, variable ):\r
-+ code_creator.code_creator_t.__init__( self )\r
-+ declaration_based.declaration_based_t.__init__( self, declaration=variable)\r
-+ self.py_class_type = declarations.reference_t(declarations.const_t(declarations.dummy_type_t( "bp::object" )))\r
-+\r
-+ @property\r
-+ def wrapped_class_type( self ):\r
-+ wrapped_cls_type = declarations.declarated_t( self.declaration.parent )\r
-+ if declarations.is_const( self.declaration.type ):\r
-+ wrapped_cls_type = declarations.const_t( wrapped_cls_type )\r
-+ return declarations.reference_t( wrapped_cls_type )\r
-+ \r
-+ @property\r
-+ def wrapper_creator_name(self):\r
-+ return '_'.join( ['pyplusplus', self.declaration.name, 'wrapper'] )\r
-+\r
-+ @property\r
-+ def wrapper_creator_full_name(self):\r
-+ return '::'.join( [self.parent.full_name, self.wrapper_creator_name] )\r
-+\r
-+ def _create_impl( self ): \r
-+ if self.declaration.type_qualifiers.has_static:\r
-+ tmpl = [ "static %(wrapper_type)s %(wrapper_creator_name)s( ){" ]\r
-+ tmpl.append( self.indent( "return bn::from_data( %(parent_class_type)s::%(mem_var_ref)s," ) )\r
-+ else:\r
-+ tmpl = [ "static %(wrapper_type)s %(wrapper_creator_name)s( %(py_class_type)s inst ){" ]\r
-+ tmpl.append( self.indent( "return bn::from_data(bp::extract< %(wrapped_class_type)s >(inst)().%(mem_var_ref)s," ) )\r
-+ owner = "bp::object()"\r
-+\r
-+ tmpl.append( self.indent(self.indent("bn::dtype::get_builtin< %(item_type)s >(), bp::make_tuple(%(array_size)s),")) )\r
-+ tmpl.append( self.indent(self.indent("bp::make_tuple(sizeof(%(item_type)s)), %(owner)s);")) )\r
-+ tmpl.append( "}" )\r
-+ \r
-+ tmpl = os.linesep.join( tmpl )\r
-+ \r
-+ return tmpl % {\r
-+ 'wrapper_type' : "bn::ndarray"\r
-+ , 'parent_class_type' : self.parent.declaration.partial_decl_string\r
-+ , 'wrapper_creator_name' : self.wrapper_creator_name\r
-+ , 'wrapped_class_type' : self.wrapped_class_type.decl_string\r
-+ , 'mem_var_ref' : self.declaration.name\r
-+ , 'py_class_type' : self.py_class_type.decl_string\r
-+ , 'item_type' : declarations.array_item_type( self.declaration.type ).decl_string\r
-+ , 'array_size': declarations.array_size( self.declaration.type )\r
-+ , 'owner': owner\r
-+ }\r
-+\r
-+ def _get_system_files_impl( self ):\r
-+ return []\r
-+ \r
- class mem_var_ref_t( member_variable_base_t ):\r
- """\r
- creates get/set accessors for class member variable, that has type reference.\r
-Index: pyplusplus/code_creators/module_body.py\r
-===================================================================\r
---- pyplusplus/code_creators/module_body.py.orig\r
-+++ pyplusplus/code_creators/module_body.py\r
-@@ -18,6 +18,7 @@ class module_body_t(compound.compound_t)\r
- def _create_impl(self):\r
- result = []\r
- result.append( "BOOST_PYTHON_MODULE(%s){" % self.name )\r
-+ result.append( "bn::initialize();" )\r
- result.append( compound.compound_t.create_internal_code( self.creators ) )\r
- result.append( "}" )\r
- return os.linesep.join( result )\r
-Index: pyplusplus/creators_factory/bpcreator.py\r
-===================================================================\r
---- pyplusplus/creators_factory/bpcreator.py.orig\r
-+++ pyplusplus/creators_factory/bpcreator.py\r
-@@ -76,10 +76,14 @@ class bpcreator_t( declarations.decl_vis\r
- global_ns = declarations.get_global_namespace(decls)\r
- \r
- self.__extmodule = code_creators.bpmodule_t( global_ns )\r
-- if boost_python_ns_name:\r
-- bp_ns_alias = code_creators.namespace_alias_t( alias=boost_python_ns_name\r
-- , full_namespace_name='::boost::python' )\r
-- self.__extmodule.adopt_creator( bp_ns_alias )\r
-+\r
-+ # alias of boost::numpy is hard-coded here, as it will be merged into boost::python.\r
-+ for ns_name, full_ns_name in {boost_python_ns_name: '::boost::python'\r
-+ , 'bn': '::boost::numpy'}.iteritems():\r
-+ if ns_name:\r
-+ ns_alias = code_creators.namespace_alias_t( alias=ns_name\r
-+ , full_namespace_name=full_ns_name )\r
-+ self.__extmodule.adopt_creator( ns_alias )\r
- \r
- self.__module_body = code_creators.module_body_t( name=module_name )\r
- \r
-@@ -723,8 +727,12 @@ class bpcreator_t( declarations.decl_vis\r
- wrapper = code_creators.bit_field_wrapper_t( variable=self.curr_decl )\r
- maker = code_creators.bit_field_t( variable=self.curr_decl, wrapper=wrapper )\r
- elif declarations.is_array( self.curr_decl.type ):\r
-- wrapper = code_creators.array_mv_wrapper_t( variable=self.curr_decl )\r
-- maker = code_creators.array_mv_t( variable=self.curr_decl, wrapper=wrapper )\r
-+ if declarations.is_arithmetic(declarations.array_item_type( self.curr_decl.type )):\r
-+ wrapper = code_creators.array_numpy_wrapper_t( variable=self.curr_decl )\r
-+ maker = code_creators.array_numpy_t( variable=self.curr_decl, wrapper=wrapper )\r
-+ else:\r
-+ wrapper = code_creators.array_mv_wrapper_t( variable=self.curr_decl )\r
-+ maker = code_creators.array_mv_t( variable=self.curr_decl, wrapper=wrapper )\r
- elif declarations.is_pointer( self.curr_decl.type ):\r
- wrapper = code_creators.member_variable_wrapper_t( variable=self.curr_decl )\r
- maker = code_creators.member_variable_t( variable=self.curr_decl, wrapper=wrapper )\r