[gobject-introspection] Add more tests for boxed types



commit 5153efd29e9a813a97d58905340c0ec4af04c5bd
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Tue Nov 20 00:20:46 2012 +0100

    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

 tests/scanner/regress.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 tests/scanner/regress.h |   10 ++++++++++
 2 files changed, 57 insertions(+), 0 deletions(-)
---
diff --git a/tests/scanner/regress.c b/tests/scanner/regress.c
index bdc1dc3..b7526bf 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 137c4e0..d8a3002 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))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]