[pygccxml-commit] SF.net SVN: pygccxml:[1621] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2009-01-26 15:03:06
|
Revision: 1621 http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1621&view=rev Author: roman_yakovenko Date: 2009-01-26 15:03:04 +0000 (Mon, 26 Jan 2009) Log Message: ----------- fixing problems found by pychecker Modified Paths: -------------- pygccxml_dev/pygccxml/declarations/algorithms_cache.py pygccxml_dev/pygccxml/declarations/class_declaration.py pygccxml_dev/pygccxml/declarations/container_traits.py pygccxml_dev/pygccxml/declarations/cpptypes.py pygccxml_dev/pygccxml/declarations/decl_printer.py pygccxml_dev/pygccxml/declarations/dependencies.py pygccxml_dev/pygccxml/declarations/function_traits.py pygccxml_dev/pygccxml/declarations/scopedef.py pygccxml_dev/pygccxml/declarations/type_traits.py pygccxml_dev/pygccxml/parser/config.py pygccxml_dev/pygccxml/parser/project_reader.py pygccxml_dev/pygccxml/parser/source_reader.py pygccxml_dev/pygccxml/utils/__init__.py pygccxml_dev/unittests/autoconfig.py Modified: pygccxml_dev/pygccxml/declarations/algorithms_cache.py =================================================================== --- pygccxml_dev/pygccxml/declarations/algorithms_cache.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/algorithms_cache.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -17,8 +17,8 @@ self._access_type = None self._demangled_name = None self._declaration_path = None - self._partial_declaration_path = None - self._container_key_type = None + self._partial_declaration_path = None + self._container_key_type = None self._container_element_type = None def disable( self ): @@ -36,7 +36,7 @@ def _set_full_name( self, fname ): if not self.enabled: fname = None - self._full_name = fname + self._full_name = fname full_name = property( _get_full_name, _set_full_name ) def _get_full_partial_name( self ): @@ -44,7 +44,7 @@ def _set_full_partial_name( self, fname ): if not self.enabled: fname = None - self._full_partial_name = fname + self._full_partial_name = fname full_partial_name = property( _get_full_partial_name, _set_full_partial_name ) def _get_access_type( self ): @@ -59,8 +59,8 @@ return self._demangled_name def _set_demangled_name( self, demangled_name ): if not self.enabled: - demangled_name = None - self._demangled_name = demangled_name + demangled_name = None + self._demangled_name = demangled_name demangled_name = property( _get_demangled_name, _set_demangled_name ) def _get_declaration_path( self ): @@ -87,14 +87,14 @@ etype = None self._container_element_type = etype container_element_type = property( _get_container_element_type, _set_container_element_type ) - + def _get_container_key_type( self ): return self._container_key_type def _set_container_key_type( self, ktype ): if not self.enabled: ktype = None self._container_key_type = ktype - container_key_type = property( _get_container_key_type, _set_container_key_type ) + container_key_type = property( _get_container_key_type, _set_container_key_type ) def reset( self ): self.full_name = None @@ -120,13 +120,13 @@ class type_algs_cache_t( object ): enabled = True - + @staticmethod def disable(): type_algs_cache_t.enabled = False @staticmethod - def enable( self ): + def enable(): type_algs_cache_t.enabled = True def __init__( self ): @@ -139,9 +139,9 @@ if not type_algs_cache_t.enabled: remove_alias = None self._remove_alias = remove_alias - + remove_alias = property( _get_remove_alias, _set_remove_alias ) def reset(self): self.remove_alias = None - + Modified: pygccxml_dev/pygccxml/declarations/class_declaration.py =================================================================== --- pygccxml_dev/pygccxml/declarations/class_declaration.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/class_declaration.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -13,7 +13,6 @@ """ import scopedef -import itertools import compilers import algorithm import declaration Modified: pygccxml_dev/pygccxml/declarations/container_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/container_traits.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/container_traits.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -258,7 +258,7 @@ , container_name , element_type_index , element_type_typedef - , defaults_remover + , defaults_remover , key_type_index=None , key_type_typedef=None ): """ @@ -267,7 +267,7 @@ arguments list element_type_typedef - class typedef to the value\\mapped type key_type_index - position of key type within template arguments list - key_type_typedef - class typedef to the key type + key_type_typedef - class typedef to the key type """ self._name = container_name self.remove_defaults_impl = defaults_remover @@ -279,18 +279,18 @@ def name(self): return self._name - def get_container_or_none( self, type ): + def get_container_or_none( self, type_ ): """returns reference to the class declaration or None""" - type = type_traits.remove_alias( type ) - type = type_traits.remove_cv( type ) + type_ = type_traits.remove_alias( type_ ) + type_ = type_traits.remove_cv( type_ ) cls = None - if isinstance( type, cpptypes.declarated_t ): - cls = type_traits.remove_alias( type.declaration ) - elif isinstance( type, class_declaration.class_t ): - cls = type - elif isinstance( type, class_declaration.class_declaration_t ): - cls = type + if isinstance( type_, cpptypes.declarated_t ): + cls = type_traits.remove_alias( type_.declaration ) + elif isinstance( type_, class_declaration.class_t ): + cls = type_ + elif isinstance( type_, class_declaration.class_declaration_t ): + cls = type_ else: return @@ -301,29 +301,29 @@ if type_traits.impl_details.is_defined_in_xxx( ns, cls ): return cls - def is_my_case( self, type ): + def is_my_case( self, type_ ): """checks, whether type is STD container or not""" - return bool( self.get_container_or_none( type ) ) + return bool( self.get_container_or_none( type_ ) ) - def class_declaration( self, type ): + def class_declaration( self, type_ ): """returns reference to the class declaration""" - cls = self.get_container_or_none( type ) + cls = self.get_container_or_none( type_ ) if not cls: - raise TypeError( 'Type "%s" is not instantiation of std::%s' % ( type.decl_string, self.name() ) ) + raise TypeError( 'Type "%s" is not instantiation of std::%s' % ( type_.decl_string, self.name() ) ) return cls - def is_sequence( self, type ): + def is_sequence( self, type_ ): #raise exception if type is not container - unused = self.class_declaration( type ) + unused = self.class_declaration( type_ ) return self.key_type_index is None - - def is_mapping( self, type ): - return not self.is_sequence( type ) - def __find_xxx_type( self, type, xxx_index, xxx_typedef, cache_property_name ): - cls = self.class_declaration( type ) + def is_mapping( self, type_ ): + return not self.is_sequence( type_ ) + + def __find_xxx_type( self, type_, xxx_index, xxx_typedef, cache_property_name ): + cls = self.class_declaration( type_ ) result = getattr( cls.cache, cache_property_name ) - if not result: + if not result: if isinstance( cls, class_declaration.class_t ): xxx_type = cls.typedef( xxx_typedef, recursive=False ).type result = type_traits.remove_declarated( xxx_type ) @@ -336,29 +336,29 @@ setattr( cls.cache, cache_property_name, result ) return result - def element_type( self, type ): + def element_type( self, type_ ): """returns reference to the class value\\mapped type declaration""" - return self.__find_xxx_type( type + return self.__find_xxx_type( type_ , self.element_type_index , self.element_type_typedef , 'container_element_type') - def key_type( self, type ): - """returns reference to the class key type declaration""" - if not self.is_mapping( type ): - raise TypeError( 'Type "%s" is not "mapping" container' % str( type ) ) - return self.__find_xxx_type( type + def key_type( self, type_ ): + """returns reference to the class key type declaration""" + if not self.is_mapping( type_ ): + raise TypeError( 'Type "%s" is not "mapping" container' % str( type_ ) ) + return self.__find_xxx_type( type_ , self.key_type_index , self.key_type_typedef , 'container_key_type' ) def remove_defaults( self, type_or_string ): """remove template defaults from a template class instantiation - + For example: - std::vector< int, std::allocator< int > > + std::vector< int, std::allocator< int > > will become - std::vector< int > + std::vector< int > """ name = type_or_string if not isinstance( type_or_string, types.StringTypes ): @@ -408,11 +408,11 @@ , defaults_eraser.erase_map_compare_allocator , key_type_index=0 , key_type_typedef='key_type') - + multimap_traits = create_traits( 'multimap' , 1 , 'mapped_type' - , defaults_eraser.erase_map_compare_allocator + , defaults_eraser.erase_map_compare_allocator , key_type_index=0 , key_type_typedef='key_type') @@ -420,15 +420,15 @@ hash_map_traits = create_traits( 'hash_map' , 1 , 'mapped_type' - , defaults_eraser.erase_hashmap_compare_allocator + , defaults_eraser.erase_hashmap_compare_allocator , key_type_index=0 , key_type_typedef='key_type') - - + + hash_multimap_traits = create_traits( 'hash_multimap' , 1 , 'mapped_type' - , defaults_eraser.erase_hashmap_compare_allocator + , defaults_eraser.erase_hashmap_compare_allocator , key_type_index=0 , key_type_typedef='key_type') @@ -436,7 +436,7 @@ , 0 , 'value_type' , defaults_eraser.erase_compare_allocator) - + multiset_traits = create_traits( 'multiset' , 0 , 'value_type' @@ -446,7 +446,7 @@ , 0 , 'value_type' , defaults_eraser.erase_hash_allocator ) - + hash_multiset_traits = create_traits( 'hash_multiset' , 0 , 'value_type' Modified: pygccxml_dev/pygccxml/declarations/cpptypes.py =================================================================== --- pygccxml_dev/pygccxml/declarations/cpptypes.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/cpptypes.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -501,10 +501,10 @@ @return: L{free_function_type_t} """ + f = lambda x: x.build_decl_string( with_defaults ) return free_function_type_t.NAME_TEMPLATE % { 'return_type' : return_type.build_decl_string( with_defaults ) - , 'arguments' : ','.join( map( lambda x: x.build_decl_string( with_defaults ) - , arguments_types ) ) } + , 'arguments' : ','.join( map( f, arguments_types ) ) } def build_decl_string(self, with_defaults=True): return self.create_decl_string( self.return_type, self.arguments_types, with_defaults ) @@ -523,11 +523,11 @@ @param name: the desired name of typedef """ #unused argument simplifies user code + f = lambda x: x.build_decl_string( with_defaults ) return free_function_type_t.TYPEDEF_NAME_TEMPLATE % { 'typedef_name' : typedef_name , 'return_type' : self.return_type.build_decl_string( with_defaults ) - , 'arguments' : ','.join( map( lambda x: x.build_decl_string( with_defaults ) - , self.arguments_types ) ) } + , 'arguments' : ','.join( map( f, self.arguments_types ) ) } class member_function_type_t( type_t, calldef_type_t ): """describes member function type""" @@ -569,12 +569,12 @@ class_alias = self.class_inst.decl_string else: class_alias = self.class_inst.partial_decl_string + f = lambda x: x.build_decl_string(with_defaults) return member_function_type_t.TYPEDEF_NAME_TEMPLATE % { 'typedef_name' : typedef_name , 'return_type' : self.return_type.build_decl_string( with_defaults ) , 'class' : class_alias - , 'arguments' : ','.join( map( lambda x: x.build_decl_string(with_defaults) - , self.arguments_types ) ) + , 'arguments' : ','.join( map( f, self.arguments_types ) ) , 'has_const' : has_const_str } def create(self): @@ -592,11 +592,11 @@ return_type_decl_string = '' if return_type: return_type_decl_string = return_type.build_decl_string( with_defaults ) + f = lambda x: x.build_decl_string(with_defaults) return member_function_type_t.NAME_TEMPLATE % { 'return_type' : return_type_decl_string , 'class' : class_decl_string - , 'arguments' : ','.join( map( lambda x: x.build_decl_string(with_defaults) - , arguments_types ) ) + , 'arguments' : ','.join( map( f, arguments_types ) ) , 'has_const' : has_const_str } def build_decl_string(self, with_defaults=True): Modified: pygccxml_dev/pygccxml/declarations/decl_printer.py =================================================================== --- pygccxml_dev/pygccxml/declarations/decl_printer.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/decl_printer.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -240,7 +240,7 @@ self.writer( value_level + "%s : %s"% (name, value) + os.linesep) def visit_namespace(self ): - if self.verbose == False and not self.__inst.declarations: + if not self.verbose and not self.__inst.declarations: return #don't print info about empty namespaces self.print_decl_header() if self.__recursive: Modified: pygccxml_dev/pygccxml/declarations/dependencies.py =================================================================== --- pygccxml_dev/pygccxml/declarations/dependencies.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/dependencies.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -79,9 +79,8 @@ def we_depend_on_them( decls ): """returns set of declarations. every item in the returned set, depends on a declaration from the input""" - import class_declaration #prevent cyclic imports to_be_included = set() for decl in decls: - to_be_included.update( dependency_info_t.they_depend_on_me( decl ) ) + to_be_included.update( dependency_info_t.i_depend_on_them( decl ) ) return to_be_included Modified: pygccxml_dev/pygccxml/declarations/function_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/function_traits.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/function_traits.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -13,17 +13,17 @@ def is_same_return_type( f1, f2 ): #covariant returns - #The return type of an overriding function shall be either identical to the - #return type of the overridden function or covariant with the classes of the - #functions. If a function D::f overrides a function B::f, the return types + #The return type of an overriding function shall be either identical to the + #return type of the overridden function or covariant with the classes of the + #functions. If a function D::f overrides a function B::f, the return types #of the functions are covariant if they satisfy the following criteria: #* both are pointers to classes or references to classes - #* the class in the return type of B::f is the same class as the class in - # the return type of D::f or, is an unambiguous direct or indirect base + #* the class in the return type of B::f is the same class as the class in + # the return type of D::f or, is an unambiguous direct or indirect base # class of the class in the return type of D::f and is accessible in D - #* both pointers or references have the same cv-qualification and the class - # type in the return type of D::f has the same cv-qualification as or less + #* both pointers or references have the same cv-qualification and the class + # type in the return type of D::f has the same cv-qualification as or less # cv-qualification than the class type in the return type of B::f. if not f1.__class__ is f2.__class__: @@ -43,11 +43,11 @@ rt2 = type_traits.remove_pointer( rt2 ) elif type_traits.is_reference( rt1 ) and type_traits.is_reference( rt2 ): rt1 = type_traits.remove_reference( rt1 ) - rt2 = type_traits.remove_reference( rt2 ) + rt2 = type_traits.remove_reference( rt2 ) else: return type_traits.is_same( f1.return_type, f2.return_type) if ( type_traits.is_const( rt1 ) and type_traits.is_const( rt2 ) ) \ - or ( False == type_traits.is_const( rt1 ) and False == type_traits.is_const( rt2 ) ): + or ( not type_traits.is_const( rt1 ) and not type_traits.is_const( rt2 ) ): rt1 = type_traits.remove_const( rt1 ) rt2 = type_traits.remove_const( rt2 ) else: @@ -62,8 +62,8 @@ return type_traits.is_same( c1, c2 ) \ or type_traits.is_base_and_derived( c1, c2 ) \ or type_traits.is_base_and_derived( c2, c1 ) - + def is_same_function( f1, f2 ): """returns true if f1 and f2 is same function Modified: pygccxml_dev/pygccxml/declarations/scopedef.py =================================================================== --- pygccxml_dev/pygccxml/declarations/scopedef.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/scopedef.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -117,7 +117,7 @@ raise NotImplementedError() def _get_declarations(self): - if True == self._optimized: + if self._optimized: return self._all_decls_not_recursive else: return self._get_declarations_impl() @@ -309,7 +309,7 @@ #templates has tricky mode to compare them, so lets check the whole #range name = None - + if name and decl_type: matcher = scopedef_t._impl_matchers[ scopedef_t.decl ]( name=name ) if matcher.is_full_name(): Modified: pygccxml_dev/pygccxml/declarations/type_traits.py =================================================================== --- pygccxml_dev/pygccxml/declarations/type_traits.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/declarations/type_traits.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -16,7 +16,6 @@ """ import os -import types import matchers import typedef import calldef @@ -187,7 +186,7 @@ elif isinstance( nake_type, cpptypes.volatile_t ) \ and isinstance( nake_type.base, cpptypes.const_t ) \ and isinstance( nake_type.base.base, cpptypes.pointer_t ): - return cpptypes.volatile_t( ctypes.const_t( nake_type.base.base.base ) ) + return cpptypes.volatile_t( cpptypes.const_t( nake_type.base.base.base ) ) elif isinstance( nake_type.base, cpptypes.calldef_type_t ): return type else: @@ -222,7 +221,7 @@ elif is_pointer( type_ ): return remove_pointer( type_ ) else: - assert 0 + raise RuntimeError( "array_item_type functions takes as argument array or pointer types" ) def remove_reference(type): """removes reference from the type definition @@ -252,15 +251,15 @@ else: return nake_type.base -def remove_declarated( type ): - """removes type-declaration class-binder L{declarated_t} from the type +def remove_declarated( type_ ): + """removes type-declaration class-binder L{declarated_t} from the type_ - If type is not L{declarated_t}, it will be returned as is + If type_ is not L{declarated_t}, it will be returned as is """ - type = remove_alias( type ) - if isinstance( type, cpptypes.declarated_t ): - type = type.declaration - return type + type_ = remove_alias( type_ ) + if isinstance( type_, cpptypes.declarated_t ): + type_ = type_.declaration + return type_ def is_same(type1, type2): """returns True, if type1 and type2 are same types""" @@ -316,22 +315,22 @@ def __init__( self, declaration_class ): self.declaration_class = declaration_class - def __apply_sequence( self, type ): + def __apply_sequence( self, type_ ): for f in self.sequence: - type = f( type ) - return type + type_ = f( type_ ) + return type_ - def is_my_case( self, type ): + def is_my_case( self, type_ ): """returns True, if type represents the desired declaration, False otherwise""" - return isinstance( self.__apply_sequence( type ), self.declaration_class ) + return isinstance( self.__apply_sequence( type_ ), self.declaration_class ) - def get_declaration( self, type ): + def get_declaration( self, type_ ): """returns reference to the declaration Precondition: self.is_my_case( type ) == True """ - assert self.is_my_case( type ) - return self.__apply_sequence( type ) + assert self.is_my_case( type_ ) + return self.__apply_sequence( type_ ) enum_traits = declaration_xxx_traits( enumeration.enumeration_t ) """implements functionality, needed for convinient work with C++ enums""" @@ -354,10 +353,10 @@ is_class_declaration = class_declaration_traits.is_my_case """returns True, if type represents C++ class declaration, False otherwise""" -def find_trivial_constructor( type ): +def find_trivial_constructor( type_ ): """returns reference to trivial constructor or None""" - assert isinstance( type, class_declaration.class_t ) - return type.find_trivial_constructor() + assert isinstance( type_, class_declaration.class_t ) + return type_.find_trivial_constructor() def has_trivial_constructor( class_ ): """if class has public trivial constructor, this function will return reference to it, None otherwise""" @@ -425,42 +424,42 @@ if decls: return decls -def has_public_binary_operator( type, operator_symbol ): - """returns True, if type has public binary operator, otherwise False""" - not_artificial = lambda decl: decl.is_artificial == False - type = remove_alias( type ) - type = remove_cv( type ) - type = remove_declarated( type ) - assert isinstance( type, class_declaration.class_t ) +def has_public_binary_operator( type_, operator_symbol ): + """returns True, if type_ has public binary operator, otherwise False""" + not_artificial = lambda decl: not decl.is_artificial + type_ = remove_alias( type_ ) + type_ = remove_cv( type_ ) + type_ = remove_declarated( type_ ) + assert isinstance( type_, class_declaration.class_t ) - if is_std_string( type ) or is_std_wstring( type ): + if is_std_string( type_ ) or is_std_wstring( type_ ): #In some case compare operators of std::basic_string are not instantiated return True - operators = type.member_operators( function=matchers.custom_matcher_t( not_artificial ) \ - & matchers.access_type_matcher_t( 'public' ) + operators = type_.member_operators( function=matchers.custom_matcher_t( not_artificial ) \ + & matchers.access_type_matcher_t( 'public' ) , symbol=operator_symbol , allow_empty=True , recursive=False ) if operators: return True - t = cpptypes.declarated_t( type ) + t = cpptypes.declarated_t( type_ ) t = cpptypes.const_t( t ) t = cpptypes.reference_t( t ) - operators = type.top_parent.operators( function=not_artificial + operators = type_.top_parent.operators( function=not_artificial , arg_types=[t, None] , symbol=operator_symbol , allow_empty=True , recursive=True ) if operators: return True - for bi in type.recursive_bases: + for bi in type_.recursive_bases: assert isinstance( bi, class_declaration.hierarchy_info_t ) if bi.access_type != class_declaration.ACCESS_TYPES.PUBLIC: continue operators = bi.related_class.member_operators( function=matchers.custom_matcher_t( not_artificial ) \ - & matchers.access_type_matcher_t( 'public' ) + & matchers.access_type_matcher_t( 'public' ) , symbol=operator_symbol , allow_empty=True , recursive=False ) @@ -843,7 +842,7 @@ class_ = class_traits.get_declaration( class_ ) true_header = "is_noncopyable(TRUE) - %s - " % class_.decl_string - false_header = "is_noncopyable(false) - %s - " % class_.decl_string + #~ false_header = "is_noncopyable(false) - %s - " % class_.decl_string if class_.class_type == class_declaration.CLASS_TYPES.UNION: return False @@ -989,12 +988,12 @@ """small convenience class, which provides access to internal types""" #TODO: add exists function @staticmethod - def get_by_name( type, name ): - if class_traits.is_my_case( type ): - cls = class_traits.declaration_class( type ) + def get_by_name( type_, name ): + if class_traits.is_my_case( type_ ): + cls = class_traits.declaration_class( type_ ) return remove_declarated( cls.typedef( name, recursive=False ).type ) - elif class_declaration_traits.is_my_case( type ): - cls = class_declaration_traits.get_declaration( type ) + elif class_declaration_traits.is_my_case( type_ ): + cls = class_declaration_traits.get_declaration( type_ ) value_type_str = templates.args( cls.name )[0] ref = impl_details.find_value_type( cls.top_parent, value_type_str ) if ref: @@ -1004,102 +1003,102 @@ % ( name, cls.decl_string ) ) else: raise RuntimeError( "Unable to find reference to internal type '%s' in type '%s'." - % ( name, type.decl_string ) ) + % ( name, type_.decl_string ) ) class smart_pointer_traits: """implements functionality, needed for convinient work with smart pointers""" @staticmethod - def is_smart_pointer( type ): + def is_smart_pointer( type_ ): """returns True, if type represents instantiation of C{boost::shared_ptr}, False otherwise""" - type = remove_alias( type ) - type = remove_cv( type ) - type = remove_declarated( type ) - if not isinstance( type, ( class_declaration.class_declaration_t, class_declaration.class_t ) ): + type_ = remove_alias( type_ ) + type_ = remove_cv( type_ ) + type_ = remove_declarated( type_ ) + if not isinstance( type_, ( class_declaration.class_declaration_t, class_declaration.class_t ) ): return False - if not impl_details.is_defined_in_xxx( 'boost', type ): + if not impl_details.is_defined_in_xxx( 'boost', type_ ): return False - return type.decl_string.startswith( '::boost::shared_ptr<' ) + return type_.decl_string.startswith( '::boost::shared_ptr<' ) @staticmethod - def value_type( type ): + def value_type( type_ ): """returns reference to boost::shared_ptr value type""" - if not smart_pointer_traits.is_smart_pointer( type ): - raise TypeError( 'Type "%s" is not instantiation of boost::shared_ptr' % type.decl_string ) - return internal_type_traits.get_by_name( type, "value_type" ) + if not smart_pointer_traits.is_smart_pointer( type_ ): + raise TypeError( 'Type "%s" is not instantiation of boost::shared_ptr' % type_.decl_string ) + return internal_type_traits.get_by_name( type_, "value_type" ) class auto_ptr_traits: """implements functionality, needed for convinient work with std::auto_ptr pointers""" @staticmethod - def is_smart_pointer( type ): + def is_smart_pointer( type_ ): """returns True, if type represents instantiation of C{boost::shared_ptr}, False otherwise""" - type = remove_alias( type ) - type = remove_cv( type ) - type = remove_declarated( type ) - if not isinstance( type, ( class_declaration.class_declaration_t, class_declaration.class_t ) ): + type_ = remove_alias( type_ ) + type_ = remove_cv( type_ ) + type_ = remove_declarated( type_ ) + if not isinstance( type_, ( class_declaration.class_declaration_t, class_declaration.class_t ) ): return False - if not impl_details.is_defined_in_xxx( 'std', type ): + if not impl_details.is_defined_in_xxx( 'std', type_ ): return False - return type.decl_string.startswith( '::std::auto_ptr<' ) + return type_.decl_string.startswith( '::std::auto_ptr<' ) @staticmethod - def value_type( type ): + def value_type( type_ ): """returns reference to boost::shared_ptr value type""" - if not auto_ptr_traits.is_smart_pointer( type ): - raise TypeError( 'Type "%s" is not instantiation of std::auto_ptr' % type.decl_string ) - return internal_type_traits.get_by_name( type, "element_type" ) + if not auto_ptr_traits.is_smart_pointer( type_ ): + raise TypeError( 'Type "%s" is not instantiation of std::auto_ptr' % type_.decl_string ) + return internal_type_traits.get_by_name( type_, "element_type" ) -def is_std_string( type ): +def is_std_string( type_ ): """returns True, if type represents C++ std::string, False otherwise""" decl_strings = [ '::std::basic_string<char,std::char_traits<char>,std::allocator<char> >' , '::std::basic_string<char, std::char_traits<char>, std::allocator<char> >' , '::std::string' ] - if isinstance( type, types.StringTypes ): - return type in decl_strings + if isinstance( type_, build_in_types.StringTypes ): + return type_ in decl_strings else: - type = remove_alias( type ) - return remove_cv( type ).decl_string in decl_strings + type_ = remove_alias( type_ ) + return remove_cv( type_ ).decl_string in decl_strings -def is_std_wstring( type ): +def is_std_wstring( type_ ): """returns True, if type represents C++ std::wstring, False otherwise""" decl_strings = [ '::std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t> >' , '::std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >' , '::std::wstring' ] - if isinstance( type, types.StringTypes ): - return type in decl_strings + if isinstance( type_, build_in_types.StringTypes ): + return type_ in decl_strings else: - type = remove_alias( type ) - return remove_cv( type ).decl_string in decl_strings + type_ = remove_alias( type_ ) + return remove_cv( type_ ).decl_string in decl_strings -def is_std_ostream( type ): +def is_std_ostream( type_ ): """returns True, if type represents C++ std::string, False otherwise""" decl_strings = [ '::std::basic_ostream<char, std::char_traits<char> >' , '::std::basic_ostream<char,std::char_traits<char> >' , '::std::ostream' ] - if isinstance( type, types.StringTypes ): - return type in decl_strings + if isinstance( type_, build_in_types.StringTypes ): + return type_ in decl_strings else: - type = remove_alias( type ) - return remove_cv( type ).decl_string in decl_strings + type_ = remove_alias( type_ ) + return remove_cv( type_ ).decl_string in decl_strings -def is_std_wostream( type ): +def is_std_wostream( type_ ): """returns True, if type represents C++ std::string, False otherwise""" decl_strings = [ '::std::basic_ostream<wchar_t, std::char_traits<wchar_t> >' , '::std::basic_ostream<wchar_t,std::char_traits<wchar_t> >' , '::std::wostream' ] - if isinstance( type, types.StringTypes ): - return type in decl_strings + if isinstance( type_, build_in_types.StringTypes ): + return type_ in decl_strings else: - type = remove_alias( type ) - return remove_cv( type ).decl_string in decl_strings + type_ = remove_alias( type_ ) + return remove_cv( type_ ).decl_string in decl_strings Modified: pygccxml_dev/pygccxml/parser/config.py =================================================================== --- pygccxml_dev/pygccxml/parser/config.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/parser/config.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -98,7 +98,6 @@ def __ensure_dir_exists( self, dir_path, meaning ): if os.path.isdir( dir_path ): return - msg = None if os.path.exists( self.working_directory ): raise RuntimeError( '%s("%s") does not exist!' % ( meaning, dir_path ) ) else: @@ -219,9 +218,9 @@ Configuration file sceleton: >>> start <<< - + %s - + >>> end <<< configuration could be string( configuration file path ) or instance of Modified: pygccxml_dev/pygccxml/parser/project_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/project_reader.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/parser/project_reader.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -330,8 +330,8 @@ if dir_ and not os.path.exists( dir_ ): os.makedirs( dir_ ) self.logger.info( 'Creating xml file "%s" from source file "%s" ... ' - % ( fc.cached_source_file, header ) ) - xml_file_path = reader.create_xml_file( header, fc.cached_source_file ) + % ( fc.cached_source_file, fc.data ) ) + xml_file_path = reader.create_xml_file( fc.data, fc.cached_source_file ) else: xml_file_path = fc.cached_source_file else: Modified: pygccxml_dev/pygccxml/parser/source_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/source_reader.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/parser/source_reader.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -193,10 +193,7 @@ return gccxml_file def read_file( self, source_file ): - if isinstance( self.__config, config.gccxml_configuration_t ): - return self.read_gccxml_file( source_file ) - else: - return self.read_synopsis_file( source_file ) + return self.read_gccxml_file( source_file ) def read_gccxml_file(self, source_file): """ @@ -205,7 +202,7 @@ @param source_file: path to C++ source file @type source_file: str """ - declarations, types = None, None + declarations = None gccxml_file = '' try: ffname = self.__file_full_name(source_file) Modified: pygccxml_dev/pygccxml/utils/__init__.py =================================================================== --- pygccxml_dev/pygccxml/utils/__init__.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/pygccxml/utils/__init__.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -79,7 +79,7 @@ This function is a wrapper aroung Python built-in function - tempfile.mkstemp """ if not prefix: - prefix = tempfile.template + prefix = tempfile.gettempprefix() fd, name = tempfile.mkstemp( suffix=suffix, prefix=prefix, dir=dir ) file_obj = os.fdopen( fd ) file_obj.close() @@ -93,7 +93,8 @@ """returns bool( filter( lambda dir: fpath.startswith( dir ), dirs ) ) precondition: dirs and fpath should be normalize_path'ed before calling this function """ - return bool( filter( lambda dir: fpath.startswith( dir ), dirs ) ) + f = lambda dir_: fpath.startswith( dir_ ) + return bool( filter( f, dirs ) ) def get_architecture(): Modified: pygccxml_dev/unittests/autoconfig.py =================================================================== --- pygccxml_dev/unittests/autoconfig.py 2009-01-26 11:22:43 UTC (rev 1620) +++ pygccxml_dev/unittests/autoconfig.py 2009-01-26 15:03:04 UTC (rev 1621) @@ -7,8 +7,8 @@ import sys import getpass -#__pychecker__ = 'limit=1000' -#import pychecker.checker +#~ os.environ['PYCHECKER'] = '--limit=1000 -q --no-argsused' +#~ import pychecker.checker this_module_dir_path = os.path.abspath ( os.path.dirname( sys.modules[__name__].__file__) ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |