summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGiovanni Campagna <gcampagna@src.gnome.org>2012-11-20 00:20:46 +0100
committerGiovanni Campagna <gcampagna@src.gnome.org>2012-11-20 23:00:55 +0100
commit5153efd29e9a813a97d58905340c0ec4af04c5bd (patch)
treeac2699858b8531a4f51c390793f8774df0fbd457 /tests
parent3c8927ddff09745cd30654fe99c68ed9bcae6118 (diff)
downloadgobject-introspection-5153efd29e9a813a97d58905340c0ec4af04c5bd.tar.gz
Add more tests for boxed types
gjs needs a boxed type that cannot be trivially allocated but has also a complex constructor. https://bugzilla.gnome.org/show_bug.cgi?id=612033
Diffstat (limited to 'tests')
-rw-r--r--tests/scanner/regress.c47
-rw-r--r--tests/scanner/regress.h10
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index bdc1dc3c..b7526bfb 100644
--- a/tests/scanner/regress.c
+++ b/tests/scanner/regress.c
@@ -1953,6 +1953,53 @@ G_DEFINE_BOXED_TYPE(RegressTestBoxedC,
regress_test_boxed_c_ref,
regress_test_boxed_c_unref);
+struct _RegressTestBoxedD {
+ char *a_string;
+ gint a_int;
+};
+
+RegressTestBoxedD *
+regress_test_boxed_d_new (const char *a_string, int a_int)
+{
+ RegressTestBoxedD *boxed;
+
+ boxed = g_slice_new (RegressTestBoxedD);
+ boxed->a_string = g_strdup (a_string);
+ boxed->a_int = a_int;
+
+ return boxed;
+}
+
+RegressTestBoxedD *
+regress_test_boxed_d_copy (RegressTestBoxedD *boxed)
+{
+ RegressTestBoxedD *ret;
+
+ ret = g_slice_new (RegressTestBoxedD);
+ ret->a_string = g_strdup (boxed->a_string);
+ ret->a_int = boxed->a_int;
+
+ return ret;
+}
+
+void
+regress_test_boxed_d_free (RegressTestBoxedD *boxed)
+{
+ g_free (boxed->a_string);
+ g_slice_free (RegressTestBoxedD, boxed);
+}
+
+int
+regress_test_boxed_d_get_magic (RegressTestBoxedD *boxed)
+{
+ return strlen (boxed->a_string) + boxed->a_int;
+}
+
+G_DEFINE_BOXED_TYPE(RegressTestBoxedD,
+ regress_test_boxed_d,
+ regress_test_boxed_d_copy,
+ regress_test_boxed_d_free);
+
G_DEFINE_TYPE(RegressTestObj, regress_test_obj, G_TYPE_OBJECT);
enum
diff --git a/tests/scanner/regress.h b/tests/scanner/regress.h
index 137c4e04..d8a3002e 100644
--- a/tests/scanner/regress.h
+++ b/tests/scanner/regress.h
@@ -432,6 +432,16 @@ struct _RegressTestBoxedC
GType regress_test_boxed_c_get_type (void);
RegressTestBoxedC *regress_test_boxed_c_new (void);
+typedef struct _RegressTestBoxedD RegressTestBoxedD;
+
+GType regress_test_boxed_d_get_type (void);
+
+RegressTestBoxedD *regress_test_boxed_d_new (const char *a_string, int a_int);
+RegressTestBoxedD *regress_test_boxed_d_copy (RegressTestBoxedD *boxed);
+void regress_test_boxed_d_free (RegressTestBoxedD *boxed);
+
+int regress_test_boxed_d_get_magic (RegressTestBoxedD *boxed);
+
/* gobject */
#define REGRESS_TEST_TYPE_OBJ (regress_test_obj_get_type ())
#define REGRESS_TEST_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), REGRESS_TEST_TYPE_OBJ, RegressTestObj))