summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2014-07-28 17:54:14 -0400
committerColin Walters <walters@verbum.org>2014-09-05 18:49:22 -0400
commitbce199127da5368700f3105e0bd19bc338810915 (patch)
treedeb2f4889590a3a575d068c566e79e5a5ff942a5
parent9b2effedf08c5842f9ac49896875e5df1f63db4d (diff)
downloadgobject-introspection-bce199127da5368700f3105e0bd19bc338810915.tar.gz
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
-rw-r--r--giscanner/maintransformer.py5
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.TestObj-pptrarray.page15
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-pptrarray.page18
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-pptrarray.page18
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.page2
-rw-r--r--tests/scanner/Regress-1.0-expected.gir5
-rw-r--r--tests/scanner/regress.c12
7 files changed, 73 insertions, 2 deletions
diff --git a/giscanner/maintransformer.py b/giscanner/maintransformer.py
index 19e3f24c..4326374f 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 00000000..36a32b05
--- /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 00000000..2c7cff0a
--- /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 00000000..f30deac3
--- /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 56033fd0..4f05703c 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 a907b300..98f7ec97 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 48d9e931..3d3cfdde 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",