Revision: 274
Author: roman_yakovenko
Date: 2006-07-05 05:55:47 -0700 (Wed, 05 Jul 2006)
ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=274&view=rev
Log Message:
-----------
small refactoring before adding fix for 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 08:12:38 UTC (rev 273)
+++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-07-05 12:55:47 UTC (rev 274)
@@ -34,7 +34,7 @@
self._wrapper = new_wrapper
wrapper = property( _get_wrapper, _set_wrapper )
- def def_identifier( self ):
+ def def_identifier( self ):
return algorithm.create_identifier( self, '::boost::python::def' )
def pure_virtual_identifier( self ):
@@ -65,7 +65,30 @@
result.append( '=%s()' % boost_obj )
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 ) )
+
+
class calldef_wrapper_t( declaration_based.declaration_based_t):
def __init__(self, function ):
declaration_based.declaration_based_t.__init__( self, declaration=function )
@@ -136,7 +159,9 @@
result = [ self.def_identifier() ]
result.append( '(' )
- result.append( '"%s"' % self.alias )
+
+ self.append_alias_code( result )
+
result.append( param_sep )
if self.declaration.create_with_signature:
result.append( '(%s)( &%s )'
@@ -144,15 +169,10 @@
, declarations.full_name( self.declaration ) ) )
else:
result.append( '&%s' % declarations.full_name( self.declaration ) )
-
- if self.declaration.use_keywords:
- result.append( param_sep )
- result.append( self.keywords_args() )
- if self.declaration.call_policies:
- result.append( param_sep )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
+
+ self.append_use_keywords_code( result )
+ self.append_call_policies_code( result )
+
result.append( ' );' )
return ''.join( result )
@@ -163,9 +183,11 @@
def _create_impl(self):
param_sep = self.param_sep()
- result = [ 'def' ]
- result.append( '(' )
- result.append( '"%s"' % self.alias )
+ 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 )'
@@ -173,16 +195,12 @@
, 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 )
+
+ self.append_def_end_code( result )
- if self.declaration.use_keywords:
- result.append( param_sep )
- result.append( self.keywords_args() )
- if self.declaration.call_policies:
- result.append( param_sep )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
- result.append( ' )' )
return ''.join( result )
@@ -193,9 +211,11 @@
def _create_impl(self):
param_sep = self.param_sep()
- result = [ 'def' ]
- result.append( '(' )
- result.append( '"%s"' % self.alias )
+ 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)(&%s) )'
@@ -207,15 +227,11 @@
% ( self.pure_virtual_identifier()
, declarations.full_name( self.declaration ) ) )
- if self.declaration.use_keywords:
- result.append( param_sep )
- result.append( self.keywords_args() )
- if self.declaration.call_policies:
- result.append( param_sep )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
- result.append( ' )' )
+ self.append_use_keywords_code( result )
+ self.append_call_policies_code( result )
+
+ self.append_def_end_code( result )
+
return ''.join( result )
class mem_fun_pv_wrapper_t( calldef_wrapper_t ):
@@ -269,9 +285,11 @@
def _create_impl(self):
param_sep = self.param_sep()
- result = [ 'def' ]
- result.append( '(' )
- result.append( '"%s"' % self.alias )
+ 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)'
@@ -286,16 +304,12 @@
if self.wrapper:
result.append( param_sep )
result.append( '&%s' % self.wrapper.default_full_name() )
-
- if self.declaration.use_keywords:
- result.append( param_sep )
- result.append( self.keywords_args() )
- if self.declaration.call_policies:
- result.append( param_sep )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
- result.append( ' )' )
+
+ 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 ):
@@ -387,9 +401,11 @@
def _create_impl(self):
param_sep = self.param_sep()
- result = [ 'def' ]
- result.append( '(' )
- result.append( '"%s"' % self.alias )
+ 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)'
@@ -398,15 +414,12 @@
else:
result.append( '&%s' % self.wrapper.full_name() )
- if self.declaration.use_keywords:
- result.append( param_sep )
- result.append( self.keywords_args() )
- if self.declaration.call_policies:
- result.append( param_sep )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
- result.append( ' )' )
+
+ self.append_use_keywords_code( result )
+ self.append_call_policies_code( result )
+
+ self.append_def_end_code( result )
+
return ''.join( result )
class mem_fun_protected_wrapper_t( calldef_wrapper_t ):
@@ -470,9 +483,11 @@
def _create_impl(self):
param_sep = self.param_sep()
- result = [ 'def' ]
- result.append( '(' )
- result.append( '"%s"' % self.alias )
+ 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)'
@@ -480,16 +495,12 @@
, self.wrapper.full_name() ) )
else:
result.append( '&%s' % self.wrapper.full_name() )
-
- if self.declaration.use_keywords:
- result.append( param_sep )
- result.append( self.keywords_args() )
- if self.declaration.call_policies:
- result.append( param_sep )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
- result.append( ' )' )
+
+ self.append_use_keywords_code( result )
+ self.append_call_policies_code( result )
+
+ self.append_def_end_code( result )
+
return ''.join( result )
class mem_fun_protected_s_wrapper_t( calldef_wrapper_t ):
@@ -544,9 +555,11 @@
def _create_impl(self):
param_sep = self.param_sep()
- result = [ 'def' ]
- result.append( '(' )
- result.append( '"%s"' % self.alias )
+ 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)'
@@ -554,15 +567,12 @@
else:
result.append( '&%s' % self.wrapper.full_name() )
- if self.declaration.use_keywords:
- result.append( param_sep )
- result.append( self.keywords_args() )
- if self.declaration.call_policies:
- result.append( param_sep )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
- result.append( ' )' )
+
+ self.append_use_keywords_code( result )
+ self.append_call_policies_code( result )
+
+ self.append_def_end_code( result )
+
return ''.join( result )
@@ -632,9 +642,11 @@
def _create_impl(self):
param_sep = self.param_sep()
- result = [ 'def' ]
- result.append( '(' )
- result.append( '"%s"' % self.alias )
+ 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)'
@@ -643,15 +655,12 @@
else:
result.append( '&%s' % self.wrapper.full_name() )
- if self.declaration.use_keywords:
- result.append( param_sep )
- result.append( self.keywords_args() )
- if self.declaration.call_policies:
- result.append( param_sep )
- result.append( self.declaration.call_policies.create( self ) )
- else:
- result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) )
- result.append( ' )' )
+
+ self.append_use_keywords_code( result )
+ self.append_call_policies_code( result )
+
+ self.append_def_end_code( result )
+
return ''.join( result )
class mem_fun_protected_pv_wrapper_t( calldef_wrapper_t ):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|