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