Revision: 317
Author: roman_yakovenko
Date: 2006-07-18 06:13:47 -0700 (Tue, 18 Jul 2006)
ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=317&view=rev
Log Message:
-----------
fixing warnings reporting
Now py++ will write why declaration could not be exported.
Also it will write additional information it has about declaration.
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py
pyplusplus_dev/pyplusplus/module_creator/creator.py
pyplusplus_dev/pyplusplus/module_creator/types_database.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-07-18 08:52:35 UTC (rev 316)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2006-07-18 13:13:47 UTC (rev 317)
@@ -24,10 +24,7 @@
this class are never created by the user, instead they are
returned by the API.
"""
-
- DO_NOT_REPORT_MSGS = [ "pyplusplus does not exports compiler generated constructors" ]
- ALREADY_REPORTED_MSGS = set()
-
+
def __init__(self):
object.__init__(self)
self._alias = None
@@ -75,21 +72,8 @@
def rename( self, new_name ):
self.alias = new_name
- def __report_warning( self, reason ):
- if reason in decl_wrapper_t.DO_NOT_REPORT_MSGS:
- return
- if reason in decl_wrapper_t.ALREADY_REPORTED_MSGS:
- return
- decl_wrapper_t.ALREADY_REPORTED_MSGS.add( reason )
- msg = [ 'Declaration "%s" could not be exported.' % declarations.full_name( self ) ]
- reason = reason.replace( os.linesep, os.linesep + '\t' )
- msg.append( '\tReason: %s' % reason )
- self.logger.warn( os.linesep.join( msg ) )
-
def _get_ignore( self ):
- if False == self._ignore and not self.exportable:
- self.__report_warning( self.why_not_exportable() )
- return self._ignore or not self.exportable
+ return self._ignore
def _set_ignore( self, value ):
self._ignore = value
@@ -129,23 +113,6 @@
exportable = property( get_exportable, set_exportable
, doc="Returns True if declaration could be exported to Python, otherwise False" )
- #TODO:
- #I think that almost every declaration could have some wrapper. This is the
- #main reason why those 3 functions does not have some well defined interface.
- #def has_wrapper( self ):
- #return False
-
- #def _finalize_impl( self, error_behavior ):
- #pass
-
- #def finalize( self, error_behavior=None):
- #try:
- #self._finalize_impl( self )
- #except Exception, error:
- #if None is error_behavior or error_behavior == ERROR_BEHAVIOR.PRINT:
- #print 'Unable to finalize declaration: ', str( error )
- #else:
- #raise
def _readme_impl( self ):
return []
@@ -157,6 +124,6 @@
"""
text = []
if not self.exportable:
- text.append( 'WARNING: ' + self.why_not_exportable() )
+ text.append( self.why_not_exportable() )
text.extend( self._readme_impl() )
return text
Modified: pyplusplus_dev/pyplusplus/module_creator/creator.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-07-18 08:52:35 UTC (rev 316)
+++ pyplusplus_dev/pyplusplus/module_creator/creator.py 2006-07-18 13:13:47 UTC (rev 317)
@@ -2,7 +2,8 @@
# 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)
-
+
+import os
import time
import types_database
import class_organizer
@@ -43,8 +44,9 @@
#TODO: queue, priority, stack, multimap, hash_multimap, multiset, hash_multiset
}
-INDEXING_SUITE_2_MAIN_HEADER = "boost/python/suite/indexing/container_suite.hpp"
+INDEXING_SUITE_2_MAIN_HEADER = "boost/python/suite/indexing/container_suite.hpp"
+DO_NOT_REPORT_MSGS = [ "pyplusplus does not exports compiler generated constructors" ]
class creator_t( declarations.decl_visitor_t ):
"""Creating code creators.
@@ -90,7 +92,8 @@
@type doc_extractor: callable
"""
declarations.decl_visitor_t.__init__(self)
- self.logger = _logging_.loggers.module_builder
+ self.logger = _logging_.loggers.module_builder
+ self.decl_logger = _logging_.loggers.declarations
self.__enable_indexing_suite = enable_indexing_suite
self.__target_configuration = target_configuration
@@ -127,25 +130,42 @@
self.__array_1_registered = set() #(type.decl_string,size)
self.__free_operators = []
- def _prepare_decls( self, decls, doc_extractor ):
+ def _prepare_decls( self, decls, doc_extractor ):
+ global DO_NOT_REPORT_MSGS
decls = declarations.make_flatten( decls )
#leave only declarations defined under namespace, but remove namespaces
decls = filter( lambda x: not isinstance( x, declarations.namespace_t ) \
and isinstance( x.parent, declarations.namespace_t )
, decls )
- #leave only decls that should be exported
- decls = filter( lambda x: not x.ignore, decls )
- if doc_extractor:
- start_time = time.clock()
- self.logger.debug( 'Documentation extraction process started.' )
+ #leave only decls that user wants to export
+ decls = filter( lambda x: not x.ignore, decls )
+
+ for decl in decls:
+ if doc_extractor and decl.exportable:
+ decl.documentation = doc_extractor( decl )
+
+ readme = decl.readme()
+ if not readme:
+ continue
+ #Now we should print what py++ has to say to user
+ full_name = declarations.full_name( decl )
+ if not decl.name:
+ full_name = full_name + '::{unnamed}'
+
+ if not decl.exportable:
+ reason = readme[0]
+ if reason in DO_NOT_REPORT_MSGS:
+ continue
+ readme = readme[1:]
+ msg = [ 'Declaration "%s" could not be exported.' % full_name ]
+ msg.append( reason.replace( os.linesep, os.linesep + '\t' ) )
+ self.decl_logger.warn( os.linesep.join( msg ) )
+
+ for msg in readme:
+ self.decl_logger.warn( 'Declaration "%s": %s' % ( full_name, msg ) )
+
+ return filter( lambda x: x.exportable, decls )
- for decl in decls:
- decl.documentation = doc_extractor( decl )
-
- self.logger.debug( 'Documentation extraction process finished in %F seconds'
- % ( time.clock() - start_time ) )
- return decls
-
def _reorder_decls(self, decls ):
classes = filter( lambda x: isinstance( x, declarations.class_t )
, decls )
@@ -192,7 +212,7 @@
def _exportable_class_members( self, class_decl ):
assert isinstance( class_decl, declarations.class_t )
- members = filter( lambda mv: mv.ignore == False, class_decl.public_members )
+ members = filter( lambda mv: mv.ignore == False and mv.exportable, class_decl.public_members )
#protected and private virtual functions that not overridable and not pure
#virtual should not be exported
for member in class_decl.protected_members:
@@ -214,7 +234,7 @@
members = filter( lambda decl: not isinstance( decl, declarations.constructor_t )
or not decl.is_artificial
, members )
- members = filter( lambda member: not member.ignore, members )
+ members = filter( lambda member: member.ignore == False and member.exportable, members )
ordered_members = self._reorder_decls( members )
return ordered_members
@@ -253,7 +273,7 @@
return True
def redefined_funcs( self, cls ):
- all_included = declarations.custom_matcher_t( lambda decl: decl.ignore == False )
+ all_included = declarations.custom_matcher_t( lambda decl: decl.ignore == False and decl.exportable )
all_protected = declarations.access_type_matcher_t( 'protected' ) & all_included
all_pure_virtual = declarations.virtuality_type_matcher_t( VIRTUALITY_TYPES.PURE_VIRTUAL )
all_not_pure_virtual = ~all_pure_virtual
@@ -567,8 +587,6 @@
return ( maker_cls, fwrapper_cls )
def visit_member_function( self ):
- if self.curr_decl.ignore:
- return
fwrapper = None
self.__types_db.update( self.curr_decl )
if None is self.curr_decl.call_policies:
@@ -601,9 +619,6 @@
self.curr_code_creator.adopt_creator( static_method )
def visit_constructor( self ):
- if self.curr_decl.ignore:
- return
-
if self.curr_decl.is_copy_constructor:
return
self.__types_db.update( self.curr_decl )
@@ -629,9 +644,6 @@
pass
def visit_member_operator( self ):
- if self.curr_decl.ignore:
- return
-
if self.curr_decl.symbol in ( '()', '[]' ):
self.visit_member_function()
else:
@@ -640,9 +652,6 @@
self.curr_code_creator.adopt_creator( maker )
def visit_casting_operator( self ):
- if self.curr_decl.ignore:
- return
-
if not declarations.is_fundamental( self.curr_decl.return_type ) \
and not self.curr_decl.has_const:
return #only const casting operators can generate implicitly_convertible
@@ -661,8 +670,6 @@
self.curr_code_creator.adopt_creator( maker )
def visit_free_function( self ):
- if self.curr_decl.ignore:
- return
self.__types_db.update( self.curr_decl )
maker = code_creators.free_function_t( function=self.curr_decl )
if None is self.curr_decl.call_policies:
@@ -670,9 +677,6 @@
self.curr_code_creator.adopt_creator( maker )
def visit_free_operator( self ):
- if self.curr_decl.ignore:
- return
-
self.__types_db.update( self.curr_decl )
self.__free_operators.append( self.curr_decl )
@@ -680,8 +684,6 @@
pass
def visit_class(self ):
- if self.curr_decl.ignore:
- return
assert isinstance( self.curr_decl, declarations.class_t )
temp_curr_decl = self.curr_decl
temp_curr_parent = self.curr_code_creator
@@ -736,9 +738,6 @@
self.curr_code_creator = temp_curr_parent
def visit_enumeration(self):
- if self.curr_decl.ignore:
- return
-
assert isinstance( self.curr_decl, declarations.enumeration_t )
maker = None
if self.curr_decl.name:
@@ -762,9 +761,6 @@
return True
def visit_variable(self):
- if self.curr_decl.ignore:
- return
-
self.__types_db.update( self.curr_decl )
if declarations.is_array( self.curr_decl.type ):
Modified: pyplusplus_dev/pyplusplus/module_creator/types_database.py
===================================================================
--- pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-07-18 08:52:35 UTC (rev 316)
+++ pyplusplus_dev/pyplusplus/module_creator/types_database.py 2006-07-18 13:13:47 UTC (rev 317)
@@ -74,10 +74,10 @@
check_extraction = container_cls.indexing_suite.element_type
except RuntimeError, error:
msg = []
- msg.append( 'pyplusplus found class "%s" - instantiation declaration, not definition.' % container_cls.name )
- msg.append( 'pyplusplus can not find out container value_type( mapped_type )!' )
- msg.append( 'This class will be exported, but there is a posiblity, that generated code will not compile.' )
- msg.append( 'The solution to the problem is to create a variable of the class.' )
+ msg.append( 'pyplusplus found template class instantiation "%s" declaration ( not definition ). ' % container_cls.name )
+ msg.append( '\tpyplusplus can not find out container value_type( mapped_type )!' )
+ msg.append( '\tThis class will be exported, but there is a posiblity, that generated code will not compile.' )
+ msg.append( '\tThe solution to the problem is to create a variable of the class.' )
_logging_.loggers.declarations.warn( os.linesep.join( msg ) )
self.__containers.add( container_cls )
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|