[pygccxml-commit] SF.net SVN: pygccxml: [1336] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2008-06-12 07:09:58
|
Revision: 1336 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1336&view=rev Author: roman_yakovenko Date: 2008-06-12 00:10:06 -0700 (Thu, 12 Jun 2008) Log Message: ----------- improving control over order of generated code for classes Thanks to Jason Kankiewicz for the patch Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/pyplusplus/module_creator/creator.py pyplusplus_dev/unittests/classes_tester.py Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-06-12 06:24:44 UTC (rev 1335) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2008-06-12 07:10:06 UTC (rev 1336) @@ -178,7 +178,8 @@ self._held_type = None self._noncopyable = None self._wrapper_alias = None - self._registration_code = [] + self._registration_code_head = [] + self._registration_code_tail = [] self._declaration_code = [] self._wrapper_code = [] self._null_constructor_body = '' @@ -236,17 +237,33 @@ def declaration_code( self ): """ List of strings, that contains valid C++ code, that will be added to - the class registration section + the class declaration section """ return self._declaration_code @property + def registration_code_head( self ): + """ + List of strings, that contains valid C++ code, that will be added to + the head of the class registration section + """ + return self._registration_code_head + + @property + def registration_code_tail( self ): + """ + List of strings, that contains valid C++ code, that will be added to + the tail of the class registration section + """ + return self._registration_code_tail + + @property def registration_code( self ): """ - List of strings, that contains valid C++ code, that will be added to + List of strings, that contains all C++ code, that will be added to the class registration section """ - return self._registration_code + return self.registration_code_head + self.registration_code_tail @property def wrapper_code( self ): @@ -311,13 +328,20 @@ """adds the code to the declaration section""" self.declaration_code.append( user_text.user_text_t( code ) ) - def add_registration_code( self, code, works_on_instance=True ): + def add_registration_code( self, code, works_on_instance=True, tail=True ): """adds the code to the class registration section - works_on_instance: If true, the custom code can be applied directly to obj inst. - Example: ObjInst."CustomCode" + @param works_on_instance: If true, the custom code can be applied directly to obj inst. Example: ObjInst.code + @type works_on_instance: bool + + @param tail: if True, the custom code is appended to the end of the class registration code. + @type tail: bool """ - self.registration_code.append( user_text.class_user_text_t( code, works_on_instance ) ) + if tail: + self.registration_code_tail.append( user_text.class_user_text_t( code, works_on_instance ) ) + else: + self.registration_code_head.append( user_text.class_user_text_t( code, works_on_instance ) ) + #preserving backward computability add_code = add_registration_code Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/creator.py 2008-06-12 06:24:44 UTC (rev 1335) +++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2008-06-12 07:10:06 UTC (rev 1336) @@ -244,11 +244,15 @@ ctext_t = code_creators.custom_text_t for cls_creator in class_creators: cls_decl = cls_creator.declaration - #uc = user code - uc_creators = map( lambda uc: ctext_t( uc.text, uc.works_on_instance ) - , cls_decl.registration_code ) - cls_creator.adopt_creators( uc_creators ) + uc_creators_head = map( lambda uc: ctext_t( uc.text, uc.works_on_instance ) + , cls_decl.registration_code_head ) + cls_creator.adopt_creators( uc_creators_head, 0 ) + + uc_creators_tail = map( lambda uc: ctext_t( uc.text, uc.works_on_instance ) + , cls_decl.registration_code_tail ) + cls_creator.adopt_creators( uc_creators_tail ) + uc_creators = map( lambda uc: ctext_t( uc.text ), cls_decl.wrapper_code ) if uc_creators: cls_creator.wrapper.adopt_creators( uc_creators ) Modified: pyplusplus_dev/unittests/classes_tester.py =================================================================== --- pyplusplus_dev/unittests/classes_tester.py 2008-06-12 06:24:44 UTC (rev 1335) +++ pyplusplus_dev/unittests/classes_tester.py 2008-06-12 07:10:06 UTC (rev 1336) @@ -22,6 +22,8 @@ apple = mb.class_( 'apple' ) self.failUnless( apple.alias == 'the_tastest_fruit' ) apple.alias = 'apple' + apple.add_registration_code( "/*head*/", works_on_instance=False, tail=False ) + apple.add_registration_code( "/*tail*/", works_on_instance=False, tail=True ) protected_static_t = mb.class_( 'protected_static_t' ) self.failUnless( 'PROTECTED_STATIC' in protected_static_t.alias) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |