[pygccxml-commit] SF.net SVN: pygccxml:[1759] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-09-21 19:20:32
|
Revision: 1759 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1759&view=rev Author: roman_yakovenko Date: 2009-09-21 19:20:25 +0000 (Mon, 21 Sep 2009) Log Message: ----------- function transformation functionality was fixed for virtual functions, which returns "reference" Modified Paths: -------------- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py pyplusplus_dev/pyplusplus/function_transformers/controllers.py pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp pyplusplus_dev/unittests/function_transformations_tester.py Modified: pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py =================================================================== --- pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-09-19 18:59:58 UTC (rev 1758) +++ pyplusplus_dev/pyplusplus/code_creators/calldef_transformed.py 2009-09-21 19:20:25 UTC (rev 1759) @@ -351,7 +351,10 @@ tmpl_values['save_result'] = '' if not declarations.is_void( self.declaration.return_type ): - tmpl_values['save_result'] = '%s = ' % cntrl.result_variable.name + tmpl_tmp = '%(result_var_name)s = ' + if declarations.is_reference( self.declaration.return_type ): + tmpl_tmp = '%(result_var_name)s = &' + tmpl_values['save_result'] = tmpl_tmp % dict( result_var_name=cntrl.result_variable.name ) tmpl_values['function_name'] = self.declaration.name tmpl_values['arg_expressions'] = self.PARAM_SEPARATOR.join( cntrl.arg_expressions ) Modified: pyplusplus_dev/pyplusplus/function_transformers/controllers.py =================================================================== --- pyplusplus_dev/pyplusplus/function_transformers/controllers.py 2009-09-19 18:59:58 UTC (rev 1758) +++ pyplusplus_dev/pyplusplus/function_transformers/controllers.py 2009-09-21 19:20:25 UTC (rev 1759) @@ -131,8 +131,15 @@ controller_base_t.__init__( self, function ) self.__vars_manager = create_variables_manager( function ) self.__wrapper_args = [ arg.clone() for arg in function.arguments ] - self.__result_var = variable_t( self.function.return_type - , self.register_variable_name( 'result' ) ) + + initialize_expr = '' + result_type = self.function.return_type + if declarations.is_reference( self.function.return_type ): + initialize_expr = ' = 0' + result_type = declarations.pointer_t( declarations.remove_reference( self.function.return_type ) ) + self.__result_var = variable_t( result_type + , self.register_variable_name( 'result' ) + , initialize_expr=initialize_expr ) self.__return_variables = [] self.__pre_call = [] self.__post_call = [] Modified: pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2009-09-19 18:59:58 UTC (rev 1758) +++ pyplusplus_dev/unittests/data/function_transformations_to_be_exported.hpp 2009-09-21 19:20:25 UTC (rev 1759) @@ -269,9 +269,10 @@ class B { public: - virtual C* h(A const & x){ return 0;} // this does not work - //C *h(A const & x); // this works - //virtual C *h(); // and this + virtual C* h(A const & x){ return 0;} + virtual C& h2(A const & x){ return c;} +private: + C c; }; } Modified: pyplusplus_dev/unittests/function_transformations_tester.py =================================================================== --- pyplusplus_dev/unittests/function_transformations_tester.py 2009-09-19 18:59:58 UTC (rev 1758) +++ pyplusplus_dev/unittests/function_transformations_tester.py 2009-09-21 19:20:25 UTC (rev 1759) @@ -107,6 +107,12 @@ h = ft_bugs.mem_fun( 'h' ) h.add_transformation( ft.modify_type(0, remove_const_ref ) ) h.call_policies = call_policies.return_internal_reference() + + h2 = ft_bugs.mem_fun( 'h2' ) + h2.add_transformation( ft.modify_type(0, remove_const_ref ) ) + h2.call_policies = call_policies.return_internal_reference() + + ft_bugs.class_( 'B' ).always_expose_using_scope = True ft_bugs.mem_fun( 'get_a' ).call_policies \ = call_policies.return_value_policy( call_policies.reference_existing_object ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |