[pygccxml-commit] SF.net SVN: pygccxml: [779] pyplusplus_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-12-06 07:27:03
|
Revision: 779 http://svn.sourceforge.net/pygccxml/?rev=779&view=rev Author: roman_yakovenko Date: 2006-12-05 23:27:03 -0800 (Tue, 05 Dec 2006) Log Message: ----------- adding new functionality - "pragma warning disable" :-) User now can filter messages, reported by Py++ per declaration basis Modified Paths: -------------- pyplusplus_dev/pyplusplus/__init__.py pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py pyplusplus_dev/pyplusplus/messages/__init__.py pyplusplus_dev/pyplusplus/module_creator/creator.py pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py pyplusplus_dev/unittests/smart_pointers_tester.py Modified: pyplusplus_dev/pyplusplus/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/__init__.py 2006-12-05 21:36:37 UTC (rev 778) +++ pyplusplus_dev/pyplusplus/__init__.py 2006-12-06 07:27:03 UTC (rev 779) @@ -30,6 +30,7 @@ import utils import decl_wrappers import module_builder +import messages from _logging_ import multi_line_formatter_t Modified: pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2006-12-05 21:36:37 UTC (rev 778) +++ pyplusplus_dev/pyplusplus/decl_wrappers/__init__.py 2006-12-06 07:27:03 UTC (rev 779) @@ -148,18 +148,3 @@ 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/decl_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-12-05 21:36:37 UTC (rev 778) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-12-06 07:27:03 UTC (rev 779) @@ -28,6 +28,7 @@ self._exportable = None self._exportable_reason = None self._documentation = None + self.__msgs_to_ignore = set() @property def logger( self ): @@ -114,14 +115,34 @@ def _readme_impl( self ): return [] - def readme( self ): + + def readme( self, skip_ignored=True ): """This function will returns some hints/tips/description of problems that applied to the declarations. For example function that has argument reference to some fundamental type could be exported, but could not be called from Python + + @param skip_ignored: if True, messages that user asked to not reported + will not be returned """ - text = [] + msgs = [] if not self.exportable: - text.append( self.why_not_exportable() ) - text.extend( self._readme_impl() ) - return text + msgs.append( self.why_not_exportable() ) + msgs.extend( self._readme_impl() ) + return messages.filter_disabled_msgs( msgs, self.__msgs_to_ignore ) + + @property + def disabled_messaged( self ): + return self.__msgs_to_ignore + + def disable_messages( self, *args ): + """Using this method you can tell to Py++ to not report some specifiec warnings. + + Usage example: decl.ignore_warnings( messages.W1001, messages.W1040 ) + """ + for msg in args: + msg_id = messages.find_out_message_id( msg ) + if not msg_id: + raise RuntimeError( "Unable to find out message id. The message is: " + msg ) + self.__msgs_to_ignore.add( msg ) + disable_warnings = disable_messages Modified: pyplusplus_dev/pyplusplus/messages/__init__.py =================================================================== --- pyplusplus_dev/pyplusplus/messages/__init__.py 2006-12-05 21:36:37 UTC (rev 778) +++ pyplusplus_dev/pyplusplus/messages/__init__.py 2006-12-06 07:27:03 UTC (rev 779) @@ -6,122 +6,41 @@ """This package defines all user messages( warnings + errors ), which will be reported to user. """ +from warnings_ import * -W1000 = 'Py++, by default, does not expose internal compilers declarations.'\ - 'Names of those declarations usually start with "__".' +import re +__RE_GET_WARNING_ID = re.compile( r'warning\s(?P<id>W(\d){4})' ) +def find_out_message_id( msg ): + match_obj = __RE_GET_WARNING_ID.search(msg) + if not match_obj: + return None + else: + return match_obj.group( 'id' ) -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.' +DISABLE_MESSAGES = [ + W1000, W1001, W1002, W1011, W1012, W1013, W1015, W1019, W1030, W1034, W1039 +] +#Messages kept by DISABLE_MESSAGES list will not be reported -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.' +def filter_disabled_msgs( msgs, disable_messages=None ): + report = [] + + skip_them = DISABLE_MESSAGES[:] + if disable_messages: + skip_them.extend( disable_messages ) + + skip_them = filter( None, map( find_out_message_id, skip_them ) ) -W1005 = 'Py++ can not expose function that takes as argument/returns instance of non public class. ' \ - 'Generated code will not compile.' + for msg in msgs: + msg_id = find_out_message_id( msg ) + if msg_id and msg_id not in skip_them: + report.append( msg ) -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.' + return report -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/creator.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-12-05 21:36:37 UTC (rev 778) +++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-12-06 07:27:03 UTC (rev 779) @@ -152,7 +152,7 @@ if doc_extractor and decl.exportable: decl.documentation = doc_extractor( decl ) - readme = filter( lambda msg: msg not in decl_wrappers.skip_messages, decl.readme() ) + readme = decl.readme() if not readme: continue Modified: pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py 2006-12-05 21:36:37 UTC (rev 778) +++ pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py 2006-12-06 07:27:03 UTC (rev 779) @@ -71,7 +71,9 @@ if isinstance( depend_on_decl, declarations.class_types ) and depend_on_decl.opaque: continue if id( depend_on_decl ) not in exported_ids: - used_not_exported.append( dependency ) + report = messages.filter_disabled_msgs([messages.W1040], depend_on_decl.disabled_messaged ) + if report: + used_not_exported.append( dependency ) return used_not_exported def __group_by_unexposed( self, dependencies ): Modified: pyplusplus_dev/unittests/smart_pointers_tester.py =================================================================== --- pyplusplus_dev/unittests/smart_pointers_tester.py 2006-12-05 21:36:37 UTC (rev 778) +++ pyplusplus_dev/unittests/smart_pointers_tester.py 2006-12-06 07:27:03 UTC (rev 779) @@ -8,6 +8,7 @@ import unittest import fundamental_tester_base from pyplusplus import code_creators +from pyplusplus import messages class tester_t(fundamental_tester_base.fundamental_tester_base_t): EXTENSION_NAME = 'smart_pointers' @@ -20,7 +21,8 @@ def customize( self, mb ): base = mb.class_( 'base' ) - #base.held_type = '' + shared_ptrs = mb.decls( lambda decl: decl.name.startswith( 'shared_ptr<' ) ) + shared_ptrs.disable_warnings( messages.W1040 ) def create_py_derived( self, module ): class py_derived_t( module.base ): @@ -90,4 +92,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. |