[pygccxml-commit] SF.net SVN: pygccxml:[1803] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2010-01-14 10:18:06
|
Revision: 1803 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1803&view=rev Author: roman_yakovenko Date: 2010-01-14 10:17:58 +0000 (Thu, 14 Jan 2010) Log Message: ----------- fix code generation for static array properties Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/member_variable.py pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp pyplusplus_dev/unittests/member_variables_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/member_variable.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-01-14 08:50:23 UTC (rev 1802) +++ pyplusplus_dev/pyplusplus/code_creators/member_variable.py 2010-01-14 10:17:58 UTC (rev 1803) @@ -434,7 +434,6 @@ class array_mv_wrapper_t( code_creator.code_creator_t , declaration_based.declaration_based_t ): """registers array class""" - def __init__(self, variable ): code_creator.code_creator_t.__init__( self ) declaration_based.declaration_based_t.__init__( self, declaration=variable) @@ -463,9 +462,12 @@ @property def wrapper_creator_type(self): - return declarations.free_function_type_t( - return_type=self.wrapper_type - , arguments_types=[self.wrapped_class_type] ) + if self.declaration.type_qualifiers.has_static: + return declarations.free_function_type_t( return_type=self.wrapper_type ) + else: + return declarations.free_function_type_t( + return_type=self.wrapper_type + , arguments_types=[self.wrapped_class_type] ) @property def wrapper_creator_name(self): @@ -475,15 +477,21 @@ def wrapper_creator_full_name(self): return '::'.join( [self.parent.full_name, self.wrapper_creator_name] ) - def _create_impl( self ): - tmpl = os.linesep.join([ - "static %(wrapper_type)s" - , "%(wrapper_creator_name)s( %(wrapped_class_type)s inst ){" - , self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) - , "}" - ]) + def _create_impl( self ): + tmpl = [ "static %(wrapper_type)s" ] + if self.declaration.type_qualifiers.has_static: + tmpl.append( "%(wrapper_creator_name)s(){" ) + tmpl.append( self.indent( "return %(wrapper_type)s( %(parent_class_type)s::%(mem_var_ref)s );" ) ) + else: + tmpl.append( "%(wrapper_creator_name)s( %(wrapped_class_type)s inst ){" ) + tmpl.append( self.indent( "return %(wrapper_type)s( inst.%(mem_var_ref)s );" ) ) + tmpl.append( "}" ) + + tmpl = os.linesep.join( tmpl ) + return tmpl % { 'wrapper_type' : self.wrapper_type.decl_string + , 'parent_class_type' : self.parent.declaration.partial_decl_string , 'wrapper_creator_name' : self.wrapper_creator_name , 'wrapped_class_type' : self.wrapped_class_type.decl_string , 'mem_var_ref' : self.declaration.name Modified: pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp 2010-01-14 08:50:23 UTC (rev 1802) +++ pyplusplus_dev/unittests/data/member_variables_to_be_exported.cpp 2010-01-14 10:17:58 UTC (rev 1803) @@ -8,6 +8,7 @@ namespace member_variables{ const array_t::variable_t array_t::vars[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; +array_t::variable_t array_t::vars_nonconst[] = { array_t::variable_t(), array_t::variable_t(), array_t::variable_t() }; int point::instance_count = 0; const point::color point::default_color = point::red; Modified: pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp 2010-01-14 08:50:23 UTC (rev 1802) +++ pyplusplus_dev/unittests/data/member_variables_to_be_exported.hpp 2010-01-14 10:17:58 UTC (rev 1803) @@ -66,6 +66,7 @@ } static const variable_t vars[3]; + static variable_t vars_nonconst[3]; int ivars[10]; int ivars2[10]; }; Modified: pyplusplus_dev/unittests/member_variables_tester.py =================================================================== --- pyplusplus_dev/unittests/member_variables_tester.py 2010-01-14 08:50:23 UTC (rev 1802) +++ pyplusplus_dev/unittests/member_variables_tester.py 2010-01-14 10:17:58 UTC (rev 1803) @@ -106,10 +106,17 @@ array.ivars[index] = index * index self.failUnless( array.get_ivars_item( index ) == index * index ) - self.failUnless( len( array.vars ) == 3 ) - for i in range( len( array.vars ) ): - self.failUnless( array.vars[i].value == -9 ) + #~ import pdb + #~ pdb.set_trace() + self.failUnless( len( module.array_t.vars ) == 3 ) + for i in range( len( module.array_t.vars ) ): + self.failUnless( module.array_t.vars[i].value == -9 ) + + self.failUnless( len( module.array_t.vars_nonconst ) == 3 ) + for i in range( len( module.array_t.vars_nonconst ) ): + self.failUnless( module.array_t.vars_nonconst[i].value == -9 ) + def create_suite(): suite = unittest.TestSuite() suite.addTest( unittest.makeSuite(tester_t)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |