[pygccxml-commit] SF.net SVN: pygccxml: [799] pyplusplus_dev/pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-12-14 08:21:54
|
Revision: 799 http://svn.sourceforge.net/pygccxml/?rev=799&view=rev Author: roman_yakovenko Date: 2006-12-14 00:21:53 -0800 (Thu, 14 Dec 2006) Log Message: ----------- a group of small improvements to the projects, mainly improving error messages Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/calldef.py pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py pyplusplus_dev/pyplusplus/decl_wrappers/properties.py pyplusplus_dev/pyplusplus/file_writers/multiple_files.py pyplusplus_dev/pyplusplus/messages/warnings_.py pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py pyplusplus_dev/pyplusplus/module_creator/types_database.py Modified: pygccxml_dev/pygccxml/declarations/calldef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/calldef.py 2006-12-14 07:04:27 UTC (rev 798) +++ pygccxml_dev/pygccxml/declarations/calldef.py 2006-12-14 08:21:53 UTC (rev 799) @@ -431,6 +431,20 @@ def __init__( self, *args, **keywords ): member_calldef_t.__init__( self, *args, **keywords ) + def __str__(self): + # Get the full name of the calldef... + name = algorithm.full_name(self) + if name[:2]=="::": + name = name[2:] + # Add the arguments... + args = map(lambda a: str(a), self.arguments) + res = "%s(%s)"%(name, ", ".join(args)) + # Append the declaration class + cls = 'constructor' + if self.is_copy_constructor: + cls = 'copy ' + cls + return "%s [%s]"%(res, cls) + def _get_is_copy_constructor(self): args = self.arguments if 1 != len( args ): Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-12-14 07:04:27 UTC (rev 798) +++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-12-14 08:21:53 UTC (rev 799) @@ -128,7 +128,13 @@ msgs = [] if not self.exportable: msgs.append( self.why_not_exportable() ) - msgs.extend( self._readme_impl() ) + + if declarations.templates.is_instantiation( self.name ) \ + and self.alias == self._generate_valid_name(): + msgs.append( messages.W1043 % self.alias ) + + msgs.extend( self._readme_impl() ) + return messages.filter_disabled_msgs( msgs, self.__msgs_to_ignore ) @property Modified: pyplusplus_dev/pyplusplus/decl_wrappers/properties.py =================================================================== --- pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-12-14 07:04:27 UTC (rev 798) +++ pyplusplus_dev/pyplusplus/decl_wrappers/properties.py 2006-12-14 08:21:53 UTC (rev 799) @@ -6,6 +6,8 @@ "defines property_t helper class" import algorithm +from pyplusplus import messages +from pyplusplus import _logging_ from pygccxml import declarations class property_t( object ): @@ -248,6 +250,12 @@ self.getters, self.setters = recognizer.class_accessors( cls ) self.inherited_getters, self.inherited_setters = recognizer.inherited_accessors( cls ) + def __report_illegal_property( self, property_ ): + logger = _logging_.loggers.declarations + if not messages.filter_disabled_msgs([messages.W1041], property_.fget.parent.disabled_messaged ): + return #user disabled property warning + logger.warn( "%s;%s" % ( property_.fget.parent, messages.W1041 % property_ ) ) + def __is_legal_property( self, property_ ): """property is legal if it does not hide other declarations""" def is_relevant( decl ): @@ -281,11 +289,14 @@ if fset in used_setters: continue property_ = self.recognizer.create_property( fget, fset ) - if property_ and self.__is_legal_property( property_ ): - used_getters.add( fget ) - used_setters.add( fset ) - properties.append( property_ ) - break + if property_: + if self.__is_legal_property( property_ ): + used_getters.add( fget ) + used_setters.add( fset ) + properties.append( property_ ) + break + else: + self.__report_illegal_property( property_ ) return properties def __call__( self ): @@ -306,10 +317,13 @@ if fget in used_getters: continue property_ = self.recognizer.create_read_only_property( fget ) - if property_ and self.__is_legal_property( property_ ): - used_getters.add( fget ) - properties.append( property_ ) - + if property_: + if self.__is_legal_property( property_ ): + used_getters.add( fget ) + properties.append( property_ ) + else: + self.__report_illegal_property( property_ ) + if self.exclude_accessors: map( lambda accessor: accessor.exclude(), used_getters ) map( lambda accessor: accessor.exclude(), used_setters ) Modified: pyplusplus_dev/pyplusplus/file_writers/multiple_files.py =================================================================== --- pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2006-12-14 07:04:27 UTC (rev 798) +++ pyplusplus_dev/pyplusplus/file_writers/multiple_files.py 2006-12-14 08:21:53 UTC (rev 799) @@ -7,6 +7,8 @@ import os import writer +from pyplusplus import messages +from pyplusplus import _logging_ from pygccxml import declarations from pyplusplus import decl_wrappers from pyplusplus import code_creators @@ -133,13 +135,10 @@ value_class = class_traits.get_declaration( element_type ) return self.create_value_traits_header_name( value_class ) except RuntimeError, error: - msg = "%s;%s" \ - % ( str(code_creator.declaration) - , "Py++ can not find out container value_type( mapped_type )." - "The container class is template instantiation declaration and not definition." - "This container class will be exported, but there is a posiblity, that generated code will not compile." - "The solution to the problem is to create a variable of the class." ) - self.logger.warn( msg ) + decls_logger = _logging_.loggers.declarations + if not messages.filter_disabled_msgs([messages.W1042], code_creator.declaration.disabled_messaged ): + return #user disabled property warning + decls_logger.warn( "%s;%s" % ( code_creator.declaration, messages.W1042 ) ) def create_include_code( self, creators, head_headers=None, tail_headers=None ): answer = [] Modified: pyplusplus_dev/pyplusplus/messages/warnings_.py =================================================================== --- pyplusplus_dev/pyplusplus/messages/warnings_.py 2006-12-14 07:04:27 UTC (rev 798) +++ pyplusplus_dev/pyplusplus/messages/warnings_.py 2006-12-14 08:21:53 UTC (rev 799) @@ -3,11 +3,11 @@ # 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 +"""This package defines all user messages (warnings + errors), which will be reported to user. """ -W1000 = 'Py++, by default, does not expose internal compilers declarations.'\ +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. ' \ @@ -15,7 +15,7 @@ W1002 = 'Py++, by default, does not expose compiler generated declarations.' -W1003 = 'Virtual functions that returns const reference can not be overriden from Python. ' \ +W1003 = 'Virtual functions that returns const reference cannot be overridden 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 ' \ @@ -25,7 +25,7 @@ '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. ' \ +W1005 = 'Py++ cannot 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. ' \ @@ -36,9 +36,9 @@ '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. ' + 'The value cannot be modified from Python. ' -W1009 = 'The function takes as argument (name=%s, pos=%d ) non-const reference ' \ +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.' @@ -98,7 +98,7 @@ W1033 = "Py++ can not expose unnamed variables" -W1034 = "Py++ can not expose alignement bit." +W1034 = "Py++ can not expose alignment bit." W1035 = "Py++ can not expose static pointer member variables. This could be changed in future." @@ -111,11 +111,21 @@ 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.' \ +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' +W1041 = 'Property "%s" could not be created. There is another exposed declaration with the same name( alias )." ' \ + 'The property will make it inaccessible.' +W1042 = 'Py++ can not find out container value_type( mapped_type ). ' \ + 'The container class is template instantiation declaration and not definition. ' \ + 'This container class will be exported, but there is a possibility, that ' \ + 'generated code will not compile or will lack some functionality. ' \ + 'The solution to the problem is to create a variable of the class.' + +W1043 = 'Py++ created an ugly alias ("%s") for template instantiated class.' + warnings = globals() for identifier, explanation in warnings.items(): Modified: pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py 2006-12-14 07:04:27 UTC (rev 798) +++ pyplusplus_dev/pyplusplus/module_creator/dependencies_manager.py 2006-12-14 08:21:53 UTC (rev 799) @@ -20,29 +20,13 @@ self.__exported_decls.append( decl ) def __is_std_decl( self, decl ): - if not decl.parent: + #Every class under std should be exported by Boost.Python and\\or Py++ + #Also this is not the case right now, I prefer to hide the warnings + dpath = declarations.declaration_path( decl ) + if len( dpath ) < 3: return False - - if not isinstance( decl.parent, declarations.namespace_t ): + if dpath[1] != 'std': return False - - if 'std' != decl.parent.name: - return False - - ns_std = decl.parent - if not ns_std.parent: - return False - - if not isinstance( ns_std.parent, declarations.namespace_t ): - return False - - if '::' != ns_std.parent.name: - return False - - global_ns = ns_std.parent - if global_ns.parent: - return False - if decl.name.startswith( 'pair<' ): #special case return False Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py =================================================================== --- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-12-14 07:04:27 UTC (rev 798) +++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-12-14 08:21:53 UTC (rev 799) @@ -3,6 +3,7 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +from pyplusplus import messages from pygccxml import declarations from pyplusplus import code_creators from pyplusplus import _logging_ @@ -73,14 +74,10 @@ #check extraction of element type from container container_cls.indexing_suite.element_type except RuntimeError: - msg = "%s;%s" \ - % ( str(container_cls) - , "Py++ can not find out container value_type( mapped_type )." - "The container class is template instantiation declaration and not definition." - "This container class will be exported, but there is a posiblity, that generated code will not compile." - "The solution to the problem is to create a variable of the class." ) - _logging_.loggers.declarations.warn( msg ) - + decls_logger = _logging_.loggers.declarations + if not messages.filter_disabled_msgs([messages.W1042], container_cls.disabled_messaged ): + return #user disabled property warning + decls_logger.warn( "%s;%s" % ( container_cls, messages.W1042 ) ) self.__containers.add( container_cls ) return True @@ -182,4 +179,4 @@ def _get_used_containers( self ): return self.__containers used_containers = property( _get_used_containers) - \ No newline at end of file + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |