summaryrefslogtreecommitdiff
path: root/giscanner/girwriter.py
diff options
context:
space:
mode:
authorJonathan Matthew <jonathan@d14n.org>2010-10-27 19:11:13 +1000
committerJonathan Matthew <jonathan@d14n.org>2010-12-16 07:45:36 +1000
commit24a5ba0dc0be57146f6504679adf2527ed4a2802 (patch)
treef270f24231da3557c9a9e5e56bbb19dbe77419bf /giscanner/girwriter.py
parent112100a47956effefc07ed594fb921cf941fd828 (diff)
downloadgobject-introspection-24a5ba0dc0be57146f6504679adf2527ed4a2802.tar.gz
scanner: support typedefs for container types
Inside an alias definition, we only need the name of the alias target type. Add a method to GIRWriter to write out a type reference rather than full type definition and use it when writing out an alias. Determine introspectableness of aliases in IntrospectablePass so functions using aliases can be marked not-introspectable if the alias itself is not. https://bugzilla.gnome.org/show_bug.cgi?id=629682
Diffstat (limited to 'giscanner/girwriter.py')
-rw-r--r--giscanner/girwriter.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/giscanner/girwriter.py b/giscanner/girwriter.py
index 43dbd26c..4f7bd64c 100644
--- a/giscanner/girwriter.py
+++ b/giscanner/girwriter.py
@@ -157,7 +157,7 @@ and/or use gtk-doc annotations. ''')
self._append_node_generic(alias, attrs)
with self.tagcontext('alias', attrs):
self._write_generic(alias)
- self._write_type(alias.target)
+ self._write_type_ref(alias.target)
def _write_callable(self, callable, tag_name, extra_attrs):
attrs = [('name', callable.name)]
@@ -241,6 +241,28 @@ and/or use gtk-doc annotations. ''')
return typeval.target_giname[len(prefix):]
return typeval.target_giname
+ def _write_type_ref(self, ntype):
+ """ Like _write_type, but only writes the type name rather than the full details """
+ assert isinstance(ntype, ast.Type), ntype
+ attrs = []
+ if ntype.ctype:
+ attrs.append(('c:type', ntype.ctype))
+ if isinstance(ntype, ast.Array):
+ if ntype.array_type != ast.Array.C:
+ attrs.insert(0, ('name', ntype.array_type))
+ elif isinstance(ntype, ast.List):
+ if ntype.name:
+ attrs.insert(0, ('name', ntype.name))
+ elif isinstance(ntype, ast.Map):
+ attrs.insert(0, ('name', 'GLib.HashTable'))
+ else:
+ if ntype.target_giname:
+ attrs.insert(0, ('name', self._type_to_name(ntype)))
+ elif ntype.target_fundamental:
+ attrs.insert(0, ('name', ntype.target_fundamental))
+
+ self.write_tag('type', attrs)
+
def _write_type(self, ntype, relation=None, function=None):
assert isinstance(ntype, ast.Type), ntype
attrs = []