[pygccxml-commit] SF.net SVN: pygccxml: [1056] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2007-06-13 07:34:58
|
Revision: 1056 http://svn.sourceforge.net/pygccxml/?rev=1056&view=rev Author: roman_yakovenko Date: 2007-06-13 00:34:59 -0700 (Wed, 13 Jun 2007) Log Message: ----------- fixing bug caused by user, when he excludes class but not free operators related to the class Modified Paths: -------------- pyplusplus_dev/pyplusplus/__init__.py pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/pyplusplus/messages/warnings_.py pyplusplus_dev/pyplusplus/module_creator/creator.py pyplusplus_dev/unittests/data/free_operators_to_be_exported.hpp pyplusplus_dev/unittests/free_operators_tester.py Modified: pyplusplus_dev/pyplusplus/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/__init__.py 2007-06-13 07:31:24 UTC (rev 1055) +++ pyplusplus_dev/pyplusplus/__init__.py 2007-06-13 07:34:59 UTC (rev 1056) @@ -36,6 +36,13 @@ __version__ = '0.9.0' +import pygccxml +if not hasattr( pygccxml, '__revision__' ) or pygccxml.__revision__ < 1053: + msg = 'This revision of Py++ requieres pygccxml revision to be ' \ + 'greater or equal to %d. ' \ + 'Please install right pygccxml version.' + raise AssertionError( msg % pygccxml.__revision__ ) + #Known issues: #3. #~ > > 2. An other difference: when Py++ creates bindings for a set of Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-06-13 07:31:24 UTC (rev 1055) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2007-06-13 07:34:59 UTC (rev 1056) @@ -369,6 +369,13 @@ return '' if not operators_helper.is_supported( oper ): return messages.W1014 % oper.name + if isinstance( oper, declarations.free_operator_t ): + #Py++ should find out whether the relevant class is exposed to Python + #and if not, than this operator should not be exposed too + included = filter( lambda decl: decl.ignore == False, oper.class_types ) + if not included: + return messages.W1052 % str(oper) + return '' class member_operator_t( declarations.member_operator_t, calldef_t ): Modified: pyplusplus_dev/pyplusplus/messages/warnings_.py =================================================================== --- pyplusplus_dev/pyplusplus/messages/warnings_.py 2007-06-13 07:31:24 UTC (rev 1055) +++ pyplusplus_dev/pyplusplus/messages/warnings_.py 2007-06-13 07:34:59 UTC (rev 1056) @@ -205,10 +205,13 @@ 'Be sure to take a look on Py++ defined call policies: ' 'http://language-binding.net/pyplusplus/documentation/functions/call_policies.html#py-defined-call-policies' ) -W1051 = warning( 'The function takes as argument (name=%s, pos=%d) "%s" type. ' - 'You have to specify a call policies or to use "Function Transformation" ' - 'functionality.' ) +W1051 = warning( + 'The function takes as argument (name=%s, pos=%d) "%s" type. ' + 'You have to specify a call policies or to use "Function Transformation" ' + 'functionality.' ) +W1052 = warning( + 'Py++ will not expose free operator "%s" - all classes, this operator works on, are excluded.' ) warnings = globals() Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-06-13 07:31:24 UTC (rev 1055) +++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2007-06-13 07:34:59 UTC (rev 1056) @@ -175,16 +175,15 @@ , self.__extmodule.body.creators ) adopt_operator_impl( operator, found ) else: - arg_type = declarations.base_type( operator.arguments[0].type ) - if isinstance( arg_type, declarations.fundamental_t ): - arg_type = declarations.base_type( operator.arguments[1].type ) - elif isinstance( arg_type, declarations.declarated_t ) and arg_type.declaration.ignore: - arg_type = declarations.base_type( operator.arguments[1].type ) - else: - pass - assert isinstance( arg_type, declarations.declarated_t ) - found = find( lambda decl: arg_type.declaration is decl - , self.__extmodule.body.creators ) + #select all to be exposed declarations + included = filter( lambda decl: decl.ignore == False, operator.class_types ) + if not included: + msg = 'Py++ bug found!' \ + ' For some reason Py++ decided to expose free operator "%s", when all class types related to the operator definition are excluded.' \ + ' Please report this bug. Thanks! ' + raise RuntimeError( msg % str( operator ) ) + + found = find( lambda decl: included[0] is decl, self.__extmodule.body.creators ) adopt_operator_impl( operator, found ) def _is_registered_smart_pointer_creator( self, creator, db ): Modified: pyplusplus_dev/unittests/data/free_operators_to_be_exported.hpp =================================================================== --- pyplusplus_dev/unittests/data/free_operators_to_be_exported.hpp 2007-06-13 07:31:24 UTC (rev 1055) +++ pyplusplus_dev/unittests/data/free_operators_to_be_exported.hpp 2007-06-13 07:34:59 UTC (rev 1056) @@ -17,13 +17,16 @@ } }; +struct rational{ + int x, y; +}; + number operator+( const number& x, int y ){ number z; z.i = x.i + y; return z; } - bool operator!( const number& x ){ return !x.i; } @@ -38,8 +41,17 @@ return n2; } +rational operator*( int i, const rational& r ){ + rational rr = { r.x * i, r.y }; + return rr; +} +bool operator!( const rational& x ){ + return !x.x; } + + +} #endif//__free_operators_to_be_exported_hpp__ Modified: pyplusplus_dev/unittests/free_operators_tester.py =================================================================== --- pyplusplus_dev/unittests/free_operators_tester.py 2007-06-13 07:31:24 UTC (rev 1055) +++ pyplusplus_dev/unittests/free_operators_tester.py 2007-06-13 07:34:59 UTC (rev 1056) @@ -17,6 +17,9 @@ , tester_t.EXTENSION_NAME , *args ) + def customize( self, mb ): + mb.class_( 'rational' ).exclude() + def run_tests(self, module): n = module.number() self.failUnless( not n ) @@ -33,4 +36,4 @@ unittest.TextTestRunner(verbosity=2).run( create_suite() ) if __name__ == "__main__": - run_suite() \ No newline at end of file + run_suite() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |