diff options
author | Simon van der Linden <svdlinden@src.gnome.org> | 2009-06-28 16:05:46 +0200 |
---|---|---|
committer | Simon van der Linden <svdlinden@src.gnome.org> | 2009-07-05 15:00:22 +0200 |
commit | 11af62358ce600cecceb7af858074281901d5067 (patch) | |
tree | ae61175b19508e1bf51e515b6e379336b4b61c32 | |
parent | 5f811f2d0d192c3d546b91e12fcf74b341434ca9 (diff) | |
download | gobject-introspection-11af62358ce600cecceb7af858074281901d5067.tar.gz |
Add a TestObj subclass in Everything
Add an instance method to TestObj.
Add a TestObj subclass in Everything, with another constructor, an
additional instance method and an overridden instance method.
-rw-r--r-- | gir/Everything-1.0-expected.gir | 38 | ||||
-rw-r--r-- | gir/everything.c | 37 | ||||
-rw-r--r-- | gir/everything.h | 25 |
3 files changed, 100 insertions, 0 deletions
diff --git a/gir/Everything-1.0-expected.gir b/gir/Everything-1.0-expected.gir index d762bb55..35aa7709 100644 --- a/gir/Everything-1.0-expected.gir +++ b/gir/Everything-1.0-expected.gir @@ -159,6 +159,11 @@ and/or use gtk-doc annotations. --> </parameter> </parameters> </method> + <method name="instance_method" c:identifier="test_obj_instance_method"> + <return-value transfer-ownership="none"> + <type name="int" c:type="int"/> + </return-value> + </method> <method name="do_matrix" c:identifier="test_obj_do_matrix" doc="This method is virtual. Notably its name differs from the virtual @@ -332,6 +337,39 @@ case."> <type name="GObject.Object" c:type="GObject*"/> </field> </record> + <class name="TestSubObj" + c:type="TestSubObj" + parent="TestObj" + glib:type-name="TestSubObj" + glib:get-type="test_sub_obj_get_type" + glib:type-struct="TestSubObjClass"> + <constructor name="new" c:identifier="test_sub_obj_new"> + <return-value transfer-ownership="full"> + <type name="TestSubObj" c:type="TestSubObj*"/> + </return-value> + </constructor> + <method name="unset_bare" c:identifier="test_sub_obj_unset_bare"> + <return-value transfer-ownership="none"> + <type name="none" c:type="void"/> + </return-value> + </method> + <method name="instance_method" + c:identifier="test_sub_obj_instance_method"> + <return-value transfer-ownership="none"> + <type name="int" c:type="int"/> + </return-value> + </method> + <field name="parent_instance"> + <type name="TestObj" c:type="TestObj"/> + </field> + </class> + <record name="TestSubObjClass" + c:type="TestSubObjClass" + glib:is-gtype-struct-for="TestSubObj"> + <field name="parent_class"> + <type name="TestObjClass" c:type="TestObjClass"/> + </field> + </record> <class name="TestWi8021x" c:type="TestWi8021x" parent="GObject.Object" diff --git a/gir/everything.c b/gir/everything.c index 62a80109..2eedeef0 100644 --- a/gir/everything.c +++ b/gir/everything.c @@ -1423,6 +1423,12 @@ test_obj_set_bare (TestObj *obj, GObject *bare) g_object_ref (obj->bare); } +int +test_obj_instance_method (TestObj *obj) +{ + return -1; +} + double test_obj_static_method (int x) { @@ -1456,6 +1462,37 @@ struct _CallbackInfo }; +G_DEFINE_TYPE(TestSubObj, test_sub_obj, TEST_TYPE_OBJ); + +static void +test_sub_obj_class_init (TestSubObjClass *klass) +{ +} + +static void +test_sub_obj_init (TestSubObj *obj) +{ +} + +TestSubObj* +test_sub_obj_new () +{ + return g_object_new (TEST_TYPE_SUB_OBJ, NULL); +} + +int +test_sub_obj_instance_method (TestSubObj *obj) +{ + return 0; +} + +void +test_sub_obj_unset_bare (TestSubObj *obj) +{ + test_obj_set_bare(TEST_OBJECT(obj), NULL); +} + + /** * test_callback: * @callback: (scope call): diff --git a/gir/everything.h b/gir/everything.h index 8ce29c5a..d566f5f8 100644 --- a/gir/everything.h +++ b/gir/everything.h @@ -249,11 +249,36 @@ struct _TestObjClass GType test_obj_get_type (void); TestObj* test_obj_new_from_file (const char *x, GError **error); void test_obj_set_bare (TestObj *obj, GObject *bare); +int test_obj_instance_method (TestObj *obj); double test_obj_static_method (int x); /* virtual */ int test_obj_do_matrix (TestObj *obj, const char *somestr); +/* inheritance */ +#define TEST_TYPE_SUB_OBJ (test_sub_obj_get_type ()) +#define TEST_SUB_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), TEST_TYPE_SUB_OBJ, TestSubObj)) +#define TEST_IS_SUB_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), TEST_TYPE_SUB_OBJ)) +#define TEST_SUB_OBJ_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TEST_TYPE_SUB_OBJ, TestSubObjClass)) + +typedef struct _TestSubObj TestSubObj; +typedef struct _TestSubObjClass TestSubObjClass; + +struct _TestSubObj +{ + TestObj parent_instance; +}; + +struct _TestSubObjClass +{ + TestObjClass parent_class; +}; + +GType test_sub_obj_get_type (void); +TestSubObj* test_sub_obj_new (void); +void test_sub_obj_unset_bare (TestSubObj *obj); +int test_sub_obj_instance_method (TestSubObj *obj); + /* callback */ typedef int (*TestCallback) (); typedef int (*TestCallbackUserData) (gpointer user_data); |