summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhilip Chimento <philip.chimento@gmail.com>2018-05-09 23:38:38 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2018-06-20 18:33:32 -0700
commitc4f5896068ca342b75bc438af0b78d44cf635305 (patch)
tree249fb8a3b5cf2e4b709895724ec3b8363940ba4b /tests
parent4fa6c29987ac23ff1e1f094a3d0ef4c4bcdacf4f (diff)
downloadgobject-introspection-c4f5896068ca342b75bc438af0b78d44cf635305.tar.gz
regress: Add test with signal inout parameter
This is modeled after GtkEditable::insert-text which isn't marshalled properly in GJS. See gjs#147.
Diffstat (limited to 'tests')
-rw-r--r--tests/scanner/Regress-1.0-expected.gir30
-rw-r--r--tests/scanner/regress.c36
-rw-r--r--tests/scanner/regress.h3
3 files changed, 69 insertions, 0 deletions
diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir
index 316c12ca..ad6af895 100644
--- a/tests/scanner/Regress-1.0-expected.gir
+++ b/tests/scanner/Regress-1.0-expected.gir
@@ -3134,6 +3134,19 @@ case.</doc>
</instance-parameter>
</parameters>
</method>
+ <method name="emit_sig_with_inout_int"
+ c:identifier="regress_test_obj_emit_sig_with_inout_int">
+ <doc xml:space="preserve">The signal handler must increment the inout parameter by 1.</doc>
+ <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">The object to emit the signal.</doc>
+ <type name="TestObj" c:type="RegressTestObj*"/>
+ </instance-parameter>
+ </parameters>
+ </method>
<method name="emit_sig_with_int64"
c:identifier="regress_test_obj_emit_sig_with_int64">
<return-value transfer-ownership="none">
@@ -3787,6 +3800,23 @@ raise from the introspection client language.</doc>
</parameter>
</parameters>
</glib:signal>
+ <glib:signal name="sig-with-inout-int" when="last">
+ <doc xml:space="preserve">This signal is modeled after GtkEditable::insert-text.</doc>
+ <return-value transfer-ownership="none">
+ <type name="none" c:type="void"/>
+ </return-value>
+ <parameters>
+ <parameter name="position"
+ direction="inout"
+ caller-allocates="0"
+ transfer-ownership="full">
+ <doc xml:space="preserve">The position, in characters, at which to
+ insert the new text. This is an in-out paramter. After the signal
+ emission is finished, it should point after the newly inserted text.</doc>
+ <type name="gint" c:type="gpointer"/>
+ </parameter>
+ </parameters>
+ </glib:signal>
<glib:signal name="sig-with-int64-prop" when="last">
<doc xml:space="preserve">You can use this with regress_test_obj_emit_sig_with_int64, or raise from
the introspection client langage.</doc>
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index 2cf4cddb..a321c5eb 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -2279,6 +2279,7 @@ enum {
REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INT64_PROP,
REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_UINT64_PROP,
REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INTARRAY_RET,
+ REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INOUT_INT,
N_REGRESS_TEST_OBJ_SIGNALS
};
@@ -2529,6 +2530,27 @@ regress_test_obj_class_init (RegressTestObjClass *klass)
1,
G_TYPE_INT);
+ /**
+ * RegressTestObj::sig-with-inout-int
+ * @self: The object that emitted the signal
+ * @position: (inout) (type int): The position, in characters, at which to
+ * insert the new text. This is an in-out paramter. After the signal
+ * emission is finished, it should point after the newly inserted text.
+ *
+ * This signal is modeled after GtkEditable::insert-text.
+ */
+ regress_test_obj_signals[REGRESS_TEST_OBJ_SIGNAL_SIG_WITH_INOUT_INT] =
+ g_signal_new ("sig-with-inout-int",
+ G_TYPE_FROM_CLASS (gobject_class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL,
+ NULL,
+ NULL,
+ G_TYPE_NONE,
+ 1,
+ G_TYPE_POINTER);
+
gobject_class->set_property = regress_test_obj_set_property;
gobject_class->get_property = regress_test_obj_get_property;
gobject_class->dispose = regress_test_obj_dispose;
@@ -2807,6 +2829,20 @@ regress_test_obj_emit_sig_with_array_len_prop (RegressTestObj *obj)
g_signal_emit_by_name (obj, "sig-with-array-len-prop", &arr, 5);
}
+/**
+ * regress_test_obj_emit_sig_with_inout_int:
+ * @obj: The object to emit the signal.
+ *
+ * The signal handler must increment the inout parameter by 1.
+ */
+void
+regress_test_obj_emit_sig_with_inout_int (RegressTestObj *obj)
+{
+ int inout = 42;
+ g_signal_emit_by_name (obj, "sig-with-inout-int", &inout);
+ g_assert_cmpint (inout, ==, 43);
+}
+
int
regress_test_obj_instance_method (RegressTestObj *obj)
{
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index d88df3f2..f07d162c 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -840,6 +840,9 @@ _GI_TEST_EXTERN
void regress_test_obj_emit_sig_with_array_len_prop (RegressTestObj *obj);
_GI_TEST_EXTERN
+void regress_test_obj_emit_sig_with_inout_int (RegressTestObj *obj);
+
+_GI_TEST_EXTERN
int regress_test_obj_instance_method (RegressTestObj *obj);
_GI_TEST_EXTERN