diff options
author | Philip Chimento <philip.chimento@gmail.com> | 2018-06-21 01:41:00 +0000 |
---|---|---|
committer | Philip Chimento <philip.chimento@gmail.com> | 2018-06-21 01:41:00 +0000 |
commit | 1636bb0ef2b294ca07eea0aae51f16a984044c8c (patch) | |
tree | b5d3c46b463861d79527a47f119c64604f2404f8 | |
parent | 7043bb4b6842ba5572a4cf289a720b4044aeab5f (diff) | |
parent | ecf5b9ddb7a38b4bd44ce5c8678604145d906536 (diff) | |
download | gobject-introspection-1636bb0ef2b294ca07eea0aae51f16a984044c8c.tar.gz |
Merge branch 'regress-tests-interface-inout' into 'master'
Regress tests for interface signals and signals with inout params
See merge request GNOME/gobject-introspection!32
-rw-r--r-- | tests/gimarshallingtests.c | 11 | ||||
-rw-r--r-- | tests/scanner/Regress-1.0-expected.gir | 54 | ||||
-rw-r--r-- | tests/scanner/regress.c | 63 | ||||
-rw-r--r-- | tests/scanner/regress.h | 6 |
4 files changed, 133 insertions, 1 deletions
diff --git a/tests/gimarshallingtests.c b/tests/gimarshallingtests.c index 92c181a4..0ddaed71 100644 --- a/tests/gimarshallingtests.c +++ b/tests/gimarshallingtests.c @@ -5356,6 +5356,7 @@ enum SOME_FLAGS_PROPERTY, SOME_ENUM_PROPERTY, SOME_BYTE_ARRAY_PROPERTY, + SOME_READONLY_PROPERTY, }; G_DEFINE_TYPE (GIMarshallingTestsPropertiesObject, gi_marshalling_tests_properties_object, G_TYPE_OBJECT); @@ -5451,6 +5452,9 @@ gi_marshalling_tests_properties_object_get_property (GObject *object, case SOME_BYTE_ARRAY_PROPERTY: g_value_set_boxed (value, self->some_byte_array); break; + case SOME_READONLY_PROPERTY: + g_value_set_int (value, 42); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -5698,6 +5702,13 @@ static void gi_marshalling_tests_properties_object_class_init (GIMarshallingTest "some-byte-array", G_TYPE_BYTE_ARRAY, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + + g_object_class_install_property (object_class, SOME_READONLY_PROPERTY, + g_param_spec_int ("some-readonly", + "some-readonly", + "some-readonly", + G_MININT, G_MAXINT, 0, + G_PARAM_READABLE)); } GIMarshallingTestsPropertiesObject * diff --git a/tests/scanner/Regress-1.0-expected.gir b/tests/scanner/Regress-1.0-expected.gir index 39f5d05d..ad6af895 100644 --- a/tests/scanner/Regress-1.0-expected.gir +++ b/tests/scanner/Regress-1.0-expected.gir @@ -2907,6 +2907,30 @@ use it should be.</doc> glib:type-name="RegressTestInterface" glib:get-type="regress_test_interface_get_type" glib:type-struct="TestInterfaceIface"> + <method name="emit_signal" + c:identifier="regress_test_interface_emit_signal"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <instance-parameter name="self" transfer-ownership="none"> + <doc xml:space="preserve">the object to emit the signal</doc> + <type name="TestInterface" c:type="RegressTestInterface*"/> + </instance-parameter> + </parameters> + </method> + <glib:signal name="interface-signal" when="last"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + <parameters> + <parameter name="ptr" transfer-ownership="none"> + <doc xml:space="preserve">the code must look up the signal with + g_interface_info_find_signal() in order to get this to work.</doc> + <type name="gint" c:type="gpointer"/> + </parameter> + </parameters> + </glib:signal> </interface> <record name="TestInterfaceIface" c:type="RegressTestInterfaceIface" @@ -3110,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"> @@ -3763,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 3c186238..e1da3d17 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; @@ -2646,7 +2668,7 @@ regress_test_obj_class_init (RegressTestObjClass *klass) "A contained double", G_MINDOUBLE, G_MAXDOUBLE, - 1.0f, + 1.0, G_PARAM_READWRITE); g_object_class_install_property (gobject_class, PROP_TEST_OBJ_DOUBLE, @@ -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) { @@ -3908,6 +3944,31 @@ G_DEFINE_INTERFACE (RegressTestInterface, regress_test_interface, G_TYPE_OBJECT) static void regress_test_interface_default_init(RegressTestInterfaceIface *iface) { + static gboolean initialized = FALSE; + if (initialized) + return; + + /** + * RegressTestInterface::interface-signal: + * @self: the object which emitted the signal + * @ptr: (type int): the code must look up the signal with + * g_interface_info_find_signal() in order to get this to work. + */ + g_signal_new ("interface-signal", REGRESS_TEST_TYPE_INTERFACE, + G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, + G_TYPE_NONE, 1, G_TYPE_POINTER); + + initialized = TRUE; +} + +/** + * regress_test_interface_emit_signal: + * @self: the object to emit the signal + */ +void +regress_test_interface_emit_signal (RegressTestInterface *self) +{ + g_signal_emit_by_name (self, "interface-signal", NULL); } /* gobject with non-standard prefix */ diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h index 23b5792b..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 @@ -1196,6 +1199,9 @@ struct _RegressTestInterfaceIface { _GI_TEST_EXTERN GType regress_test_interface_get_type (void) G_GNUC_CONST; +_GI_TEST_EXTERN +void regress_test_interface_emit_signal (RegressTestInterface *self); + /* gobject with non-standard prefix */ #define REGRESS_TEST_TYPE_WI_802_1X (regress_test_wi_802_1x_get_type ()) #define REGRESS_TEST_WI_802_1X(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), REGRESS_TEST_TYPE_WI_802_1X, RegressTestWi8021x)) |