Update of /cvsroot/pygccxml/source/pygccxml/declarations
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28954/pygccxml/declarations
Modified Files:
call_invocation.py declaration.py filtering.py filters.py
pattern_parser.py templates.py type_traits.py
Log Message:
There are a lot of changes, sorry CVS did not worked for week or something like this
Changes
1. Lots of code clean up
2. Adding and updating documentation
3. Adding new method on decl_wrapper - readme. This method will return list of msgs to the developer.
For example if function takes by reference fundamental type it will say that this function could not be called from Python
4. Logging functionlity has been added to file writers too
5. Few bug fixes
6. For operator [] call policies is always set.
Index: call_invocation.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/call_invocation.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** call_invocation.py 21 Dec 2005 07:29:23 -0000 1.4
--- call_invocation.py 6 Apr 2006 06:15:56 -0000 1.5
***************
*** 16,20 ****
"""
- import types
import pattern_parser
--- 16,19 ----
Index: filters.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/filters.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** filters.py 30 Mar 2006 05:56:16 -0000 1.7
--- filters.py 6 Apr 2006 06:15:56 -0000 1.8
***************
*** 42,46 ****
class and_matcher_t(matcher_base_t):
! """Combine several other matchers with "&"."""
def __init__(self, matchers):
matcher_base_t.__init__(self)
--- 42,51 ----
class and_matcher_t(matcher_base_t):
! """Combine several other matchers with "&".
!
! For example: find all private functions with name XXX
!
! C{ matcher = access_type_matcher_t( 'private' ) & calldef_matcher_t( name='XXX' ) }
! """
def __init__(self, matchers):
matcher_base_t.__init__(self)
***************
*** 58,62 ****
class or_matcher_t(matcher_base_t):
! """Combine several other matchers with "|"."""
def __init__(self, matchers):
matcher_base_t.__init__(self)
--- 63,73 ----
class or_matcher_t(matcher_base_t):
! """Combine several other matchers with "|".
!
! For example: find all functions and variables with name 'XXX'
!
! C{ matcher = variable_matcher_t( name='XXX' ) | calldef_matcher_t( name='XXX' ) }
!
! """
def __init__(self, matchers):
matcher_base_t.__init__(self)
***************
*** 74,78 ****
class not_matcher_t(matcher_base_t):
! """Return the inverse result of matcher"""
def __init__(self, matcher):
matcher_base_t.__init__(self)
--- 85,95 ----
class not_matcher_t(matcher_base_t):
! """Return the inverse result of matcher, using "~"
!
! For example: find all private and protected declarations
!
! C{ matcher = ~access_type_matcher_t( 'private' ) }
!
! """
def __init__(self, matcher):
matcher_base_t.__init__(self)
***************
*** 86,111 ****
class declaration_matcher_t( matcher_base_t ):
def __init__( self, name=None, decl_type=None, header_dir=None, header_file=None ):
! """ Instance of this class will match declarations by next criteria:
! declaration type - any class that derives from L{pygccxml.declarations.declaration_t} class
! header - file in which declaration has been declarated.
! Header path should be absolute!
- header directory - directory to which belongs file, in which
- declaration has been declarated.
- Header directory path should be absolute!
-
- declaration name - name of declaration, could be full name or
- declaration name only.
-
- @param decl_type: reference to one of the classes that derives from L{declarations.declaration_t} class.
- @param name: declaration name, could be full name.
- @param header_dir: absolute directory path
- @param header_file: absolute file path
"""
! #An other option is that
! #pygccxml will create absolute path using os.path.abspath function.
! #But I think this is just wrong, because abspath wbuilds path using
! #cwd and this behaviour is fragile and not so easy to find the bug.
matcher_base_t.__init__( self )
self.decl_type = decl_type
--- 103,133 ----
class declaration_matcher_t( matcher_base_t ):
+ """
+ Instance of this class will match declarations by next criteria:
+ - declaration name, also could be fully qualified name
+ Example: wstring or ::std::wstring
+ - declaration type
+ Example: L{class_t}, L{namespace_t}, L{enumeration_t}
+ - location within file system ( file or directory )
+ """
def __init__( self, name=None, decl_type=None, header_dir=None, header_file=None ):
! """
! @param decl_type: declaration type to match by. For example L{enumeration_t}.
! @type decl_type: any class that derives from L{declarations.declaration_t} class
!
! @param name: declaration name, could be full name.
! @type name: str
!
! @param header_dir: absolute directory path
! @type header_dir: str
!
! @param header_file: absolute file path
! @type header_file: str
"""
! #An other option is that pygccxml will create absolute path using
! #os.path.abspath function. But I think this is just wrong, because abspath
! #builds path using current working directory. This behaviour is fragile
! #and very difficult to find a bug.
matcher_base_t.__init__( self )
self.decl_type = decl_type
***************
*** 222,228 ****
class variable_matcher_t( declaration_matcher_t ):
! def __init__( self, name=None, type=None, decl_type=None, header_dir=None, header_file=None ):
"""
! type could be string or instance of class derived from cpptypes.type_t
"""
declaration_matcher_t.__init__( self
--- 244,256 ----
class variable_matcher_t( declaration_matcher_t ):
! """
! Instance of this class will match variables by next criteria:
! - L{declaration_matcher_t} criteria
! - variable type. Example: L{int_t} or 'int'
! """
! def __init__( self, name=None, type=None, header_dir=None, header_file=None ):
"""
! @param type: variable type
! @type type: string or instance of L{type_t} derived class
"""
declaration_matcher_t.__init__( self
***************
*** 257,260 ****
--- 285,290 ----
class namespace_matcher_t( declaration_matcher_t ):
+ """Instance of this class will match namespaces by name."""
+
def __init__( self, name=None ):
declaration_matcher_t.__init__( self, name=name, decl_type=namespace.namespace_t)
***************
*** 265,279 ****
class calldef_matcher_t( declaration_matcher_t ):
def __init__( self, name=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None):
! """Constructor.
!
! return_value_type could be string or instance of class derived from
! cpptypes.type_t
! arg_types could be a list of strings or cpptypes.type_t.
! It could be a mix. In this case you should specify all arguments.
! If you don't want to match some argument you can insert None
! instead.
! In future it should be possible to select function by it's
! default argument value and/or exception ....
"""
if None is decl_type:
--- 295,320 ----
class calldef_matcher_t( declaration_matcher_t ):
+ """
+ Instance of this class will match callables by next criteria:
+ - L{declaration_matcher_t} criteria
+ - return type. Example: L{int_t} or 'int'
+ - argument types
+ """
+
def __init__( self, name=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None):
! """
! @param return_type: callable return type
! @type return_type: string or instance of L{type_t} derived class
!
! @param arg_types: list of function argument types. arg_types can contain.
! Any item within the list could be string or instance of L{type_t} derived
! class. If you don't want some argument to participate in match you can
! put None. For example:
!
! C{ calldef_matcher_t( arg_types=[ 'int &', None ] ) }
!
! will match all functions that takes 2 arguments, where the first one is
! reference to integer and second any
! @type arg_types: list
"""
if None is decl_type:
***************
*** 334,338 ****
--- 375,388 ----
class operator_matcher_t( calldef_matcher_t ):
+ """
+ Instance of this class will match operators by next criteria:
+ - L{calldef_matcher_t} criteria
+ - operator symbol: =, !=, (), [] and etc
+ """
def __init__( self, name=None, symbol=None, return_type=None, arg_types=None, decl_type=None, header_dir=None, header_file=None):
+ """
+ @param symbol: operator symbol
+ @type symbol: str
+ """
if None is decl_type:
decl_type = calldef.operator_t
***************
*** 365,369 ****
--- 415,435 ----
class regex_matcher_t( matcher_base_t ):
+ """
+ Instance of this class will match declaration using regular expression.
+ User should supply a function that will extract from declaration desired
+ information as string. Later, this matcher will match that string using
+ user regular expression.
+ """
def __init__( self, regex, function=None ):
+ """
+ @param regex: regular expression
+ @type regex: string, an instance of this class will compile it for you
+
+ @param function: function that will be called to get an information from
+ declaration as string. As input this function takes 1 argument: reference
+ to declaration. Return value should be string. If function is None, then
+ the matcher will use declaration name.
+
+ """
matcher_base_t.__init__(self)
self.regex = re.compile( regex )
***************
*** 380,384 ****
--- 446,461 ----
class access_type_matcher_t( matcher_base_t ):
+ """
+ Instance of this class will match declaration by its access type: public,
+ private or protected. If declarations does not have access type, for example
+ free function, then False will be returned.
+ """
+
def __init__( self, access_type ):
+ """
+ @param access_type: declaration access type
+ @type access_type: L{ACCESS_TYPES} defines few consts for your convinience.
+ Any way you can pass public, private or protected as argument to this function
+ """
matcher_base_t.__init__( self )
self.access_type = access_type
Index: declaration.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/declaration.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** declaration.py 22 Mar 2006 10:37:47 -0000 1.20
--- declaration.py 6 Apr 2006 06:15:56 -0000 1.21
***************
*** 12,16 ****
import algorithm
- import pygccxml.utils
import templates
--- 12,15 ----
Index: type_traits.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/type_traits.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** type_traits.py 5 Mar 2006 05:41:11 -0000 1.23
--- type_traits.py 6 Apr 2006 06:15:56 -0000 1.24
***************
*** 395,407 ****
return found
! def __normalize( self, type ):
! type = remove_alias( type )
! bt_of_type = base_type( type )
if isinstance( bt_of_type, cpptypes.declarated_t ) \
and isinstance( bt_of_type.declaration, class_declaration.class_declaration_t ):
! type = type.clone()
! bt_of_type = base_type( type )
bt_of_type.declaration = self.__find_class_by_class_declaration( bt_of_type.declaration )
! return type
def __test_trivial( self, source, target ):
--- 395,407 ----
return found
! def __normalize( self, type_ ):
! type_ = remove_alias( type_ )
! bt_of_type = base_type( type_ )
if isinstance( bt_of_type, cpptypes.declarated_t ) \
and isinstance( bt_of_type.declaration, class_declaration.class_declaration_t ):
! type_ = type_.clone()
! bt_of_type = base_type( type_ )
bt_of_type.declaration = self.__find_class_by_class_declaration( bt_of_type.declaration )
! return type_
def __test_trivial( self, source, target ):
***************
*** 594,598 ****
and is_both_declarated( base.base.base, derived.base ):
return True
!
def is_convertible( self ):
source = self.__source
--- 594,599 ----
and is_both_declarated( base.base.base, derived.base ):
return True
! return False
!
def is_convertible( self ):
source = self.__source
***************
*** 639,643 ****
if isinstance( target, cpptypes.declarated_t ):
assert isinstance( target.declaration, class_declaration.class_t )
- target_inst = target.declaration
constructors = algorithm.find_all_declarations( target.declaration.declarations
, type=calldef.constructor_t
--- 640,643 ----
Index: filtering.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/filtering.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** filtering.py 22 Jan 2006 13:09:18 -0000 1.7
--- filtering.py 6 Apr 2006 06:15:56 -0000 1.8
***************
*** 21,28 ****
normalize_path = staticmethod( normalize_path )
! def __contains_parent_dir( fpath, dirs ):
#precondition: dirs and fpath should be normalize_path'ed before calling this function
return bool( filter( lambda dir: fpath.startswith( dir ), dirs ) )
! __contains_parent_dir = staticmethod( __contains_parent_dir )
def by_location( decls, locations ):
--- 21,28 ----
normalize_path = staticmethod( normalize_path )
! def contains_parent_dir( fpath, dirs ):
#precondition: dirs and fpath should be normalize_path'ed before calling this function
return bool( filter( lambda dir: fpath.startswith( dir ), dirs ) )
! contains_parent_dir = staticmethod( contains_parent_dir )
def by_location( decls, locations ):
***************
*** 53,57 ****
continue
fpath = filtering.normalize_path( decl.location.file_name )
! if filtering.__contains_parent_dir( fpath, dirs ) or fpath in files:
result.append( decl )
return result
--- 53,57 ----
continue
fpath = filtering.normalize_path( decl.location.file_name )
! if filtering.contains_parent_dir( fpath, dirs ) or fpath in files:
result.append( decl )
return result
Index: pattern_parser.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/pattern_parser.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** pattern_parser.py 30 Mar 2006 08:09:41 -0000 1.4
--- pattern_parser.py 6 Apr 2006 06:15:56 -0000 1.5
***************
*** 88,91 ****
--- 88,92 ----
pass
previous_found = found + 1 #skip found sep
+ #TODO: find out what is args and correct the code
return [ arg.strip() for arg in args ]
Index: templates.py
===================================================================
RCS file: /cvsroot/pygccxml/source/pygccxml/declarations/templates.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** templates.py 21 Dec 2005 07:29:23 -0000 1.7
--- templates.py 6 Apr 2006 06:15:56 -0000 1.8
***************
*** 16,20 ****
"""
- import types
import pattern_parser
--- 16,19 ----
|