Gentoo Archives: gentoo-commits

From: "Benda XU (heroxbd)" <heroxbd@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in dev-python/pyplusplus/files: pyplusplus-1.0.0_p20131206-numpy.patch
Date: Fri, 06 Dec 2013 13:45:22
Message-Id: 20131206134516.10A532004B@flycatcher.gentoo.org
1 heroxbd 13/12/06 13:45:15
2
3 Modified: pyplusplus-1.0.0_p20131206-numpy.patch
4 Log:
5 patch submitted upstream
6
7 (Portage version: 2.2.7/cvs/Linux x86_64, unsigned Manifest commit)
8
9 Revision Changes Path
10 1.2 dev-python/pyplusplus/files/pyplusplus-1.0.0_p20131206-numpy.patch
11
12 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pyplusplus/files/pyplusplus-1.0.0_p20131206-numpy.patch?rev=1.2&view=markup
13 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pyplusplus/files/pyplusplus-1.0.0_p20131206-numpy.patch?rev=1.2&content-type=text/plain
14 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/dev-python/pyplusplus/files/pyplusplus-1.0.0_p20131206-numpy.patch?r1=1.1&r2=1.2
15
16 Index: pyplusplus-1.0.0_p20131206-numpy.patch
17 ===================================================================
18 RCS file: /var/cvsroot/gentoo-x86/dev-python/pyplusplus/files/pyplusplus-1.0.0_p20131206-numpy.patch,v
19 retrieving revision 1.1
20 retrieving revision 1.2
21 diff -u -r1.1 -r1.2
22 --- pyplusplus-1.0.0_p20131206-numpy.patch 6 Dec 2013 13:35:53 -0000 1.1
23 +++ pyplusplus-1.0.0_p20131206-numpy.patch 6 Dec 2013 13:45:15 -0000 1.2
24 @@ -1,175 +1,179 @@
25 +generate code for Boost.NumPy[1] to accelerate c 1D array handling
26 +
27 +Upstream: https://sourceforge.net/p/pygccxml/patches/2/
28 +
29 Index: pyplusplus/code_creators/__init__.py
30 ===================================================================
31 --- pyplusplus/code_creators/__init__.py.orig
32 +++ pyplusplus/code_creators/__init__.py
33 @@ -110,6 +110,8 @@ from member_variable import bit_field_t
34 - from member_variable import bit_field_wrapper_t
35 - from member_variable import array_mv_t
36 - from member_variable import array_mv_wrapper_t
37 -+from member_variable import array_numpy_t
38 -+from member_variable import array_numpy_wrapper_t
39 - from member_variable import mem_var_ref_t
40 - from member_variable import mem_var_ref_wrapper_t
41 - from member_variable import member_variable_addressof_t
42 + from member_variable import bit_field_wrapper_t
43 + from member_variable import array_mv_t
44 + from member_variable import array_mv_wrapper_t
45 ++from member_variable import array_numpy_t
46 ++from member_variable import array_numpy_wrapper_t
47 + from member_variable import mem_var_ref_t
48 + from member_variable import mem_var_ref_wrapper_t
49 + from member_variable import member_variable_addressof_t
50 Index: pyplusplus/code_creators/code_creator.py
51 ===================================================================
52 --- pyplusplus/code_creators/code_creator.py.orig
53 +++ pyplusplus/code_creators/code_creator.py
54 @@ -126,6 +126,7 @@ class code_creator_t(object):
55 - files = []
56 - if self.code_generator == self.CODE_GENERATOR_TYPES.BOOST_PYTHON:
57 - files.append( "boost/python.hpp" )
58 -+ files.append( "boost/numpy.hpp" )
59 - files.append( code_repository.named_tuple.file_name )
60 - else:
61 - files.append( code_repository.ctypes_utils.file_name )
62 + files = []
63 + if self.code_generator == self.CODE_GENERATOR_TYPES.BOOST_PYTHON:
64 + files.append( "boost/python.hpp" )
65 ++ files.append( "boost/numpy.hpp" )
66 + files.append( code_repository.named_tuple.file_name )
67 + else:
68 + files.append( code_repository.ctypes_utils.file_name )
69 Index: pyplusplus/code_creators/member_variable.py
70 ===================================================================
71 --- pyplusplus/code_creators/member_variable.py.orig
72 +++ pyplusplus/code_creators/member_variable.py
73 @@ -507,7 +507,95 @@ class array_mv_wrapper_t( code_creator.c
74 - def _get_system_files_impl( self ):
75 - return [code_repository.array_1.file_name]
76 -
77 -+class array_numpy_t( member_variable_base_t ):
78 -+ """
79 -+ Creates boost.python code that exposes array member variable via boost.numpy.
80 -+ """
81 -+ def __init__(self, variable, wrapper ):
82 -+ member_variable_base_t.__init__( self, variable=variable, wrapper=wrapper )
83 -+ self.works_on_instance = False
84 -+
85 -+ def _create_body( self ):
86 -+ answer = []
87 -+ doc = ''
88 -+ if self.declaration.type_qualifiers.has_static:
89 -+ answer.append( self.parent.class_var_name + '.add_static_property' )
90 -+ else:
91 -+ if self.documentation:
92 -+ doc = self.documentation
93 -+ answer.append( self.parent.class_var_name + '.add_property' )
94 -+ answer.append('( "%s", &%s );' % (self.declaration.name, self.wrapper.wrapper_creator_full_name ))
95 -+ if doc:
96 -+ answer.append( os.linesep )
97 -+ answer.append( self.PARAM_SEPARATOR )
98 -+ answer.append( doc )
99 -+ return ''.join( answer )
100 -+
101 -+ def _create_impl( self ):
102 -+ answer = []
103 -+ answer.append( '{ //%s, type=%s' % ( self.declaration, self.declaration.type ) )
104 -+ answer.append( os.linesep )
105 -+ answer.append( self.indent( self._create_body() ) )
106 -+ answer.append( os.linesep )
107 -+ answer.append( '}' )
108 -+ return ''.join( answer )
109 -+
110 -+ def _get_system_files_impl( self ):
111 -+ return []
112 -
113 -+class array_numpy_wrapper_t( code_creator.code_creator_t
114 -+ , declaration_based.declaration_based_t ):
115 -+ """registers array class"""
116 -+ def __init__(self, variable ):
117 -+ code_creator.code_creator_t.__init__( self )
118 -+ declaration_based.declaration_based_t.__init__( self, declaration=variable)
119 -+ self.py_class_type = declarations.reference_t(declarations.const_t(declarations.dummy_type_t( "bp::object" )))
120 -+
121 -+ @property
122 -+ def wrapped_class_type( self ):
123 -+ wrapped_cls_type = declarations.declarated_t( self.declaration.parent )
124 -+ if declarations.is_const( self.declaration.type ):
125 -+ wrapped_cls_type = declarations.const_t( wrapped_cls_type )
126 -+ return declarations.reference_t( wrapped_cls_type )
127 -+
128 -+ @property
129 -+ def wrapper_creator_name(self):
130 -+ return '_'.join( ['pyplusplus', self.declaration.name, 'wrapper'] )
131 -+
132 -+ @property
133 -+ def wrapper_creator_full_name(self):
134 -+ return '::'.join( [self.parent.full_name, self.wrapper_creator_name] )
135 -+
136 -+ def _create_impl( self ):
137 -+ if self.declaration.type_qualifiers.has_static:
138 -+ tmpl = [ "static %(wrapper_type)s %(wrapper_creator_name)s( ){" ]
139 -+ tmpl.append( self.indent( "return bn::from_data( %(parent_class_type)s::%(mem_var_ref)s," ) )
140 -+ owner = "bp::object()"
141 -+ else:
142 -+ tmpl = [ "static %(wrapper_type)s %(wrapper_creator_name)s( %(py_class_type)s inst ){" ]
143 -+ tmpl.append( self.indent( "return bn::from_data(bp::extract< %(wrapped_class_type)s >(inst)().%(mem_var_ref)s," ) )
144 -+ owner = "inst"
145 -+ tmpl.append( self.indent(self.indent("bn::dtype::get_builtin< %(item_type)s >(), bp::make_tuple(%(array_size)s),")) )
146 -+ tmpl.append( self.indent(self.indent("bp::make_tuple(sizeof(%(item_type)s)), %(owner)s);")) )
147 -+ tmpl.append( "}" )
148 -+
149 -+ tmpl = os.linesep.join( tmpl )
150 -+
151 -+ return tmpl % {
152 -+ 'wrapper_type' : "bn::ndarray"
153 -+ , 'parent_class_type' : self.parent.declaration.partial_decl_string
154 -+ , 'wrapper_creator_name' : self.wrapper_creator_name
155 -+ , 'wrapped_class_type' : self.wrapped_class_type.decl_string
156 -+ , 'mem_var_ref' : self.declaration.name
157 -+ , 'py_class_type' : self.py_class_type.decl_string
158 -+ , 'item_type' : declarations.array_item_type( self.declaration.type ).decl_string
159 -+ , 'array_size': declarations.array_size( self.declaration.type )
160 -+ , 'owner': owner
161 -+ }
162 -+
163 -+ def _get_system_files_impl( self ):
164 -+ return []
165 -+
166 - class mem_var_ref_t( member_variable_base_t ):
167 - """
168 - creates get/set accessors for class member variable, that has type reference.
169 + def _get_system_files_impl( self ):
170 + return [code_repository.array_1.file_name]
171 +
172 ++class array_numpy_t( member_variable_base_t ):
173 ++ """
174 ++ Creates boost.python code that exposes array member variable via boost.numpy.
175 ++ """
176 ++ def __init__(self, variable, wrapper ):
177 ++ member_variable_base_t.__init__( self, variable=variable, wrapper=wrapper )
178 ++ self.works_on_instance = False
179 ++
180 ++ def _create_body( self ):
181 ++ answer = []
182 ++ doc = ''
183 ++ if self.declaration.type_qualifiers.has_static:
184 ++ answer.append( self.parent.class_var_name + '.add_static_property' )
185 ++ else:
186 ++ if self.documentation:
187 ++ doc = self.documentation
188 ++ answer.append( self.parent.class_var_name + '.add_property' )
189 ++ answer.append('( "%s", &%s );' % (self.declaration.name, self.wrapper.wrapper_creator_full_name ))
190 ++ if doc:
191 ++ answer.append( os.linesep )
192 ++ answer.append( self.PARAM_SEPARATOR )
193 ++ answer.append( doc )
194 ++ return ''.join( answer )
195 ++
196 ++ def _create_impl( self ):
197 ++ answer = []
198 ++ answer.append( '{ //%s, type=%s' % ( self.declaration, self.declaration.type ) )
199 ++ answer.append( os.linesep )
200 ++ answer.append( self.indent( self._create_body() ) )
201 ++ answer.append( os.linesep )
202 ++ answer.append( '}' )
203 ++ return ''.join( answer )
204 ++
205 ++ def _get_system_files_impl( self ):
206 ++ return []
207 +
208 ++class array_numpy_wrapper_t( code_creator.code_creator_t
209 ++ , declaration_based.declaration_based_t ):
210 ++ """registers array class"""
211 ++ def __init__(self, variable ):
212 ++ code_creator.code_creator_t.__init__( self )
213 ++ declaration_based.declaration_based_t.__init__( self, declaration=variable)
214 ++ self.py_class_type = declarations.reference_t(declarations.const_t(declarations.dummy_type_t( "bp::object" )))
215 ++
216 ++ @property
217 ++ def wrapped_class_type( self ):
218 ++ wrapped_cls_type = declarations.declarated_t( self.declaration.parent )
219 ++ if declarations.is_const( self.declaration.type ):
220 ++ wrapped_cls_type = declarations.const_t( wrapped_cls_type )
221 ++ return declarations.reference_t( wrapped_cls_type )
222 ++
223 ++ @property
224 ++ def wrapper_creator_name(self):
225 ++ return '_'.join( ['pyplusplus', self.declaration.name, 'wrapper'] )
226 ++
227 ++ @property
228 ++ def wrapper_creator_full_name(self):
229 ++ return '::'.join( [self.parent.full_name, self.wrapper_creator_name] )
230 ++
231 ++ def _create_impl( self ):
232 ++ if self.declaration.type_qualifiers.has_static:
233 ++ tmpl = [ "static %(wrapper_type)s %(wrapper_creator_name)s( ){" ]
234 ++ tmpl.append( self.indent( "return bn::from_data( %(parent_class_type)s::%(mem_var_ref)s," ) )
235 ++ owner = "bp::object()"
236 ++ else:
237 ++ tmpl = [ "static %(wrapper_type)s %(wrapper_creator_name)s( %(py_class_type)s inst ){" ]
238 ++ tmpl.append( self.indent( "return bn::from_data(bp::extract< %(wrapped_class_type)s >(inst)().%(mem_var_ref)s," ) )
239 ++ owner = "inst"
240 ++ tmpl.append( self.indent(self.indent("bn::dtype::get_builtin< %(item_type)s >(), bp::make_tuple(%(array_size)s),")) )
241 ++ tmpl.append( self.indent(self.indent("bp::make_tuple(sizeof(%(item_type)s)), %(owner)s);")) )
242 ++ tmpl.append( "}" )
243 ++
244 ++ tmpl = os.linesep.join( tmpl )
245 ++
246 ++ return tmpl % {
247 ++ 'wrapper_type' : "bn::ndarray"
248 ++ , 'parent_class_type' : self.parent.declaration.partial_decl_string
249 ++ , 'wrapper_creator_name' : self.wrapper_creator_name
250 ++ , 'wrapped_class_type' : self.wrapped_class_type.decl_string
251 ++ , 'mem_var_ref' : self.declaration.name
252 ++ , 'py_class_type' : self.py_class_type.decl_string
253 ++ , 'item_type' : declarations.array_item_type( self.declaration.type ).decl_string
254 ++ , 'array_size': declarations.array_size( self.declaration.type )
255 ++ , 'owner': owner
256 ++ }
257 ++
258 ++ def _get_system_files_impl( self ):
259 ++ return []
260 ++
261 + class mem_var_ref_t( member_variable_base_t ):
262 + """
263 + creates get/set accessors for class member variable, that has type reference.
264 Index: pyplusplus/code_creators/module_body.py
265 ===================================================================
266 --- pyplusplus/code_creators/module_body.py.orig
267 +++ pyplusplus/code_creators/module_body.py
268 @@ -18,6 +18,7 @@ class module_body_t(compound.compound_t)
269 - def _create_impl(self):
270 - result = []
271 - result.append( "BOOST_PYTHON_MODULE(%s){" % self.name )
272 -+ result.append( "bn::initialize();" )
273 - result.append( compound.compound_t.create_internal_code( self.creators ) )
274 - result.append( "}" )
275 - return os.linesep.join( result )
276 + def _create_impl(self):
277 + result = []
278 + result.append( "BOOST_PYTHON_MODULE(%s){" % self.name )
279 ++ result.append( "bn::initialize();" )
280 + result.append( compound.compound_t.create_internal_code( self.creators ) )
281 + result.append( "}" )
282 + return os.linesep.join( result )
283 Index: pyplusplus/creators_factory/bpcreator.py
284 ===================================================================
285 --- pyplusplus/creators_factory/bpcreator.py.orig
286 +++ pyplusplus/creators_factory/bpcreator.py
287 @@ -76,10 +76,14 @@ class bpcreator_t( declarations.decl_vis
288 - global_ns = declarations.get_global_namespace(decls)
289 -
290 - self.__extmodule = code_creators.bpmodule_t( global_ns )
291 -- if boost_python_ns_name:
292 -- bp_ns_alias = code_creators.namespace_alias_t( alias=boost_python_ns_name
293 -- , full_namespace_name='::boost::python' )
294 -- self.__extmodule.adopt_creator( bp_ns_alias )
295 -+
296 -+ # alias of boost::numpy is hard-coded here, as it will be merged into boost::python.
297 -+ for ns_name, full_ns_name in {boost_python_ns_name: '::boost::python'
298 -+ , 'bn': '::boost::numpy'}.iteritems():
299 -+ if ns_name:
300 -+ ns_alias = code_creators.namespace_alias_t( alias=ns_name
301 -+ , full_namespace_name=full_ns_name )
302 -+ self.__extmodule.adopt_creator( ns_alias )
303 -
304 - self.__module_body = code_creators.module_body_t( name=module_name )
305 -
306 + global_ns = declarations.get_global_namespace(decls)
307 +
308 + self.__extmodule = code_creators.bpmodule_t( global_ns )
309 +- if boost_python_ns_name:
310 +- bp_ns_alias = code_creators.namespace_alias_t( alias=boost_python_ns_name
311 +- , full_namespace_name='::boost::python' )
312 +- self.__extmodule.adopt_creator( bp_ns_alias )
313 ++
314 ++ # alias of boost::numpy is hard-coded here, as it will be merged into boost::python.
315 ++ for ns_name, full_ns_name in {boost_python_ns_name: '::boost::python'
316 ++ , 'bn': '::boost::numpy'}.iteritems():
317 ++ if ns_name:
318 ++ ns_alias = code_creators.namespace_alias_t( alias=ns_name
319 ++ , full_namespace_name=full_ns_name )
320 ++ self.__extmodule.adopt_creator( ns_alias )
321 +
322 + self.__module_body = code_creators.module_body_t( name=module_name )
323 +
324 @@ -723,8 +727,12 @@ class bpcreator_t( declarations.decl_vis
325 - wrapper = code_creators.bit_field_wrapper_t( variable=self.curr_decl )
326 - maker = code_creators.bit_field_t( variable=self.curr_decl, wrapper=wrapper )
327 - elif declarations.is_array( self.curr_decl.type ):
328 -- wrapper = code_creators.array_mv_wrapper_t( variable=self.curr_decl )
329 -- maker = code_creators.array_mv_t( variable=self.curr_decl, wrapper=wrapper )
330 -+ if declarations.is_fundamental(declarations.array_item_type( self.curr_decl.type )):
331 -+ wrapper = code_creators.array_numpy_wrapper_t( variable=self.curr_decl )
332 -+ maker = code_creators.array_numpy_t( variable=self.curr_decl, wrapper=wrapper )
333 -+ else:
334 -+ wrapper = code_creators.array_mv_wrapper_t( variable=self.curr_decl )
335 -+ maker = code_creators.array_mv_t( variable=self.curr_decl, wrapper=wrapper )
336 - elif declarations.is_pointer( self.curr_decl.type ):
337 - wrapper = code_creators.member_variable_wrapper_t( variable=self.curr_decl )
338 - maker = code_creators.member_variable_t( variable=self.curr_decl, wrapper=wrapper )
339 + wrapper = code_creators.bit_field_wrapper_t( variable=self.curr_decl )
340 + maker = code_creators.bit_field_t( variable=self.curr_decl, wrapper=wrapper )
341 + elif declarations.is_array( self.curr_decl.type ):
342 +- wrapper = code_creators.array_mv_wrapper_t( variable=self.curr_decl )
343 +- maker = code_creators.array_mv_t( variable=self.curr_decl, wrapper=wrapper )
344 ++ if declarations.is_fundamental(declarations.array_item_type( self.curr_decl.type )):
345 ++ wrapper = code_creators.array_numpy_wrapper_t( variable=self.curr_decl )
346 ++ maker = code_creators.array_numpy_t( variable=self.curr_decl, wrapper=wrapper )
347 ++ else:
348 ++ wrapper = code_creators.array_mv_wrapper_t( variable=self.curr_decl )
349 ++ maker = code_creators.array_mv_t( variable=self.curr_decl, wrapper=wrapper )
350 + elif declarations.is_pointer( self.curr_decl.type ):
351 + wrapper = code_creators.member_variable_wrapper_t( variable=self.curr_decl )
352 + maker = code_creators.member_variable_t( variable=self.curr_decl, wrapper=wrapper )