[pygccxml-commit] SF.net SVN: pygccxml: [1235] pygccxml_dev
Brought to you by:
mbaas,
roman_yakovenko
|
From: <rom...@us...> - 2008-02-07 07:47:22
|
Revision: 1235
http://pygccxml.svn.sourceforge.net/pygccxml/?rev=1235&view=rev
Author: roman_yakovenko
Date: 2008-02-06 23:47:26 -0800 (Wed, 06 Feb 2008)
Log Message:
-----------
removing synopsis parser
Modified Paths:
--------------
pygccxml_dev/pygccxml/parser/config.py
pygccxml_dev/pygccxml/parser/etree_scanner.py
pygccxml_dev/pygccxml/parser/pdb_reader.py
pygccxml_dev/pygccxml/parser/project_reader.py
pygccxml_dev/pygccxml/parser/source_reader.py
pygccxml_dev/unittests/data/core_cache.hpp
Removed Paths:
-------------
pygccxml_dev/pygccxml/parser/synopsis_reader.py
pygccxml_dev/pygccxml/parser/synopsis_scanner.py
Modified: pygccxml_dev/pygccxml/parser/config.py
===================================================================
--- pygccxml_dev/pygccxml/parser/config.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/config.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -14,13 +14,13 @@
"""Configuration object to collect parameters for invoking C++ parser
This class serves as a base class for the parameters that can be used
- to customize the call to C++ parser. This class also allows users to work with
+ to customize the call to C++ parser. This class also allows users to work with
relative files paths. In this case files are searched in the following order:
-
+
1. current directory
-
+
2. working directory
-
+
3. additional include paths specified by the user
"""
@@ -31,7 +31,7 @@
, undefine_symbols=None
, cflags=""
, compiler=None):
- """Constructor.
+ """Constructor.
"""
object.__init__( self )
self.__working_directory = working_directory
@@ -49,23 +49,23 @@
self.__undefine_symbols = undefine_symbols
self.__cflags = cflags
-
+
self.__compiler = compiler
-
+
def clone(self):
raise NotImplementedError( self.__class__.__name__ )
-
+
def __get_working_directory(self):
return self.__working_directory
def __set_working_directory(self, working_dir):
self.__working_directory=working_dir
working_directory = property( __get_working_directory, __set_working_directory )
-
+
@property
def include_paths(self):
"""list of include paths to look for header files"""
return self.__include_paths
-
+
@property
def define_symbols(self):
"""list of "define" directives """
@@ -77,7 +77,7 @@
return self.__undefine_symbols
@property
- def compiler(self):
+ def compiler(self):
"""compiler name to simulate"""
return self.__compiler
@@ -90,7 +90,7 @@
def __ensure_dir_exists( self, dir_path, meaning ):
if os.path.isdir( dir_path ):
- return
+ return
msg = None
if os.path.exists( self.working_directory ):
raise RuntimeError( '%s("%s") does not exist!' % ( meaning, dir_path ) )
@@ -98,18 +98,18 @@
raise RuntimeError( '%s("%s") should be "directory", not a file.' % ( meaning, dir_path ) )
- def raise_on_wrong_settings( self ):
+ def raise_on_wrong_settings( self ):
"""validates the configuration settings and raises RuntimeError on error"""
self.__ensure_dir_exists( self.working_directory, 'working directory' )
map( lambda idir: self.__ensure_dir_exists( idir, 'include directory' )
, self.include_paths )
-
+
class gccxml_configuration_t(parser_configuration_t):
"""Configuration object to collect parameters for invoking gccxml.
This class serves as a container for the parameters that can be used
- to customize the call to gccxml.
+ to customize the call to gccxml.
"""
def __init__( self
, gccxml_path=''
@@ -121,7 +121,7 @@
, ignore_gccxml_output=False
, cflags=""
, compiler=None):
- """Constructor.
+ """Constructor.
"""
parser_configuration_t.__init__( self
, working_directory=working_directory
@@ -130,7 +130,7 @@
, undefine_symbols=undefine_symbols
, cflags=cflags
, compiler=compiler)
-
+
self.__gccxml_path = gccxml_path
if not start_with_declarations:
@@ -138,10 +138,10 @@
self.__start_with_declarations = start_with_declarations
self.__ignore_gccxml_output = ignore_gccxml_output
-
+
def clone(self):
return copy.deepcopy( self )
-
+
def __get_gccxml_path(self):
return self.__gccxml_path
def __set_gccxml_path(self, new_path ):
@@ -151,9 +151,9 @@
@property
def start_with_declarations(self):
- """list of declarations gccxml should start with, when it dumps declaration tree"""
+ """list of declarations gccxml should start with, when it dumps declaration tree"""
return self.__start_with_declarations
-
+
def __get_ignore_gccxml_output(self):
return self.__ignore_gccxml_output
def __set_ignore_gccxml_output(self, val=True):
@@ -161,11 +161,11 @@
ignore_gccxml_output = property( __get_ignore_gccxml_output, __set_ignore_gccxml_output
, doc="set this property to True, if you want pygccxml to ignore any error\\warning that comes from gccxml" )
-
- def raise_on_wrong_settings( self ):
+
+ def raise_on_wrong_settings( self ):
super( gccxml_configuration_t, self ).raise_on_wrong_settings()
if os.path.isfile( self.gccxml_path ):
- return
+ return
if sys.platform == 'win32':
gccxml_name = 'gccxml' + '.exe'
environment_var_delimiter = ';'
@@ -187,31 +187,5 @@
msg = 'gccxml_path("%s") should exists or to be a valid file name.' \
% self.gccxml_path
raise RuntimeError( msg )
-
-config_t = gccxml_configuration_t #backward computability
-class synopsis_configuration_t(parser_configuration_t):
- """Configuration object to collect parameters for invoking gccxml.
-
- This class serves as a container for the parameters that can be used
- to customize the call to synopsis.
- """
- def __init__( self
- , working_directory='.'
- , include_paths=None
- , define_symbols=None
- , undefine_symbols=None
- , cflags=""
- , compiler=None):
- """Constructor.
- """
- parser_configuration_t.__init__( self
- , working_directory=working_directory
- , include_paths=include_paths
- , define_symbols=define_symbols
- , undefine_symbols=undefine_symbols
- , cflags=cflags
- , compiler=compiler)
-
- def clone(self):
- return copy.deepcopy( self )
+config_t = gccxml_configuration_t #backward computability
Modified: pygccxml_dev/pygccxml/parser/etree_scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/etree_scanner.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/etree_scanner.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -5,12 +5,12 @@
import scanner
import xml.etree.cElementTree as ElementTree
-
+
class etree_saxifier_t(object):
def __init__(self, etree, handler):
self.__root_elem = etree.getroot()
- self.__handler = handler
-
+ self.__handler = handler
+
def saxify(self):
self.__handler.startDocument()
self.__recursive_saxify( self.__root_elem )
@@ -18,31 +18,23 @@
def __recursive_saxify(self, element ):
self.__handler.startElement( element.tag, element.attrib )
-
- #~ if element.text:
- #~ self.__handler.characters(element.text)
-
map( self.__recursive_saxify, element )
-
self.__handler.endElement( element.tag )
- #~ if element.tail:
- #~ self.__handler.characters(element.tail)
-
class etree_scanner_t( scanner.scanner_t ):
def __init__(self, gccxml_file, decl_factory, *args ):
scanner.scanner_t.__init__( self, gccxml_file, decl_factory, *args )
-
- def read( self ):
+
+ def read( self ):
tree = ElementTree.parse( self.gccxml_file )
saxifier = etree_saxifier_t( tree, self )
- saxifier.saxify()
+ saxifier.saxify()
class ietree_scanner_t( scanner.scanner_t ):
def __init__(self, gccxml_file, decl_factory, *args ):
scanner.scanner_t.__init__( self, gccxml_file, decl_factory, *args )
-
- def read( self ):
+
+ def read( self ):
context = ElementTree.iterparse(self.gccxml_file, events=("start", "end"))
for event, elem in context:
if event == 'start':
@@ -51,5 +43,5 @@
self.endElement( elem.tag )
elem.clear()
self.endDocument()
-
+
etree_scanner_t = ietree_scanner_t
Modified: pygccxml_dev/pygccxml/parser/pdb_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/pdb_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -1,8 +1,12 @@
import os
import sys
+import comtypes
import comtypes.client
from sets import Set as set
+comtypes.client.gen_dir = r'D:\dev\language-binding\sources\pygccxml_dev\pygccxml\parser\gen'
+print comtypes.client.GetModule( r'D:\Program Files\Microsoft Visual Studio .NET 2003\Visual Studio SDKs\DIA SDK\bin\msdia71.dll' )
+
#~ MODULE_IDENTIFIER = ('{106173A0-0173-4e5c-84E7-E915422BE997}', 0, 2, 0)
#~ MODULE_PATH = r'Lib\site-packages\win32com\gen_py\106173A0-0173-4e5c-84E7-E915422BE997x0x2x0.py'
@@ -17,8 +21,9 @@
#~ msdia = win32com.client.gencache.EnsureModule( *MODULE_IDENTIFIER )
-ds = comtypes.client.CreateObject( "{e60afbee-502d-46ae-858f-8272a09bd707}" )
-ds.loadDataFromPdb( 'xxx.pdb' )
+#ds = comtypes.client.CreateObject( "{e60afbee-502d-46ae-858f-8272a09bd707}" )
+#print dir( ds )
+#ds.loadDataFromPdb( 'xxx.pdb' )
#~ ds = msdia.DiaSource()
#~ ds.loadDataFromPdb( 'xxx.pdb' )
Modified: pygccxml_dev/pygccxml/parser/project_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/project_reader.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/project_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -71,21 +71,21 @@
and self.__content_type == self.CONTENT_TYPE.CACHED_SOURCE_FILE:
self.__cached_source_file = self.__data + '.xml'
- def __get_data(self):
+ @property
+ def data(self):
return self.__data
- data = property( __get_data )
- def __get_start_with_declarations(self):
+ @property
+ def start_with_declarations(self):
return self.__start_with_declarations
- start_with_declarations = property( __get_start_with_declarations )
- def __get_content_type(self):
+ @property
+ def content_type(self):
return self.__content_type
- content_type = property( __get_content_type )
- def __get_cached_source_file(self):
+ @property
+ def cached_source_file(self):
return self.__cached_source_file
- cached_source_file = property( __get_cached_source_file )
def create_text_fc( text ):
"""
@@ -427,7 +427,7 @@
for decl_wrapper_type in declarated_types:
#it is possible, that cache contains reference to dropped class
#We need to clear it
- decl_wrapper_type.cache.reset()
+ decl_wrapper_type.cache.reset()
if isinstance( decl_wrapper_type.declaration, pygccxml.declarations.class_t ):
key = create_key(decl_wrapper_type.declaration)
if leaved_classes.has_key( key ):
Modified: pygccxml_dev/pygccxml/parser/source_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/source_reader.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/source_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -10,29 +10,28 @@
import patcher
import pygccxml.utils
-try: #select faster xml parser
+try: #select the faster xml parser
from etree_scanner import etree_scanner_t as scanner_t
except:
from scanner import scanner_t
import declarations_cache
-from pygccxml import utils
+from pygccxml import utils
from pygccxml.declarations import *
class gccxml_runtime_error_t( RuntimeError ):
def __init__( self, msg ):
RuntimeError.__init__( self, msg )
-
def bind_aliases( decls ):
"""
- This function binds between class and it's typedefs.
+ This function binds between class and it's typedefs.
@param decls: list of all declarations
@type all_classes: list of L{declaration_t} items
@return: None
- """
+ """
visited = set()
typedefs = filter( lambda decl: isinstance( decl, typedef_t ), decls )
for decl in typedefs:
@@ -50,31 +49,31 @@
class source_reader_t:
"""
This class reads C++ source code and returns declarations tree.
-
- This class is the only class that have an intime knowledge about GCC-XML.
+
+ This class is the only class that have an intime knowledge about GCC-XML.
It has only one responsibility: it calls GCC-XML with a source file specified
by user and creates declarations tree. The implementation of this class is split
- to 2 classes:
-
- 1. L{scanner_t} - this class scans the "XML" file, generated by GCC-XML and
- creates `pygccxml`_ declarations and types classes. After the xml file has
- been processed declarations and type class instances keeps references to
- each other using GCC-XML generated id's.
+ to 2 classes:
- 2. L{linker_t} - this class contains logic for replacing GCC-XML generated
+ 1. L{scanner_t} - this class scans the "XML" file, generated by GCC-XML and
+ creates `pygccxml`_ declarations and types classes. After the xml file has
+ been processed declarations and type class instances keeps references to
+ each other using GCC-XML generated id's.
+
+ 2. L{linker_t} - this class contains logic for replacing GCC-XML generated
ids with references to declarations or type class instances.
"""
def __init__( self, config, cache=None, decl_factory=None ):
"""
- @param config: instance of L{config_t} class, that contains GCC-XML
+ @param config: instance of L{config_t} class, that contains GCC-XML
configuration
@type config: L{config_t}
-
- @param cache: reference to cache object, that will be updated after
+
+ @param cache: reference to cache object, that will be updated after
file has been parsed.
@param cache: instance of class, that derives from {cache_base_t}
-
- @param decl_factory: declarations factory, if not given default
+
+ @param decl_factory: declarations factory, if not given default
declarations factory L{decl_factory_t} will be used
"""
self.logger = utils.loggers.cxx_parser
@@ -99,7 +98,7 @@
cmd.append( '"%s"' % os.path.normpath( self.__config.gccxml_path ) )
else:
cmd.append( '%s' % os.path.normpath( self.__config.gccxml_path ) )
-
+
# Add all cflags passed
if self.__config.cflags != "":
cmd.append(" %s "%self.__config.cflags)
@@ -116,7 +115,7 @@
cmd.append( '-fxml-start="%s"' % ','.join( self.__config.start_with_declarations ) )
# Specify compiler if asked to
if self.__config.compiler:
- cmd.append( " --gccxml-compiler %s" % self.__config.compiler )
+ cmd.append( " --gccxml-compiler %s" % self.__config.compiler )
cmd_line = ' '.join(cmd)
if 'win32' in sys.platform :
cmd_line = '"%s"' % cmd_line
@@ -126,16 +125,16 @@
def create_xml_file( self, header, destination=None ):
"""
This function will return the file name of the file, created by GCC-XML
- for "header" file. If destination_file_path is not None, then this file
+ for "header" file. If destination_file_path is not None, then this file
path will be used and returned.
@param header: path to source file, that should be parsed
@type header: str
-
- @param destination: if given, will be used as target file/path for
+
+ @param destination: if given, will be used as target file/path for
GCC-XML generated file.
@type destination: str
-
+
@return: path to GCC-XML generated file
"""
gccxml_file = destination
@@ -173,13 +172,13 @@
def create_xml_file_from_string( self, content, destination=None ):
"""
Creates XML file from text.
-
+
@param content: C++ source code
@type content: str
-
+
@param destination: file name for GCC-XML generated file
@type destination: str
-
+
@return: returns file name of GCC-XML generated file
"""
header_file = pygccxml.utils.create_temp_file_name( suffix='.h' )
@@ -198,11 +197,11 @@
return self.read_gccxml_file( source_file )
else:
return self.read_synopsis_file( source_file )
-
+
def read_gccxml_file(self, source_file):
"""
Reads C++ source file and returns declarations tree
-
+
@param source_file: path to C++ source file
@type source_file: str
"""
@@ -230,10 +229,10 @@
def read_xml_file(self, gccxml_created_file):
"""
Reads GCC-XML generated XML file.
-
+
@param gccxml_created_file: path to GCC-XML generated file
@type gccxml_created_file: str
-
+
@return: declarations tree
"""
assert(self.__config!=None)
@@ -289,7 +288,7 @@
return file_path
except Exception:
return file_path
-
+
def __parse_gccxml_created_file( self, gccxml_file ):
scanner_ = scanner_t( gccxml_file, self.__decl_factory )
scanner_.read()
@@ -314,20 +313,20 @@
#some times gccxml report typedefs defined in no namespace
#it happens for example in next situation
#template< typename X>
- #void ddd(){ typedef typename X::Y YY;}
+ #void ddd(){ typedef typename X::Y YY;}
#if I will fail on this bug next time, the right way to fix it may be different
patcher.fix_calldef_decls( scanner_.calldefs(), scanner_.enums() )
decls = filter( lambda inst: isinstance( inst, namespace_t ) and not inst.parent
, decls.itervalues() )
return ( decls, files.values() )
-
+
def read_synopsis_file( self, source_file ):
import synopsis_scanner
from Synopsis import AST
from Synopsis.Parsers import Cxx
ffname = self.__file_full_name(source_file)
-
+
cppflags = []
map( lambda dpath: cppflags.append( '-I %s' % dpath )
, self.__config.include_paths )
@@ -335,7 +334,7 @@
, self.__config.define_symbols )
map( lambda define: cppflags.append( '-U %s' % define )
, self.__config.undefine_symbols )
-
+
cxx = Cxx.Parser( preprocess=True, cppflags=cppflags )
ast = AST.AST()
cxx.process( ast, input=[source_file] )
@@ -344,4 +343,4 @@
declarations = [scanner.global_ns]
self.__dcache.update( ffname, self.__config, declarations, [] )
return declarations
-
+
Deleted: pygccxml_dev/pygccxml/parser/synopsis_reader.py
===================================================================
--- pygccxml_dev/pygccxml/parser/synopsis_reader.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/synopsis_reader.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -1,36 +0,0 @@
-import os
-import sys
-
-from Synopsis import AST
-from Synopsis.Parsers import Cxx
-
-headers_dir = '/home/roman/language-binding/sources/pygccxml_dev/unittests/data'
-
-offset = 0
-def print_decls( d ):
- global offset
- print offset * ' ', d.name(), d.__class__.__name__
- if hasattr( d, 'declarations' ):
- offset += 1
- for d1 in d.declarations():
- print_decls( d1 )
- offset -= 1
-
-def parse( f ):
- global offset, headers_dir
- print 'file ', f
- cxx = Cxx.Parser(
- preprocess=True
- , cppflags=['-I %s' % headers_dir ] )
-
- ast = AST.AST()
- cxx.process( ast, input=[os.path.join(headers_dir, f )] )
-
- offset = 0
- for d in ast.declarations():
- print_decls( d )
-
-parse( 'declarations_enums.hpp' )
-#for x in os.listdir( headers_dir ):
- #if x.endswith( 'hpp' ):
- #parse( x )
Deleted: pygccxml_dev/pygccxml/parser/synopsis_scanner.py
===================================================================
--- pygccxml_dev/pygccxml/parser/synopsis_scanner.py 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/pygccxml/parser/synopsis_scanner.py 2008-02-07 07:47:26 UTC (rev 1235)
@@ -1,46 +0,0 @@
-# Copyright 2004 Roman Yakovenko.
-# Distributed under the Boost Software License, Version 1.0. (See
-# accompanying file LICENSE_1_0.txt or copy at
-# http://www.boost.org/LICENSE_1_0.txt)
-
-import os
-import types
-import pprint
-import warnings
-from Synopsis import AST
-from pygccxml import utils
-from pygccxml.declarations import *
-
-class scanner_t( AST.Visitor, object ):
- def __init__(self, ast, decl_factory ):
- self.logger = utils.loggers.cxx_parser
- self.ast = ast
-
- assert isinstance( decl_factory, decl_factory_t )
- self.__decl_factory = decl_factory
-
- #mapping from id -> decl
- self.__decl = self.__decl_factory.create_namespace( name='::' )
- self.global_ns = self.__decl
-
-
- def read_deaclaration( self, node, decl ):
- #this function should not be called for namespace
- decl.name = node.name()
- decl.location = location_t( file_name=node.file(), line=node.line() )
-
- def visitModule( self, node ):
- ns = self.__decl_factory.create_namespace( name=node.name() )
- self.__decl.adopt_declaration( ns )
- self.__decl = ns
- super( scanner_t, self ).visitModule( node )
-
- def visitEnum( self, node ):
- values = []
- for enumerator in node.enumerators():
- print enumerator.name(), ':', enumerator.value()
- values.append( ( enumerator.name(), enumerator.value() ) )
- enum = self.__decl_factory.create_enumeration( values=values )
- self.read_deaclaration( node, enum )
- self.__decl.adopt_declaration( enum )
- super( scanner_t, self ).visitEnum( node )
Modified: pygccxml_dev/unittests/data/core_cache.hpp
===================================================================
--- pygccxml_dev/unittests/data/core_cache.hpp 2008-02-06 10:07:10 UTC (rev 1234)
+++ pygccxml_dev/unittests/data/core_cache.hpp 2008-02-07 07:47:26 UTC (rev 1235)
@@ -22,4 +22,4 @@
#endif//__core_cache_hpp__
-//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch
\ No newline at end of file
+//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch//touch
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|