summaryrefslogtreecommitdiff
path: root/giscanner/girparser.py
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 /giscanner/girparser.py
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 'giscanner/girparser.py')
-rw-r--r--giscanner/girparser.py36
1 files changed, 18 insertions, 18 deletions
diff --git a/giscanner/girparser.py b/giscanner/girparser.py
index 689b635b..8b255a43 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -46,26 +46,23 @@ def _cns(tag):
class GIRParser(object):
- def __init__(self, filename,
- initial_parse=True,
- include_parsing=False):
+ def __init__(self):
+ self._include_parsing = False
+ self._shared_libraries = []
self._includes = set()
self._namespace = None
- self._shared_libraries = []
- self._include_parsing = include_parsing
- self._tree = parse(filename)
-
- if initial_parse:
- self.parse()
# Public API
- def parse(self):
- self._includes.clear()
- del self._namespace
- del self._shared_libraries[:]
+ def parse(self, filename):
+ tree = parse(filename)
+ self.parse_tree(tree)
- self._parse_api(self._tree.getroot())
+ def parse_tree(self, tree):
+ self._includes.clear()
+ self._namespace = None
+ self._shared_libraries = []
+ self._parse_api(tree.getroot())
def get_namespace(self):
return self._namespace
@@ -77,7 +74,10 @@ class GIRParser(object):
return self._includes
def get_doc(self):
- return self._tree
+ return parse(self._filename)
+
+ def set_include_parsing(self, include_parsing):
+ self._include_parsing = include_parsing
# Private
@@ -159,8 +159,8 @@ class GIRParser(object):
obj.fields.append(self._parse_function_common(callback, Callback))
for field in node.findall(_corens('field')):
obj.fields.append(self._parse_field(field))
- for property in node.findall(_corens('property')):
- obj.properties.append(self._parse_property(property))
+ for prop in node.findall(_corens('property')):
+ obj.properties.append(self._parse_property(prop))
for signal in node.findall(_glibns('signal')):
obj.signals.append(self._parse_function_common(signal, Function))
@@ -237,7 +237,7 @@ class GIRParser(object):
node.attrib.get(_cns('type')))
else:
union = Union(node.attrib['name'],
- node.attrib.get(_cns('type')))
+ node.attrib.get(_cns('type')))
self._add_node(union)
if self._include_parsing: