[pygccxml-commit] SF.net SVN: pygccxml: [1209] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2007-12-24 19:19:40
|
Revision: 1209 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1209&view=rev Author: roman_yakovenko Date: 2007-12-24 11:17:09 -0800 (Mon, 24 Dec 2007) Log Message: ----------- switching from "name" to "partial_name" for better code generation Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef.py pyplusplus_dev/pyplusplus/code_creators/class_declaration.py pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/unittests/ogre_generate_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-12-24 15:34:46 UTC (rev 1208) +++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2007-12-24 19:17:09 UTC (rev 1209) @@ -300,11 +300,16 @@ result = [] ftype = self.declaration.function_type() - result.append( 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) ) + result.append( 'typedef %s;' + % ftype.create_typedef( self.function_type_alias + , exported_class_alias + , with_defaults=False) ) if self.wrapper: result.append( os.linesep ) ftype = self.wrapper.function_type() - result.append( 'typedef %s;' % ftype.create_typedef( self.default_function_type_alias ) ) + result.append( 'typedef %s;' + % ftype.create_typedef( self.default_function_type_alias + , with_defaults=False) ) return ''.join( result ) def create_doc(self): @@ -362,7 +367,7 @@ return template % { 'virtual' : virtual - , 'return_type' : self.declaration.return_type.decl_string + , 'return_type' : self.declaration.return_type.partial_decl_string , 'name' : name , 'args' : self.args_declaration() , 'constness' : constness @@ -386,7 +391,7 @@ return template % { 'override' : self.override_identifier() - , 'name' : self.declaration.name + , 'name' : self.declaration.partial_name , 'alias' : self.declaration.alias , 'return_' : return_ , 'args' : self.function_call_args() @@ -394,7 +399,7 @@ } def create_default_body(self): - function_call = declarations.call_invocation.join( self.declaration.name + function_call = declarations.call_invocation.join( self.declaration.partial_name , [ self.function_call_args() ] ) body = self.wrapped_class_identifier() + '::' + function_call + ';' if not declarations.is_void( self.declaration.return_type ): @@ -406,7 +411,7 @@ def create_function(self): - answer = [ self.create_declaration(self.declaration.name) + '{' ] + answer = [ self.create_declaration(self.declaration.partial_name) + '{' ] answer.append( self.indent( self.create_virtual_body() ) ) answer.append( '}' ) return os.linesep.join( answer ) @@ -430,7 +435,7 @@ def create_function_type_alias_code( self, exported_class_alias=None ): ftype = self.wrapper.function_type() - return 'typedef ' + ftype.create_typedef( self.function_type_alias ) + ';' + return 'typedef ' + ftype.create_typedef( self.function_type_alias, with_defaults=False ) + ';' def create_function_ref_code(self, use_function_alias=False): if use_function_alias: @@ -447,7 +452,7 @@ calldef_wrapper_t.__init__( self, function=function ) def full_name(self): - return '::'.join( [self.parent.full_name, self.declaration.name] ) + return '::'.join( [self.parent.full_name, self.declaration.partial_name] ) def function_type(self): return declarations.member_function_type_t( @@ -464,7 +469,7 @@ constness = ' const ' return template % { - 'return_type' : self.declaration.return_type.decl_string + 'return_type' : self.declaration.return_type.partial_decl_string , 'name' : name , 'args' : self.args_declaration() , 'constness' : constness @@ -479,14 +484,14 @@ return_ = 'return ' return tmpl % { - 'name' : self.declaration.name + 'name' : self.declaration.partial_name , 'return_' : return_ , 'args' : self.function_call_args() , 'wrapped_class' : self.wrapped_class_identifier() } def create_function(self): - answer = [ self.create_declaration(self.declaration.name) + '{' ] + answer = [ self.create_declaration(self.declaration.partial_name) + '{' ] answer.append( self.indent( self.create_body() ) ) answer.append( '}' ) return os.linesep.join( answer ) @@ -502,7 +507,7 @@ def create_function_type_alias_code( self, exported_class_alias=None ): ftype = self.wrapper.function_type() - return 'typedef %s;' % ftype.create_typedef( self.function_type_alias ) + return 'typedef %s;' % ftype.create_typedef( self.function_type_alias, with_defaults=False ) def create_function_ref_code(self, use_function_alias=False): if use_function_alias: @@ -510,7 +515,7 @@ % ( self.function_type_alias, self.wrapper.full_name() ) elif self.declaration.create_with_signature: return '(%s)(&%s)' \ - % ( self.wrapper.function_type().decl_string, self.wrapper.full_name() ) + % ( self.wrapper.function_type().partial_decl_string, self.wrapper.full_name() ) else: return '&%s' % self.wrapper.full_name() @@ -530,7 +535,7 @@ template = 'static %(return_type)s %(name)s( %(args)s )%(throw)s' return template % { - 'return_type' : self.declaration.return_type.decl_string + 'return_type' : self.declaration.return_type.partial_decl_string , 'name' : name , 'args' : self.args_declaration() , 'throw' : self.throw_specifier_code() @@ -565,7 +570,7 @@ def create_function_type_alias_code( self, exported_class_alias=None ): ftype = self.wrapper.function_type() - return 'typedef %s;' % ftype.create_typedef( self.function_type_alias ) + return 'typedef %s;' % ftype.create_typedef( self.function_type_alias, with_defaults=False ) def create_function_ref_code(self, use_function_alias=False): if use_function_alias: @@ -573,7 +578,7 @@ % ( self.function_type_alias, self.wrapper.full_name() ) elif self.declaration.create_with_signature: return '(%s)(&%s)' \ - % ( self.wrapper.function_type().decl_string, self.wrapper.full_name() ) + % ( self.wrapper.function_type().partial_decl_string, self.wrapper.full_name() ) else: return '&%s' % self.wrapper.full_name() @@ -599,7 +604,7 @@ constness = ' const ' return template % { - 'return_type' : self.declaration.return_type.decl_string + 'return_type' : self.declaration.return_type.partial_decl_string , 'name' : name , 'args' : self.args_declaration() , 'constness' : constness @@ -625,7 +630,7 @@ return template % { 'override' : self.override_identifier() - , 'name' : self.declaration.name + , 'name' : self.declaration.partial_name , 'alias' : self.declaration.alias , 'return_' : return_ , 'args' : self.function_call_args() @@ -633,7 +638,7 @@ } def create_function(self): - answer = [ self.create_declaration(self.declaration.name) + '{' ] + answer = [ self.create_declaration(self.declaration.partial_name) + '{' ] answer.append( self.indent( self.create_virtual_body() ) ) answer.append( '}' ) return os.linesep.join( answer ) @@ -647,7 +652,7 @@ def create_function_type_alias_code( self, exported_class_alias=None ): ftype = self.wrapper.function_type() - return 'typedef %s;' % ftype.create_typedef( self.function_type_alias ) + return 'typedef %s;' % ftype.create_typedef( self.function_type_alias, with_defaults=False ) def create_function_ref_code(self, use_function_alias=False): if use_function_alias: @@ -655,7 +660,7 @@ % ( self.function_type_alias, self.wrapper.full_name() ) elif self.declaration.create_with_signature: return '(%s)(&%s)' \ - % ( self.wrapper.function_type().decl_string, self.wrapper.full_name() ) + % ( self.wrapper.function_type().partial_decl_string, self.wrapper.full_name() ) else: return '&%s' % self.wrapper.full_name() @@ -664,7 +669,7 @@ calldef_wrapper_t.__init__( self, function=function ) def full_name(self): - return self.parent.full_name + '::' + self.declaration.name + return self.parent.full_name + '::' + self.declaration.partial_name def function_type(self): return declarations.member_function_type_t( @@ -681,7 +686,7 @@ constness = ' const ' return template % { - 'return_type' : self.declaration.return_type.decl_string + 'return_type' : self.declaration.return_type.partial_decl_string , 'name' : self.declaration.name , 'args' : self.args_declaration() , 'constness' : constness @@ -724,7 +729,7 @@ calldef_wrapper_t.__init__( self, function=function ) def full_name(self): - return self.parent.full_name + '::' + self.declaration.name + return self.parent.full_name + '::' + self.declaration.partial_name def function_type(self): return declarations.member_function_type_t( @@ -741,7 +746,7 @@ constness = ' const ' return template % { - 'return_type' : self.declaration.return_type.decl_string + 'return_type' : self.declaration.return_type.partial_decl_string , 'name' : self.declaration.name , 'args' : self.args_declaration() , 'constness' : constness @@ -1001,7 +1006,7 @@ x = declarations.remove_reference( type ) x = declarations.remove_cv( x ) other = algorithm.create_identifier( self, '::boost::python::other' ) - type_ = algorithm.create_identifier( self, x.decl_string ) + type_ = algorithm.create_identifier( self, x.partial_decl_string ) return declarations.templates.join( other, [ type_ ] ) + '()' def _findout_self_position(self): @@ -1077,11 +1082,11 @@ def _create_impl(self): #TODO add comment in case of non const operator implicitly_convertible = algorithm.create_identifier( self, '::boost::python::implicitly_convertible' ) - from_arg = algorithm.create_identifier( self - , declarations.full_name( self.declaration.parent ) ) + from_name = declarations.full_name( self.declaration.parent, with_defaults=False ) + from_arg = algorithm.create_identifier( self, from_name ) to_arg = algorithm.create_identifier( self - , self.declaration.return_type.decl_string ) + , self.declaration.return_type.partial_decl_string ) return declarations.templates.join(implicitly_convertible , [ from_arg , to_arg ] ) \ + '();' @@ -1102,10 +1107,9 @@ def _create_impl(self): template = 'def( "%(function_name)s", &%(class_name)s::operator %(destination_type)s %(call_policies)s%(doc)s )' + p_name = declarations.full_name( self.declaration.parent, with_defaults=False ) + class_name = algorithm.create_identifier( self, p_name ) - class_name = algorithm.create_identifier( self - , declarations.full_name( self.declaration.parent ) ) - policies = '' if self.declaration.call_policies: if not self.declaration.call_policies.is_default(): @@ -1119,7 +1123,7 @@ return template % { 'function_name' : self.declaration.alias , 'class_name' : class_name - , 'destination_type' : self.declaration.return_type.decl_string + , 'destination_type' : self.declaration.return_type.partial_decl_string , 'call_policies' : policies , 'doc' : doc } @@ -1141,12 +1145,11 @@ def _create_impl(self): implicitly_convertible = algorithm.create_identifier( self, '::boost::python::implicitly_convertible' ) from_arg = algorithm.create_identifier( self - , self.declaration.arguments[0].type.decl_string) + , self.declaration.arguments[0].type.partial_decl_string) - to_arg = algorithm.create_identifier( self - , declarations.full_name( self.declaration.parent ) ) - return declarations.templates.join(implicitly_convertible - , [ from_arg , to_arg ] ) \ + to_name = declarations.full_name( self.declaration.parent, with_defaults=False ) + to_arg = algorithm.create_identifier( self, to_name ) + return declarations.templates.join(implicitly_convertible, [from_arg, to_arg ]) \ + '();' def _get_system_headers_impl( self ): Modified: pyplusplus_dev/pyplusplus/code_creators/class_declaration.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2007-12-24 15:34:46 UTC (rev 1208) +++ pyplusplus_dev/pyplusplus/code_creators/class_declaration.py 2007-12-24 19:17:09 UTC (rev 1209) @@ -347,7 +347,8 @@ self.declaration.wrapper_alias = walias wrapper_alias = property( _get_wrapper_alias, _set_wrapper_alias ) - def _get_base_wrappers( self ): + @property + def base_wrappers( self ): if self.declaration.is_abstract and not self._base_wrappers: bases = [ hi.related_class for hi in self.declaration.bases ] creators_before_me = algorithm.creators_affect_on_me( self ) @@ -356,17 +357,17 @@ and creator.declaration in bases , creators_before_me ) return self._base_wrappers - base_wrappers = property( _get_base_wrappers ) - def _get_exposed_identifier(self): - return algorithm.create_identifier( self, self.declaration.decl_string ) - exposed_identifier = property( _get_exposed_identifier ) + @property + def exposed_identifier(self): + return algorithm.create_identifier( self, self.declaration.partial_decl_string ) - def _get_class_creator(self): + @property + def class_creator(self): return self._class_creator - class_creator = property( _get_class_creator ) - def _get_full_name( self ): + @property + def full_name( self ): if not isinstance( self.parent, class_wrapper_t ): return self.declaration.wrapper_alias else: @@ -378,16 +379,15 @@ parent = parent.parent full_name.reverse() return '::'.join( full_name ) - full_name = property( _get_full_name ) - def _get_held_type(self): + @property + def held_type(self): return self._class_creator.held_type - held_type = property( _get_held_type ) - def _get_boost_wrapper_identifier(self): + @property + def boost_wrapper_identifier(self): boost_wrapper = algorithm.create_identifier( self, '::boost::python::wrapper' ) return declarations.templates.join( boost_wrapper, [self.exposed_identifier] ) - boost_wrapper_identifier = property( _get_boost_wrapper_identifier ) def _create_bases(self): return ', '.join( [self.exposed_identifier, self.boost_wrapper_identifier] ) Modified: pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py 2007-12-24 15:34:46 UTC (rev 1208) +++ pyplusplus_dev/pyplusplus/code_creators/smart_pointers.py 2007-12-24 19:17:09 UTC (rev 1209) @@ -106,7 +106,7 @@ smart_ptr = property( _get_smart_ptr, _set_smart_ptr ) def _instantiate_smart_ptr( self, decl ): - identifier = algorithm.create_identifier( self, decl.decl_string ) + identifier = algorithm.create_identifier( self, decl.partial_decl_string ) return templates.join( self.smart_ptr, [identifier] ) def _create_impl(self): Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2007-12-24 15:34:46 UTC (rev 1208) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2007-12-24 19:17:09 UTC (rev 1209) @@ -177,7 +177,7 @@ self._redefine_operators = False self._held_type = None self._noncopyable = None - self._wrapper_alias = self._generate_valid_name() + "_wrapper" + self._wrapper_alias = self._generate_valid_name(self.partial_name) + "_wrapper" self._registration_code = [] self._declaration_code = [] self._wrapper_code = [] Modified: pyplusplus_dev/unittests/ogre_generate_tester.py =================================================================== --- pyplusplus_dev/unittests/ogre_generate_tester.py 2007-12-24 15:34:46 UTC (rev 1208) +++ pyplusplus_dev/unittests/ogre_generate_tester.py 2007-12-24 19:17:09 UTC (rev 1209) @@ -41,9 +41,9 @@ print declarations.full_name( y, with_defaults=False ) target_dir = os.path.join( autoconfig.build_directory, 'ogre' ) - if os.path.exists( target_dir ): - shutil.rmtree( target_dir ) - os.mkdir( target_dir ) + #~ if os.path.exists( target_dir ): + #~ shutil.rmtree( target_dir ) + #~ os.mkdir( target_dir ) mb.build_code_creator( 'Ogre3d' ) mb.split_module( target_dir ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |