diff options
author | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-02-20 02:35:23 +0100 |
---|---|---|
committer | Giovanni Campagna <gcampagna@src.gnome.org> | 2014-02-20 02:40:03 +0100 |
commit | 6cc9207cbdb1328c746e0899f459bb09d1e3e954 (patch) | |
tree | b73473301bb202ea882c966ffadb3accbeab8ed4 /giscanner | |
parent | e70abadf0dd7d5312311926ec5b5130e1933d83b (diff) | |
download | gobject-introspection-6cc9207cbdb1328c746e0899f459bb09d1e3e954.tar.gz |
doctool/Gjs: some more fixes for structs and unions
Stop pretending we have fields on unions (only methods are
supported).
Add minimal support (ie, don't crash) to nested structures,
that due to how ast works have namespace None (and the
transformers hard-depend on that). Uncovered by GLib's
GDoubleIEEE754, before I removed union fields.
For some reason, RegressTestStructE (anonymous union) has a
completely different behavior and generates a weird name,
while RegressLikeGnomeKeyringSchema (array of unnamed structs)
becomes array(gpointer).
Bah, one should have methods anyway...
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/doctemplates/Gjs/class.tmpl | 13 | ||||
-rw-r--r-- | giscanner/docwriter.py | 4 |
2 files changed, 14 insertions, 3 deletions
diff --git a/giscanner/doctemplates/Gjs/class.tmpl b/giscanner/doctemplates/Gjs/class.tmpl index d8433704..7694d726 100644 --- a/giscanner/doctemplates/Gjs/class.tmpl +++ b/giscanner/doctemplates/Gjs/class.tmpl @@ -1,6 +1,8 @@ <%inherit file="/class.tmpl"/> <%block name="synopsis"> - <synopsis><code> + <synopsis>\ +% if node.namespace is not None: +<code> const ${namespace.name} = imports.gi.${namespace.name}; let ${formatter.to_lower_camel_case(node.name)} = new ${namespace.name}.${node.name}(\ @@ -18,4 +20,11 @@ let ${formatter.to_lower_camel_case(node.name)} = new ${namespace.name}.${node.n ${formatter.format_gboxed_constructor(node)}\ % endif ); - </code></synopsis></%block> + </code>\ +% else: + <p> + This structure is inside ${node.parent.namespace.name}.${node.parent.name} + and can only be used as a field of that. + </p> +% endif +</synopsis></%block> diff --git a/giscanner/docwriter.py b/giscanner/docwriter.py index 75a2b03b..92fa127a 100644 --- a/giscanner/docwriter.py +++ b/giscanner/docwriter.py @@ -597,7 +597,7 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): if isinstance(node, ast.Field): if node.type is None: return False - if isinstance(node.parent, ast.Class): + if isinstance(node.parent, (ast.Class, ast.Union)): return False if isinstance(node, ast.Union) and node.name is None: return False @@ -775,6 +775,8 @@ class DocFormatterGjs(DocFormatterIntrospectableBase): return False if node.private: return False + if isinstance(node.parent, ast.Union): + return False if node.type.target_fundamental not in \ (None, 'none', 'gpointer', 'utf8', 'filename', 'va_list'): return True |