[pygccxml-commit] SF.net SVN: pygccxml: [427] pygccxml_dev/pygccxml/utils
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-08-21 08:04:37
|
Revision: 427 Author: roman_yakovenko Date: 2006-08-21 01:04:14 -0700 (Mon, 21 Aug 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=427&view=rev Log Message: ----------- updating documentation strings Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/calldef.py pygccxml_dev/pygccxml/declarations/class_declaration.py pygccxml_dev/pygccxml/declarations/cpptypes.py pygccxml_dev/pygccxml/declarations/decl_factory.py pygccxml_dev/pygccxml/declarations/declaration.py pygccxml_dev/pygccxml/declarations/enumeration.py pygccxml_dev/pygccxml/declarations/filtering.py pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py pygccxml_dev/pygccxml/declarations/namespace.py pygccxml_dev/pygccxml/declarations/pattern_parser.py pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/pygccxml/declarations/typedef.py pygccxml_dev/pygccxml/declarations/variable.py pygccxml_dev/pygccxml/utils/__init__.py Modified: pygccxml_dev/pygccxml/declarations/calldef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/calldef.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/calldef.py 2006-08-21 08:04:14 UTC (rev 427) @@ -8,18 +8,18 @@ This modules contains definition for next C++ declarations: - operator - - member + - member - free - - function + - function - member - free - constructor - destructor """ -import cpptypes +import cpptypes import algorithm -import declaration +import declaration import type_traits import call_invocation @@ -29,7 +29,7 @@ VIRTUAL = 'virtual' PURE_VIRTUAL = 'pure virtual' ALL = [NOT_VIRTUAL, VIRTUAL, PURE_VIRTUAL] -#preserving backward compatebility +#preserving backward compatebility FUNCTION_VIRTUALITY_TYPES = VIRTUALITY_TYPES #First level in hierarchy of calldef @@ -37,13 +37,13 @@ """ class, that describes argument of "callable" declaration """ - + def __init__( self, name='', type=None, default_value=None ): object.__init__(self) self._name = name self._default_value = default_value self._type = type - + def __str__(self): if self.default_value==None: return "%s %s"%(self.type, self.name) @@ -104,20 +104,20 @@ self._return_type = return_type self._has_extern = has_extern self._demangled_name = None - + def _get__cmp__call_items(self): - """@undocumented _get__cmp__call_items:""" + """implementation details""" raise NotImplementedError() def _get__cmp__items( self ): - """@undocumented _get__cmp__items:""" + """implementation details""" items = [ self._sorted_list( self.arguments ) , self.return_type , self.has_extern , self._sorted_list( self.exceptions ) ] items.extend( self._get__cmp__call_items() ) return items - + def __eq__(self, other): if not declaration.declaration_t.__eq__( self, other ): return False @@ -125,7 +125,7 @@ and self.arguments == other.arguments \ and self.has_extern == other.has_extern \ and self._sorted_list( self.exceptions ) \ - == other._sorted_list( other.exceptions ) + == other._sorted_list( other.exceptions ) def _get_arguments(self): return self._arguments @@ -160,7 +160,7 @@ = algorithm.find_all_declarations( self.parent.declarations , type=calldef_t , name=self.name - , recursive=False ) + , recursive=False ) if not overloaded_funcs: return overloaded_funcs overloaded_funcs_ids = map( id, overloaded_funcs ) @@ -178,30 +178,30 @@ doc="""Was this callable declared as "extern"? @type: bool """) - + def __remove_parent_fname( self, demangled ): - """@undocumented __remove_parent_fname:""" + """implementation details""" demangled = demangled.strip() parent_fname = algorithm.full_name( self.parent ) if parent_fname.startswith( '::' ) and not demangled.startswith( '::' ): parent_fname = parent_fname[2:] demangled = demangled[ len( parent_fname ): ] return demangled - + def _get_demangled_name( self ): if not self.demangled: self._demangled_name = '' - + if self._demangled_name: return self._demangled_name - + if self._demangled_name == '': return self.name - + demangled = self.demangled if self.return_type: return_type = type_traits.remove_alias( self.return_type ).decl_string - + if return_type.startswith( '::' ) and not self.demangled.startswith( '::' ): return_type = return_type[2:] demangled = self.demangled @@ -216,7 +216,7 @@ if demangled_name.startswith( self.name ): self._demangled_name = demangled_name return self._demangled_name - + #well, I am going to try an other strategy fname = algorithm.full_name( self ) found = self.demangled.find( fname ) @@ -238,9 +238,10 @@ #if -1 == found: self._demangled_name = '' return self.name - - demangled_name = property( _get_demangled_name ) - + + demangled_name = property( _get_demangled_name + , doc="returns function demangled name. It can help you to deal with function template instantiations") + #Second level in hierarchy of calldef class member_calldef_t( calldef_t ): """base class for "callable" declarations that defined within C++ class or struct""" @@ -274,9 +275,9 @@ return "%s [%s]"%(res, cls) def _get__cmp__call_items(self): - """@undocumented _get__cmp__call_items:""" + """implementation details""" return [ self.virtuality, self.has_static, self.has_const ] - + def __eq__(self, other): if not calldef_t.__eq__( self, other ): return False @@ -289,7 +290,7 @@ def _set_virtuality(self, virtuality): assert virtuality in VIRTUALITY_TYPES.ALL self._virtuality = virtuality - virtuality = property( _get_virtuality, _set_virtuality + virtuality = property( _get_virtuality, _set_virtuality , doc="""Describes the "virtuality" of the member (as defined by the string constants in the class L{VIRTUALITY_TYPES}). @type: str""") @@ -326,8 +327,8 @@ def _create_decl_string(self): return self.function_type().decl_string - + class free_calldef_t( calldef_t ): """base class for "callable" declarations that defined within C++ namespace""" def __init__( self, *args, **keywords ): @@ -354,7 +355,7 @@ return "%s [%s]"%(res, cls) def _get__cmp__call_items(self): - """@undocumented _get__cmp__call_items:""" + """implementation details""" return [] def function_type(self): @@ -370,12 +371,12 @@ OPERATOR_WORD_LEN = len( 'operator' ) def __init__(self): object.__init__(self) - + def _get_symbol(self): return self.name[operator_t.OPERATOR_WORD_LEN:].strip() symbol = property( _get_symbol, doc="returns symbol of operator. For example: operator+, symbol is equal to '+'") - + #Third level in hierarchy of calldef class member_function_t( member_calldef_t ): """describes member function declaration""" @@ -387,8 +388,8 @@ """describes constructor declaration""" def __init__( self, *args, **keywords ): member_calldef_t.__init__( self, *args, **keywords ) - - def _get_is_copy_constructor(self): + + def _get_is_copy_constructor(self): args = self.arguments if 1 != len( args ): return False @@ -431,4 +432,4 @@ """describes free operator declaration""" def __init__( self, *args, **keywords ): free_calldef_t.__init__( self, *args, **keywords ) - operator_t.__init__( self, *args, **keywords ) \ No newline at end of file + operator_t.__init__( self, *args, **keywords ) Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/class_declaration.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2006-08-21 08:04:14 UTC (rev 427) @@ -20,7 +20,7 @@ """class that defines "access" constants""" PUBLIC = "public" PRIVATE = "private" - PROTECTED = "protected" + PROTECTED = "protected" ALL = [ PUBLIC, PRIVATE, PROTECTED ] class CLASS_TYPES: @@ -31,10 +31,9 @@ ALL = [ CLASS, STRUCT, UNION ] class hierarchy_info_t( object ): - """ - describes class relationship - """ + """describes class relationship""" def __init__(self, related_class=None, access=None ): + """creates class that contains partial information about class relationship""" if related_class: assert( isinstance( related_class, class_t ) ) self._related_class = related_class @@ -78,17 +77,19 @@ class class_declaration_t( declaration.declaration_t ): """describes class declaration""" def __init__( self, name='' ): + """creates class that describes C++ class declaration( and not definition )""" declaration.declaration_t.__init__( self, name ) - + def _get__cmp__items(self): - """@undocumented _get__cmp__items:""" - return [] + """implementation details""" + return [] class class_t( scopedef.scopedef_t ): """describes class definition""" USE_DEMANGLED_AS_NAME = True def __init__( self, name='', class_type=CLASS_TYPES.CLASS, is_abstract=False ): + """creates class that describes C++ class definition""" scopedef.scopedef_t.__init__( self, name ) if class_type: assert( class_type in CLASS_TYPES.ALL ) @@ -100,7 +101,7 @@ self._private_members = [] self._protected_members = [] self._aliases = [] - + def _get_name_impl( self ): if not self._name: #class with empty name return self._name @@ -111,13 +112,13 @@ if self.demangled.startswith( fname ): tmp = self.demangled[ len( fname ): ] #demangled::name if tmp.startswith( '::' ): - tmp = tmp[2:] + tmp = tmp[2:] return tmp else: return self._name else: return self._name - + def __str__(self): name = algorithm.full_name(self) if name[:2]=="::": @@ -125,15 +126,15 @@ return "%s [%s]"%(name, self.class_type) def _get__cmp__scope_items(self): - """@undocumented _get__cmp__scope_items:""" - return [ self.class_type + """implementation details""" + return [ self.class_type , self._sorted_list( [ algorithm.declaration_path( base.related_class ) for base in self.bases ] ) , self._sorted_list( [ algorithm.declaration_path( derive.related_class ) for derive in self.derived ] ) - , self.is_abstract + , self.is_abstract , self._sorted_list( self.public_members ) , self._sorted_list( self.private_members ) , self._sorted_list( self.protected_members ) ] - + def __eq__(self, other): if not scopedef.scopedef_t.__eq__( self, other ): return False @@ -177,7 +178,7 @@ return all_bases recursive_bases = property( _get_recursive_bases , doc="returns a list of all L{base classes<hierarchy_info_t>}") - + def _get_derived(self): return self._derived def _set_derived( self, new_derived ): @@ -238,12 +239,12 @@ def get_members( self, access=None): """ returns list of members according to access type - + If access equals to None, then returned list will contain all members. - + @param access: describes desired members @type access: L{ACCESS_TYPES} - + @return: [ members ] """ if access == ACCESS_TYPES.PUBLIC: @@ -262,10 +263,10 @@ def set_members( self, access, new_members ): """ set list of members according to access type - + @param access: describes desired members @type access: L{ACCESS_TYPES} - + @param new_members: list of new members @type new_members: [ L{member<declaration_t>} ] """ @@ -278,11 +279,11 @@ self.private_members = new_members for member in new_members: member.parent = self - + def remove_declaration( self, decl ): """ removes decl from members list - + @param decl: declaration to be removed @type decl: L{declaration_t} """ @@ -299,14 +300,14 @@ #add more comment about this. #if not keep_parent: # decl.parent=None - + def find_out_member_access_type( self, member ): """ returns member access type - + @param member: member of the class @type member: L{declaration_t} - + @return: L{ACCESS_TYPES} """ assert member.parent is self @@ -317,4 +318,4 @@ elif member in self.private_members: return ACCESS_TYPES.PRIVATE else: - raise RuntimeError( "Unable to find member within internal members list." ) \ No newline at end of file + raise RuntimeError( "Unable to find member within internal members list." ) Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py =================================================================== --- pygccxml_dev/pygccxml/declarations/cpptypes.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2006-08-21 08:04:14 UTC (rev 427) @@ -40,27 +40,30 @@ def _clone_impl( self ): raise NotImplementedError() - + def clone( self ): "returns new instance of the type" answer = self._clone_impl() assert answer return answer - + #There are cases when GCC-XML reports something like this #<Unimplemented id="_9482" tree_code="188" tree_code_name="template_type_parm" node="0xcc4d5b0"/> #In this case I will use this as type class dummy_type_t( type_t ): - #This class is very usefull for code generation + """provides L{type_t} interface for a string, that defines C++ type. + + This class could be very useful in the code generator. + """ def __init__( self, decl_string ): type_t.__init__( self ) self._decl_string = decl_string - + def _create_decl_string(self): return self._decl_string - + def _clone_impl( self ): return dummy_type_t( self._decl_string ) @@ -71,10 +74,10 @@ def _create_decl_string(self): return '?unknown?' - + def _clone_impl( self ): - return self - + return self + ################################################################################ ## Fundamental types: @@ -91,142 +94,168 @@ return self class java_fundamental_t( fundamental_t ): + """base class for all JNI defined fundamental types""" def __init__( self, name ): fundamental_t.__init__( self, name ) class void_t( fundamental_t ): + """represents void type""" CPPNAME = 'void' def __init__( self ): fundamental_t.__init__( self,void_t.CPPNAME ) class char_t( fundamental_t ): + """represents char type""" CPPNAME = 'char' def __init__( self ): fundamental_t.__init__( self, char_t.CPPNAME ) class unsigned_char_t( fundamental_t ): + """represents unsigned char type""" CPPNAME = 'unsigned char' def __init__( self ): fundamental_t.__init__( self, unsigned_char_t.CPPNAME ) class wchar_t( fundamental_t ): + """represents wchar_t type""" CPPNAME = 'wchar_t' def __init__( self ): fundamental_t.__init__( self, wchar_t.CPPNAME ) class short_int_t( fundamental_t ): + """represents short int type""" CPPNAME = 'short int' def __init__( self ): fundamental_t.__init__( self, short_int_t.CPPNAME ) class short_unsigned_int_t( fundamental_t ): + """represents short unsigned int type""" CPPNAME = 'short unsigned int' def __init__( self ): fundamental_t.__init__( self, short_unsigned_int_t.CPPNAME ) class bool_t( fundamental_t ): + """represents bool type""" CPPNAME = 'bool' def __init__( self ): fundamental_t.__init__( self, bool_t.CPPNAME ) class int_t( fundamental_t ): + """represents int type""" CPPNAME = 'int' def __init__( self ): fundamental_t.__init__( self, int_t.CPPNAME ) class unsigned_int_t( fundamental_t ): + """represents unsigned int type""" CPPNAME = 'unsigned int' def __init__( self ): fundamental_t.__init__( self, unsigned_int_t.CPPNAME ) class long_int_t( fundamental_t ): + """represents long int type""" CPPNAME = 'long int' def __init__( self ): fundamental_t.__init__( self, long_int_t.CPPNAME ) class long_unsigned_int_t( fundamental_t ): + """represents long unsigned int type""" CPPNAME = 'long unsigned int' def __init__( self ): fundamental_t.__init__( self, long_unsigned_int_t.CPPNAME ) class long_long_int_t( fundamental_t ): + """represents long long int type""" CPPNAME = 'long long int' def __init__( self ): fundamental_t.__init__( self, long_long_int_t.CPPNAME ) class long_long_unsigned_int_t( fundamental_t ): + """represents long long unsigned int type""" CPPNAME = 'long long unsigned int' def __init__( self ): fundamental_t.__init__( self, long_long_unsigned_int_t.CPPNAME ) class float_t( fundamental_t ): + """represents float type""" CPPNAME = 'float' def __init__( self ): fundamental_t.__init__( self, float_t.CPPNAME ) class double_t( fundamental_t ): + """represents double type""" CPPNAME = 'double' def __init__( self ): fundamental_t.__init__( self, double_t.CPPNAME ) class long_double_t( fundamental_t ): + """represents long double type""" CPPNAME = 'long double' def __init__( self ): fundamental_t.__init__( self, long_double_t.CPPNAME ) class complex_double_t( fundamental_t ): + """represents complex double type""" CPPNAME = 'complex double' def __init__( self ): fundamental_t.__init__( self, complex_double_t.CPPNAME ) class complex_long_double_t( fundamental_t ): + """represents complex long double type""" CPPNAME = 'complex long double' def __init__( self ): fundamental_t.__init__( self, complex_long_double_t.CPPNAME ) class complex_float_t( fundamental_t ): + """represents complex float type""" CPPNAME = 'complex float' def __init__( self ): fundamental_t.__init__( self, complex_float_t.CPPNAME ) class jbyte_t( java_fundamental_t ): + """represents jbyte type""" JNAME = 'jbyte' def __init__( self ): java_fundamental_t.__init__( self, jbyte_t.JNAME ) class jshort_t( java_fundamental_t ): + """represents jshort type""" JNAME = 'jshort' def __init__( self ): java_fundamental_t.__init__( self, jshort_t.JNAME ) class jint_t( java_fundamental_t ): + """represents jint type""" JNAME = 'jint' def __init__( self ): java_fundamental_t.__init__( self, jint_t.JNAME ) class jlong_t( java_fundamental_t ): + """represents jlong type""" JNAME = 'jlong' def __init__( self ): java_fundamental_t.__init__( self, jlong_t.JNAME ) class jfloat_t( java_fundamental_t ): + """represents jfloat type""" JNAME = 'jfloat' def __init__( self ): java_fundamental_t.__init__( self, jfloat_t.JNAME ) - class jdouble_t( java_fundamental_t ): + """represents jdouble type""" JNAME = 'jdouble' def __init__( self ): java_fundamental_t.__init__( self, jdouble_t.JNAME ) - class jchar_t( java_fundamental_t ): + """represents jchar type""" JNAME = 'jchar' def __init__( self ): java_fundamental_t.__init__( self, jchar_t.JNAME ) class jboolean_t( java_fundamental_t ): + """represents jboolean type""" JNAME = 'jboolean' def __init__( self ): java_fundamental_t.__init__( self, jboolean_t.JNAME ) @@ -271,8 +300,11 @@ , '__java_double' : jdouble_t() , '__java_char' : jchar_t() , '__java_boolean' : jboolean_t() - } +""" +defines a mapping between funcdamental type name and its synonym to the instance +of class that describes the type +""" ################################################################################ ## Compaund types: @@ -292,6 +324,7 @@ , doc="reference to internal/base class") class volatile_t( compound_t ): + """represents C{volatile whatever} type""" def __init__( self, base ): compound_t.__init__( self, base) @@ -300,8 +333,9 @@ def _clone_impl( self ): return volatile_t( self.base.clone() ) - + class const_t( compound_t ): + """represents C{whatever const} type""" def __init__( self, base ): compound_t.__init__( self, base ) @@ -312,6 +346,7 @@ return const_t( self.base.clone() ) class pointer_t( compound_t ): + """represents C{whatever*} type""" def __init__( self, base ): compound_t.__init__( self, base ) @@ -322,6 +357,7 @@ return pointer_t( self.base.clone() ) class reference_t( compound_t ): + """represents C{whatever&} type""" def __init__( self, base ): compound_t.__init__( self, base) @@ -332,6 +368,7 @@ return reference_t( self.base.clone() ) class array_t( compound_t ): + """represents C++ array type""" SIZE_UNKNOWN = -1 def __init__( self, base, size ): compound_t.__init__( self, base ) @@ -339,7 +376,7 @@ def _get_size(self): return self._size - size = property( _get_size, + size = property( _get_size, doc="returns array size" ) def _create_decl_string(self): @@ -355,7 +392,7 @@ self._return_type = return_type if arguments_types is None: arguments_types = [] - self._arguments_types = arguments_types + self._arguments_types = arguments_types def _get_return_type(self): return self._return_type @@ -379,45 +416,49 @@ type_t.__init__(self) calldef_type_t.__init__( self, return_type, arguments_types ) - @staticmethod + @staticmethod def create_decl_string( return_type, arguments_types ): """ returns free function type - + @param return_type: function return type @type return_type: L{type_t} - + @param arguments_types: list of argument L{type<type_t>} - + @return: L{free_function_type_t} """ - return free_function_type_t.NAME_TEMPLATE % { + return free_function_type_t.NAME_TEMPLATE % { 'return_type' : return_type.decl_string , 'arguments' : ','.join( map( lambda x: x.decl_string, arguments_types ) ) } - + def _create_decl_string(self): return self.create_decl_string( self.return_type, self.arguments_types ) def _clone_impl( self ): rt_clone = None if self.return_type: - rt_clone = self.return_type.clone() + rt_clone = self.return_type.clone() return free_function_type_t( rt_clone , [ arg.clone() for arg in self.arguments_types ] ) #TODO: create real typedef def create_typedef( self, typedef_name, unused=None): + """returns string, that contains valid C++ code, that defines typedef to function type + + @param name: the desired name of typedef + """ #unused argument simplifies user code - return free_function_type_t.TYPEDEF_NAME_TEMPLATE % { + return free_function_type_t.TYPEDEF_NAME_TEMPLATE % { 'typedef_name' : typedef_name - , 'return_type' : self.return_type.decl_string + , 'return_type' : self.return_type.decl_string , 'arguments' : ','.join( map( lambda x: x.decl_string, self.arguments_types ) ) } - + class member_function_type_t( type_t, calldef_type_t ): """describes member function type""" NAME_TEMPLATE = '%(return_type)s ( %(class)s::* )( %(arguments)s ) %(has_const)s' TYPEDEF_NAME_TEMPLATE = '%(return_type)s ( %(class)s::*%(typedef_name)s )( %(arguments)s ) %(has_const)s' - + def __init__( self, class_inst=None, return_type=None, arguments_types=None, has_const=False): type_t.__init__(self) calldef_type_t.__init__( self, return_type, arguments_types ) @@ -429,7 +470,7 @@ def _set_has_const(self, has_const ): self._has_const = has_const has_const = property( _get_has_const, _set_has_const - , doc="describes, whether function has const modifier") + , doc="describes, whether function has const modifier") def _get_class_inst(self): return self._class_inst @@ -440,9 +481,8 @@ #TODO: create real typedef def create_typedef( self, typedef_name, class_alias=None): - """ - creates typedef to the function type - + """creates typedef to the function type + @param typedef_name: desired type name @return: string """ @@ -451,12 +491,12 @@ has_const_str = 'const' if None is class_alias: class_alias = self.class_inst.decl_string - return member_function_type_t.TYPEDEF_NAME_TEMPLATE % { + return member_function_type_t.TYPEDEF_NAME_TEMPLATE % { 'typedef_name' : typedef_name - , 'return_type' : self.return_type.decl_string + , 'return_type' : self.return_type.decl_string , 'class' : class_alias , 'arguments' : ','.join( map( lambda x: x.decl_string, self.arguments_types ) ) - , 'has_const' : has_const_str } + , 'has_const' : has_const_str } def create(self): return self.create_decl_string( self.return_type @@ -465,7 +505,7 @@ , self.has_const ) - @staticmethod + @staticmethod def create_decl_string(return_type, class_decl_string, arguments_types, has_const): has_const_str = '' if has_const: @@ -473,12 +513,12 @@ return_type_decl_string = '' if return_type: return_type_decl_string = return_type.decl_string - return member_function_type_t.NAME_TEMPLATE % { - 'return_type' : return_type_decl_string + return member_function_type_t.NAME_TEMPLATE % { + 'return_type' : return_type_decl_string , 'class' : class_decl_string , 'arguments' : ','.join( map( lambda x: x.decl_string, arguments_types ) ) - , 'has_const' : has_const_str } - + , 'has_const' : has_const_str } + def _create_decl_string(self): return self.create_decl_string( self.return_type , self.class_inst.decl_string @@ -489,19 +529,19 @@ rt_clone = None if self.return_type: rt_clone = self.return_type.clone() - + return member_function_type_t( self.class_inst , rt_clone , [ arg.clone() for arg in self.arguments_types ] , self.has_const ) - + class member_variable_type_t( compound_t ): """describes member variable type""" NAME_TEMPLATE = '%(type)s ( %(class)s::* )' def __init__( self, class_inst=None, variable_type=None ): compound_t.__init__(self, class_inst) - self._mv_type = variable_type + self._mv_type = variable_type def _get_variable_type(self): return self._mv_type @@ -516,13 +556,13 @@ def _clone_impl( self ): return member_variable_type_t( class_inst=self.base , variable_type=self.variable_type.clone() ) - + ################################################################################ ## declarated types: class declarated_t( type_t ): - """describes type declared by user""" + """class that binds between to hierarchies: L{type_t} and L{declaration_t}""" def __init__( self, declaration ): type_t.__init__( self ) self._declaration = declaration @@ -541,6 +581,7 @@ return declarated_t( self.declaration ) class type_qualifiers_t( object ): + """contains additional information about type: mutable, static, extern""" def __init__(self, has_static=False, has_mutable=False ): self._has_static = has_static self._has_mutable = has_mutable @@ -572,15 +613,3 @@ def _set_has_mutable(self, has_mutable ): self._has_mutable = has_mutable has_mutable = property( _get_has_mutable, _set_has_mutable ) - - #~ def apply_qualifiers( qualifiers, type ): - #~ result = [] - #~ if qualifiers.has_static: - #~ result.append( 'static' ) - #~ if qualifiers.has_mutable: - #~ result.append( 'mutable' ) - #~ if isinstance( type, type_t ): - #~ result.append( type.decl_string ) - #~ else: - #~ result.append( type ) - #~ return ' '.join( result ) Modified: pygccxml_dev/pygccxml/declarations/decl_factory.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_factory.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/decl_factory.py 2006-08-21 08:04:14 UTC (rev 427) @@ -4,7 +4,7 @@ # http://www.boost.org/LICENSE_1_0.txt) """ -defines declarations factory class +defines default declarations factory class """ from calldef import member_function_t @@ -26,43 +26,57 @@ declarations factory class """ def __init__(self): + """creates declarations factory""" object.__init__(self) - + def create_member_function( self, *arguments, **keywords ): + """creates instance of class that describes member function declaration""" return member_function_t(*arguments, **keywords) - + def create_constructor( self, *arguments, **keywords ): + """creates instance of class that describes constructor declaration""" return constructor_t(*arguments, **keywords) - + def create_destructor( self, *arguments, **keywords ): + """creates instance of class that describes destructor declaration""" return destructor_t(*arguments, **keywords) - + def create_member_operator( self, *arguments, **keywords ): + """creates instance of class that describes member operator declaration""" return member_operator_t(*arguments, **keywords) - + def create_casting_operator( self, *arguments, **keywords ): + """creates instance of class that describes casting operator declaration""" return casting_operator_t(*arguments, **keywords) - + def create_free_function( self, *arguments, **keywords ): + """creates instance of class that describes free function declaration""" return free_function_t(*arguments, **keywords) - + def create_free_operator( self, *arguments, **keywords ): + """creates instance of class that describes free operator declaration""" return free_operator_t(*arguments, **keywords) def create_class_declaration(self, *arguments, **keywords ): + """creates instance of class that describes class declaration""" return class_declaration_t(*arguments, **keywords) - + def create_class( self, *arguments, **keywords ): + """creates instance of class that describes class definition declaration""" return class_t(*arguments, **keywords) - + def create_enumeration( self, *arguments, **keywords ): + """creates instance of class that describes enumeration declaration""" return enumeration_t(*arguments, **keywords) - + def create_namespace( self, *arguments, **keywords ): + """creates instance of class that describes namespace declaration""" return namespace_t(*arguments, **keywords) - + def create_typedef( self, *arguments, **keywords ): + """creates instance of class that describes typedef declaration""" return typedef_t(*arguments, **keywords) - + def create_variable( self, *arguments, **keywords ): + """creates instance of class that describes variable declaration""" return variable_t(*arguments, **keywords) Modified: pygccxml_dev/pygccxml/declarations/declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/declaration.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/declaration.py 2006-08-21 08:04:14 UTC (rev 427) @@ -15,8 +15,7 @@ class location_t(object): - - """Provides information about the location of the declaration within the source file. + """provides information about the location of the declaration within the source file. The header file name and the line number of the declaration can be accessed via the attributes C{file_name} and C{line}. @@ -57,7 +56,7 @@ , doc="""The line number where the declaration was found @type: int """) - + def as_tuple( self ): """Return the header file name and the line number. @@ -68,7 +67,7 @@ class declaration_t( object ): """Base class for all classes that represent a C++ declaration. """ - + def __init__( self, name='', location=None, is_artificial=False, mangled=None, demangled=None ): self._name = name self._location = location @@ -94,25 +93,25 @@ # Append the declaration class cls = self.__class__.__name__ if cls[-2:]=="_t": - cls = cls[:-2] + cls = cls[:-2] return "%s [%s]"%(name, cls) - @staticmethod + @staticmethod def _sorted_list( some_list ): - """@undocumented _sorted_list:""" + """implementation details""" some_list.sort() return some_list def _get__cmp__items( self ): - """@undocumented _get__cmp__items:""" - #Every derived class should implement this method. This method should + """implementation details""" + #Every derived class should implement this method. This method should #return a list of items, that should be compared. print '_get__cmp__items not implemented for class ', self.__class__.__name__ raise NotImplemented() def _get__cmp__data(self): - """@undocumented _get__cmp__data:""" + """implementation details""" data = [ algorithm.declaration_path( self.parent ), self.name, self.location ] data.extend( self._get__cmp__items() ) return data @@ -120,8 +119,8 @@ def __eq__(self, other): """ function will return true, if both declarations refers to the same object. - This function could be implemented in terms of _get__cmp__data, but in - this case it will downgrade performance. self.mangled property is not + This function could be implemented in terms of _get__cmp__data, but in + this case it will downgrade performance. self.mangled property is not compared, because it could be chaned from one compilation time to an other. """ @@ -145,13 +144,13 @@ if not isinstance( other, self.__class__ ): return self.__class__.__name__ < other.__class__.__name__ return self._get__cmp__data() < other._get__cmp__data() - + def _get_name_impl( self ): return self._name - + def _get_name( self ): return self._get_name_impl() - + def _set_name( self, new_name ): self._name = new_name name = property( _get_name, _set_name @@ -222,10 +221,10 @@ def _create_decl_string(self): return algorithm.full_name( self ) - + def _decl_string(self): - return self._create_decl_string() + return self._create_decl_string() decl_string = property( _decl_string, doc="""Full name of the declaration @type: str - """ ) \ No newline at end of file + """ ) Modified: pygccxml_dev/pygccxml/declarations/enumeration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/enumeration.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/enumeration.py 2006-08-21 08:04:14 UTC (rev 427) @@ -16,11 +16,11 @@ describes C++ enum """ def __init__( self, name='', values=None ): - """Constructor. + """creates class that describes C++ enum declaration The items of the list 'values' may either be strings containing the enumeration value name or tuples (name, numvalue). - + @param name: Enum name @type name: str @param parent: Parent declaration @@ -43,7 +43,7 @@ return self.values == other.values def _get__cmp__items( self ): - """@undocumented _get__cmp__items:""" + """implementation details""" return [self.values] def _get_values(self): @@ -108,7 +108,8 @@ return False def get_name2value_dict( self ): + """returns a dictionary, that maps between enum name( key ) and enum value( value )""" x = {} for val, num in self._values: x[val] = num - return x \ No newline at end of file + return x Modified: pygccxml_dev/pygccxml/declarations/filtering.py =================================================================== --- pygccxml_dev/pygccxml/declarations/filtering.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/filtering.py 2006-08-21 08:04:14 UTC (rev 427) @@ -4,41 +4,44 @@ # http://www.boost.org/LICENSE_1_0.txt) """ -defines few algorithms for filtering declarations +deprecated! + +This module defines few algorithms for filtering declarations. """ import os import algorithm class filtering: - """ + """deprecated! + defines few algorithms for filtering declarations """ - - @staticmethod + + @staticmethod def normalize_path( some_path ): """return os.path.normcase( os.path.normpath( some_path ) )""" return os.path.normcase( os.path.normpath( some_path ) ) - - @staticmethod + + @staticmethod 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 ) ) - - @staticmethod - def by_location( decls, locations ): + + @staticmethod + def by_location( decls, locations ): """ returns list of declarations that belongs to specified locations. - + This function works recursively. Pay attention: if you remove namespace, then you remove all declarations defined within the namespace. - + @param decls: declaration or list of declarations @type decls: L{declaration<declaration_t>} or list of L{declarations<declaration_t>} - + @param locations: list of directories and/or files names @type locations: list of strings - + @return: list of L{declarations<declaration_t>} """ #precondition: decls is a list of op level namespaces @@ -48,7 +51,7 @@ dirs = filter( lambda location: os.path.isdir( location ), locations ) files = filter( lambda location: os.path.isfile( location ), locations ) result = [] - for decl in temp_decls: + for decl in temp_decls: if not decl.location: result.append( decl ) continue @@ -57,21 +60,20 @@ result.append( decl ) return result - @staticmethod + @staticmethod def user_defined( decls, matcher ): """ returns list of declarations that match user specified criteria. - + This function works recursively. - + @param decls: declaration or list of declarations @type decls: L{declaration<declaration_t>} or list of L{declarations<declaration_t>} - + @param matcher: callable object, that takes 1 argument - declaration and returns True if object should stay, and false otherwise - + @return: list of L{declarations<declaration_t>} - """ + """ #precondition: decls is a list of op level namespaces return filter( matcher, algorithm.make_flatten( decls ) ) - \ No newline at end of file Modified: pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py =================================================================== --- pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/mdecl_wrapper.py 2006-08-21 08:04:14 UTC (rev 427) @@ -3,32 +3,45 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +""" +defines class L{mdecl_wrapper_t} that allows to work on set of declarations, +as it was one declaration. + +The L{class<mdecl_wrapper_t>} allows user to not write "for" loops within the code. +""" + class call_redirector_t( object ): """Internal class used to call some function of objects""" def __init__( self, name, decls ): + """creates call_redirector_t instance. + + @param name: name of method, to be called on every object in C{decls} list + @param decls: list of objects + """ object.__init__( self ) self.name = name self.decls = decls - + def __call__( self, *arguments, **keywords ): + """calls method C{self.name} on every object within C{self.decls} list""" for d in self.decls: callable_ = getattr(d, self.name) callable_( *arguments, **keywords ) class mdecl_wrapper_t( object ): - """Multiple declarations wrapper. - - The main purpose of this class is to allow an user to work on many - declarations, as they were only one single declaration. - - Example: + """Multiple declarations wrapper. + + The main purpose of this class is to allow an user to work on many + declarations, as they were only one single declaration. + + Example: mb = module_builder_t( ... ) #lets say we want to exclude all member functions, that returns reference to int: mb.member_functions( return_type='int &' ).exclude() - + "exclude" function will be called on every function that match the criteria. """ - + def __init__( self, decls ): """@param decls: list of declarations to operate on. @type decls: list of L{declaration wrappers<decl_wrapper_t>} @@ -42,19 +55,19 @@ def __len__( self ): """returns the number of declarations""" return len( self.decls ) - + def __getitem__( self, index ): """provides access to declaration""" return self.decls[index] - + def __iter__( self ): return iter(self.decls) - + def __ensure_attribute( self, name ): invalid_decls = filter( lambda d: not hasattr( d, name ), self.decls ) if invalid_decls: raise RuntimeError( "Not all declarations have '%s' attribute." % name ) - + def __setattr__( self, name, value ): """Updates the value of attribute on all declarations. @param name: name of attribute @@ -63,11 +76,11 @@ self.__ensure_attribute( name ) for d in self.decls: setattr( d, name, value ) - + def __getattr__( self, name ): """@param name: name of method """ return call_redirector_t( name, self.decls ) - + def __contains__( self, item ): - return item in self.decls \ No newline at end of file + return item in self.decls Modified: pygccxml_dev/pygccxml/declarations/namespace.py =================================================================== --- pygccxml_dev/pygccxml/declarations/namespace.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/namespace.py 2006-08-21 08:04:14 UTC (rev 427) @@ -3,9 +3,8 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -""" -defines class, that describes C++ namespace -""" +"""defines class, that describes C++ namespace declaration""" + import declaration import scopedef import algorithm @@ -14,8 +13,9 @@ """ describes C++ namespace """ - + def __init__( self, name='', declarations=None ): + """creates class that describes C++ namespace declaration""" scopedef.scopedef_t.__init__( self, name ) if not declarations: declarations = [] @@ -28,15 +28,17 @@ return "%s [namespace]"%name def _get__cmp__scope_items(self): - """@undocumented _get__cmp__scope_items:""" + """implementation details""" return [ self._sorted_list( self.declarations ) ] - + def _get_declarations_impl(self): return self._declarations def _set_declarations(self, declarations): self._declarations = declarations - declarations = property( scopedef.scopedef_t._get_declarations, _set_declarations ) - + declarations = property( scopedef.scopedef_t._get_declarations + , _set_declarations + , doc="list of all declarations, defined in the namespace") + def take_parenting( self, inst ): """Takes parenting from inst and transfers it to self""" if self is inst: @@ -45,11 +47,11 @@ decl.parent = self self.declarations.append( decl ) inst.declarations = [] - + def remove_declaration( self, decl ): """ removes decl from members list - + @param decl: declaration to be removed @type decl: L{declaration_t} """ @@ -59,12 +61,14 @@ # decl.parent=None def namespace( self, name=None, function=None, recursive=None ): + """returns reference to namespace declaration, that is matched defined criterias""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.namespace ] , name=name , function=function , recursive=recursive ) def namespaces( self, name=None, function=None, recursive=None, allow_empty=None ): + """returns a set of namespace declarations, that are matched defined criterias""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.namespace ] , name=name , function=function @@ -72,51 +76,54 @@ , allow_empty=allow_empty) def free_function( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + """returns reference to free function declaration, that is matched defined criterias""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ] , name=name , function=function , decl_type=self._impl_decl_types[ namespace_t.free_function ] , return_type=return_type - , arg_types=arg_types + , arg_types=arg_types , header_dir=header_dir - , header_file=header_file + , header_file=header_file , recursive=recursive ) def free_functions( self, name=None, function=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): + """returns a set of free function declarations, that are matched defined criterias""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.free_function ] , name=name , function=function , decl_type=self._impl_decl_types[ namespace_t.free_function ] , return_type=return_type - , arg_types=arg_types + , arg_types=arg_types , header_dir=header_dir , header_file=header_file , recursive=recursive , allow_empty=allow_empty) def free_operator( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None ): + """returns reference to free operator declaration, that is matched defined criterias""" return self._find_single( scopedef.scopedef_t._impl_matchers[ namespace_t.free_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol , function=function , decl_type=self._impl_decl_types[ namespace_t.free_operator ] , return_type=return_type - , arg_types=arg_types + , arg_types=arg_types , header_dir=header_dir - , header_file=header_file + , header_file=header_file , recursive=recursive ) def free_operators( self, name=None, function=None, symbol=None, return_type=None, arg_types=None, header_dir=None, header_file=None, recursive=None, allow_empty=None ): + """returns a set of free operator declarations, that are matched defined criterias""" return self._find_multiple( scopedef.scopedef_t._impl_matchers[ namespace_t.free_operator ] , name=self._build_operator_name( name, function, symbol ) , symbol=symbol , function=function , decl_type=self._impl_decl_types[ namespace_t.free_operator ] , return_type=return_type - , arg_types=arg_types + , arg_types=arg_types , header_dir=header_dir - , header_file=header_file + , header_file=header_file , recursive=recursive , allow_empty=allow_empty) - - \ No newline at end of file + Modified: pygccxml_dev/pygccxml/declarations/pattern_parser.py =================================================================== --- pygccxml_dev/pygccxml/declarations/pattern_parser.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/pattern_parser.py 2006-08-21 08:04:14 UTC (rev 427) @@ -3,13 +3,12 @@ # accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) -""" -implementation details -""" +"""implementation details""" import types class parser_t( object ): + """implementation details""" def __init__( self , pattern_char_begin , pattern_char_end @@ -21,12 +20,14 @@ self.__text_qualifier = '"' self.__char_qualifier = "'" self.__escape = '\\' - - def has_pattern( self, decl_string ): + + def has_pattern( self, decl_string ): + """implementation details""" last_part = decl_string.split( '::' )[-1] return -1 != last_part.find( self.__end ) def name( self, decl_string ): + """implementation details""" assert isinstance( decl_string, types.StringTypes ) if not self.has_pattern( decl_string ): return decl_string @@ -34,6 +35,7 @@ return decl_string[0: args_begin].strip() def __find_args_separator( self, decl_string, start_pos ): + """implementation details""" bracket_depth = 0 for index, ch in enumerate( decl_string[start_pos:] ): if ch not in ( self.__begin, self.__end, self.__separator ): @@ -50,12 +52,13 @@ return -1 def args( self, decl_string ): + """implementation details""" args_begin = decl_string.find( self.__begin ) args_end = decl_string.rfind( self.__end ) if -1 in ( args_begin, args_end ) or args_begin == args_end: raise RuntimeError( "%s doesn't valid template instantiation string" % decl_string ) - - args_only = decl_string[args_begin + 1: args_end ] + + args_only = decl_string[args_begin + 1: args_end ] args = [] previous_found, found = 0, 0 while True: @@ -71,10 +74,13 @@ return [ arg.strip() for arg in args ] NOT_FOUND = ( -1, -1 ) + """implementation details""" + def find_args(self, text, start=None ): + """implementation details""" if start==None: start = 0 - first_occurance = text.find( self.__begin, start ) + first_occurance = text.find( self.__begin, start ) if first_occurance == -1: return self.NOT_FOUND previous_found, found = first_occurance + 1, 0 @@ -88,11 +94,13 @@ previous_found = found + 1 #skip found sep def split( self, decl_string ): + """implementation details""" assert self.has_pattern( decl_string ) return self.name( decl_string ), self.args( decl_string ) - + def split_recursive( self, decl_string ): - assert self.has_pattern( decl_string ) + """implementation details""" + assert self.has_pattern( decl_string ) answer = [] to_go = [ decl_string ] while to_go: @@ -102,8 +110,9 @@ if self.has_pattern( arg ): to_go.append( arg ) return answer - + def join( self, name, args ): + """implementation details""" args = filter( None, args) args_str = '' if not args: @@ -112,5 +121,6 @@ args_str = ' ' + args[0] + ' ' else: args_str = ' ' + ', '.join( args ) + ' ' - - return ''.join( [ name, self.__begin, args_str, self.__end ] ) \ No newline at end of file + + return ''.join( [ name, self.__begin, args_str, self.__end ] ) + Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2006-08-20 19:53:54 UTC (rev 426) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2006-08-21 08:04:14 UTC (rev 427) @@ -21,51 +21,51 @@ This is the base class for all declaration classes that may have children nodes. The children can be accessed via the C{declarations} property. - + Also this class provides "get/select/find" interface. Using this class you - can get instance or instances of internal declaration(s). - + can get instance or instances of internal declaration(s). + You can find declaration(s) using next criteria: 1. name - declaration name, could be full qualified name 2. header_dir - directory, to which belongs file, that the declaration was declarated in. - header_dir should be absolute path. + header_dir should be absolute path. 3. header_file - file that the declaration was declarated in. 4. function - user ( your ) custom criteria. The interesting thing is that this function will be joined with other arguments ( criteria ). 5. recursive - the search declaration range, if True will be search in internal declarations too. - + Every "select" API you can invoke and pass as first argument at declaration name or function. This class will find out correctly what argument represents. - + Example:: ns - referrers to global namespace ns.member_function( "do_something ) - will return reference to member function named "do_something". If there is no such function exception will be raised. If there is more then one function exception will be raised too. - + Example 2:: ns - referers to global namespace - do_smths = ns.member_functions( "do_something ) - will return instance + do_smths = ns.member_functions( "do_something ) - will return instance of L{mdecl_wrapper_t} object. This object allows you few things: - + 1. To iterate on selected declarations 2. To set some property to desired value using one line of code only: do_smths.call_policies = x 3. To call some function on every instance using one line of code: do_smths.exclude() - - Pay attention: you can not use "get" functions or properties. + + Pay attention: you can not use "get" functions or properties. """ - RECURSIVE_DEFAULT = True + RECURSIVE_DEFAULT = True ALLOW_EMPTY_MDECL_WRAPPER = False - + _impl_matchers = {} #this class variable is used to prevent recursive imports _impl_decl_types = {} #this class variable is used to prevent recursive imports _impl_all_decl_types = [] #this class variable is used to prevent recursive imports - + def __init__( self, name=''): declaration.declaration_t.__init__( self, name ) @@ -78,18 +78,18 @@ def _get_logger( self ): return utils.loggers.queries_engine - _logger = property( _get_logger ) - + _logger = property( _get_logger, doc="reference to C{queries_engine} logger" ) + def _get__cmp__scope_i... [truncated message content] |