[pygccxml-commit] SF.net SVN: pygccxml: [778] pyplusplus_dev/pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-12-05 21:36:39
|
Revision: 778 http://svn.sourceforge.net/pygccxml/?rev=778&view=rev Author: roman_yakovenko Date: 2006-12-05 13:36:37 -0800 (Tue, 05 Dec 2006) Log Message: ----------- switching to use central repository for all messages. This refactoring will help users to define filter that will ignore selected messages Modified Paths: -------------- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/enumeration_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py Added Paths: ----------- pyplusplus_dev/pyplusplus/messages/ pyplusplus_dev/pyplusplus/messages/__init__.py Modified: pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-12-05 21:34:41 UTC (rev 777) +++ pyplusplus_dev/pyplusplus/decl_wrappers/calldef_wrapper.py 2006-12-05 21:36:37 UTC (rev 778) @@ -9,6 +9,8 @@ import user_text import algorithm import decl_wrapper +import python_traits +from pyplusplus import messages from pygccxml import declarations from pyplusplus import function_transformers as ft @@ -88,15 +90,7 @@ and self.virtuality != declarations.VIRTUALITY_TYPES.NOT_VIRTUAL \ and declarations.is_reference( self.return_type ): self._overridable = False - self._non_overridable_reason = "Virtual functions that return "\ - "const reference can not be overriden from Python. "\ - "Ther is current no way for them to return a reference "\ - "to C++ code that calls them because in "\ - "boost::python::override::operator(...) the result of "\ - "marshaling (Python to C++) is saved on stack, after function "\ - "exit, thus the resulting reference would be a reference to "\ - "a temporary variable and would cause an access violation. "\ - "For an example of this see the temporary_variable_tester." + self._non_overridable_reason = messages.W1003 else: self._overridable = True self._non_overridable_reason = "" @@ -138,20 +132,19 @@ ptr2functions = filter( lambda unit: isinstance( unit, declarations.calldef_type_t ) , units ) if ptr2functions: - return "boost.python can not expose function, which takes as argument/returns pointer to function." \ - + " See http://www.boost.org/libs/python/doc/v2/faq.html#funcptr for more information." + return messages.W1004 #Function that take as agrument some instance of non public class #will not be exported. Same to the return variable if isinstance( units[-1], declarations.declarated_t ): dtype = units[-1] if isinstance( dtype.declaration.parent, declarations.class_t ): if dtype.declaration not in dtype.declaration.parent.public_members: - return "Py++ can not expose function that takes as argument/returns instance of non public class. Generated code will not compile." + return messages.W1005 no_ref = declarations.remove_reference( some_type ) no_ptr = declarations.remove_pointer( no_ref ) no_const = declarations.remove_const( no_ptr ) if declarations.is_array( no_const ): - return "Py++ can not expose function that takes as argument/returns C++ arrays. This will be changed in near future." + return messages.W1006 return self._exportable_impl_derived() def _readme_impl( self ): @@ -160,44 +153,34 @@ return False type_no_ref = declarations.remove_reference( type_ ) return not declarations.is_const( type_no_ref ) \ - and declarations.is_fundamental( type_no_ref ) + and python_traits.is_immutable( type_no_ref ) msgs = [] #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 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://www.boost.org/libs/python/doc/v2/configuration.html" ) - tmp = ' '.join( tmp ) - msgs.append( tmp % ( calldef_t.BOOST_PYTHON_MAX_ARITY, len( self.arguments ) ) ) + msgs.append( messages.W1007 % ( 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 ) ) + msgs.append( messages.W1008 ) for index, arg in enumerate( self.arguments ): if suspicious_type( arg.type ): - tmpl = [ 'The function takes as argument (name=%s, pos=%d ) ' ] - tmpl.append( 'non-const reference to C++ fundamental type - ' ) - tmpl.append( 'function could not be called from Python.' ) - msgs.append( ''.join( tmpl ) % ( arg.name, index ) ) + msgs.append( messages.W1009 % ( arg.name, index ) ) 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: " ) + tmp = [] for f in problematics: tmp.append( os.linesep + '\t' + str(f) ) - msgs.append( os.linesep.join( tmp ) ) + msgs.append( messages.W1010 % os.linesep.join( tmp ) ) return msgs class member_function_t( declarations.member_function_t, calldef_t ): @@ -218,7 +201,7 @@ def _exportable_impl_derived(self): if self.access_type == declarations.ACCESS_TYPES.PRIVATE \ and self.virtuality == declarations.VIRTUALITY_TYPES.NOT_VIRTUAL: - return "Py++ doesn't export private not virtual functions." + return messages.W1011 return '' class constructor_t( declarations.constructor_t, calldef_t ): @@ -238,9 +221,9 @@ def _exportable_impl_derived( self ): if self.is_artificial: - return 'Py++ does not exports compiler generated constructors' + return messages.W1012 if self.access_type == declarations.ACCESS_TYPES.PRIVATE: - return "Py++ doesn't export private constructor." + return messages.W1013 return '' def does_define_implicit_conversion( self ): @@ -304,9 +287,7 @@ if isinstance( oper, declarations.member_operator_t ) and oper.symbol in ( '()', '[]' ): return '' if not operators_helper.is_supported( oper ): - msg = [ '"%s" is not supported. ' % oper.name ] - msg.append( 'See Boost.Python documentation: http://www.boost.org/libs/python/doc/v2/operators.html#introduction.' ) - return ' '.join( msg ) + return messages.W1014 % oper.name return '' class member_operator_t( declarations.member_operator_t, calldef_t ): @@ -331,7 +312,7 @@ def _exportable_impl_derived( self ): if self.access_type == declarations.ACCESS_TYPES.PRIVATE \ and self.virtuality == declarations.VIRTUALITY_TYPES.NOT_VIRTUAL: - return "Py++ doesn't export private operators." + return messages.W1015 return operators_helper.exportable( self ) @@ -404,9 +385,9 @@ def _exportable_impl_derived( self ): if not declarations.is_fundamental( self.return_type ) and not self.has_const: - return 'Py++ does not exports non-const casting operators with user defined type as return value. This could be change in future.' + return messages.W1016 if self.access_type != declarations.ACCESS_TYPES.PUBLIC: - return "Py++ doesn't export non-public casting operators." + return messages.W1017 return '' Modified: pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-12-05 21:34:41 UTC (rev 777) +++ pyplusplus_dev/pyplusplus/decl_wrappers/class_wrapper.py 2006-12-05 21:36:37 UTC (rev 778) @@ -10,6 +10,7 @@ import properties import decl_wrapper import scopedef_wrapper +from pyplusplus import messages from pygccxml import declarations import indexing_suite1 as isuite1 import indexing_suite2 as isuite2 @@ -289,12 +290,12 @@ def _exportable_impl( self ): if not self.name: - return 'Py++ can not expose unnamed classes.' + return messages.W1018 #it is possible to do so, but not for unnamed classes defined under namespace. if isinstance( self.parent, declarations.namespace_t ): return '' if not self in self.parent.public_members: - return 'Py++ can not expose private class.' + return messages.W1019 return '' def get_exportable_members( self, sort=None ): @@ -433,40 +434,38 @@ """ explanation = [] if self.wrapper_code: - explanation.append( "Py++ will generate class wrapper - hand written code should be added to the wrapper class" ) + explanation.append( messages.W1020 ) if self.null_constructor_body: - explanation.append( "Py++ will generate class wrapper - hand written code should be added to the wrapper class null constructor body" ) + explanation.append( messages.W1021 ) if self.copy_constructor_body: - explanation.append( "Py++ will generate class wrapper - hand written code should be added to the wrapper class copy constructor body" ) + explanation.append( messages.W1022 ) if self.redefined_funcs(): - explanation.append( "Py++ will generate class wrapper - there are few functions that should be redefined in class wrapper" ) + explanation.append( messages.W1023 ) for member in self.get_exportable_members(): if isinstance( member, declarations.destructor_t ): continue if isinstance( member, declarations.variable_t ): if member.bits: - explanation.append( "Py++ will generate class wrapper - class contains bit field member variable" ) + explanation.append( messages.W1024 ) if declarations.is_pointer( member.type ): - explanation.append( "Py++ will generate class wrapper - class contains T* member variable" ) + explanation.append( messages.W1025 ) if declarations.is_reference( member.type ): - explanation.append( "Py++ will generate class wrapper - class contains T& member variable" ) + explanation.append( messages.W1026 ) if declarations.is_array( member.type ): - explanation.append( "Py++ will generate class wrapper - class contains array member variable" ) + explanation.append( messages.W1027 ) if isinstance( member, declarations.class_t ) and member.is_wrapper_needed(): - explanation.append( "Py++ will generate class wrapper - class contains definition of nested class that requires wrapper class" ) + explanation.append( messages.W1028 ) if isinstance( member, declarations.calldef_t ): if isinstance( member, declarations.constructor_t ) and member.body: - explanation.append( "Py++ will generate class wrapper - hand written code should be added to the wrapper class constructor body" ) + explanation.append( messages.W1029 ) if member.virtuality != VIRTUALITY_TYPES.NOT_VIRTUAL: - explanation.append( "Py++ will generate class wrapper - class contains definition of virtual or pure virtual member function" ) + explanation.append( messages.W1030 ) if member.access_type in ( ACCESS_TYPES.PROTECTED, ACCESS_TYPES.PRIVATE ): - explanation.append( "Py++ will generate class wrapper - user asked to expose non - public member function" ) - #if member.function_transformers: - # return True #function transformers require wrapper + explanation.append( messages.W1031 ) return explanation def _readme_impl( self ): Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-12-05 21:34:41 UTC (rev 777) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-12-05 21:36:37 UTC (rev 778) @@ -9,6 +9,7 @@ import algorithm from pyplusplus import _logging_ from pygccxml import declarations +from pyplusplus import messages class decl_wrapper_t(object): """Declaration interface. @@ -38,7 +39,7 @@ def _set_documentation( self, value ): self._documentation = value documentation = property( _get_documentation, _set_documentation - , doc="Using this property you can set documentatio of exported declaration." ) + , doc="Using this property you can set documentation of the declaration." ) def _generate_valid_name(self, name=None): if name == None: @@ -94,12 +95,12 @@ def get_exportable( self ): if self._exportable is None: if self.name.startswith( '__' ): - self._exportable_reason = 'Py++, by default, does not expose internal compilers declarations. Names of those declarations usually start with "__".' + self._exportable_reason = messages.W1000 elif self.location and self.location.file_name == "<internal>": - self._exportable_reason = 'Py++, by default, does not expose internal declarations (those that gccxml say belong to "<internal>" header).' + self._exportable_reason = messages.W1001 elif self.is_artificial \ and not isinstance( self, ( declarations.class_t, declarations.enumeration_t ) ): - self._exportable_reason = 'Py++, by default, does not expose compiler generated declarations.' + self._exportable_reason = messages.W1002 else: self._exportable_reason = self._exportable_impl( ) self._exportable = not bool( self._exportable_reason ) Modified: pyplusplus_dev/pyplusplus/decl_wrappers/enumeration_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/enumeration_wrapper.py 2006-12-05 21:34:41 UTC (rev 777) +++ pyplusplus_dev/pyplusplus/decl_wrappers/enumeration_wrapper.py 2006-12-05 21:36:37 UTC (rev 778) @@ -5,8 +5,9 @@ """defines class that configure enumeration declaration exposing""" -from pygccxml import declarations import decl_wrapper +from pyplusplus import messages +from pygccxml import declarations class enumeration_t(decl_wrapper.decl_wrapper_t, declarations.enumeration_t): """defines a set of properties, that will instruct Py++ how to expose the enumeration @@ -72,7 +73,5 @@ if self.name: name2value = self.get_name2value_dict() if len( set( name2value.keys() ) ) != len( set( name2value.values() ) ): - msgs.append( "Boost.Python does not support enums with duplicate values. " - "You can read more about this here: http://boost.org/libs/python/todo.html#support-for-enums-with-duplicate-values . " - "The quick work around is to add new class variable to the exported enum, from Python. " ) + msgs.append( messages.W1032 ) return msgs Modified: pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2006-12-05 21:34:41 UTC (rev 777) +++ pyplusplus_dev/pyplusplus/decl_wrappers/variable_wrapper.py 2006-12-05 21:36:37 UTC (rev 778) @@ -6,6 +6,7 @@ """defines class that configure global and member variable exposing""" import decl_wrapper +from pyplusplus import messages from pygccxml import declarations from pyplusplus.decl_wrappers import python_traits @@ -43,29 +44,28 @@ def _exportable_impl( self ): if not self.name: - return "Py++ can not expose unnamed variables" + return messages.W1033 if self.bits == 0 and self.name == "": - return "Py++ can not expose alignement bit." + return messages.W1034 type_ = declarations.remove_alias( self.type ) type_ = declarations.remove_const( type_ ) if declarations.is_pointer( type_ ): if self.type_qualifiers.has_static: - return "Py++ can not expose static pointer member variables. This could be changed in future." + return messages.W1035 if python_traits.is_immutable( type_.base ): - return "Py++ can not expose pointer to Python immutable member variables. This could be changed in future." + return messages.W1036 units = declarations.decompose_type( type_ ) ptr2functions = filter( lambda unit: isinstance( unit, declarations.calldef_type_t ) , units ) if ptr2functions: - return "boost.python can not expose variables, which are pointer to function." \ - + " See http://www.boost.org/libs/python/doc/v2/faq.html#funcptr for more information." + return messages.W1037 type_ = declarations.remove_pointer( type_ ) if declarations.class_traits.is_my_case( type_ ): cls = declarations.class_traits.get_declaration( type_ ) if not cls.name: - return "Py++ can not expose variables of with unnamed type." + return messages.W1038 if isinstance( self.parent, declarations.class_t ): if self.access_type != declarations.ACCESS_TYPES.PUBLIC: - return "Py++ doesn't expose private or protected member variables." + return messages.W1039 return '' Added: pyplusplus_dev/pyplusplus/messages/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/messages/__init__.py (rev 0) +++ pyplusplus_dev/pyplusplus/messages/__init__.py 2006-12-05 21:36:37 UTC (rev 778) @@ -0,0 +1,127 @@ +# 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) + +"""This package defines all user messages( warnings + errors ), which will be +reported to user. +""" + +W1000 = 'Py++, by default, does not expose internal compilers declarations.'\ + 'Names of those declarations usually start with "__".' + +W1001 = 'Py++, by default, does not expose internal declarations. ' \ + 'GCC-XML reports that these declaration belong to "<internal>" header.' + +W1002 = 'Py++, by default, does not expose compiler generated declarations.' + +W1003 = 'Virtual functions that returns const reference can not be overriden from Python. ' \ + 'Reason: boost::python::override::operator()(...) saves the result of the marshaling ' \ + '(from Python to C++) on the stack. Thus operator() returns reference ' \ + 'to a temporary variable. Consider to use "Function Transformation" functionality ' \ + 'to solve the problem.' + +W1004 = 'Boost.Python library can not expose function, which takes as argument/returns ' \ + 'pointer to function. ' \ + ' See http://www.boost.org/libs/python/doc/v2/faq.html#funcptr for more information.' + +W1005 = 'Py++ can not expose function that takes as argument/returns instance of non public class. ' \ + 'Generated code will not compile.' + +W1006 = 'Py++ need your help to expose function that takes as argument/returns C++ arrays. ' \ + 'Take a look on "Function Transformation" functionality and define the transformation.' + +W1007 = 'The function has more than %d arguments ( %d ). ' \ + 'You should adjust BOOST_PYTHON_MAX_ARITY macro. ' \ + 'For more information see: http://www.boost.org/libs/python/doc/v2/configuration.html' + +W1008 = 'The function returns non-const reference to "Python immutable" type. ' \ + 'The value can not be modified from Python. ' + +W1009 = 'The function takes as argument (name=%s, pos=%d ) non-const reference ' \ + 'to Python immutable type - function could not be called from Python. ' \ + 'Take a look on "Function Transformation" functionality and define the transformation.' + +W1010 = 'The function introduces registration order problem. ' \ + 'For more information about the problem read next document: ' \ + 'http://language-binding.net/pyplusplus/documentation/functions/registration_order.html ' \ + 'Problematic functions list: %s' + +W1011 = "Py++ doesn't export private not virtual functions." + +W1012 = 'Py++ does not exports compiler generated constructors.' + +W1013 = "Py++ doesn't export private constructor." + +W1014 = '"%s" is not supported. ' \ + 'See Boost.Python documentation: http://www.boost.org/libs/python/doc/v2/operators.html#introduction.' + +W1015 = "Py++ doesn't export private operators." + +W1016 = 'Py++ does not exports non-const casting operators with user defined type as return value. ' \ + 'This could be change in future.' + +W1017 = "Py++ doesn't export non-public casting operators." + +W1018 = 'Py++ can not expose unnamed classes.' + +W1019 = 'Py++ can not expose private class.' + +W1020 = "Py++ will generate class wrapper - hand written code should be added to the wrapper class" + +W1021 = "Py++ will generate class wrapper - hand written code should be added to the wrapper class null constructor body" + +W1022 = "Py++ will generate class wrapper - hand written code should be added to the wrapper class copy constructor body" + +W1023 = "Py++ will generate class wrapper - there are few functions that should be redefined in class wrapper" + +W1024 = "Py++ will generate class wrapper - class contains bit field member variable" + +W1025 = "Py++ will generate class wrapper - class contains T* member variable" + +W1026 = "Py++ will generate class wrapper - class contains T& member variable" + +W1027 = "Py++ will generate class wrapper - class contains array member variable" + +W1028 = "Py++ will generate class wrapper - class contains definition of nested class that requires wrapper class" + +W1029 = "Py++ will generate class wrapper - hand written code should be added to the wrapper class constructor body" + +W1030 = "Py++ will generate class wrapper - class contains definition of virtual or pure virtual member function" + +W1031 = "Py++ will generate class wrapper - user asked to expose non - public member function" + +W1032 = "Boost.Python library does not support enums with duplicate values. " \ + "You can read more about this here: " \ + "http://boost.org/libs/python/todo.html#support-for-enums-with-duplicate-values . " \ + "The quick work around is to add new class variable to the exported enum, from Python. " + +W1033 = "Py++ can not expose unnamed variables" + +W1034 = "Py++ can not expose alignement bit." + +W1035 = "Py++ can not expose static pointer member variables. This could be changed in future." + +W1036 = "Py++ can not expose pointer to Python immutable member variables. This could be changed in future." + +W1037 = "Boost.Python library can not expose variables, which are pointer to function." \ + " See http://www.boost.org/libs/python/doc/v2/faq.html#funcptr for more information." + +W1038 = "Py++ can not expose variables of with unnamed type." + +W1039 = "Py++ doesn't expose private or protected member variables." + +W1040 = 'The declaration is unexposed, but there are other declarations, which refer to it.' \ + 'This could cause "no to_python converter found" run time error.' \ + 'Declarations: %s' + + + + + + + + + + + Modified: pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py 2006-12-05 21:34:41 UTC (rev 777) +++ pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py 2006-12-05 21:36:37 UTC (rev 778) @@ -6,6 +6,7 @@ """defines class, which informs user about used, but unexposed declarations""" import os +from pyplusplus import messages from pygccxml import declarations from pyplusplus import decl_wrappers @@ -84,10 +85,10 @@ def __create_msg( self, dependencies ): depend_on_decl = dependencies[0].find_out_depend_on_declaration() - reason = [ 'There are declarations, which depend on the unexposed one:' ] + decls = [] for dependency in dependencies: - reason.append( ' ' + str( dependency.declaration ) ) - return "%s;%s" % ( depend_on_decl, os.linesep.join( reason ) ) + decls.append( os.linesep + ' ' + str( dependency.declaration ) ) + return "%s;%s" % ( depend_on_decl, messages.W1040 % ''.join( decls ) ) def inform_user( self ): used_not_exported_decls = self.__find_out_used_but_not_exported() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |