[pygccxml-commit] SF.net SVN: pygccxml: [73] pygccxml_dev/pygccxml/parser
Brought to you by:
mbaas,
roman_yakovenko
From: <rom...@us...> - 2006-05-14 07:25:32
|
Revision: 73 Author: roman_yakovenko Date: 2006-05-14 00:25:24 -0700 (Sun, 14 May 2006) ViewCVS: http://svn.sourceforge.net/pygccxml/?rev=73&view=rev Log Message: ----------- adding demangled property to declaration_t class, requiered few fixes in parser package Modified Paths: -------------- pygccxml_dev/pygccxml/parser/linker.py pygccxml_dev/pygccxml/parser/patcher.py pygccxml_dev/pygccxml/parser/project_reader.py pygccxml_dev/pygccxml/parser/scanner.py Modified: pygccxml_dev/pygccxml/parser/linker.py =================================================================== --- pygccxml_dev/pygccxml/parser/linker.py 2006-05-14 07:23:52 UTC (rev 72) +++ pygccxml_dev/pygccxml/parser/linker.py 2006-05-14 07:25:24 UTC (rev 73) @@ -84,7 +84,8 @@ def visit_casting_operator( self ): self.__link_calldef() - self.__inst.name = 'operator ' + self.__inst.return_type.decl_string + #will be fixed by patcher. It is needed because of demangled name taken into account + #self.__inst._name = 'operator ' + self.__inst.return_type.decl_string def visit_free_function( self ): self.__link_calldef() @@ -101,15 +102,15 @@ #class name. I think this is because those constructors are compiler #generated. I need to find out more about this and to talk with Brad - new_name = self.__inst.name + new_name = self.__inst._name if templates.is_instantiation( new_name ): new_name = templates.name( new_name ) for decl in self.__inst.declarations: if not isinstance( decl, constructor_t ): continue - if '.' in decl.name or '$' in decl.name: - decl.name = new_name + if '.' in decl._name or '$' in decl._name: + decl._name = new_name bases = self.__inst.bases.split() self.__inst.bases = [] Modified: pygccxml_dev/pygccxml/parser/patcher.py =================================================================== --- pygccxml_dev/pygccxml/parser/patcher.py 2006-05-14 07:23:52 UTC (rev 72) +++ pygccxml_dev/pygccxml/parser/patcher.py 2006-05-14 07:25:24 UTC (rev 73) @@ -172,8 +172,20 @@ return call_invocation.join( f_q_name, args ) +class fix_casting_operator_name_patcher_t( patcher_base_t ): + def __init__( self, decls ): + patcher_base_t.__init__( self, decls ) + + def patch_it(self): + for decl in declarations.make_flatten( self.decls ): + if not isinstance( decl, declarations.casting_operator_t): + continue + decl.name = 'operator ' + decl.return_type.decl_string + def patch_it(decls): patcher = default_argument_patcher_t( decls ) patcher.patch_it() + patcher2 = fix_casting_operator_name_patcher_t( decls ) + patcher2.patch_it() return patcher.decls \ No newline at end of file Modified: pygccxml_dev/pygccxml/parser/project_reader.py =================================================================== --- pygccxml_dev/pygccxml/parser/project_reader.py 2006-05-14 07:23:52 UTC (rev 72) +++ pygccxml_dev/pygccxml/parser/project_reader.py 2006-05-14 07:25:24 UTC (rev 73) @@ -15,6 +15,51 @@ ALL_AT_ONCE = 'all at once' FILE_BY_FILE = 'file by file' + +#TODO: rework next explanation to something useful. +""" +file_configuration_t is rather cool feature. When you create module_builder_t +class instance you should pass list of files. This list can contain string( == file paths ) and/or instances of file_configuration_t class. + +file_configuration_t is class with fat interface. +It has 4 states: + 1. it could contain reference to source file. + Use "create_source_fc" function to create an instance of file_configuration_t + + 2. it could contain reference to source file and xml file. In this case if xml file + exist, source file will not be parsed by gccxml. If xml file does not exists, source + file will be parsed and xml file will be saved for future use. + See create_cached_source_fc function + + 3. it could contain reference to xml file only + See create_gccxml_fc + + 4. it could contain some text. In this case, parser will create temporal file on + disk and will pass it as an argument to gccxml. + See create_text_fc + +In most cases you don't all those features. If I were you, I would create regular +source file and put all template instantiation there. + +Any way the code: + +tmpl_inst = ''' +===================== + #include "TempClass.h" + + namespace details{ + inline void export_templates(){ + sizeof( TempClass<int> ); + } + } +''' + +import module_builder +mb = module_builder.module_builder_t( + [ module_builder.create_text_fc( tmpl_inst ) ] + , .... ) + +""" class file_configuration_t( object ): class CONTENT_TYPE: STANDARD_SOURCE_FILE = 'standard source file' @@ -239,7 +284,7 @@ for other_ns in other_ns_list: main_ns = pygccxml.declarations.find_declaration( answer , type=pygccxml.declarations.namespace_t - , name=other_ns.name + , name=other_ns._name , recursive=False ) if main_ns: main_ns.take_parenting( other_ns ) @@ -253,23 +298,23 @@ decls = [] for decl in nsref.declarations: if not ddhash.has_key( decl.__class__ ): - ddhash[ decl.__class__ ] = { decl.name : [ decl ] } + ddhash[ decl.__class__ ] = { decl._name : [ decl ] } decls.append( decl ) else: joined_decls = ddhash[ decl.__class__ ] - if not joined_decls.has_key( decl.name ): + if not joined_decls.has_key( decl._name ): decls.append( decl ) - joined_decls[decl.name] = [ decl ] + joined_decls[decl._name] = [ decl ] else: if isinstance( decl, pygccxml.declarations.calldef_t ): - if decl not in joined_decls[decl.name]: + if decl not in joined_decls[decl._name]: #functions has overloading decls.append( decl ) - joined_decls[decl.name].append( decl ) + joined_decls[decl._name].append( decl ) else: - assert 1 == len( joined_decls[ decl.name ] ) + assert 1 == len( joined_decls[ decl._name ] ) if isinstance( decl, pygccxml.declarations.namespace_t ): - joined_decls[ decl.name ][0].take_parenting( decl ) + joined_decls[ decl._name ][0].take_parenting( decl ) nsref.declarations = decls def _join_class_hierarchy( self, namespaces ): @@ -347,7 +392,7 @@ decl_wrapper_type.declaration = leaved_classes[ create_key(decl_wrapper_type.declaration) ] else: msg = [] - msg.append( "Unable to find out actual class definition: '%s'." % decl_wrapper_type.declaration.name ) + msg.append( "Unable to find out actual class definition: '%s'." % decl_wrapper_type.declaration._name ) msg.append( "Class definition has been changed from one compilation to an other." ) msg.append( "Why did it happen to me? Here is a short list of reasons: " ) msg.append( " 1. There are different preprocessor definitions applied on same file during compilation" ) Modified: pygccxml_dev/pygccxml/parser/scanner.py =================================================================== --- pygccxml_dev/pygccxml/parser/scanner.py 2006-05-14 07:23:52 UTC (rev 72) +++ pygccxml_dev/pygccxml/parser/scanner.py 2006-05-14 07:25:24 UTC (rev 73) @@ -25,6 +25,7 @@ XML_AN_CONST = "const" XML_AN_CONTEXT = "context" XML_AN_DEFAULT = "default" +XML_AN_DEMANGLED = "demangled" XML_AN_EXTERN = "extern" XML_AN_FILE = "file" XML_AN_ID = "id" @@ -145,11 +146,6 @@ continue members_mapping[ id( decl ) ] = members self.__members = members_mapping - #for id, members in self.__members.iteritems(): - #decl = self.__declarations.get( id, None ) - #if not decl or not isinstance( decl, scopedef_t): - #continue - #self.__declarations[id].declarations = members def declarations(self): return self.__declarations @@ -189,6 +185,7 @@ self.__read_bases( obj, attrs ) self.__read_artificial(obj, attrs) self.__read_mangled( obj, attrs) + self.__read_demangled( obj, attrs) elif isinstance( obj, type_t ): self.__types[ attrs[XML_AN_ID] ] = obj elif isinstance( obj, types.StringTypes ): @@ -229,6 +226,9 @@ def __read_mangled( self, decl, attrs ): decl.mangled = attrs.get( XML_AN_MANGLED, None ) + def __read_demangled( self, decl, attrs ): + decl.demangled = attrs.get( XML_AN_DEMANGLED, None ) + def __read_access( self, attrs ): self.__access[ attrs[XML_AN_ID] ] = attrs.get( XML_AN_ACCESS, ACCESS_TYPES.PUBLIC ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |