[pygccxml-commit] SF.net SVN: pygccxml: [742] pyplusplus_dev_ft
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-11-21 13:00:32
|
Revision: 742 http://svn.sourceforge.net/pygccxml/?rev=742&view=rev Author: roman_yakovenko Date: 2006-11-21 05:00:32 -0800 (Tue, 21 Nov 2006) Log Message: ----------- Modified Paths: -------------- pyplusplus_dev_ft/pyplusplus/code_creators/__init__.py pyplusplus_dev_ft/pyplusplus/code_creators/algorithm.py pyplusplus_dev_ft/pyplusplus/code_creators/calldef.py pyplusplus_dev_ft/pyplusplus/code_creators/calldef_transformed.py pyplusplus_dev_ft/pyplusplus/function_transformers/__init__.py pyplusplus_dev_ft/pyplusplus/function_transformers/controllers.py pyplusplus_dev_ft/pyplusplus/function_transformers/function_transformation.py pyplusplus_dev_ft/pyplusplus/function_transformers/templates.py pyplusplus_dev_ft/pyplusplus/function_transformers/transformer.py pyplusplus_dev_ft/pyplusplus/function_transformers/transformers.py pyplusplus_dev_ft/unittests/data/function_transformations_to_be_exported.hpp pyplusplus_dev_ft/unittests/function_transformations_tester.py Modified: pyplusplus_dev_ft/pyplusplus/code_creators/__init__.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/code_creators/__init__.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/code_creators/__init__.py 2006-11-21 13:00:32 UTC (rev 742) @@ -78,8 +78,8 @@ from calldef_transformed import mem_fun_transformed_t from calldef_transformed import mem_fun_transformed_wrapper_t -from calldef_transformed import mem_fun_v_transformed_t -from calldef_transformed import mem_fun_v_transformed_wrapper_t +#~ from calldef_transformed import mem_fun_v_transformed_t +#~ from calldef_transformed import mem_fun_v_transformed_wrapper_t from global_variable import global_variable_base_t from global_variable import global_variable_t Modified: pyplusplus_dev_ft/pyplusplus/code_creators/algorithm.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/code_creators/algorithm.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/code_creators/algorithm.py 2006-11-21 13:00:32 UTC (rev 742) @@ -99,3 +99,6 @@ if recursive: search_area = make_flatten_generator( where ) return filter( lambda inst: isinstance( inst, what ), search_area ) + +def make_id_creator( code_creator ): + return lambda decl_string: create_identifier( code_creator, decl_string ) Modified: pyplusplus_dev_ft/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/code_creators/calldef.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/code_creators/calldef.py 2006-11-21 13:00:32 UTC (rev 742) @@ -19,9 +19,6 @@ #protected member functions - call, override #private - override -def make_id_creator( code_creator ): - return lambda decl_string: algorithm.create_identifier( code_creator, decl_string ) - class calldef_t( registration_based.registration_based_t , declaration_based.declaration_based_t ): def __init__(self, function, wrapper=None ): @@ -51,7 +48,7 @@ return os.linesep + self.indent( self.PARAM_SEPARATOR ) def keywords_args(self): - arg_utils = calldef_utils.argument_utils_t( self.declaration, make_id_creator( self ) ) + arg_utils = calldef_utils.argument_utils_t( self.declaration, algorithm.make_id_creator( self ) ) return arg_utils.keywords_args() def create_def_code( self ): @@ -139,11 +136,11 @@ return algorithm.create_identifier( self, '::boost::python::override' ) def function_call_args( self ): - arg_utils = calldef_utils.argument_utils_t( self.declaration, make_id_creator( self ) ) + arg_utils = calldef_utils.argument_utils_t( self.declaration, algorithm.make_id_creator( self ) ) return arg_utils.call_args() def args_declaration( self ): - arg_utils = calldef_utils.argument_utils_t( self.declaration, make_id_creator( self ) ) + arg_utils = calldef_utils.argument_utils_t( self.declaration, algorithm.make_id_creator( self ) ) return arg_utils.args_declaration() def wrapped_class_identifier( self ): @@ -841,7 +838,7 @@ def _create_constructor_call( self ): answer = [ algorithm.create_identifier( self, self.parent.declaration.decl_string ) ] answer.append( '( ' ) - arg_utils = calldef_utils.argument_utils_t( self.declaration, make_id_creator( self ) ) + arg_utils = calldef_utils.argument_utils_t( self.declaration, algorithm.make_id_creator( self ) ) params = arg_utils.call_args() answer.append( params ) if params: Modified: pyplusplus_dev_ft/pyplusplus/code_creators/calldef_transformed.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/code_creators/calldef_transformed.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/code_creators/calldef_transformed.py 2006-11-21 13:00:32 UTC (rev 742) @@ -4,8 +4,9 @@ # http://www.boost.org/LICENSE_1_0.txt) import os -#import algorithm -#import code_creator +import algorithm +import code_creator +import calldef_utils import class_declaration from pygccxml import declarations from calldef import calldef_t, calldef_wrapper_t @@ -21,42 +22,34 @@ def __init__( self, function, wrapper=None ): calldef_t.__init__( self, function=function, wrapper=wrapper ) + @property + def ft( self ): #function transformation + return self.declaration.transformations[0] + def create_function_type_alias_code( self, exported_class_alias=None ): - if self.wrapper==None: - ftype = self.declaration.function_type() - else: - ftype = self.wrapper.function_type() - res = 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) - return res + ftype = self.wrapper.function_type() + return 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) def create_function_ref_code(self, use_function_alias=False): - if self.wrapper: - full_name = self.wrapper.full_name() - else: - full_name = declarations.full_name( self.declaration ) + full_name = self.wrapper.full_name() if use_function_alias: return '%s( &%s )' \ % ( self.function_type_alias, full_name ) elif self.declaration.create_with_signature: - if self.wrapper: - func_type = self.wrapper.function_type() - else: - func_type = self.declaration.function_type().decl_string - return '(%s)( &%s )' \ - % ( func_type, full_name ) + func_type = self.wrapper.function_type() + return '(%s)( &%s )' % ( func_type, full_name ) else: return '&%s' % full_name + def keywords_args(self): + arg_utils = calldef_utils.argument_utils_t( self.declaration + , algorithm.make_id_creator( self ) + , self.ft.controller.wrapper_args ) + return arg_utils.keywords_args() -class mem_fun_transformed_wrapper_t( calldef_wrapper_t ): - """Creates wrapper code for (public) non-virtual member functions. - The generated function is either used as a static member inside the - wrapper class (when self.parent is not None) or as a free function - (when self.parent is None). - """ - +class mem_fun_transformed_wrapper_t( calldef_wrapper_t ): def __init__( self, function ): """Constructor. @@ -64,422 +57,390 @@ @type function: calldef_t """ calldef_wrapper_t.__init__( self, function=function ) + + this_arg_type = declarations.declarated_t( self.declaration.parent ) + if self.declaration.has_const: + this_arg_type = declarations.const_t( this_arg_type ) + this_arg_type = declarations.reference_t( this_arg_type ) + + self.__this_arg = declarations.argument_t( + name=self.ft.controller.register_variable_name( 'self' ) + , type=this_arg_type ) + + @property + def ft( self ): #function transformation + return self.declaration.transformations[0] - # Create the substitution manager - sm = function_transformers.substitution_manager_t( function - , transformers=function.transformations[0].transformers) - sm.init_funcs() - self._subst_manager = sm - def function_type(self): - """Return the type of the wrapper function. - - @rtype: type_t - """ - template = '$RET_TYPE' - rettype = self._subst_manager.subst_wrapper(template) - rettype = declarations.dummy_type_t(rettype) - return declarations.free_function_type_t( - return_type=rettype - , arguments_types=map( lambda arg: arg.type, self.declaration.arguments ) ) + return_type=self.declaration.return_type + , arguments_types=[ declarations.dummy_type_t( self.parent.full_name ) ] + + map( lambda arg: arg.type, self.ft.controller.wrapper_args ) ) - def wrapper_name(self): - """Return the name of the wrapper function. - - This is just the local name without any scope information. - """ - # A list with the individual components of the name - components = ["_py"] - # Is the wrapper placed outside a wrapper class? - if not isinstance(self.parent, class_declaration.class_wrapper_t): - # Incorporate the original class name into the name - components.append(self.declaration.parent.name) - components.append(self.declaration.alias) - return "_".join(components) - def full_name(self): - """Return the full name of the wrapper function. + return self.parent.full_name + '::' + self.declaration.name - The returned name also includes the class name (if there is any). + def args_declaration( self ): + arg_utils = calldef_utils.argument_utils_t( + self.declaration + , algorithm.make_id_creator( self ) + , [ self.__this_arg ] + self.ft.controller.wrapper_args ) + return arg_utils.args_declaration() - @rtype: str - """ - if isinstance(self.parent, class_declaration.class_wrapper_t): - return self.parent.full_name + '::' + self.wrapper_name() - else: - return self.wrapper_name() - def create_declaration(self, name): - """Create the function header. - """ - template = 'static $RET_TYPE %(name)s( $ARG_LIST_DEF ) %(throw)s' + template = 'static %(return_type)s %(name)s( %(args)s )' - # Substitute the $-variables - template = self._subst_manager.subst_wrapper(template) - return template % { - 'name' : self.wrapper_name() - , 'throw' : self.throw_specifier_code() + 'return_type' : self.ft.controller.wrapper_return_type.decl_string + , 'name' : self.declaration.name + , 'args' : self.args_declaration() } def create_body(self): - body = os.linesep.join([ - '$DECLARATIONS' - , '$PRE_CALL' - , '$RESULT_VAR_ASSIGNMENT$CALL_FUNC_NAME($INPUT_PARAMS);' - , '$POST_CALL' - , '$RETURN_STMT' - ]) + cntrl = self.ft.controller + arg_utils = calldef_utils.argument_utils_t( + self.declaration + , algorithm.make_id_creator( self ) + , cntrl.wrapper_args ) - # Replace the $-variables - body = self._subst_manager.subst_wrapper(body) - - return body - - def create_function(self): - answer = [70*"/"] - answer.append("// Transformed wrapper function for:") - answer.append("// %s"%self.declaration) - answer.append(70*"/") + return cntrl.template.substitute( + declare_variables=map( lambda var: var.declare_var_string(), cntrl.variables ) + , pre_call=os.linesep.join( cntrl.pre_call ) + , post_call=os.linesep.join( cntrl.post_call ) + , save_return_value_stmt=cntrl.save_return_value_stmt + , function=self.__this_arg.name + '.' + self.declaration.name + , arg_expressions=self.PARAM_SEPARATOR.join( cntrl.arg_expressions ) + , return_stmt='' + ) + + def _create_impl(self): + answer = ['// Transformed wrapper function for "%s"' % self.declaration ] answer.append( self.create_declaration(self.declaration.alias) + '{') answer.append( self.indent( self.create_body() ) ) answer.append( '}' ) return os.linesep.join( answer ) - def _create_impl(self): +#~ ###################################################################### - answer = self.create_function() +#~ class mem_fun_v_transformed_t( calldef_t ): + #~ """Creates code for (public) virtual member functions. + #~ """ - # Replace the argument list of the declaration so that in the - # case that keywords are created, the correct arguments will be - # picked up (i.e. the modified argument list and not the original - # argument list) - self.declaration.arguments = self._subst_manager.wrapper_func.arg_list + #~ def __init__( self, function, wrapper=None ): + #~ calldef_t.__init__( self, function=function, wrapper=wrapper ) + #~ self.default_function_type_alias = 'default_' + self.function_type_alias - return answer + #~ def create_function_type_alias_code( self, exported_class_alias=None ): + #~ if self.wrapper==None: + #~ ftype = self.declaration.function_type() + #~ else: + #~ ftype = self.wrapper.function_type() -###################################################################### + #~ result = [] + #~ result.append( 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) ) + #~ return ''.join( result ) -class mem_fun_v_transformed_t( calldef_t ): - """Creates code for (public) virtual member functions. - """ + #~ def create_doc(self): + #~ return None - def __init__( self, function, wrapper=None ): - calldef_t.__init__( self, function=function, wrapper=wrapper ) - self.default_function_type_alias = 'default_' + self.function_type_alias + #~ def create_function_ref_code(self, use_function_alias=False): + #~ if self.wrapper: + #~ full_name = self.wrapper.default_full_name() + #~ else: + #~ full_name = declarations.full_name( self.declaration ) - def create_function_type_alias_code( self, exported_class_alias=None ): - if self.wrapper==None: - ftype = self.declaration.function_type() - else: - ftype = self.wrapper.function_type() + #~ result = [] + #~ if use_function_alias: + #~ result.append( '%s(&%s)' + #~ % ( self.function_type_alias, full_name ) ) + #~ elif self.declaration.create_with_signature: + #~ if self.wrapper: + #~ func_type = self.wrapper.function_type() + #~ else: + #~ func_type = self.declaration.function_type().decl_string + #~ result.append( '(%s)(&%s)' + #~ % ( func_type, full_name ) ) + #~ else: + #~ result.append( '&%s' % full_name ) - result = [] - result.append( 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) ) - return ''.join( result ) + #~ return ''.join( result ) - def create_doc(self): - return None - def create_function_ref_code(self, use_function_alias=False): - if self.wrapper: - full_name = self.wrapper.default_full_name() - else: - full_name = declarations.full_name( self.declaration ) +#~ class mem_fun_v_transformed_wrapper_t( calldef_wrapper_t ): + #~ """Creates wrapper code for (public) virtual member functions. - result = [] - if use_function_alias: - result.append( '%s(&%s)' - % ( self.function_type_alias, full_name ) ) - elif self.declaration.create_with_signature: - if self.wrapper: - func_type = self.wrapper.function_type() - else: - func_type = self.declaration.function_type().decl_string - result.append( '(%s)(&%s)' - % ( func_type, full_name ) ) - else: - result.append( '&%s' % full_name ) + #~ The generated code consists of two functions: the virtual function + #~ and the 'default' function. + #~ """ - return ''.join( result ) + #~ def __init__( self, function ): + #~ """Constructor. + #~ @param function: Function declaration + #~ @type function: calldef_t + #~ """ + #~ calldef_wrapper_t.__init__( self, function=function ) -class mem_fun_v_transformed_wrapper_t( calldef_wrapper_t ): - """Creates wrapper code for (public) virtual member functions. - - The generated code consists of two functions: the virtual function - and the 'default' function. - """ - - def __init__( self, function ): - """Constructor. - - @param function: Function declaration - @type function: calldef_t - """ - calldef_wrapper_t.__init__( self, function=function ) - - # Create the substitution manager - sm = function_transformers.substitution_manager_t(function - , transformers=function.transformations[0].transformers ) + #~ # Create the substitution manager + #~ sm = function_transformers.substitution_manager_t(function + #~ , transformers=function.transformations[0].transformers ) - sm.init_funcs() - self._subst_manager = sm + #~ sm.init_funcs() + #~ self._subst_manager = sm - # Stores the name of the variable that holds the override - self._override_var \ - = sm.virtual_func.declare_variable(function.alias + "_callable", 'boost::python::override') - # Stores the name of the 'gstate' variable - self._gstate_var \ - = sm.virtual_func.declare_variable("gstate", 'pyplusplus::threading ::gil_guard_t' ) + #~ # Stores the name of the variable that holds the override + #~ self._override_var \ + #~ = sm.virtual_func.declare_variable(function.alias + "_callable", 'boost::python::override') + #~ # Stores the name of the 'gstate' variable + #~ self._gstate_var \ + #~ = sm.virtual_func.declare_variable("gstate", 'pyplusplus::threading ::gil_guard_t' ) - def default_name(self): - """Return the name of the 'default' function. + #~ def default_name(self): + #~ """Return the name of the 'default' function. - @rtype: str - """ - return "default_" + self.declaration.alias + #~ @rtype: str + #~ """ + #~ return "default_" + self.declaration.alias - def default_full_name(self): - """Return the full name of the 'default' function. + #~ def default_full_name(self): + #~ """Return the full name of the 'default' function. - The returned name also includes the class name. + #~ The returned name also includes the class name. - @rtype: str - """ - return self.parent.full_name + '::default_' + self.declaration.alias + #~ @rtype: str + #~ """ + #~ return self.parent.full_name + '::default_' + self.declaration.alias - def virtual_name(self): - """Return the name of the 'virtual' function. + #~ def virtual_name(self): + #~ """Return the name of the 'virtual' function. - @rtype: str - """ - return self.declaration.name + #~ @rtype: str + #~ """ + #~ return self.declaration.name - def base_name(self): - """Return the name of the 'base' function. + #~ def base_name(self): + #~ """Return the name of the 'base' function. - @rtype: str - """ - return "base_" + self.declaration.name + #~ @rtype: str + #~ """ + #~ return "base_" + self.declaration.name - def function_type(self): - template = '$RET_TYPE' - rettype = self._subst_manager.subst_wrapper(template) - rettype = declarations.dummy_type_t(rettype) + #~ def function_type(self): + #~ template = '$RET_TYPE' + #~ rettype = self._subst_manager.subst_wrapper(template) + #~ rettype = declarations.dummy_type_t(rettype) - return declarations.free_function_type_t( - return_type=rettype - , arguments_types=map( lambda arg: arg.type, self.declaration.arguments ) ) + #~ return declarations.free_function_type_t( + #~ return_type=rettype + #~ , arguments_types=map( lambda arg: arg.type, self.declaration.arguments ) ) - return declarations.member_function_type_t( - return_type=self.declaration.return_type - , class_inst=declarations.dummy_type_t( self.parent.full_name ) - , arguments_types=map( lambda arg: arg.type, self.declaration.arguments ) - , has_const=self.declaration.has_const ) + #~ return declarations.member_function_type_t( + #~ return_type=self.declaration.return_type + #~ , class_inst=declarations.dummy_type_t( self.parent.full_name ) + #~ , arguments_types=map( lambda arg: arg.type, self.declaration.arguments ) + #~ , has_const=self.declaration.has_const ) - def create_declaration(self, name, virtual=True): - """Create the function header. + #~ def create_declaration(self, name, virtual=True): + #~ """Create the function header. - This method is used for the virtual function (and the base_ function), - but not for the default function. - """ - template = '%(virtual)s$RET_TYPE %(name)s( $ARG_LIST_DEF )%(constness)s %(throw)s' + #~ This method is used for the virtual function (and the base_ function), + #~ but not for the default function. + #~ """ + #~ template = '%(virtual)s$RET_TYPE %(name)s( $ARG_LIST_DEF )%(constness)s %(throw)s' - # Substitute the $-variables - template = self._subst_manager.subst_virtual(template) + #~ # Substitute the $-variables + #~ template = self._subst_manager.subst_virtual(template) - virtualspec = '' - if virtual: - virtualspec = 'virtual ' + #~ virtualspec = '' + #~ if virtual: + #~ virtualspec = 'virtual ' - constness = '' - if self.declaration.has_const: - constness = ' const ' + #~ constness = '' + #~ if self.declaration.has_const: + #~ constness = ' const ' - return template % { - 'virtual' : virtualspec - , 'name' : name - , 'constness' : constness - , 'throw' : self.throw_specifier_code() - } + #~ return template % { + #~ 'virtual' : virtualspec + #~ , 'name' : name + #~ , 'constness' : constness + #~ , 'throw' : self.throw_specifier_code() + #~ } - def create_base_body(self): - body = "%(return_)s%(wrapped_class)s::%(name)s( %(args)s );" + #~ def create_base_body(self): + #~ body = "%(return_)s%(wrapped_class)s::%(name)s( %(args)s );" - return_ = '' - if not declarations.is_void( self.declaration.return_type ): - return_ = 'return ' + #~ return_ = '' + #~ if not declarations.is_void( self.declaration.return_type ): + #~ return_ = 'return ' - return body % { - 'name' : self.declaration.name - , 'args' : self.function_call_args() - , 'return_' : return_ - , 'wrapped_class' : self.wrapped_class_identifier() - } + #~ return body % { + #~ 'name' : self.declaration.name + #~ , 'args' : self.function_call_args() + #~ , 'return_' : return_ + #~ , 'wrapped_class' : self.wrapped_class_identifier() + #~ } - def create_virtual_body(self): + #~ def create_virtual_body(self): - thread_safe = self.declaration.transformations[0].thread_safe + #~ thread_safe = self.declaration.transformations[0].thread_safe - if thread_safe: - body = """ -pyplusplus::threading::gil_guard_t %(gstate_var)s; + #~ if thread_safe: + #~ body = """ +#~ pyplusplus::threading::gil_guard_t %(gstate_var)s; -%(gstate_var)s.ensure(); -boost::python::override %(override_var)s = this->get_override( "%(alias)s" ); -%(gstate_var)s.release(); +#~ %(gstate_var)s.ensure(); +#~ boost::python::override %(override_var)s = this->get_override( "%(alias)s" ); +#~ %(gstate_var)s.release(); -if( %(override_var)s ) -{ - // The corresponding release() is done in the destructor of %(gstate_var)s - %(gstate_var)s.ensure(); +#~ if( %(override_var)s ) +#~ { + #~ // The corresponding release() is done in the destructor of %(gstate_var)s + #~ %(gstate_var)s.ensure(); - $DECLARATIONS + #~ $DECLARATIONS - try { - $PRE_CALL + #~ try { + #~ $PRE_CALL - ${RESULT_VAR_ASSIGNMENT}boost::python::call<$RESULT_TYPE>($INPUT_PARAMS); + #~ ${RESULT_VAR_ASSIGNMENT}boost::python::call<$RESULT_TYPE>($INPUT_PARAMS); - $POST_CALL + #~ $POST_CALL - $RETURN_STMT - } - catch(...) - { - if (PyErr_Occurred()) - { - PyErr_Print(); - } + #~ $RETURN_STMT + #~ } + #~ catch(...) + #~ { + #~ if (PyErr_Occurred()) + #~ { + #~ PyErr_Print(); + #~ } - $CLEANUP + #~ $CLEANUP - $EXCEPTION_HANDLER_EXIT - } -} -else -{ - %(inherited)s -} -""" + #~ $EXCEPTION_HANDLER_EXIT + #~ } +#~ } +#~ else +#~ { + #~ %(inherited)s +#~ } +#~ """ - if not thread_safe: - body = """ -boost::python::override %(override_var)s = this->get_override( "%(alias)s" ); + #~ if not thread_safe: + #~ body = """ +#~ boost::python::override %(override_var)s = this->get_override( "%(alias)s" ); -if( %(override_var)s ) -{ - $DECLARATIONS +#~ if( %(override_var)s ) +#~ { + #~ $DECLARATIONS - $PRE_CALL + #~ $PRE_CALL - ${RESULT_VAR_ASSIGNMENT}boost::python::call<$RESULT_TYPE>($INPUT_PARAMS); + #~ ${RESULT_VAR_ASSIGNMENT}boost::python::call<$RESULT_TYPE>($INPUT_PARAMS); - $POST_CALL + #~ $POST_CALL - $RETURN_STMT -} -else -{ - %(inherited)s -} -""" + #~ $RETURN_STMT +#~ } +#~ else +#~ { + #~ %(inherited)s +#~ } +#~ """ - vf = self._subst_manager.virtual_func - arg0 = "%s.ptr()"%self._override_var - if vf.INPUT_PARAMS=="": - vf.INPUT_PARAMS = arg0 - else: - vf.INPUT_PARAMS = arg0+", "+vf.INPUT_PARAMS + #~ vf = self._subst_manager.virtual_func + #~ arg0 = "%s.ptr()"%self._override_var + #~ if vf.INPUT_PARAMS=="": + #~ vf.INPUT_PARAMS = arg0 + #~ else: + #~ vf.INPUT_PARAMS = arg0+", "+vf.INPUT_PARAMS - # Replace the $-variables - body = self._subst_manager.subst_virtual(body) + #~ # Replace the $-variables + #~ body = self._subst_manager.subst_virtual(body) - return body % { - 'override_var' : self._override_var - , 'gstate_var' : self._gstate_var - , 'alias' : self.declaration.alias - , 'inherited' : self.create_base_body() - } + #~ return body % { + #~ 'override_var' : self._override_var + #~ , 'gstate_var' : self._gstate_var + #~ , 'alias' : self.declaration.alias + #~ , 'inherited' : self.create_base_body() + #~ } - def create_default_body(self): - cls_wrapper_type = self.parent.full_name - cls_wrapper = self._subst_manager.wrapper_func.declare_variable("cls_wrapper", cls_wrapper_type); - # The name of the 'self' variable (i.e. first argument) - selfname = self._subst_manager.wrapper_func.arg_list[0].name + #~ def create_default_body(self): + #~ cls_wrapper_type = self.parent.full_name + #~ cls_wrapper = self._subst_manager.wrapper_func.declare_variable("cls_wrapper", cls_wrapper_type); + #~ # The name of the 'self' variable (i.e. first argument) + #~ selfname = self._subst_manager.wrapper_func.arg_list[0].name - body = """$DECLARATIONS + #~ body = """$DECLARATIONS -$PRE_CALL +#~ $PRE_CALL -%(cls_wrapper_type)s* %(cls_wrapper)s = dynamic_cast<%(cls_wrapper_type)s*>(boost::addressof(%(self)s)); -if (%(cls_wrapper)s==0) -{ - // The following call is done on an instance created in C++, - // so it won't invoke Python code. - $RESULT_VAR_ASSIGNMENT$CALL_FUNC_NAME($INPUT_PARAMS); -} -else -{ - // The following call is done on an instance created in Python, - // i.e. a wrapper instance. This call might invoke Python code. - $RESULT_VAR_ASSIGNMENT%(cls_wrapper)s->%(base_name)s($INPUT_PARAMS); -} +#~ %(cls_wrapper_type)s* %(cls_wrapper)s = dynamic_cast<%(cls_wrapper_type)s*>(boost::addressof(%(self)s)); +#~ if (%(cls_wrapper)s==0) +#~ { + #~ // The following call is done on an instance created in C++, + #~ // so it won't invoke Python code. + #~ $RESULT_VAR_ASSIGNMENT$CALL_FUNC_NAME($INPUT_PARAMS); +#~ } +#~ else +#~ { + #~ // The following call is done on an instance created in Python, + #~ // i.e. a wrapper instance. This call might invoke Python code. + #~ $RESULT_VAR_ASSIGNMENT%(cls_wrapper)s->%(base_name)s($INPUT_PARAMS); +#~ } -$POST_CALL +#~ $POST_CALL -$RETURN_STMT -""" +#~ $RETURN_STMT +#~ """ - # Replace the $-variables - body = self._subst_manager.subst_wrapper(body) + #~ # Replace the $-variables + #~ body = self._subst_manager.subst_wrapper(body) - # Replace the remaining parameters - body = body%{"cls_wrapper_type" : cls_wrapper_type, - "cls_wrapper" : cls_wrapper, - "self" : selfname, - "base_name" : self.base_name() } - return body + #~ # Replace the remaining parameters + #~ body = body%{"cls_wrapper_type" : cls_wrapper_type, + #~ "cls_wrapper" : cls_wrapper, + #~ "self" : selfname, + #~ "base_name" : self.base_name() } + #~ return body - def create_function(self): - answer = [ self.create_declaration(self.declaration.name) + '{' ] - answer.append( self.indent( self.create_virtual_body() ) ) - answer.append( '}' ) - return os.linesep.join( answer ) + #~ def create_function(self): + #~ answer = [ self.create_declaration(self.declaration.name) + '{' ] + #~ answer.append( self.indent( self.create_virtual_body() ) ) + #~ answer.append( '}' ) + #~ return os.linesep.join( answer ) - def create_base_function( self ): - answer = [ self.create_declaration("base_"+self.declaration.name, False) + '{' ] - body = "%(return_)s%(wrapped_class)s::%(name)s( %(args)s );" - answer.append( self.indent( self.create_base_body() ) ) - answer.append( '}' ) - return os.linesep.join( answer ) + #~ def create_base_function( self ): + #~ answer = [ self.create_declaration("base_"+self.declaration.name, False) + '{' ] + #~ body = "%(return_)s%(wrapped_class)s::%(name)s( %(args)s );" + #~ answer.append( self.indent( self.create_base_body() ) ) + #~ answer.append( '}' ) + #~ return os.linesep.join( answer ) - def create_default_function( self ): + #~ def create_default_function( self ): - header = 'static $RET_TYPE %s( $ARG_LIST_DEF ) {'%self.default_name() - header = self._subst_manager.subst_wrapper(header) + #~ header = 'static $RET_TYPE %s( $ARG_LIST_DEF ) {'%self.default_name() + #~ header = self._subst_manager.subst_wrapper(header) - answer = [ header ] - answer.append( self.indent( self.create_default_body() ) ) - answer.append( '}' ) - return os.linesep.join( answer ) + #~ answer = [ header ] + #~ answer.append( self.indent( self.create_default_body() ) ) + #~ answer.append( '}' ) + #~ return os.linesep.join( answer ) - def _create_impl(self): + #~ def _create_impl(self): - answer = [ self.create_function() ] - answer.append( os.linesep ) - answer.append( self.create_base_function() ) - answer.append( os.linesep ) - answer.append( self.create_default_function() ) - answer = os.linesep.join( answer ) + #~ answer = [ self.create_function() ] + #~ answer.append( os.linesep ) + #~ answer.append( self.create_base_function() ) + #~ answer.append( os.linesep ) + #~ answer.append( self.create_default_function() ) + #~ answer = os.linesep.join( answer ) - # Replace the argument list of the declaration so that in the - # case that keywords are created, the correct arguments will be - # picked up (i.e. the modified argument list and not the original - # argument list) - self.declaration.arguments = self._subst_manager.wrapper_func.arg_list + #~ # Replace the argument list of the declaration so that in the + #~ # case that keywords are created, the correct arguments will be + #~ # picked up (i.e. the modified argument list and not the original + #~ # argument list) + #~ self.declaration.arguments = self._subst_manager.wrapper_func.arg_list - return answer - \ No newline at end of file + #~ return answer + Modified: pyplusplus_dev_ft/pyplusplus/function_transformers/__init__.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/function_transformers/__init__.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/function_transformers/__init__.py 2006-11-21 13:00:32 UTC (rev 742) @@ -26,22 +26,22 @@ return transformers.output_t( function, *args, **keywd ) return creator -def input( *args, **keywd ): - def creator( function ): - return transformers.input_t( function, *args, **keywd ) - return creator +#def input( *args, **keywd ): + #def creator( function ): + #return transformers.input_t( function, *args, **keywd ) + #return creator -def inout( *args, **keywd ): - def creator( function ): - return transformers.inout_t( function, *args, **keywd ) - return creator +#def inout( *args, **keywd ): + #def creator( function ): + #return transformers.inout_t( function, *args, **keywd ) + #return creator -def input_array( *args, **keywd ): - def creator( function ): - return transformers.input_array_t( function, *args, **keywd ) - return creator +#def input_array( *args, **keywd ): + #def creator( function ): + #return transformers.input_array_t( function, *args, **keywd ) + #return creator -def output_array( *args, **keywd ): - def creator( function ): - return transformers.output_array_t( function, *args, **keywd ) - return creator +#def output_array( *args, **keywd ): + #def creator( function ): + #return transformers.output_array_t( function, *args, **keywd ) + #return creator \ No newline at end of file Modified: pyplusplus_dev_ft/pyplusplus/function_transformers/controllers.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/function_transformers/controllers.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/function_transformers/controllers.py 2006-11-21 13:00:32 UTC (rev 742) @@ -32,7 +32,15 @@ self.__function = function self.__variables = {} #name : variable self.__names_in_use = set( map( lambda arg: arg.name, self.function.arguments ) ) + + @property + def function( self ): + return self.__function + @property + def variables( self ): + return self.__variables + def declare_variable( self, type, name, initialize_expr='' ): unique_name = self.__create_unique_var_name( name ) self.__variables[ unique_name ] = variable_t( type, unique_name, initialize_expr ) @@ -52,6 +60,7 @@ return unique_name class mem_fun_controller_t( controller_base_t ): + def __init__( self, function ): controller_base_t.__init__( self, function ) self.__wrapper_args = function.arguments[:] @@ -64,7 +73,12 @@ self.__arg_expressions = [ arg.name for arg in function.arguments ] self.__return_stmt = None + @property + def template( self ): + return templates.mem_fun.body + + @property def wrapper_args( self ): return self.__wrapper_args @@ -106,7 +120,7 @@ self.__pre_call.append( code ) @property - def pos_call( self ): + def post_call( self ): return self.__post_call def add_post_call_code( self, code ): Modified: pyplusplus_dev_ft/pyplusplus/function_transformers/function_transformation.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/function_transformers/function_transformation.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/function_transformers/function_transformation.py 2006-11-21 13:00:32 UTC (rev 742) @@ -3,15 +3,16 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) - """This module contains the class L{function_transformation_t}. """ +import controllers class function_transformation_t: def __init__(self, function, transformer_creator, **keywd): """Constructor. """ self.__function = function + self.__controller = controllers.mem_fun_controller_t( function ) self.__transformers = map( lambda tr_creator: tr_creator( function ), transformer_creator ) self.__thread_safe = keywd.get( 'thread_safe', False ) @@ -19,6 +20,10 @@ def transformers( self ): return self.__transformers + @property + def controller( self ): + return self.__controller + def required_headers( self ): headers = [] map( lambda transformer: headers.extend( transformer.required_headers() ) Modified: pyplusplus_dev_ft/pyplusplus/function_transformers/templates.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/function_transformers/templates.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/function_transformers/templates.py 2006-11-21 13:00:32 UTC (rev 742) @@ -15,7 +15,7 @@ body = Template( os.linesep.join([ '$declare_variables' , '$pre_call' - , '$save_return_value_stmt$function_name($input_params);' + , '$save_return_value_stmt$function($arg_expressions);' , '$post_call' , '$return_stmt' ])) @@ -26,7 +26,7 @@ override_body = Template( os.linesep.join([ '$declare_variables' - , '$declare_override_function = this->get_override( "$function_alias" );' + , 'boost::python::override $override_function_var_name = this->get_override( "$function_alias" );' , 'if( $override_function_var_name ){' , ' $declare_override_variables' , ' $override_pre_call' Modified: pyplusplus_dev_ft/pyplusplus/function_transformers/transformer.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/function_transformers/transformer.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/function_transformers/transformer.py 2006-11-21 13:00:32 UTC (rev 742) @@ -59,82 +59,5 @@ else: return self.get_argument( reference ).type - def init_funcs(self, sm): - """Wrapper initialization. - - This method is called before the actual wrapper source code is - generated. This is the place where you can modify the signature - of the C++ wrapper function or allocate local variables. - - @param sm: Substitution manager instance - @type sm: L{substitution_manager_t} - """ - pass - - def wrapper_pre_call(self, sm): - """Generate the C++ code that should be executed before the actual function call. - - The code from this method will be put into the wrapper function. - - @param sm: Substitution manager instance - @type sm: L{substitution_manager_t} - @return: C++ code or None - @rtype: str - """ - pass - - def wrapper_post_call(self, sm): - """Generate the C++ code that should be executed after the actual function call. - - The code from this method will be put into the wrapper function. - - @param sm: Substitution manager instance - @type sm: L{substitution_manager_t} - @return: C++ code or None - @rtype: str - """ - pass - - def wrapper_cleanup(self, sm): - """Generate code that should be executed in the case of an error. - - This method has to assume that the preCall code was executed but - the postCall code won't be executed because something went wrong. - - <not used yet> - - @param sm: Substitution manager instance - @type sm: L{substitution_manager_t} - @return: C++ code or None - @rtype: str - """ - pass - - def virtual_pre_call(self, sm): - """Generate the C++ code that should be executed before the actual function call. - - The code from this method will be put into the virtual function. - - @param sm: Substitution manager instance - @type sm: L{substitution_manager_t} - @return: C++ code or None - @rtype: str - """ - pass - - def virtual_post_call(self, sm): - """Generate the C++ code that should be executed after the actual function call. - - The code from this method will be put into the virtual function. - - @param sm: Substitution manager instance - @type sm: L{substitution_manager_t} - @return: C++ code or None - @rtype: str - """ - pass - - def virtual_cleanup(self, sm): - pass - - + def configure_mem_fun( self, controller ): + pass \ No newline at end of file Modified: pyplusplus_dev_ft/pyplusplus/function_transformers/transformers.py =================================================================== --- pyplusplus_dev_ft/pyplusplus/function_transformers/transformers.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/pyplusplus/function_transformers/transformers.py 2006-11-21 13:00:32 UTC (rev 742) @@ -17,6 +17,7 @@ """ import os import transformer +import controllers from pygccxml import declarations from pyplusplus import code_repository @@ -58,8 +59,7 @@ """ self.arg = self.get_argument( arg_ref ) self.arg_index = self.function.arguments.index( self.arg ) - self.local_var = "<not initialized>" - + if not is_ref_or_ptr( self.arg.type ): raise ValueError( '%s\nin order to use "output" transformation, argument %s type must be a reference or a pointer (got %s).' ) \ % ( function, self.arg_ref.name, arg.type) @@ -67,286 +67,14 @@ def __str__(self): return "output(%d)"%(self.arg_index) - def init_funcs(self, sm): - # Remove the specified output argument from the wrapper function - sm.remove_arg(self.arg_index+1) + def configure_mem_fun( self, controller ): + assert isinstance( controller, controllers.mem_fun_controller_t ) + #removing arg from the function wrapper definition + controller.remove_wrapper_arg( self.arg.name ) + #declaring new variable, which will keep result + var_name = controller.declare_variable( remove_ref_or_ptr( self.arg.type ), self.arg.name ) + #adding just declared variable to the original function call expression + controller.modify_argument_expression( self.arg_index, var_name ) + #adding the variable to return variables list + controller.return_variable( var_name ) - # Declare a local variable that will receive the output value - self.local_var = sm.wrapper_func.declare_variable( self.arg.name, str( remove_ref_or_ptr( self.arg.type ) ) ) - # Append the output to the result tuple - sm.wrapper_func.result_exprs.append(self.local_var) - - # Replace the expression in the C++ function call - input_param = self.local_var - if declarations.is_pointer( self.arg.type ): - input_param = "&%s" % self.local_var - - sm.wrapper_func.input_params[self.arg_index] = input_param - - - def virtual_post_call(self, sm): - """Extract the C++ value after the call to the Python function.""" - res = [] - if declarations.is_pointer( self.arg.type ): - res.append( "*" ) - res.append( "%s = boost::python::extract<%s>(%s);" \ - % ( self.arg.name - , remove_ref_or_ptr( self.arg.type ) - , sm.py_result_expr(self.local_var) ) ) - return ''.join( res ) - -# input_t -class input_t(transformer.transformer_t): - """Handles a single input variable. - - The reference on the specified variable is removed. - - void setValue(int& v) -> setValue(v) - """ - - def __init__(self, function, arg_ref): - """Constructor. - - The specified argument must be a reference or a pointer. - - @param idx: Index of the argument that is an output value (the first arg has index 1). - @type idx: int - """ - transformer.transformer_t.__init__( self, function ) - self.arg = self.get_argument( arg_ref ) - self.arg_index = self.function.arguments.index( self.arg ) - - if not is_ref_or_ptr( self.arg.type ): - raise ValueError( '%s\nin order to use "input" transformation, argument %s type must be a reference or a pointer (got %s).' ) \ - % ( function, self.arg_ref.name, arg.type) - - def __str__(self): - return "input(%d)"%(self.idx) - - def init_funcs(self, sm): - # Remove the specified input argument from the wrapper function - sm.remove_arg(self.arg_index + 1) - - # Create an equivalent argument that is not a reference type - noref_arg = self.arg.clone( type=remove_ref_or_ptr( self.arg.type ) ) - # Insert the noref argument - sm.insert_arg(self.arg_index + 1, noref_arg, self.arg.name) - -# inout_t -class inout_t(transformer.transformer_t): - """Handles a single input/output variable. - - void foo(int& v) -> v = foo(v) - """ - - def __init__(self, function, arg_ref): - """Constructor. - - The specified argument must be a reference or a pointer. - - @param idx: Index of the argument that is an in/out value (the first arg has index 1). - @type idx: int - """ - transformer.transformer_t.__init__( self, function ) - self.arg = self.get_argument( arg_ref ) - self.arg_index = self.function.arguments.index( self.arg ) - self.local_var = "<not initialized>" - - if not is_ref_or_ptr( self.arg.type ): - raise ValueError( '%s\nin order to use "inout" transformation, argument %s type must be a reference or a pointer (got %s).' ) \ - % ( function, self.arg_ref.name, arg.type) - - def __str__(self): - return "inout(%d)"%(self.arg_index) - - def init_funcs(self, sm): - # Remove the specified input argument from the wrapper function - sm.remove_arg(self.arg_index + 1) - - # Create an equivalent argument that is not a reference type - noref_arg = self.arg.clone( type=remove_ref_or_ptr( self.arg.type ) ) - - # Insert the noref argument - sm.insert_arg(self.idx+1, noref_arg, arg.name) - - # Use the input arg to also store the output - self.local_var = noref_arg.name - # Append the output to the result tuple - sm.wrapper_func.result_exprs.append(self.local_var) - - # Replace the expression in the C++ function call - input_param = self.local_var - if declarations.is_pointer( self.arg.type ): - input_param = "&%s" % self.local_var - - sm.wrapper_func.input_params[self.arg_index] = input_param - - def virtual_post_call(self, sm): - """Extract the C++ value after the call to the Python function.""" - res = [] - if isinstance(arg.type, declarations.pointer_t): - res.append( "*" ) - res.append( "%s = boost::python::extract<%s>(%s);" - % ( self.arg.name - , remove_ref_or_ptr( self.arg.type ) - , sm.py_result_expr( self.local_var ) ) ) - return ''.join( res ) - -# input_array_t -class input_array_t(transformer.transformer_t): - """Handles an input array with fixed size. - - void setVec3(double* v) -> setVec3(object v) - # v must be a sequence of 3 floats - """ - - def __init__(self, function, arg_ref, array_size): - """Constructor. - - @param size: The fixed size of the input array - @type size: int - """ - transformer.transformer_t.__init__( self, function ) - - self.arg = self.get_argument( arg_ref ) - self.arg_index = self.function.arguments.index( self.arg ) - - if not is_ptr_or_array( self.arg.type ): - raise ValueError( '%s\nin order to use "input_array" transformation, argument %s type must be a array or a pointer (got %s).' ) \ - % ( function, self.arg_ref.name, arg.type) - - self.array_size = array_size - self.native_array = None - self.pylist = None - - def __str__(self): - return "input_array(%s,%d)"%( self.arg.name, self.array_size) - - def required_headers( self ): - """Returns list of header files that transformer generated code depends on.""" - return [ code_repository.convenience.file_name ] - - def init_funcs(self, sm): - # Remove the original argument... - sm.remove_arg(self.arg_index + 1) - - # Declare a variable that will hold the Python list - # (this will be the input of the Python call in the virtual function) - self.pylist = sm.virtual_func.declare_variable("py_" + self.arg.name, "boost::python::list") - - # Replace the removed argument with a Python object. - newarg = self.arg.clone( type=declarations.dummy_type_t("boost::python::object") ) - sm.insert_arg(self.arg_index+1, newarg, self.pylist) - - # Declare a variable that will hold the C array... - self.native_array = sm.wrapper_func.declare_variable( - "native_" + self.arg.name - , declarations.array_item_type( self.arg.type ) - , '[%d]' % self.array_size) - - # Replace the input parameter with the C array - sm.wrapper_func.input_params[self.arg_index] = self.native_array - - def wrapper_pre_call(self, sm): - """Wrapper function code. - """ - tmpl = [] - tmpl.append( '%(pypp_con)s::ensure_uniform_sequence< %(type)s >( %(pylist)s, %(array_size)d );' ) - tmpl.append( '%(pypp_con)s::copy_sequence( %(pylist)s, %(pypp_con)s::array_inserter( %(native_array)s, %(array_size)d ) );' ) - return os.linesep.join( tmpl ) % { - 'type' : declarations.array_item_type( self.arg.type ) - , 'pypp_con' : 'pyplusplus::convenience' - , 'pylist' : self.arg.name - , 'array_size' : self.array_size - , 'native_array' : self.native_array - } - - def virtual_pre_call(self, sm): - """Virtual function code.""" - tmpl = '%(pypp_con)s::copy_container( %(native_array)s, %(native_array)s + %(array_size)d, %(pypp_con)s::list_inserter( %(pylist)s ) );' - return tmpl % { - 'pypp_con' : 'pyplusplus::convenience' - , 'native_array' : self.arg.name - , 'array_size' : self.array_size - , 'pylist' : self.pylist - } - - -# output_array_t -class output_array_t(transformer.transformer_t): - """Handles an output array of a fixed size. - - void getVec3(double* v) -> v = getVec3() - # v will be a list with 3 floats - """ - - def __init__(self, function, arg_ref, size): - """Constructor. - - @param idx: Index of the argument that is an output array (the first arg has index 1). - @type idx: int - @param size: The fixed size of the output array - @type size: int - """ - transformer.transformer_t.__init__( self, function ) - self.arg = self.get_argument( arg_ref ) - self.arg_index = self.function.arguments.index( self.arg ) - - if not is_ptr_or_array( self.arg.type ): - raise ValueError( '%s\nin order to use "input_array" transformation, argument %s type must be a array or a pointer (got %s).' ) \ - % ( function, self.arg_ref.name, arg.type) - - self.array_size = size - self.native_array = None - self.pylist = None - - def __str__(self): - return "output_array(%s,%d)"%( self.arg.name, self.array_size) - - def required_headers( self ): - """Returns list of header files that transformer generated code depends on.""" - return [ code_repository.convenience.file_name ] - - def init_funcs(self, sm): - # Remove the original argument... - sm.remove_arg(self.arg_index + 1) - - # Declare a variable that will hold the C array... - self.native_array = sm.wrapper_func.declare_variable( - "native_" + self.arg.name - , declarations.array_item_type( self.arg.type ) - , '[%d]' % self.array_size) - - # Declare a Python list which will receive the output... - self.pylist = sm.wrapper_func.declare_variable( - 'py_' + self.arg.name - , "boost::python::list" ) - - # ...and add it to the result - sm.wrapper_func.result_exprs.append(self.pylist) - - sm.wrapper_func.input_params[ self.arg_index ] = self.native_array - - self.virtual_pylist = sm.virtual_func.declare_variable("py_"+self.arg.name, "boost::python::object") - - def wrapper_post_call(self, sm): - tmpl = '%(pypp_con)s::copy_container( %(native_array)s, %(native_array)s + %(array_size)d, %(pypp_con)s::list_inserter( %(pylist)s ) );' - return tmpl % { - 'pypp_con' : 'pyplusplus::convenience' - , 'native_array' : self.native_array - , 'array_size' : self.array_size - , 'pylist' : self.pylist - } - - def virtual_post_call(self, sm): - tmpl = [] - tmpl.append( '%(pypp_con)s::ensure_uniform_sequence< %(type)s >( %(pylist)s, %(array_size)d );' ) - tmpl.append( '%(pypp_con)s::copy_sequence( %(pylist)s, %(pypp_con)s::array_inserter( %(native_array)s, %(array_size)d ) );' ) - return os.linesep.join( tmpl ) % { - 'type' : declarations.array_item_type( self.arg.type ) - , 'pypp_con' : 'pyplusplus::convenience' - , 'pylist' : sm.py_result_expr(self.pylist) - , 'array_size' : self.array_size - , 'native_array' : self.arg.name - } - Modified: pyplusplus_dev_ft/unittests/data/function_transformations_to_be_exported.hpp =================================================================== --- pyplusplus_dev_ft/unittests/data/function_transformations_to_be_exported.hpp 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/unittests/data/function_transformations_to_be_exported.hpp 2006-11-21 13:00:32 UTC (rev 742) @@ -17,7 +17,7 @@ // Made the method 'virtual' for now because func transformers // are currently only taken into account on virtual functions. - virtual void get_size( unsigned int& h, unsigned int& w ){ + void get_size( unsigned int& h, unsigned int& w ){ h = m_height; w = m_width; } Modified: pyplusplus_dev_ft/unittests/function_transformations_tester.py =================================================================== --- pyplusplus_dev_ft/unittests/function_transformations_tester.py 2006-11-21 09:10:20 UTC (rev 741) +++ pyplusplus_dev_ft/unittests/function_transformations_tester.py 2006-11-21 13:00:32 UTC (rev 742) @@ -19,24 +19,29 @@ , *args ) def customize( self, mb ): + mb.namespace( 'ft' ).exclude() image = mb.class_( "image_t" ) + image.include() + image.add_wrapper_code( '' ) + image.member_functions().exclude() + image.member_function( "get_size" ).include() image.member_function( "get_size" ).add_transformation( ft.output(0), ft.output(1) ) - image.member_function( "get_one_value" ).add_transformation( ft.output(0) ) - image.member_function( "get_size2" ).add_transformation( ft.output(0), ft.output(1) ) - image.member_function( "input_arg" ).add_transformation( ft.input(0) ) - image.member_function( "fixed_input_array" ).add_transformation( ft.input_array(0,3) ) - image.member_function( "fixed_output_array" ).add_transformation( ft.output_array(0,3) ) - mb.free_function("get_cpp_instance").call_policies \ - = call_policies.return_value_policy(call_policies.reference_existing_object) - mb.variable( "cpp_instance" ).exclude() + #~ image.member_function( "get_one_value" ).add_transformation( ft.output(0) ) + #~ image.member_function( "get_size2" ).add_transformation( ft.output(0), ft.output(1) ) + #~ image.member_function( "input_arg" ).add_transformation( ft.input(0) ) + #~ image.member_function( "fixed_input_array" ).add_transformation( ft.input_array(0,3) ) + #~ image.member_function( "fixed_output_array" ).add_transformation( ft.output_array(0,3) ) + #~ mb.free_function("get_cpp_instance").call_policies \ + #~ = call_policies.return_value_policy(call_policies.reference_existing_object) + #~ mb.variable( "cpp_instance" ).exclude() - cls = mb.class_("no_virtual_members_t") - cls.member_function("member").add_transformation( ft.output(0) ) + #~ cls = mb.class_("no_virtual_members_t") + #~ cls.member_function("member").add_transformation( ft.output(0) ) - cls = mb.class_("ft_private_destructor_t") - cls.member_function("get_value").add_transformation( ft.output(0) ) + #~ cls = mb.class_("ft_private_destructor_t") + #~ cls.member_function("get_value").add_transformation( ft.output(0) ) - mb.decls(lambda decl: decl.name[0]=="_").exclude() + #~ mb.decls(lambda decl: decl.name[0]=="_").exclude() def run_tests(self, module): """Run the actual unit tests. @@ -49,101 +54,101 @@ # Check a method that returns two values by reference self.assertEqual(img.get_size(), (2,6)) - # Check a method that only returns one value by reference - self.a... [truncated message content] |