[pygccxml-commit] SF.net SVN: pygccxml: [733] pyplusplus_dev/pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-11-18 19:20:06
|
Revision: 733 http://svn.sourceforge.net/pygccxml/?rev=733&view=rev Author: roman_yakovenko Date: 2006-11-18 11:20:05 -0800 (Sat, 18 Nov 2006) Log Message: ----------- introducing registration order problem warning Modified Paths: -------------- pyplusplus_dev/pyplusplus/__init__.py pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/pyplusplus/module_creator/sort_algorithms.py Modified: pyplusplus_dev/pyplusplus/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/__init__.py 2006-11-18 19:18:32 UTC (rev 732) +++ pyplusplus_dev/pyplusplus/__init__.py 2006-11-18 19:20:05 UTC (rev 733) @@ -33,7 +33,7 @@ from _logging_ import multi_line_formatter_t -__version__ = '0.7.1' +__version__ = '0.8.3' #Known issues: #3. Modified: pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2006-11-18 19:18:32 UTC (rev 732) +++ pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2006-11-18 19:20:05 UTC (rev 733) @@ -33,6 +33,8 @@ """ +import algorithm + from decl_wrapper import decl_wrapper_t from calldef_wrapper import calldef_t Modified: pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py 2006-11-18 19:18:32 UTC (rev 732) +++ pyplusplus_dev/pyplusplus/decl_wrappers/algorithm.py 2006-11-18 19:20:05 UTC (rev 733) @@ -9,6 +9,7 @@ """ import re +from pygccxml import declarations def creators_affect_on_me( me ): """This algorithm finds all code creators that can influence on code generated @@ -92,4 +93,45 @@ new_name = nsalias.alias + '::' + full_name[ len(fnsname) : ] return new_name else: - return full_name \ No newline at end of file + return full_name + +class registration_order: + @staticmethod + def is_related( t1, t2 ): + if declarations.is_pointer( t1 ) and declarations.is_pointer( t2 ): + return registration_order.is_related( declarations.remove_pointer( t1 ) + , declarations.remove_pointer( t2 ) ) + elif declarations.is_pointer( t1 ) and not declarations.is_pointer( t2 ): + t1 = declarations.remove_cv( declarations.remove_pointer( t1 ) ) + t2 = declarations.remove_cv( t2 ) + if declarations.is_same( t1, t2 ): + return 1 + elif not declarations.is_pointer( t1 ) and declarations.is_pointer( t2 ): + t1 = declarations.remove_cv( t1 ) + t2 = declarations.remove_cv( declarations.remove_pointer( t2 ) ) + if declarations.is_same( t1, t2 ): + return -1 + else: #not is_pointer( t1 ) and not is_pointer( t2 ): + if declarations.is_integral( t1 ) and not declarations.is_bool( t1 ) \ + and declarations.is_bool( t2 ): + return -1 + elif declarations.is_bool( t1 ) \ + and declarations.is_integral( t2 ) and not declarations.is_bool( t2 ): + return 1 + else: + pass + return None + + @staticmethod + def select_problematics( calldef ): + if 1 != len( calldef.required_args ): + return [] + problematics = [] + for f in calldef.overloads: + if 1 != len( f.required_args ): + continue + if None != registration_order.is_related( calldef.arguments[0].type, f.arguments[0].type ): + problematics.append( f ) + return problematics + + \ 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-18 19:18:32 UTC (rev 732) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-11-18 19:20:05 UTC (rev 733) @@ -5,7 +5,9 @@ """defines class that configure "callable" declaration exposing""" +import os import user_text +import algorithm import decl_wrapper from pygccxml import declarations from pyplusplus import function_transformers as ft @@ -163,7 +165,6 @@ #TODO: functions that takes as argument pointer to pointer to smth, could not be exported #see http://www.boost.org/libs/python/doc/v2/faq.html#funcptr - #TODO: add warning to the case described in registration_order.rest document. 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." ) @@ -183,6 +184,16 @@ if False == self.overridable: msgs.append( self._non_overridable_reason) + + problematics = algorithm.registration_order.select_problematics( self ) + if problematics: + tmp = [ "The function introduces registration order problem. " ] + tmp.append( "For more information read next document: " + + "http://language-binding.net/pyplusplus/documentation/functions/registration_order.html" ) + tmp.append( "Problematic functions: " ) + for f in problematics: + tmp.append( os.linesep + '\t' + str(f) ) + msgs.append( os.linesep.join( tmp ) ) return msgs class member_function_t( declarations.member_function_t, calldef_t ): Modified: pyplusplus_dev/pyplusplus/module_creator/sort_algorithms.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/sort_algorithms.py 2006-11-18 19:18:32 UTC (rev 732) +++ pyplusplus_dev/pyplusplus/module_creator/sort_algorithms.py 2006-11-18 19:20:05 UTC (rev 733) @@ -4,6 +4,7 @@ # http://www.boost.org/LICENSE_1_0.txt) from pygccxml import declarations +from pyplusplus import decl_wrappers class COLOR: WHITE = 0 @@ -141,27 +142,7 @@ return groups def __cmp_types( self, t1, t2 ): - if declarations.is_pointer( t1 ) and declarations.is_pointer( t2 ): - return self.__cmp_types( declarations.remove_pointer( t1 ) - , declarations.remove_pointer( t2 ) ) - elif declarations.is_pointer( t1 ) and not declarations.is_pointer( t2 ): - t1 = declarations.remove_cv( declarations.remove_pointer( t1 ) ) - t2 = declarations.remove_cv( t2 ) - if declarations.is_same( t1, t2 ): - return 1 - elif not declarations.is_pointer( t1 ) and declarations.is_pointer( t2 ): - t1 = declarations.remove_cv( t1 ) - t2 = declarations.remove_cv( declarations.remove_pointer( t2 ) ) - if declarations.is_same( t1, t2 ): - return -1 - else: #not is_pointer( t1 ) and not is_pointer( t2 ): - if declarations.is_integral( t1 ) and not declarations.is_bool( t1 ) and declarations.is_bool( t2 ): - return -1 - elif declarations.is_bool( t1 ) and declarations.is_integral( t2 ) and not declarations.is_bool( t2 ): - return 1 - else: - pass - return None + return decl_wrappers.algorithm.registration_order.is_related( t1, t2 ) def __cmp( self, f1, f2 ): result = self.__cmp_types( f1.arguments[0].type, f2.arguments[0].type ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |