Revision: 275
Author: roman_yakovenko
Date: 2006-07-07 11:44:39 -0700 (Fri, 07 Jul 2006)
ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=275&view=rev
Log Message:
-----------
another small refactoring before implementing bug
fix for msvc 7.1 operator ()
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/code_creators/calldef.py
Modified: pyplusplus_dev/pyplusplus/code_creators/calldef.py
===================================================================
--- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-07-05 12:55:47 UTC (rev 274)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-07-07 18:44:39 UTC (rev 275)
@@ -66,29 +66,39 @@
result.append( ' )' )
return ''.join( result )
- def append_def_code( self, result ):
- result.append( 'def( ' )
-
- def append_def_end_code( self, result ):
- result.append( ' )' )
-
- def append_alias_code( self, result ):
- result.append( '"%s"' % self.alias )
-
- def append_use_keywords_code( self, result ):
- if not self.declaration.use_keywords:
- return
- result.append( self.param_sep() )
- result.append( self.keywords_args() )
-
- def append_call_policies_code( self, result ):
- if self.declaration.call_policies:
- result.append( self.param_sep() )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
-
+ def create_def_code( self ):
+ return 'def'
+
+ def create_function_ref_code( self ):
+ raise NotImplementedError()
+
+ def _create_impl( self ):
+ result = []
+
+ result.append( self.create_def_code() )
+ result.append( '( ' )
+ result.append( os.linesep + self.indent( '"%s"' % self.alias, 2 ) )
+ result.append( self.param_sep() )
+
+ result.append( self.create_function_ref_code() )
+ if self.declaration.use_keywords:
+ result.append( self.param_sep() )
+ result.append( self.keywords_args() )
+
+ if self.declaration.call_policies:
+ result.append( self.param_sep() )
+ result.append( self.declaration.call_policies.create( self ) )
+ else:
+ result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
+
+ result.append( ' )' )
+ if not self.works_on_instance:
+ result.append( ';' )
+
+ return ''.join( result )
+
+
class calldef_wrapper_t( declaration_based.declaration_based_t):
def __init__(self, function ):
declaration_based.declaration_based_t.__init__( self, declaration=function )
@@ -135,7 +145,7 @@
return ', '.join( params )
def wrapped_class_identifier( self ):
- return algorithm.create_identifier( self, self.declaration.parent.decl_string )
+ return algorithm.create_identifier( self, declarations.full_name( self.declaration.parent ) )
def unoverriden_function_body( self ):
msg = r'This function could not be overriden in Python!'
@@ -153,86 +163,46 @@
class free_function_t( calldef_t ):
def __init__( self, function ):
calldef_t.__init__( self, function=function )
-
- def _create_impl(self):
- param_sep = self.param_sep()
-
- result = [ self.def_identifier() ]
- result.append( '(' )
-
- self.append_alias_code( result )
-
- result.append( param_sep )
+ self.works_on_instance = False
+
+ def create_def_code( self ):
+ return self.def_identifier()
+
+ def create_function_ref_code(self):
if self.declaration.create_with_signature:
- result.append( '(%s)( &%s )'
- %( self.declaration.function_type().decl_string
- , declarations.full_name( self.declaration ) ) )
+ return '(%s)( &%s )' \
+ % ( self.declaration.function_type().decl_string
+ , declarations.full_name( self.declaration ) )
else:
- result.append( '&%s' % declarations.full_name( self.declaration ) )
-
- self.append_use_keywords_code( result )
- self.append_call_policies_code( result )
-
- result.append( ' );' )
- return ''.join( result )
+ return '&%s' % declarations.full_name( self.declaration )
class mem_fun_t( calldef_t ):
def __init__( self, function ):
calldef_t.__init__( self, function=function )
- def _create_impl(self):
- param_sep = self.param_sep()
-
- result = []
-
- self.append_def_code( result )
- self.append_alias_code( result )
-
- result.append( param_sep )
+ def create_function_ref_code(self):
if self.declaration.create_with_signature:
- result.append( '(%s)( &%s )'
- %( self.declaration.function_type().decl_string
- , declarations.full_name( self.declaration ) ) )
+ return '(%s)( &%s )' \
+ % ( self.declaration.function_type().decl_string
+ , declarations.full_name( self.declaration ) )
else:
- result.append( '&%s' % declarations.full_name( self.declaration ) )
-
- self.append_use_keywords_code( result )
- self.append_call_policies_code( result )
+ return '&%s' % declarations.full_name( self.declaration )
- self.append_def_end_code( result )
-
- return ''.join( result )
-
class mem_fun_pv_t( calldef_t ):
def __init__( self, function, wrapper ):
calldef_t.__init__( self, function=function, wrapper=wrapper )
- def _create_impl(self):
- param_sep = self.param_sep()
-
- result = []
-
- self.append_def_code( result )
- self.append_alias_code( result )
-
- result.append( param_sep )
+ def create_function_ref_code(self):
if self.declaration.create_with_signature:
- result.append( '%s( (%s)(&%s) )'
- % ( self.pure_virtual_identifier()
- , self.declaration.function_type().decl_string
- , declarations.full_name( self.declaration ) ) )
+ return '%s( (%s)(&%s) )' \
+ % ( self.pure_virtual_identifier()
+ , self.declaration.function_type().decl_string
+ , declarations.full_name( self.declaration ) )
else:
- result.append( '%s( &%s )'
- % ( self.pure_virtual_identifier()
- , declarations.full_name( self.declaration ) ) )
-
- self.append_use_keywords_code( result )
- self.append_call_policies_code( result )
-
- self.append_def_end_code( result )
-
- return ''.join( result )
+ return '%s( &%s )' \
+ % ( self.pure_virtual_identifier()
+ , declarations.full_name( self.declaration ) )
class mem_fun_pv_wrapper_t( calldef_wrapper_t ):
def __init__( self, function ):
@@ -282,34 +252,21 @@
def __init__( self, function, wrapper=None ):
calldef_t.__init__( self, function=function, wrapper=wrapper )
- def _create_impl(self):
- param_sep = self.param_sep()
-
+ def create_function_ref_code(self):
result = []
-
- self.append_def_code( result )
- self.append_alias_code( result )
-
- result.append( param_sep )
if self.declaration.create_with_signature:
result.append( '(%s)(&%s)'
% ( self.declaration.function_type().decl_string
, declarations.full_name( self.declaration ) ) )
if self.wrapper:
- result.append( param_sep )
+ result.append( self.param_sep() )
result.append( '(%s)(&%s)'
% ( self.wrapper.function_type().decl_string, self.wrapper.default_full_name() ) )
else:
result.append( '&%s'% declarations.full_name( self.declaration ) )
if self.wrapper:
- result.append( param_sep )
+ result.append( self.param_sep() )
result.append( '&%s' % self.wrapper.default_full_name() )
-
- self.append_use_keywords_code( result )
- self.append_call_policies_code( result )
-
- self.append_def_end_code( result )
-
return ''.join( result )
class mem_fun_v_wrapper_t( calldef_wrapper_t ):
@@ -398,29 +355,12 @@
def __init__( self, function, wrapper ):
calldef_t.__init__( self, function=function, wrapper=wrapper )
- def _create_impl(self):
- param_sep = self.param_sep()
-
- result = []
-
- self.append_def_code( result )
- self.append_alias_code( result )
-
- result.append( param_sep )
+ def create_function_ref_code(self):
if self.declaration.create_with_signature:
- result.append( '(%s)(&%s)'
- % ( self.wrapper.function_type().decl_string
- , self.wrapper.full_name() ) )
+ return '(%s)(&%s)' \
+ % ( self.wrapper.function_type().decl_string, self.wrapper.full_name() )
else:
- result.append( '&%s' % self.wrapper.full_name() )
-
-
- self.append_use_keywords_code( result )
- self.append_call_policies_code( result )
-
- self.append_def_end_code( result )
-
- return ''.join( result )
+ return '&%s' % self.wrapper.full_name()
class mem_fun_protected_wrapper_t( calldef_wrapper_t ):
def __init__( self, function ):
@@ -480,28 +420,12 @@
def __init__( self, function, wrapper ):
calldef_t.__init__( self, function=function, wrapper=wrapper )
- def _create_impl(self):
- param_sep = self.param_sep()
-
- result = []
-
- self.append_def_code( result )
- self.append_alias_code( result )
-
- result.append( param_sep )
+ def create_function_ref_code(self):
if self.declaration.create_with_signature:
- result.append( '(%s)(&%s)'
- % ( self.wrapper.function_type().decl_string
- , self.wrapper.full_name() ) )
+ return '(%s)(&%s)' \
+ % ( self.wrapper.function_type().decl_string, self.wrapper.full_name() )
else:
- result.append( '&%s' % self.wrapper.full_name() )
-
- self.append_use_keywords_code( result )
- self.append_call_policies_code( result )
-
- self.append_def_end_code( result )
-
- return ''.join( result )
+ return '&%s' % self.wrapper.full_name()
class mem_fun_protected_s_wrapper_t( calldef_wrapper_t ):
def __init__( self, function ):
@@ -552,30 +476,13 @@
def __init__( self, function, wrapper ):
calldef_t.__init__( self, function=function, wrapper=wrapper )
- def _create_impl(self):
- param_sep = self.param_sep()
-
- result = []
-
- self.append_def_code( result )
- self.append_alias_code( result )
-
- result.append( param_sep )
+ def create_function_ref_code(self):
if self.declaration.create_with_signature:
- result.append( '(%s)(&%s)'
- % ( self.wrapper.function_type().decl_string, self.wrapper.full_name() ) )
+ return '(%s)(&%s)' \
+ % ( self.wrapper.function_type().decl_string, self.wrapper.full_name() )
else:
- result.append( '&%s' % self.wrapper.full_name() )
-
-
- self.append_use_keywords_code( result )
- self.append_call_policies_code( result )
-
- self.append_def_end_code( result )
-
- return ''.join( result )
+ return '&%s' % self.wrapper.full_name()
-
class mem_fun_protected_v_wrapper_t( calldef_wrapper_t ):
def __init__( self, function):
calldef_wrapper_t.__init__( self, function=function )
@@ -639,29 +546,12 @@
def __init__( self, function, wrapper ):
calldef_t.__init__( self, function=function, wrapper=wrapper )
- def _create_impl(self):
- param_sep = self.param_sep()
-
- result = []
-
- self.append_def_code( result )
- self.append_alias_code( result )
-
- result.append( param_sep )
+ def create_function_ref_code(self):
if self.declaration.create_with_signature:
- result.append( '(%s)(&%s)'
- % ( self.wrapper.function_type().decl_string
- , self.wrapper.full_name() ) )
+ return '(%s)(&%s)' \
+ % ( self.wrapper.function_type().decl_string, self.wrapper.full_name() )
else:
- result.append( '&%s' % self.wrapper.full_name() )
-
-
- self.append_use_keywords_code( result )
- self.append_call_policies_code( result )
-
- self.append_def_end_code( result )
-
- return ''.join( result )
+ return '&%s' % self.wrapper.full_name()
class mem_fun_protected_pv_wrapper_t( calldef_wrapper_t ):
def __init__( self, function):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|