summaryrefslogtreecommitdiff
path: root/giscanner/ast.py
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2012-08-28 02:46:23 +0200
committerGiovanni Campagna <gcampagna@src.gnome.org>2012-10-28 18:41:04 +0100
commit9ff28e6abab52506933fb560de1360e16d8d3880 (patch)
treeca5f30c68df77bf3b6de0f3756b35c4b3c579623 /giscanner/ast.py
parent6fc366a66c58039aec345cc531c329729b6bce18 (diff)
downloadgobject-introspection-9ff28e6abab52506933fb560de1360e16d8d3880.tar.gz
Namespace: fix appending of nodes
Traverse appended nodes for methods, so that namespace.symbols contains all known symbols and not just global functions. Also, ensure that all relevant nodes are appended when parsing GIRs. https://bugzilla.gnome.org/show_bug.cgi?id=683046
Diffstat (limited to 'giscanner/ast.py')
-rw-r--r--giscanner/ast.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 654c68e2..be974a09 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -20,6 +20,7 @@
#
import copy
+from itertools import chain
from . import message
@@ -399,6 +400,21 @@ but adds it to things like ctypes, symbols, and type_names.
self.type_names[node.gtype_name] = node
elif isinstance(node, Function):
self.symbols[node.symbol] = node
+ if isinstance(node, (Compound, Class, Interface)):
+ for fn in chain(node.methods, node.static_methods, node.constructors):
+ if not isinstance(fn, Function):
+ continue
+ fn.namespace = self
+ self.symbols[fn.symbol] = fn
+ if isinstance(node, (Class, Interface)):
+ for m in chain(node.signals, node.properties):
+ m.namespace = self
+ if isinstance(node, Enum) or isinstance(node, Bitfield):
+ for fn in node.static_methods:
+ if not isinstance(fn, Function):
+ continue
+ fn.namespace = self
+ self.symbols[fn.symbol] = fn
if hasattr(node, 'ctype'):
self.ctypes[node.ctype] = node
@@ -990,6 +1006,9 @@ class Interface(Node, Registered):
self.properties = []
self.fields = []
self.prerequisites = []
+ # Not used yet, exists just to avoid an exception in
+ # Namespace.append()
+ self.constructors = []
def _walk(self, callback, chain):
for meth in self.methods: