[gobject-introspection] scanner: Honor nested types on array declarations as well
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gobject-introspection] scanner: Honor nested types on array declarations as well
- Date: Fri, 5 Sep 2014 22:49:47 +0000 (UTC)
commit bce199127da5368700f3105e0bd19bc338810915
Author: Colin Walters <walters verbum org>
Date: Mon Jul 28 17:54:14 2014 -0400
scanner: Honor nested types on array declarations as well
We have special code to look at (type GLib.List(utf8)), but (type
GLib.PtrArray(utf8)) didn't work.
This allows NetworkManager to annotate the ActiveConnections property.
https://bugzilla.gnome.org/show_bug.cgi?id=733879
giscanner/maintransformer.py | 5 ++++-
.../Regress.TestObj-pptrarray.page | 15 +++++++++++++++
.../Regress.TestObj-pptrarray.page | 18 ++++++++++++++++++
.../Regress.TestObj-pptrarray.page | 18 ++++++++++++++++++
.../Regress.TestObj.page | 2 +-
tests/scanner/Regress-1.0-expected.gir | 5 +++++
tests/scanner/regress.c | 12 ++++++++++++
7 files changed, 73 insertions(+), 2 deletions(-)
---
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 19e3f24..4326374 100644
--- a/giscanner/maintransformer.py
+++ b/giscanner/maintransformer.py
@@ -287,7 +287,10 @@ class MainTransformer(object):
return base
if isinstance(base, ast.List) and len(rest) == 1:
return ast.List(base.name, *rest)
- if isinstance(base, ast.Map) and len(rest) == 2:
+ elif isinstance(base, ast.Array) and len(rest) == 1:
+ base.element_type = rest[0]
+ return base
+ elif isinstance(base, ast.Map) and len(rest) == 2:
return ast.Map(*rest)
message.warn(
"Too many parameters in type specification %r" % (type_str, ))
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-pptrarray.page
b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-pptrarray.page
new file mode 100644
index 0000000..36a32b0
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-pptrarray.page
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-pptrarray"
+ type="topic"
+ style="property"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="property" type="guide"/>
+ <title type="link" role="topic">pptrarray</title>
+ </info>
+ <title>Regress.TestObj:pptrarray</title>
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-pptrarray.page
b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-pptrarray.page
new file mode 100644
index 0000000..2c7cff0
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-pptrarray.page
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-pptrarray"
+ type="topic"
+ style="property"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="property" type="guide"/>
+ <title type="link" role="topic">pptrarray</title>
+ </info>
+ <title>Regress.TestObj.pptrarray</title>
+ <synopsis><code mime="text/x-gjs">
+TestObj.pptrarray: Array(String) (Read / Write)
+ </code></synopsis>
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-pptrarray.page
b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-pptrarray.page
new file mode 100644
index 0000000..f30deac
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-pptrarray.page
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-pptrarray"
+ type="topic"
+ style="property"
+ xmlns="http://projectmallard.org/1.0/"
+ xmlns:api="http://projectmallard.org/experimental/api/"
+ xmlns:ui="http://projectmallard.org/1.0/ui/">
+ <info>
+ <link xref="Regress.TestObj" group="property" type="guide"/>
+ <title type="link" role="topic">pptrarray</title>
+ </info>
+ <title>Regress.TestObj:pptrarray</title>
+ <synopsis><code mime="text/x-python">
+"pptrarray" [unicode] : Read / Write
+ </code></synopsis>
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.page
b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.page
index 56033fd..4f05703 100644
--- a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.page
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.page
@@ -12,7 +12,7 @@
<synopsis><code>
from gi.repository import Regress
-test_obj = Regress.TestObj(<link xref='Regress.TestObj-bare'>bare</link>=value, <link
xref='Regress.TestObj-boxed'>boxed</link>=value, <link xref='Regress.TestObj-double'>double</link>=value,
<link xref='Regress.TestObj-float'>float</link>=value, <link xref='Regress.TestObj-gtype'>gtype</link>=value,
<link xref='Regress.TestObj-hash-table'>hash_table</link>=value, <link
xref='Regress.TestObj-hash-table-old'>hash_table_old</link>=value, <link
xref='Regress.TestObj-int'>int</link>=value, <link xref='Regress.TestObj-list'>list</link>=value, <link
xref='Regress.TestObj-list-old'>list_old</link>=value, <link
xref='Regress.TestObj-string'>string</link>=value)
+test_obj = Regress.TestObj(<link xref='Regress.TestObj-bare'>bare</link>=value, <link
xref='Regress.TestObj-boxed'>boxed</link>=value, <link xref='Regress.TestObj-double'>double</link>=value,
<link xref='Regress.TestObj-float'>float</link>=value, <link xref='Regress.TestObj-gtype'>gtype</link>=value,
<link xref='Regress.TestObj-hash-table'>hash_table</link>=value, <link
xref='Regress.TestObj-hash-table-old'>hash_table_old</link>=value, <link
xref='Regress.TestObj-int'>int</link>=value, <link xref='Regress.TestObj-list'>list</link>=value, <link
xref='Regress.TestObj-list-old'>list_old</link>=value, <link
xref='Regress.TestObj-pptrarray'>pptrarray</link>=value, <link
xref='Regress.TestObj-string'>string</link>=value)
</code></synopsis>
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index a907b30..98f7ec9 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -3458,6 +3458,11 @@ raise an error.</doc>
<type name="utf8"/>
</type>
</property>
+ <property name="pptrarray" writable="1" transfer-ownership="none">
+ <array name="GLib.PtrArray" c:type="gpointer">
+ <type name="utf8"/>
+ </array>
+ </property>
<property name="string" writable="1" transfer-ownership="none">
<type name="utf8" c:type="gchar*"/>
</property>
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 48d9e93..3d3cfdd 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -2021,6 +2021,7 @@ enum
PROP_TEST_OBJ_BOXED,
PROP_TEST_OBJ_HASH_TABLE,
PROP_TEST_OBJ_LIST,
+ PROP_TEST_OBJ_PPTRARRAY,
PROP_TEST_OBJ_HASH_TABLE_OLD,
PROP_TEST_OBJ_LIST_OLD,
PROP_TEST_OBJ_INT,
@@ -2490,6 +2491,17 @@ regress_test_obj_class_init (RegressTestObjClass *klass)
pspec);
/**
+ * RegressTestObj:pptrarray: (type GLib.PtrArray(utf8)) (transfer none)
+ */
+ pspec = g_param_spec_pointer ("pptrarray",
+ "PtrArray property as a pointer",
+ "Test annotating with GLib.PtrArray",
+ G_PARAM_READWRITE);
+ g_object_class_install_property (gobject_class,
+ PROP_TEST_OBJ_PPTRARRAY,
+ pspec);
+
+ /**
* RegressTestObj:hash-table-old: (type GLib.HashTable<utf8,gint8>) (transfer container)
*/
pspec = g_param_spec_boxed ("hash-table-old",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]