[gobject-introspection] doctool/Gjs: some more fixes for structs and unions
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] doctool/Gjs: some more fixes for structs and unions
- Date: Thu, 20 Feb 2014 01:43:00 +0000 (UTC)
commit 6cc9207cbdb1328c746e0899f459bb09d1e3e954
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Thu Feb 20 02:35:23 2014 +0100
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...
giscanner/doctemplates/Gjs/class.tmpl | 13 +++++++++++--
giscanner/docwriter.py | 4 +++-
.../Regress.FooBUnion-rect.page | 18 ------------------
.../Regress.FooBUnion-type.page | 18 ------------------
.../Regress.FooBUnion-v.page | 18 ------------------
.../Regress.FooBUnion.page | 5 +----
.../Regress.FooEvent-any.page | 18 ------------------
.../Regress.FooEvent-expose.page | 18 ------------------
.../Regress.FooEvent-type.page | 18 ------------------
.../Regress-1.0-Gjs-expected/Regress.FooEvent.page | 6 +-----
.../Regress.FooUnion-regress_foo.page | 18 ------------------
.../Regress-1.0-Gjs-expected/Regress.FooUnion.page | 4 +---
...ss.TestStructE__some_union__union-v_double.page | 20 --------------------
...ess.TestStructE__some_union__union-v_float.page | 20 --------------------
...gress.TestStructE__some_union__union-v_int.page | 20 --------------------
...ess.TestStructE__some_union__union-v_int64.page | 20 --------------------
...ress.TestStructE__some_union__union-v_long.page | 20 --------------------
...s.TestStructE__some_union__union-v_pointer.page | 20 --------------------
...ress.TestStructE__some_union__union-v_uint.page | 20 --------------------
...ss.TestStructE__some_union__union-v_uint64.page | 20 --------------------
...ess.TestStructE__some_union__union-v_ulong.page | 20 --------------------
.../Regress.TestStructE__some_union__union.page | 11 +----------
22 files changed, 18 insertions(+), 331 deletions(-)
---
diff --git a/giscanner/doctemplates/Gjs/class.tmpl b/giscanner/doctemplates/Gjs/class.tmpl
index d843370..7694d72 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 75a2b03..92fa127 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
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooBUnion.page
b/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooBUnion.page
index 91f431b..a5ef038 100644
--- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooBUnion.page
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooBUnion.page
@@ -12,10 +12,7 @@
<synopsis><code>
const Regress = imports.gi.Regress;
-let fooBUnion = new Regress.FooBUnion({
- <link xref='Regress.FooBUnion-type'>type</link>: value
- <link xref='Regress.FooBUnion-v'>v</link>: value
-});
+let fooBUnion = new Regress.FooBUnion();
</code></synopsis>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooEvent.page
b/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooEvent.page
index 7a6f3d1..8bd91a3 100644
--- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooEvent.page
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooEvent.page
@@ -12,11 +12,7 @@
<synopsis><code>
const Regress = imports.gi.Regress;
-let fooEvent = new Regress.FooEvent({
- <link xref='Regress.FooEvent-type'>type</link>: value
- <link xref='Regress.FooEvent-any'>any</link>: value
- <link xref='Regress.FooEvent-expose'>expose</link>: value
-});
+let fooEvent = new Regress.FooEvent();
</code></synopsis>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooUnion.page
b/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooUnion.page
index 9765253..a824d6f 100644
--- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooUnion.page
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.FooUnion.page
@@ -12,9 +12,7 @@
<synopsis><code>
const Regress = imports.gi.Regress;
-let fooUnion = new Regress.FooUnion({
- <link xref='Regress.FooUnion-regress_foo'>regress_foo</link>: value
-});
+let fooUnion = new Regress.FooUnion();
</code></synopsis>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestStructE__some_union__union.page
b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestStructE__some_union__union.page
index 38ee269..493e96d 100644
--- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestStructE__some_union__union.page
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestStructE__some_union__union.page
@@ -12,16 +12,7 @@
<synopsis><code>
const Regress = imports.gi.Regress;
-let testStructE__some_union__union = new Regress.TestStructE__some_union__union({
- <link xref='Regress.TestStructE__some_union__union-v_int'>v_int</link>: value
- <link xref='Regress.TestStructE__some_union__union-v_uint'>v_uint</link>: value
- <link xref='Regress.TestStructE__some_union__union-v_long'>v_long</link>: value
- <link xref='Regress.TestStructE__some_union__union-v_ulong'>v_ulong</link>: value
- <link xref='Regress.TestStructE__some_union__union-v_int64'>v_int64</link>: value
- <link xref='Regress.TestStructE__some_union__union-v_uint64'>v_uint64</link>: value
- <link xref='Regress.TestStructE__some_union__union-v_float'>v_float</link>: value
- <link xref='Regress.TestStructE__some_union__union-v_double'>v_double</link>: value
-});
+let testStructE__some_union__union = new Regress.TestStructE__some_union__union();
</code></synopsis>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]