[pygccxml-commit] SF.net SVN: pygccxml: [1000] pyplusplus_dev/pyplusplus
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2007-04-19 06:52:35
|
Revision: 1000
http://svn.sourceforge.net/pygccxml/?rev=1000&view=rev
Author: roman_yakovenko
Date: 2007-04-18 23:52:25 -0700 (Wed, 18 Apr 2007)
Log Message:
-----------
small optimization to message treatment
Modified Paths:
--------------
pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py
pyplusplus_dev/pyplusplus/messages/__init__.py
pyplusplus_dev/pyplusplus/messages/warnings_.py
Modified: pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py
===================================================================
--- pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2007-04-18 18:51:07 UTC (rev 999)
+++ pyplusplus_dev/pyplusplus/decl_wrappers/decl_wrapper.py 2007-04-19 06:52:25 UTC (rev 1000)
@@ -3,8 +3,7 @@
# accompanying file LICENSE_1_0.txt or copy at
# http://www.boost.org/LICENSE_1_0.txt)
-"""defines base class for all classes, that will keep Py++ code generator engine
-instructions."""
+"""defines base class for all code generator configuration classes"""
import algorithm
from pyplusplus import _logging_
@@ -12,15 +11,12 @@
from pyplusplus import messages
class decl_wrapper_t(object):
- SPECIAL_TYPEDEF_PICK_ANY = True
- """Declaration interface.
+ """code generator declaration configuration base class
- This class represents the interface to the declaration tree. Its
- main purpose is to "decorate" the nodes in the tree with
- information about how the binding is to be created. Instances of
- this class are never created by the user, instead they are
- returned by the API.
+ This class contains configuration that could be applied to all declarations.
"""
+
+ SPECIAL_TYPEDEF_PICK_ANY = True
def __init__(self):
object.__init__(self)
@@ -35,7 +31,7 @@
@property
def logger( self ):
- """returns reference to L{_logging_.loggers.declarations}"""
+ """reference to L{_logging_.loggers.declarations}"""
return _logging_.loggers.declarations
def _get_documentation( self ):
@@ -43,7 +39,7 @@
def _set_documentation( self, value ):
self._documentation = value
documentation = property( _get_documentation, _set_documentation
- , doc="Using this property you can set documentation of the declaration." )
+ , doc="exposed declaration Python documentation string" )
def _generate_valid_name(self, name=None):
if name == None:
@@ -89,10 +85,10 @@
def _set_alias(self, alias):
self._alias = alias
alias = property( _get_alias, _set_alias
- , doc="Using this property you can easily change Python name of declaration" )
+ , doc="the name under which, Python will know the declaration" )
def rename( self, new_name ):
- """renames the declaration name, under which it is exposed"""
+ """give new name to the declaration, under which Python will know the declaration"""
self.alias = new_name
def _get_ignore( self ):
@@ -100,28 +96,32 @@
def _set_ignore( self, value ):
self._ignore = value
ignore = property( _get_ignore, _set_ignore
- ,doc="If you set ignore to True then this declaration will not be exported." )
+ , doc="boolean flag, which says whether to export declaration to Python or not" )
def _get_already_exposed_impl( self ):
return self._already_exposed
-
+
def _get_already_exposed( self ):
return self._get_already_exposed_impl()
def _set_already_exposed( self, value ):
self._already_exposed = value
- already_exposed = property( _get_already_exposed, _set_already_exposed )
+ already_exposed = property( _get_already_exposed, _set_already_exposed
+ , doc="boolean flag, which says whether the declaration is already exposed or not" )
def exclude( self ):
- """Exclude "self" and child declarations from being exposed."""
+ """exclude "self" and child declarations from being exposed."""
self.ignore = True
def include( self, already_exposed=False ):
- """Include "self" and child declarations to be exposed."""
+ """include "self" and child declarations to be exposed."""
self.ignore = False
self.already_exposed = already_exposed
def why_not_exportable( self ):
- """returns strings that explains why this declaration could not be exported or None otherwise"""
+ """return the reason( string ) that explains why this declaration could not be exported
+
+ If declaration could be exported, than method will return None
+ """
if None is self._exportable_reason:
self.get_exportable()
return self._exportable_reason
@@ -130,6 +130,7 @@
return ''
def get_exportable( self ):
+ """return True if declaration could be exposed to Python, False otherwise"""
if self._exportable is None:
if self.name.startswith( '__' ) or '.' in self.name:
self._exportable_reason = messages.W1000
@@ -143,6 +144,10 @@
self._exportable = not bool( self._exportable_reason )
return self._exportable
def set_exportable( self, exportable ):
+ """change "exportable" status
+
+ This function should be use in case Py++ made a mistake and signed the
+ declaration as unexportable."""
self._exportable = exportable
exportable = property( get_exportable, set_exportable
@@ -152,13 +157,11 @@
return []
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
+ """return important information( hints/tips/warning message ) Py++ has about
+ this declaration.
+
+ skip_ignored argument allows you to control the information reported to you.
+ For more information please read: http://www.language-binding.net/pyplusplus/documentation/warnings.html
"""
msgs = []
if not self.exportable:
@@ -179,12 +182,13 @@
@property
def disabled_messaged( self ):
+ """list of messages to ignore"""
return self.__msgs_to_ignore
def disable_messages( self, *args ):
- """Using this method you can tell to Py++ to not report some specifiec warnings.
+ """set messages, which should not be reported to you
- Usage example: decl.ignore_warnings( messages.W1001, messages.W1040 )
+ Usage example: decl.disable_messages( messages.W1001, messages.W1040 )
"""
for msg in args:
msg_id = messages.find_out_message_id( msg )
Modified: pyplusplus_dev/pyplusplus/messages/__init__.py
===================================================================
--- pyplusplus_dev/pyplusplus/messages/__init__.py 2007-04-18 18:51:07 UTC (rev 999)
+++ pyplusplus_dev/pyplusplus/messages/__init__.py 2007-04-19 06:52:25 UTC (rev 1000)
@@ -8,16 +8,19 @@
"""
from warnings_ import *
-import re
-__RE_GET_WARNING_ID = re.compile( r'warning\s(?P<id>W(\d){4})' )
+#implementation using regular expression is deprecated, I will leave it here for
+#some time to be sure that the new one does not cause any problems.
+#import re
+#__RE_GET_WARNING_ID = re.compile( r'warning\s(?P<id>W(\d){4})' )
+#match_obj = __RE_GET_WARNING_ID.search(msg)
+# if not match_obj:
+# return None
+# else:
+# return match_obj.group( 'id' )
+
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' )
+ return msg.identifier
-
DISABLE_MESSAGES = [
W1000, W1001, W1002, W1011, W1012, W1013, W1015, W1019, W1030, W1034, W1039
]
Modified: pyplusplus_dev/pyplusplus/messages/warnings_.py
===================================================================
--- pyplusplus_dev/pyplusplus/messages/warnings_.py 2007-04-18 18:51:07 UTC (rev 999)
+++ pyplusplus_dev/pyplusplus/messages/warnings_.py 2007-04-19 06:52:25 UTC (rev 1000)
@@ -7,6 +7,22 @@
reported to user.
"""
+class message_type(str):
+ """implementation details"""
+ def __new__(self, value, identifier):
+ return str.__new__(self, value )
+
+ def __init__(self, value, identifier ):
+ self.__identifier = identifier
+
+ @property
+ def identifier( self ):
+ return self.__identifier
+
+ def __mod__( self, values ):
+ str_value = super( message_type, self ).__str__()
+ return message_type( str_value % values, self.identifier )
+
W1000 = 'Py++, by default, does not expose internal compilers declarations. '\
'Names of those declarations usually start with "__".'
@@ -153,7 +169,6 @@
'Be sure to take a look on Py++ defined call policies: ' \
'http://language-binding.net/pyplusplus/documentation/functions/call_policies.html#py-defined-call-policies'
-
W1051 = 'The function takes as argument (name=%s, pos=%d) "%s" type. ' \
'You have to specify a call policies or to use "Function Transformation" ' \
'functionality.'
@@ -170,13 +185,20 @@
int( identifier[1:] )
except:
continue
-
- globals()[ identifier ] = 'warning %s: %s' % ( identifier, explanation )
+ msg = '%s %s: %s' % ( 'warning', identifier, explanation)
+ globals()[ identifier ] = message_type( msg, identifier )
del warnings
del identifier
del explanation
+if __name__ == '__main__':
+ x = W1051 % ( 'xxxxxxxx', 122, 'yyyyyyyyyy' )
+ print x, x.__class__.__name__
+ print '\n\n\n'
+ y = W1000
+ print y
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|