summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJohan Dahlin <jdahlin@async.com.br>2008-10-30 17:12:51 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-10-30 17:12:51 +0000
commit53d089628f98fca0ca7984a95902134a7d7c11b8 (patch)
treeb410c743aed159768cb275a00cf4f36867c8b192 /tools
parent0fcde9ead2e60751268dde5300a7a3e4f13f5c58 (diff)
downloadgobject-introspection-53d089628f98fca0ca7984a95902134a7d7c11b8.tar.gz
Remove arguments from the constructor, move them to separate accessors.
2008-10-30 Johan Dahlin <jdahlin@async.com.br> * giscanner/girparser.py: Remove arguments from the constructor, move them to separate accessors. Add a new parse_tree method which takes an element tree instance. * tools/g-ir-scanner: Update callsite for this * giscanner/Makefile.am: * giscanner/cachestore.py: * giscanner/transformer.py: Cache the include parsing. Saves ~25% time when creating vte (which includes everything up to gtk+). svn path=/trunk/; revision=842
Diffstat (limited to 'tools')
-rwxr-xr-xtools/g-ir-scanner24
1 files changed, 16 insertions, 8 deletions
diff --git a/tools/g-ir-scanner b/tools/g-ir-scanner
index 7d89897a..99ddcf76 100755
--- a/tools/g-ir-scanner
+++ b/tools/g-ir-scanner
@@ -36,6 +36,7 @@ else:
sys.path.insert(0, path)
from giscanner.ast import Include
+from giscanner.cachestore import CacheStore
from giscanner.glibtransformer import GLibTransformer
from giscanner.minixpath import myxpath, xpath_assert
from giscanner.sourcescanner import SourceScanner
@@ -115,15 +116,19 @@ def typelib_xml_strip(path):
from giscanner.girparser import GIRParser
from giscanner.girwriter import GIRWriter
from giscanner.girparser import C_NS
+ from xml.etree.cElementTree import parse
+
c_ns_key = '{%s}' % (C_NS, )
- parser = GIRParser(path, initial_parse=False)
- doc = parser.get_doc()
- for node in doc.getiterator():
+ tree = parse(path)
+ root = tree.getroot()
+ for node in root.getiterator():
for attrib in list(node.attrib):
if attrib.startswith(c_ns_key):
del node.attrib[attrib]
- parser.parse()
+ parser = GIRParser()
+ parser.parse_tree(tree)
+
writer = GIRWriter(parser.get_namespace(),
parser.get_shared_libraries(),
parser.get_includes())
@@ -135,8 +140,8 @@ def inject(path, additions, outpath):
from giscanner.girwriter import GIRWriter
from xml.etree.cElementTree import parse
- parser = GIRParser(path, initial_parse=False)
- root = parser.get_doc().getroot()
+ tree = parse(path)
+ root = tree.getroot()
injectDoc = parse(open(additions))
for node in injectDoc.getroot():
injectPath = node.attrib['path']
@@ -145,7 +150,9 @@ def inject(path, additions, outpath):
raise ValueError("Couldn't find path %r" % (injectPath, ))
for child in node:
target.append(child)
- parser.parse()
+
+ parser = GIRParser()
+ parser.parse_tree(tree)
writer = GIRWriter(parser.get_namespace(),
parser.get_shared_libraries(),
parser.get_includes())
@@ -248,6 +255,7 @@ def main(args):
_error('%s: no such a file or directory' % (arg, ))
filenames.append(arg)
+ cachestore = CacheStore()
# Run the preprocessor, tokenize and construct simple
# objects representing the raw C symbols
ss = SourceScanner()
@@ -258,7 +266,7 @@ def main(args):
ss.parse_macros(filenames)
# Transform the C symbols into AST nodes
- transformer = Transformer(ss,
+ transformer = Transformer(cachestore, ss,
options.namespace_name,
options.namespace_version)
if options.strip_prefix: