[pygccxml-commit] SF.net SVN: pygccxml: [767] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-11-30 11:20:24
|
Revision: 767 http://svn.sourceforge.net/pygccxml/?rev=767&view=rev Author: roman_yakovenko Date: 2006-11-30 03:20:24 -0800 (Thu, 30 Nov 2006) Log Message: ----------- merge of FT feature from pyplusplus_dev_ft branch Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/__init__.py pyplusplus_dev/pyplusplus/code_creators/algorithm.py pyplusplus_dev/pyplusplus/code_creators/calldef.py pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py pyplusplus_dev/pyplusplus/code_creators/calldef_utils.py pyplusplus_dev/pyplusplus/code_creators/declaration_based.py pyplusplus_dev/pyplusplus/code_repository/__init__.py pyplusplus_dev/pyplusplus/code_repository/call_policies.py pyplusplus_dev/pyplusplus/code_repository/convenience.py pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/properties.py pyplusplus_dev/pyplusplus/file_writers/writer.py pyplusplus_dev/pyplusplus/function_transformers/__init__.py pyplusplus_dev/pyplusplus/function_transformers/controllers.py pyplusplus_dev/pyplusplus/function_transformers/function_transformation.py pyplusplus_dev/pyplusplus/function_transformers/templates.py pyplusplus_dev/pyplusplus/function_transformers/transformer.py pyplusplus_dev/pyplusplus/function_transformers/transformers.py pyplusplus_dev/pyplusplus/module_builder/builder.py pyplusplus_dev/pyplusplus/module_creator/creator.py pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp pyplusplus_dev/unittests/function_transformations_tester.py pyplusplus_dev/unittests/test_all.py Added Paths: ----------- pyplusplus_dev/pyplusplus/code_repository/named_tuple.py Removed Paths: ------------- pyplusplus_dev/pyplusplus/function_transformers/code_manager.py pyplusplus_dev/pyplusplus/function_transformers/substitution_manager.py Modified: pyplusplus_dev/pyplusplus/code_creators/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/__init__.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_creators/__init__.py 2006-11-30 11:20:24 UTC (rev 767) @@ -78,6 +78,8 @@ from calldef_transformed import mem_fun_transformed_t from calldef_transformed import mem_fun_transformed_wrapper_t +from calldef_transformed import free_fun_transformed_t +from calldef_transformed import free_fun_transformed_wrapper_t from calldef_transformed import mem_fun_v_transformed_t from calldef_transformed import mem_fun_v_transformed_wrapper_t Modified: pyplusplus_dev/pyplusplus/code_creators/algorithm.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/algorithm.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_creators/algorithm.py 2006-11-30 11:20:24 UTC (rev 767) @@ -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/pyplusplus/code_creators/calldef.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_creators/calldef.py 2006-11-30 11:20:24 UTC (rev 767) @@ -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 ): @@ -50,10 +47,15 @@ def param_sep(self): 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 ) ) + def create_keywords_args(self): + arg_utils = calldef_utils.argument_utils_t( self.declaration, algorithm.make_id_creator( self ) ) return arg_utils.keywords_args() + def create_call_policies( self ): + if self.declaration.call_policies.is_default(): + return '' + return self.declaration.call_policies.create( self ) + def create_def_code( self ): if not self.works_on_instance: return '%s.def' % self.parent.class_var_name @@ -96,15 +98,16 @@ result.append( self.create_function_ref_code( not self.works_on_instance ) ) if self.declaration.use_keywords: - result.append( self.param_sep() ) - result.append( self.keywords_args() ) + keywd_args = self.create_keywords_args() + if keywd_args: + result.append( self.param_sep() ) + result.append( keywd_args ) if self.declaration.call_policies: - if not self.declaration.call_policies.is_default(): + c_p_code = self.create_call_policies() + if c_p_code: result.append( self.param_sep() ) - result.append( self.declaration.call_policies.create( self ) ) - else: - pass#don't generate default_call_policies + result.append( c_p_code ) else: result.append( os.linesep + self.indent( '/* undefined call policies */', 2 ) ) @@ -139,11 +142,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 ): @@ -779,7 +782,7 @@ answer.append( '(' ) keywords_args = None if self.declaration.use_keywords: - keywords_args = self.keywords_args() + keywords_args = self.create_keywords_args() answer.append( '%s' % keywords_args ) if self.documentation: if keywords_args: @@ -841,7 +844,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: @@ -1177,7 +1180,7 @@ def create_end_def_code( self ): raise NotImplementedError() - def keywords_args(self): + def create_keywords_args(self): result = [ algorithm.create_identifier( self, '::boost::python::args' ) ] result.append( '( ' ) args = [] @@ -1199,7 +1202,7 @@ def create_overloads_cls( self ): result = [ self.overloads_class.name ] result.append( '( ' ) - result.append( os.linesep + self.indent( self.keywords_args(), 3 ) ) + result.append( os.linesep + self.indent( self.create_keywords_args(), 3 ) ) if self.overloads_class.max_function.documentation: result.append( os.linesep + self.indent( self.PARAM_SEPARATOR, 3 ) ) result.append( self.overloads_class.max_function.documentation ) Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2006-11-30 11:20:24 UTC (rev 767) @@ -4,482 +4,415 @@ # 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 import pyplusplus.function_transformers as function_transformers from pyplusplus import code_repository -###################################################################### +#TODO: constructors also can have transformation defined. We should use make _init +# function for this purpose -class mem_fun_transformed_t( calldef_t ): - """Creates code for public non-virtual member functions. - """ - +def remove_duplicate_linesep( code ): + lines = code.split( os.linesep ) + lines = filter( lambda line: line.strip(), lines ) + return os.linesep.join( lines ) + +class sealed_fun_transformed_t( calldef_t ): 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] + + @property + def controller( self ): + return self.ft.controller + + def _get_alias_impl( self ): + return self.wrapper.ft.alias + 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 create_call_policies( self ): + return '' -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 sealed_fun_transformed_wrapper_t( calldef_wrapper_t ): 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) - sm.init_funcs() - self._subst_manager = sm + @property + def ft( self ): #function transformation + return self.declaration.transformations[0] - def function_type(self): - """Return the type of the wrapper function. + @property + def controller( self ): + return self.ft.controller - @rtype: type_t - """ - template = '$RET_TYPE' - rettype = self._subst_manager.subst_wrapper(template) - rettype = declarations.dummy_type_t(rettype) + def resolve_function_ref( self ): + raise NotImplementedError() - return declarations.free_function_type_t( - return_type=rettype - , arguments_types=map( lambda arg: arg.type, self.declaration.arguments ) ) + def create_fun_definition(self): + cntrl = self.controller - def wrapper_name(self): - """Return the name of the wrapper function. + make_object = algorithm.create_identifier( self, 'pyplusplus::call_policies::make_object' ) + make_tuple = algorithm.create_identifier( self, 'boost::python::make_tuple' ) + + tmpl_values = dict() - 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) + tmpl_values['unique_function_name'] = self.wrapper_name() + tmpl_values['return_type'] = self.controller.wrapper_return_type.decl_string + tmpl_values['arg_declarations'] = self.args_declaration() + + tmpl_values['declare_variables'] \ + = os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string() ) + , cntrl.variables ) ) + + tmpl_values['pre_call'] = os.linesep + self.indent( os.linesep.join( cntrl.pre_call ) ) - def full_name(self): - """Return the full name of the wrapper function. + tmpl_values['save_result'] = '' + if not declarations.is_void( self.declaration.return_type ): + tmpl_values['save_result'] \ + = '%(type)s %(name)s = ' \ + % { 'type': cntrl.result_variable.type.decl_string + , 'name' : cntrl.result_variable.name } - The returned name also includes the class name (if there is any). + tmpl_values['function_name'] = self.resolve_function_ref() + tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions ) + return_stmt_creator = calldef_utils.return_stmt_creator_t( self + , self.controller + , self.controller.result_variable + , self.controller.return_variables ) - @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' - - # Substitute the $-variables - template = self._subst_manager.subst_wrapper(template) - - return template % { - 'name' : self.wrapper_name() - , 'throw' : self.throw_specifier_code() - } - - def create_body(self): - body = os.linesep.join([ - '$DECLARATIONS' - , '$PRE_CALL' - , '$RESULT_VAR_ASSIGNMENT$CALL_FUNC_NAME($INPUT_PARAMS);' - , '$POST_CALL' - , '$RETURN_STMT' - ]) - - # 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*"/") - answer.append( self.create_declaration(self.declaration.alias) + '{') - answer.append( self.indent( self.create_body() ) ) - answer.append( '}' ) - return os.linesep.join( answer ) - + tmpl_values['post_call'] = os.linesep + self.indent( os.linesep.join( cntrl.post_call ) ) + if return_stmt_creator.pre_return_code: + tmpl_values['post_call'] \ + = os.linesep.join([ tmpl_values['post_call'] + , self.indent( return_stmt_creator.pre_return_code )]) + tmpl_values['return'] = os.linesep + self.indent( return_stmt_creator.statement ) + + f_def = self.controller.template.substitute(tmpl_values) + return remove_duplicate_linesep( f_def ) + def _create_impl(self): - - answer = self.create_function() - - # 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 - -###################################################################### - -class mem_fun_v_transformed_t( calldef_t ): - """Creates code for (public) virtual member functions. + return self.create_fun_definition() + +class free_fun_transformed_t( sealed_fun_transformed_t ): + """Creates code for public non-virtual member functions. """ def __init__( self, function, wrapper=None ): - calldef_t.__init__( self, function=function, wrapper=wrapper ) - self.default_function_type_alias = 'default_' + self.function_type_alias + sealed_fun_transformed_t.__init__( self, function=function, wrapper=wrapper ) + self.works_on_instance = False - 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() + def create_def_code( self ): + return self.def_identifier() - result = [] - result.append( 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) ) - return ''.join( result ) + def create_keywords_args(self): + arg_utils = calldef_utils.argument_utils_t( self.declaration + , algorithm.make_id_creator( self ) + , self.controller.wrapper_args ) + return arg_utils.keywords_args() - 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 ) - - 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 ) - - return ''.join( result ) - - -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. - """ - +class free_fun_transformed_wrapper_t( sealed_fun_transformed_wrapper_t ): 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 ) + sealed_fun_transformed_wrapper_t .__init__( self, function=function ) - 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' ) - - def default_name(self): - """Return the name of the 'default' function. - - @rtype: str - """ - return "default_" + self.declaration.alias - - def default_full_name(self): - """Return the full name of the 'default' function. - - The returned name also includes the class name. - - @rtype: str - """ - return self.parent.full_name + '::default_' + self.declaration.alias - - def virtual_name(self): - """Return the name of the 'virtual' function. - - @rtype: str - """ - return self.declaration.name - - def base_name(self): - """Return the name of the 'base' function. - - @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) - return declarations.free_function_type_t( - return_type=rettype - , arguments_types=map( lambda arg: arg.type, self.declaration.arguments ) ) + return_type=self.controller.wrapper_return_type + , arguments_types=self.controller.wrapper_args ) - 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 wrapper_name( self ): + return self.ft.unique_name - def create_declaration(self, name, virtual=True): - """Create the function header. + def full_name(self): + return self.ft.unique_name - 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' + def args_declaration( self ): + arg_utils = calldef_utils.argument_utils_t( + self.declaration + , algorithm.make_id_creator( self ) + , self.controller.wrapper_args ) + return arg_utils.args_declaration() - # Substitute the $-variables - template = self._subst_manager.subst_virtual(template) + def create_declaration(self, name): + template = 'static %(return_type)s %(name)s( %(args)s )' - virtualspec = '' - if virtual: - virtualspec = 'virtual ' - - constness = '' - if self.declaration.has_const: - constness = ' const ' - return template % { - 'virtual' : virtualspec - , 'name' : name - , 'constness' : constness - , 'throw' : self.throw_specifier_code() + 'return_type' : self.controller.wrapper_return_type.decl_string + , 'name' : self.wrapper_name() + , 'args' : self.args_declaration() } - def create_base_body(self): - body = "%(return_)s%(wrapped_class)s::%(name)s( %(args)s );" + def resolve_function_ref( self ): + return declarations.full_name( self.declaration ) - 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() - } +class mem_fun_transformed_t( sealed_fun_transformed_t ): + """Creates code for public non-virtual member functions. + """ + def __init__( self, function, wrapper=None ): + sealed_fun_transformed_t.__init__( self, function=function, wrapper=wrapper ) - def create_virtual_body(self): + def create_keywords_args(self): + args = self.controller.wrapper_args[:] + if self.controller.inst_arg: + args.insert( 0, self.controller.inst_arg ) - thread_safe = self.declaration.transformations[0].thread_safe + arg_utils = calldef_utils.argument_utils_t( self.declaration + , algorithm.make_id_creator( self ) + , args ) + return arg_utils.keywords_args() - if thread_safe: - body = """ -pyplusplus::threading::gil_guard_t %(gstate_var)s; +class mem_fun_transformed_wrapper_t( sealed_fun_transformed_wrapper_t ): + def __init__( self, function ): + """Constructor. -%(gstate_var)s.ensure(); -boost::python::override %(override_var)s = this->get_override( "%(alias)s" ); -%(gstate_var)s.release(); + @param function: Function declaration + @type function: calldef_t + """ + sealed_fun_transformed_wrapper_t.__init__( self, function=function ) -if( %(override_var)s ) -{ - // The corresponding release() is done in the destructor of %(gstate_var)s - %(gstate_var)s.ensure(); + def __is_global( self ): + return not isinstance( self.parent, class_declaration.class_wrapper_t ) - $DECLARATIONS + def function_type(self): + args = map( lambda arg: arg.type, self.controller.wrapper_args ) + if self.controller.inst_arg: + args.insert( 0, self.controller.inst_arg.type ) + return declarations.free_function_type_t( + return_type=self.controller.wrapper_return_type + , arguments_types=args ) - try { - $PRE_CALL + def wrapper_name( self ): + if self.__is_global(): + return self.ft.unique_name + else: + if self.declaration.overloads: + #it is possible that other functions will have same signature + return self.ft.unique_name + else: + return self.declaration.name - ${RESULT_VAR_ASSIGNMENT}boost::python::call<$RESULT_TYPE>($INPUT_PARAMS); + def full_name(self): + if self.__is_global(): + return self.ft.unique_name + else: + return self.parent.full_name + '::' + self.wrapper_name() - $POST_CALL + def args_declaration( self ): + args = self.controller.wrapper_args[:] + if self.controller.inst_arg: + args.insert( 0, self.controller.inst_arg ) + arg_utils = calldef_utils.argument_utils_t( + self.declaration + , algorithm.make_id_creator( self ) + , args ) + return arg_utils.args_declaration() - $RETURN_STMT - } - catch(...) - { - if (PyErr_Occurred()) - { - PyErr_Print(); - } + def resolve_function_ref( self ): + if self.controller.inst_arg: + return self.controller.inst_arg.name + '.' + self.declaration.name + else: + return declarations.full_name( self.declaration ) - $CLEANUP +class mem_fun_v_transformed_t( calldef_t ): + def __init__( self, function, wrapper=None ): + calldef_t.__init__( self, function=function, wrapper=wrapper ) - $EXCEPTION_HANDLER_EXIT - } -} -else -{ - %(inherited)s -} -""" + @property + def ft( self ): #function transformation + return self.declaration.transformations[0] - if not thread_safe: - body = """ -boost::python::override %(override_var)s = this->get_override( "%(alias)s" ); + @property + def controller( self ): + return self.ft.controller + + def _get_alias_impl( self ): + return self.wrapper.ft.alias + + def create_function_type_alias_code( self, exported_class_alias=None ): + result = [] -if( %(override_var)s ) -{ - $DECLARATIONS + ftype = self.declaration.function_type() + result.append( 'typedef %s;' % ftype.create_typedef( self.function_type_alias, exported_class_alias ) ) + if self.wrapper: + result.append( os.linesep ) + ftype = self.wrapper.function_type() + result.append( 'typedef %s;' % ftype.create_typedef( self.default_function_type_alias ) ) + return ''.join( result ) - $PRE_CALL + def create_keywords_args(self): + cntrl = self.controller.default_controller + arg_utils = calldef_utils.argument_utils_t( self.declaration + , algorithm.make_id_creator( self ) + , [cntrl.inst_arg] + cntrl.wrapper_args ) + return arg_utils.keywords_args() - ${RESULT_VAR_ASSIGNMENT}boost::python::call<$RESULT_TYPE>($INPUT_PARAMS); + def create_function_ref_code(self, use_function_alias=False): + full_name = self.wrapper.default_full_name() + if use_function_alias: + return '%s( &%s )' % ( self.function_type_alias, full_name ) + elif self.declaration.create_with_signature: + func_type = self.wrapper.default_function_type() + return '(%s)( &%s )' % ( func_type, full_name ) + else: + return '&%s' % full_name - $POST_CALL +class mem_fun_v_transformed_wrapper_t( calldef_wrapper_t ): + def __init__( self, function ): + calldef_wrapper_t.__init__( self, function=function ) - $RETURN_STMT -} -else -{ - %(inherited)s -} -""" + @property + def ft( self ): #function transformation + return self.declaration.transformations[0] - vf = self._subst_manager.virtual_func - arg0 = "%s.ptr()"%self._override_var - if vf.INPUT_PARAMS=="": - vf.INPUT_PARAMS = arg0 + @property + def controller( self ): + return self.ft.controller + + def default_name(self): + if self.declaration.overloads: + #it is possible that other functions will have same signature + return 'default_' + self.ft.unique_name else: - vf.INPUT_PARAMS = arg0+", "+vf.INPUT_PARAMS + return 'default_' + self.declaration.alias - # Replace the $-variables - body = self._subst_manager.subst_virtual(body) + def default_full_name(self): + return self.parent.full_name + '::' + self.default_name() - return body % { - 'override_var' : self._override_var - , 'gstate_var' : self._gstate_var - , 'alias' : self.declaration.alias - , 'inherited' : self.create_base_body() - } + def args_override_declaration( self ): + return self.args_declaration() - 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 args_default_declaration( self ): + cntrl = self.controller.default_controller + arg_utils = calldef_utils.argument_utils_t( self.declaration + , algorithm.make_id_creator( self ) + , [cntrl.inst_arg] + cntrl.wrapper_args ) + return arg_utils.args_declaration() - body = """$DECLARATIONS + def default_function_type(self): + cntrl = self.controller.default_controller + args = [cntrl.inst_arg.type] + map( lambda arg: arg.type, cntrl.wrapper_args ) + return declarations.free_function_type_t( return_type=cntrl.wrapper_return_type + , arguments_types=args ) -$PRE_CALL + def create_default(self): + cntrl = self.controller.default_controller -%(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); -} + make_object = algorithm.create_identifier( self, 'pyplusplus::call_policies::make_object' ) + make_tuple = algorithm.create_identifier( self, 'boost::python::make_tuple' ) + + tmpl_values = dict() -$POST_CALL + tmpl_values['unique_function_name'] = self.default_name() + tmpl_values['return_type'] = cntrl.wrapper_return_type.decl_string + tmpl_values['arg_declarations'] = self.args_default_declaration() + tmpl_values['wrapper_class'] = self.parent.wrapper_alias + tmpl_values['wrapped_class'] = declarations.full_name( self.declaration.parent ) + tmpl_values['wrapped_inst'] = cntrl.inst_arg.name + + decl_vars = cntrl.variables[:] + if not declarations.is_void( self.declaration.return_type ): + decl_vars.append( cntrl.result_variable ) + tmpl_values['declare_variables'] \ + = os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string() ) + , decl_vars ) ) + + tmpl_values['pre_call'] = os.linesep + self.indent( os.linesep.join( cntrl.pre_call ) ) -$RETURN_STMT -""" + tmpl_values['save_result'] = '' + if not declarations.is_void( self.declaration.return_type ): + tmpl_values['save_result'] = '%s = ' % cntrl.result_variable.name - # Replace the $-variables - body = self._subst_manager.subst_wrapper(body) + tmpl_values['function_name'] = self.declaration.name + tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions ) + return_stmt_creator = calldef_utils.return_stmt_creator_t( self + , cntrl + , cntrl.result_variable + , cntrl.return_variables ) - # 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 + tmpl_values['post_call'] = os.linesep + self.indent( os.linesep.join( cntrl.post_call ) ) + if return_stmt_creator.pre_return_code: + tmpl_values['post_call'] \ + = os.linesep.join([ tmpl_values['post_call'] + , self.indent( return_stmt_creator.pre_return_code )]) + tmpl_values['return'] = os.linesep + self.indent( return_stmt_creator.statement ) + + f_def = cntrl.template.substitute(tmpl_values) + return remove_duplicate_linesep( f_def ) - 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 wrapped_class_identifier( self ): + return algorithm.create_identifier( self, declarations.full_name( self.declaration.parent ) ) - 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_override(self): + cntrl = self.controller.override_controller + + tmpl_values = dict() + tmpl_values['return_type' ] = self.declaration.return_type.decl_string + tmpl_values['function_name'] = self.declaration.name + tmpl_values['arg_declarations'] = self.args_override_declaration() + tmpl_values['constness'] = '' + if self.declaration.has_const: + tmpl_values['constness'] = ' const ' + tmpl_values['throw'] = self.throw_specifier_code() + tmpl_values['py_function_var'] = cntrl.py_function_var + tmpl_values['function_alias'] = self.declaration.alias + tmpl_values['declare_py_variables'] \ + = os.linesep + os.linesep.join( map( lambda var: self.indent( var.declare_var_string(), 2 ) + , cntrl.py_variables ) ) - def create_default_function( self ): + tmpl_values['py_pre_call'] = os.linesep + self.indent( os.linesep.join( cntrl.py_pre_call ), 2 ) + tmpl_values['py_post_call'] = os.linesep + self.indent( os.linesep.join( cntrl.py_post_call ), 2 ) + tmpl_values['py_arg_expressions'] = '' + if cntrl.py_arg_expressions: + tmpl_values['py_arg_expressions'] \ + = ', ' + declarations.call_invocation.join( '', cntrl.py_arg_expressions ) + + tmpl_values['save_py_result'] = "bpl::object %s = " % cntrl.py_result_variable.name + tmpl_values['py_return'] = '' + tmpl_values['cpp_return'] = '' + if not declarations.is_void( self.declaration.return_type ): + tmpl_values['py_return'] \ + = 'return bpl::extract< %(type)s >( pyplus_conv::get_out_argument( %(py_result)s, 0 ) );' \ + % { 'type' : self.declaration.return_type.decl_string + , 'py_result' : cntrl.py_result_variable.name } + tmpl_values['cpp_return'] = 'return ' - header = 'static $RET_TYPE %s( $ARG_LIST_DEF ) {'%self.default_name() - header = self._subst_manager.subst_wrapper(header) + tmpl_values['wrapped_class'] = self.wrapped_class_identifier() - answer = [ header ] - answer.append( self.indent( self.create_default_body() ) ) - answer.append( '}' ) - return os.linesep.join( answer ) + arg_utils = calldef_utils.argument_utils_t( self.declaration + , algorithm.make_id_creator( self ) + , self.declaration.arguments ) + tmpl_values['cpp_arg_expressions'] = arg_utils.call_args() + f_def_code = cntrl.template.substitute(tmpl_values) + return remove_duplicate_linesep( f_def_code ) + 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 ) - - # 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 os.linesep.join([ self.create_override(), '', self.create_default() ]) Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_utils.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef_utils.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_creators/calldef_utils.py 2006-11-30 11:20:24 UTC (rev 767) @@ -3,6 +3,8 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +import os +import algorithm import code_creator from pygccxml import declarations from pyplusplus import decl_wrappers @@ -39,6 +41,8 @@ return False def keywords_args(self): + if not self.__args: + return '' boost_arg = self.__id_creator( '::boost::python::arg' ) boost_obj = self.__id_creator( '::boost::python::object' ) result = ['( '] @@ -86,8 +90,66 @@ def call_args( self ): params = [] for index, arg in enumerate( self.__args ): - params.append( decl_wrappers.python_traits.call_traits( arg.type ) % self.argument_name( index ) ) + params.append( decl_wrappers.python_traits.call_traits( arg.type ) + % self.argument_name( index ) ) return ', '.join( params ) +class return_stmt_creator_t( object ): + def __init__( self, creator, controller, result_var, return_vars ): + object.__init__( self ) + self.__creator = creator + self.__controller = controller + self.__function = controller.function + self.__return_vars = return_vars[:] + self.__pre_return_code = None + self.__return_stmt = None + self.__result_var = result_var + self.__call_policy_alias = controller.register_variable_name( 'call_policies_t' ) + + @property + def pre_return_code( self ): + if None is self.__pre_return_code: + if not self.__controller.return_variables \ + or self.__function.call_policies.is_default() \ + or declarations.is_void( self.__function.return_type ): + self.__pre_return_code = '' + else: + c_p_typedef = 'typedef %s %s;' \ + % ( self.__function.call_policies.create_template_arg( self.__creator ) + , self.__call_policy_alias ) + self.__pre_return_code = c_p_typedef + return self.__pre_return_code + @property + def statement( self ): + if None is self.__return_stmt: + stmt = '' + bpl_object = algorithm.create_identifier( self.__creator, 'boost::python::object' ) + make_tuple = algorithm.create_identifier( self.__creator, 'boost::python::make_tuple' ) + make_object = algorithm.create_identifier( self.__creator, 'pyplusplus::call_policies::make_object' ) + if not declarations.is_void( self.__function.return_type ): + if self.__function.call_policies.is_default(): + self.__return_vars.insert( 0, self.__result_var.name ) + else: + self.__return_vars.insert( 0 + , declarations.call_invocation.join( + declarations.templates.join( make_object, [self.__call_policy_alias] ) + , [self.__result_var.name] ) ) + + if 0 == len( self.__return_vars ): + pass + elif 1 == len( self.__return_vars ): + stmt = bpl_object + '( %s )' % self.__return_vars[ 0 ] + else: # 1 < + stmt = declarations.call_invocation.join( make_tuple, self.__return_vars ) + if self.__creator.LINE_LENGTH < len( stmt ): + stmt = declarations.call_invocation.join( + make_tuple + , self.__return_vars + , os.linesep + self.__creator.indent( self.__creator.PARAM_SEPARATOR, 6 ) ) + + if stmt: + stmt = 'return ' + stmt + ';' + self.__return_stmt = stmt + return self.__return_stmt Modified: pyplusplus_dev/pyplusplus/code_creators/declaration_based.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/declaration_based.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_creators/declaration_based.py 2006-11-30 11:20:24 UTC (rev 767) @@ -30,9 +30,13 @@ doc="""The declaration this code creator is based on. @type: L{decl_wrapper_t<decl_wrappers.decl_wrapper_t>} """) + + def _get_alias_impl( self ): + return self.declaration.alias def _get_alias(self): - return self.declaration.alias + return self._get_alias_impl() + def _set_alias(self, alias): self.declaration.alias = alias alias = property( _get_alias, _set_alias ) Modified: pyplusplus_dev/pyplusplus/code_repository/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/__init__.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_repository/__init__.py 2006-11-30 11:20:24 UTC (rev 767) @@ -15,10 +15,11 @@ import array_1 import gil_guard +import named_tuple import convenience import call_policies -all = [ array_1, gil_guard, convenience, call_policies ] +all = [ array_1, gil_guard, convenience, call_policies, named_tuple ] headers = map( lambda f: f.file_name, all ) Modified: pyplusplus_dev/pyplusplus/code_repository/call_policies.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_repository/call_policies.py 2006-11-30 11:20:24 UTC (rev 767) @@ -70,6 +70,14 @@ }; +template< typename CallPolicies, class T > +bpl::object make_object( T const & x ){ + //constructs object using CallPolicies result_converter + typedef BOOST_DEDUCED_TYPENAME CallPolicies::result_converter:: template apply< T >::type result_converter_t; + result_converter_t rc; + return bpl::object( bpl::handle<>( rc( x ) ) ); +} + } /*pyplusplus*/ } /*call_policies*/ Modified: pyplusplus_dev/pyplusplus/code_repository/convenience.py =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/code_repository/convenience.py 2006-11-30 11:20:24 UTC (rev 767) @@ -135,8 +135,29 @@ return array_inserter_t<T>( array, size ); } +inline boost::python::object +get_out_argument( boost::python::object result, const char* arg_name ){ + if( PySequence_Check( result.ptr() ) ){ + return boost::python::getattr( result, arg_name ); + } + else{ + return result; + } +} + +inline boost::python::object +get_out_argument( boost::python::object result, index_type index ){ + if( PySequence_Check( result.ptr() ) ){ + return result[ index ]; + } + else{ + return result; + } +} + } /*pyplusplus*/ } /*convenience*/ +namespace pyplus_conv = pyplusplus::convenience; #endif//__convenience_pyplusplus_hpp__ Copied: pyplusplus_dev/pyplusplus/code_repository/named_tuple.py (from rev 765, pyplusplus_dev_ft/pyplusplus/code_repository/named_tuple.py) =================================================================== --- pyplusplus_dev/pyplusplus/code_repository/named_tuple.py (rev 0) +++ pyplusplus_dev/pyplusplus/code_repository/named_tuple.py 2006-11-30 11:20:24 UTC (rev 767) @@ -0,0 +1,65 @@ +# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +file_name = "named_tuple.py" + +code = \ +"""# Copyright 2004 Roman Yakovenko. +# Distributed under the Boost Software License, Version 1.0. (See +# accompanying file LICENSE_1_0.txt or copy at +# http://www.boost.org/LICENSE_1_0.txt) + +class named_tuple(tuple): + \"\"\"Creates tuple, which allows access to stored values by name and by index. + + named_tuple could be constructed exactly in the same way as Python dict. + \"\"\" + + def __new__(cls, seq=None, **keywd): + if seq: + if isinstance( seq, dict ): + return tuple.__new__( cls, seq.values() ) + else: + return tuple.__new__( cls, [ val for name, val in seq] ) + else: + return tuple.__new__( cls, keywd.values() ) + + def __init__(self, seq=None, **keywd): + "named_tuple could be constructed exactly in the same way as Python dict." + tuple.__init__( self ) + if seq: + if isinstance( seq, dict ): + name2value = dict( seq.iteritems() ) + else: + name2value = dict( seq ) + else: + name2value = dict( keywd ) + self.__dict__[ '__name2value' ] = name2value + + def __getattr__(self, name): + try: + return self.__dict__['__name2value'][ name ] + except KeyError: + raise AttributeError( "named_tuple has no attribute '%s'" % name ) + + def __setattr__(self, name, value): + raise AttributeError( "named_tuple has no attribute '%s'" % name ) + + def __getitem__( self, key ): + #TODO: it could be nice to support slicing. So the __getitem__ in case of + #slicing will return new named_tuple. + if isinstance( key, basestring ): + return self.__dict__['__name2value'][ key ] + else: + return super( named_tuple, self ).__getitem__( key ) + +if __name__ == '__main__': + nt = named_tuple( a=0, b=1) + assert nt.a == 0 and nt.b == 1 + a,b = nt + assert a == 0 and b == 1 + assert nt[ "a" ] == 0 and nt[ "b" ] == 1 + +""" Modified: pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2006-11-30 11:20:24 UTC (rev 767) @@ -98,6 +98,8 @@ from doc_extractor import doc_extractor_i from properties import property_t +from properties import property_recognizer_i +from properties import name_based_recognizer_t import python_traits @@ -147,3 +149,17 @@ def create_variable( self, *arguments, **keywords ): return variable_t(*arguments, **keywords) + +skip_messages = [ + "Py++ does not exports compiler generated constructors" + , 'Py++, by default, does not expose internal compilers declarations. Names of those declarations usually start with "__".' + , 'Py++, by default, does not expose internal declarations (those that gccxml say belong to "<internal>" header).' + , 'Py++, by default, does not expose compiler generated declarations.' + , 'Py++ can not expose private class.' + , 'Py++ will generate class wrapper - class contains definition of virtual or pure virtual member function' + , "Py++ doesn't expose private or protected member variables." + , "Py++ doesn't export private not virtual functions." + , "Py++ doesn't export private constructor." + , "Py++ doesn't export private operators." +] +#Messages kept by skip_messages list will not be reported Modified: pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/decl_wrappers/call_policies.py 2006-11-30 11:20:24 UTC (rev 767) @@ -38,6 +38,9 @@ code = code + '()' return code + def create_template_arg( self, function_creator ): + return self.create( function_creator, CREATION_POLICY.AS_TEMPLATE_ARGUMENT ) + def is_default( self ): """Returns True is self is instance of L{default_call_policies_t} class""" #Small hack that allows to write nicer code @@ -227,4 +230,4 @@ """returns True is policy represents return_value_policy<return_pointee_value>, False otherwise""" return isinstance( policy, return_value_policy_t ) \ and policy.result_converter_generator == return_pointee_value - \ No newline at end of file + Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-11-30 11:20:24 UTC (rev 767) @@ -168,10 +168,14 @@ if len( self.arguments ) > calldef_t.BOOST_PYTHON_MAX_ARITY: tmp = [ "The function has more than %d arguments ( %d ). " ] tmp.append( "You should adjust BOOST_PYTHON_MAX_ARITY macro." ) - tmp.append( "For more information see: http://mail.python.org/pipermail/c++-sig/2002-June/001554.html" ) + tmp.append( "For more information see: http://www.boost.org/libs/python/doc/v2/configuration.html" ) tmp = ' '.join( tmp ) msgs.append( tmp % ( calldef_t.BOOST_PYTHON_MAX_ARITY, len( self.arguments ) ) ) - + + if self.transformations: + #if user defined transformation, than I think it took care of the problems + return msgs + if suspicious_type( self.return_type ) and None is self.call_policies: msgs.append( 'The function "%s" returns non-const reference to C++ fundamental type - value can not be modified from Python.' % str( self ) ) Modified: pyplusplus_dev/pyplusplus/decl_wrappers/properties.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-11-30 11:20:24 UTC (rev 767) @@ -58,11 +58,12 @@ class name_based_recognizer_t( property_recognizer_i ): def __init__( self ): property_recognizer_i.__init__( self ) - self.__prefixes = ( - ( 'is', 'set' ) - , ( 'get', 'set' ) - , ( 'has', 'set' ) - , ( '', 'set' ) ) + + def prefixes( self ): + return [ ( 'is', 'set' ) + , ( 'get', 'set' ) + , ( 'has', 'set' ) + , ( '', 'set' ) ] def check_prefix( self, name, prefix ): if not name.startswith( prefix ): @@ -105,7 +106,7 @@ , self.make_l_camel_convention ] for convention_maker in convention_makers: - for g, s in self.__prefixes: + for g, s in self.prefixes(): gc, sc = convention_maker( g, s ) if self.check_name_compatibility( gname, sname, gc, sc ): return ( gc, sc ) @@ -118,7 +119,7 @@ , self.make_l_camel_convention ] for convention_maker in convention_makers: - for g, unused in self.__prefixes: + for g, unused in self.prefixes(): if not g: continue gc, unused = convention_maker( g, 'set' ) Modified: pyplusplus_dev/pyplusplus/file_writers/writer.py =================================================================== --- pyplusplus_dev/pyplusplus/file_writers/writer.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/file_writers/writer.py 2006-11-30 11:20:24 UTC (rev 767) @@ -50,7 +50,12 @@ for cr in code_repository.all: if self.__extmodule.is_system_header( cr.file_name ): self.write_file( os.path.join( dir, cr.file_name ), cr.code ) - + #temporal patch: always write named_tuple.py file + + f = file( os.path.join( dir, code_repository.named_tuple.file_name ), 'w+b' ) + f.write( code_repository.named_tuple.code ) + f.close() + @staticmethod def write_file( fpath, content ): """Write a source file. @@ -91,4 +96,4 @@ f.write( fcontent_new ) f.close() writer_t.logger.info( 'file "%s" - updated( %f seconds )' % ( fname, time.clock() - start_time ) ) - \ No newline at end of file + Modified: pyplusplus_dev/pyplusplus/function_transformers/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/__init__.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/function_transformers/__init__.py 2006-11-30 11:20:24 UTC (rev 767) @@ -16,7 +16,6 @@ """ -from substitution_manager import substitution_manager_t from transformer import transformer_t import transformers from function_transformation import function_transformation_t Deleted: pyplusplus_dev/pyplusplus/function_transformers/code_manager.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/code_manager.py 2006-11-30 10:33:59 UTC (rev 766) +++ pyplusplus_dev/pyplusplus/function_transformers/code_manager.py 2006-11-30 11:20:24 UTC (rev 767) @@ -1,254 +0,0 @@ -# Copyright 2006 Roman Yakovenko. -# Distributed under the Boost Software License, Version 1.0. (See -# accompanying file LICENSE_1_0.txt or copy at -# http://www.boost.org/LICENSE_1_0.txt) -# -# Initial author: Matthias Baas - -"""This module contains the L{code_manager_t} and L{wrapper_code_manager_t} classes. -""" - -import os -import types -import string - -# code_manager_t -class code_manager_t: - """This class manages pieces of source code for a C++ function. - - The class mainly provides the interface for the code blocks to - manipulate a function and stores the actual substitution variables. - Each function has its own code manager instance. - - A code block can declare a local variable using L{declare_variable()} - and it can manipulate one of the attributes that are used to - initialize the final variables (see the documentation of the - instance variables below). The final variables (such as RET_TYPE, - FUNC_NAME, ARG_LIST, etc.) are stored as regular attributes of the - object. - - The functionality to perform a text substitution (using the - substitution() method) is inherited - from the class L{subst_t}. - - @ivar class_name: The name of the class of which the generated function is a member. A value of None or an empty string is used for free functions. This attribute is used for creating the CLASS_SPEC variable. - @type class_name: str - @ivar ret_type: Return type. The value may be any object where str(obj) is valid C++ code. The value None corresponds to void. This will be the value of the variable RET_TYPE. - @type ret_type: str - @ivar arg_list: The argument list. The items are pygccxml argument_t objects. This list will appear in the variables ARG_LIST, ARG_LIST_DEF and ARG_LIST_TYPES. - @type arg_list: list of L{argument_t<pygccxml.declarations.calldef.argument_t>} - @ivar input_params: A list of strings that contain the input parameter for the function call. This list is used for the INPUT_PARAMS variable. - @type input_params: list of str - @ivar result_var: The name of the variable that will receive the result of the function call. If None, th... [truncated message content] |