summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2017-07-20 10:47:26 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2017-07-21 07:41:47 +0200
commitd48fb32d8350abbd421658c733b74aaf44cb89ce (patch)
tree64a1f9f1b152881caab3bb1bce2c16eecf55a12a
parent44aa990e80758ed9ad842fadc19857f26a663105 (diff)
downloadgobject-introspection-d48fb32d8350abbd421658c733b74aaf44cb89ce.tar.gz
regress: Test for property and method with conflicting names
This is something that libraries are not supposed to do, but some do anyway (Soup and Clutter are two examples) and language bindings should handle it somehow or other. In GJS we want to make sure that the way it's handled doesn't change inadvertently, because buggy library code should not break existing user code. https://bugzilla.gnome.org/show_bug.cgi?id=785091
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.TestObj-name-conflict.page15
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.TestObj-name_conflict.page14
-rw-r--r--tests/scanner/Regress-1.0-C-expected/Regress.TestObj.name_conflict.page38
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-name-conflict.page18
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.name_conflict.page26
-rw-r--r--tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.page1
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-name-conflict.page18
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-name_conflict.page14
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.name_conflict.page37
-rw-r--r--tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.page2
-rw-r--r--tests/scanner/Regress-1.0-expected.gir21
-rw-r--r--tests/scanner/Regress-1.0-sections-expected.txt1
-rw-r--r--tests/scanner/regress.c34
-rw-r--r--tests/scanner/regress.h4
14 files changed, 241 insertions, 2 deletions
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-name-conflict.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-name-conflict.page
new file mode 100644
index 00000000..e48c082e
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-name-conflict.page
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-name-conflict"
+ 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">name-conflict</title>
+ </info>
+ <title>Regress.TestObj:name-conflict</title>
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-name_conflict.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-name_conflict.page
new file mode 100644
index 00000000..a7945d12
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj-name_conflict.page
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-name_conflict"
+ type="topic"
+ style="field"
+ 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="field" type="guide"/>
+ </info>
+ <title>Regress.TestObj->name_conflict</title>
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.name_conflict.page b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.name_conflict.page
new file mode 100644
index 00000000..7948b7dd
--- /dev/null
+++ b/tests/scanner/Regress-1.0-C-expected/Regress.TestObj.name_conflict.page
@@ -0,0 +1,38 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.name_conflict"
+ type="topic"
+ style="method"
+ 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="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>void</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_name_conflict</api:name>
+ <api:arg>
+ <api:type>RegressTestObj*</api:type>
+ <api:name>obj</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>regress_test_obj_name_conflict</title>
+ <synopsis><code mime="text/x-csrc">
+void regress_test_obj_name_conflict (RegressTestObj* obj);
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>obj</code></title>
+ <p>A <link xref="Regress.TestObj"/></p>
+</item>
+<item>
+<title><code>Returns</code></title>
+
+</item>
+</terms>
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-name-conflict.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-name-conflict.page
new file mode 100644
index 00000000..165ea2fe
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj-name-conflict.page
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-name-conflict"
+ 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">name-conflict</title>
+ </info>
+ <title>Regress.TestObj.name_conflict</title>
+ <synopsis><code mime="text/x-gjs">
+TestObj.name_conflict: Number(gint) (Read / Write / Construct)
+ </code></synopsis>
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.name_conflict.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.name_conflict.page
new file mode 100644
index 00000000..765219bf
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.name_conflict.page
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.name_conflict"
+ type="topic"
+ style="method"
+ 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="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>void</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_name_conflict</api:name>
+ </api:function>
+ </info>
+ <title>Regress.TestObj.prototype.name_conflict</title>
+ <synopsis><code mime="text/x-gjs">
+function name_conflict(): void {
+ // Gjs wrapper for regress_test_obj_name_conflict()
+}
+ </code></synopsis>
+
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.page b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.page
index 4b43596d..d0cdfafc 100644
--- a/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.page
+++ b/tests/scanner/Regress-1.0-Gjs-expected/Regress.TestObj.page
@@ -13,6 +13,7 @@
const Regress = imports.gi.Regress;
let testObj = new Regress.TestObj({
+ <link xref='Regress.TestObj-name-conflict'>name_conflict</link>: value,
});
</code></synopsis>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-name-conflict.page b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-name-conflict.page
new file mode 100644
index 00000000..6d02a57c
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-name-conflict.page
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-name-conflict"
+ 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">name-conflict</title>
+ </info>
+ <title>Regress.TestObj:name-conflict</title>
+ <synopsis><code mime="text/x-python">
+"name-conflict" int : Read / Write / Construct
+ </code></synopsis>
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-name_conflict.page b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-name_conflict.page
new file mode 100644
index 00000000..a7945d12
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj-name_conflict.page
@@ -0,0 +1,14 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj-name_conflict"
+ type="topic"
+ style="field"
+ 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="field" type="guide"/>
+ </info>
+ <title>Regress.TestObj->name_conflict</title>
+
+
+</page>
diff --git a/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.name_conflict.page b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.name_conflict.page
new file mode 100644
index 00000000..ca3aa8da
--- /dev/null
+++ b/tests/scanner/Regress-1.0-Python-expected/Regress.TestObj.name_conflict.page
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<page id="Regress.TestObj.name_conflict"
+ type="topic"
+ style="method"
+ 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="method" type="guide"/>
+ <api:function>
+ <api:returns>
+ <api:type>none</api:type>
+ </api:returns>
+ <api:name>regress_test_obj_name_conflict</api:name>
+ <api:arg>
+ <api:type>Regress.TestObj</api:type>
+ <api:name>self</api:name>
+ </api:arg>
+ </api:function>
+ </info>
+ <title>Regress.TestObj.name_conflict</title>
+ <synopsis><code mime="text/x-python">
+@accepts(Regress.TestObj)
+@returns(none)
+def name_conflict(self):
+ # Python wrapper for regress_test_obj_name_conflict()
+ </code></synopsis>
+
+
+<terms>
+<item>
+<title><code>self</code></title>
+ <p>A <link xref="Regress.TestObj"/></p>
+</item>
+</terms>
+
+</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 4f05703c..e28fae67 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-pptrarray'>pptrarray</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-name-conflict'>name_conflict</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 7596282b..0bee81e4 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -3184,6 +3184,18 @@ case.</doc>
</instance-parameter>
</parameters>
</method>
+ <method name="name_conflict"
+ c:identifier="regress_test_obj_name_conflict">
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <instance-parameter name="obj" transfer-ownership="none">
+ <doc xml:space="preserve">A #RegressTestObj</doc>
+ <type name="TestObj" c:type="RegressTestObj*"/>
+ </instance-parameter>
+ </parameters>
+ </method>
<method name="not_nullable_element_typed_gpointer_in"
c:identifier="regress_test_obj_not_nullable_element_typed_gpointer_in">
<return-value transfer-ownership="none">
@@ -3590,6 +3602,12 @@ raise an error.</doc>
<type name="utf8"/>
</type>
</property>
+ <property name="name-conflict"
+ writable="1"
+ construct="1"
+ transfer-ownership="none">
+ <type name="gint" c:type="gint"/>
+ </property>
<property name="pptrarray" writable="1" transfer-ownership="none">
<array name="GLib.PtrArray" c:type="gpointer">
<type name="utf8"/>
@@ -3633,6 +3651,9 @@ raise an error.</doc>
<field name="gtype">
<type name="GType" c:type="GType"/>
</field>
+ <field name="name_conflict">
+ <type name="gint" c:type="gint"/>
+ </field>
<field name="function_ptr">
<callback name="function_ptr">
<return-value transfer-ownership="none">
diff --git a/tests/scanner/Regress-1.0-sections-expected.txt b/tests/scanner/Regress-1.0-sections-expected.txt
index a9574f94..a9abd20f 100644
--- a/tests/scanner/Regress-1.0-sections-expected.txt
+++ b/tests/scanner/Regress-1.0-sections-expected.txt
@@ -347,6 +347,7 @@ regress_forced_method
regress_test_obj_instance_method
regress_test_obj_instance_method_callback
regress_test_obj_instance_method_full
+regress_test_obj_name_conflict
regress_test_obj_not_nullable_element_typed_gpointer_in
regress_test_obj_not_nullable_typed_gpointer_in
regress_test_obj_set_bare
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 153b6d49..5a53291e 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -2097,7 +2097,8 @@ enum
PROP_TEST_OBJ_FLOAT,
PROP_TEST_OBJ_DOUBLE,
PROP_TEST_OBJ_STRING,
- PROP_TEST_OBJ_GTYPE
+ PROP_TEST_OBJ_GTYPE,
+ PROP_TEST_OBJ_NAME_CONFLICT
};
static void
@@ -2161,6 +2162,10 @@ regress_test_obj_set_property (GObject *object,
self->gtype = g_value_get_gtype (value);
break;
+ case PROP_TEST_OBJ_NAME_CONFLICT:
+ self->name_conflict = g_value_get_int (value);
+ break;
+
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -2218,6 +2223,10 @@ regress_test_obj_get_property (GObject *object,
g_value_set_gtype (value, self->gtype);
break;
+ case PROP_TEST_OBJ_NAME_CONFLICT:
+ g_value_set_int (value, self->name_conflict);
+ break;
+
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -2664,6 +2673,20 @@ regress_test_obj_class_init (RegressTestObjClass *klass)
PROP_TEST_OBJ_GTYPE,
pspec);
+ /**
+ * TestObj:name-conflict:
+ */
+ pspec = g_param_spec_int ("name-conflict",
+ "name-conflict property",
+ "A property name that conflicts with a method",
+ G_MININT,
+ G_MAXINT,
+ 42,
+ G_PARAM_CONSTRUCT | G_PARAM_READWRITE);
+ g_object_class_install_property (gobject_class,
+ PROP_TEST_OBJ_NAME_CONFLICT,
+ pspec);
+
klass->matrix = regress_test_obj_default_matrix;
}
@@ -3095,6 +3118,15 @@ regress_test_obj_not_nullable_element_typed_gpointer_in (RegressTestObj *obj,
}
/**
+ * regress_test_obj_name_conflict:
+ * @obj: A #RegressTestObj
+ */
+void
+regress_test_obj_name_conflict (RegressTestObj *obj)
+{
+}
+
+/**
* regress_test_array_fixed_out_objects:
* @objs: (out) (array fixed-size=2) (transfer full): An array of #RegressTestObj
*/
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index f7205f38..d6752a1c 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -771,6 +771,7 @@ struct _RegressTestObj
double some_double;
char* string;
GType gtype;
+ gint name_conflict;
/* < private > */
void (*function_ptr) (void);
@@ -940,6 +941,9 @@ void regress_test_obj_not_nullable_element_typed_gpointer_in (RegressTestObj *ob
gpointer input,
guint count);
+_GI_TEST_EXTERN
+void regress_test_obj_name_conflict (RegressTestObj *obj);
+
/* inheritance */
#define REGRESS_TEST_TYPE_SUB_OBJ (regress_test_sub_obj_get_type ())
#define REGRESS_TEST_SUB_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), REGRESS_TEST_TYPE_SUB_OBJ, RegressTestSubObj))