[gobject-introspection] Add tests for unions



commit 95b9f1832daee474d439f680d80a6538649e7aef
Author: Tomeu Vizoso <tomeu sugarlabs org>
Date:   Fri Apr 23 16:32:08 2010 +0200

    Add tests for unions

 gir/gimarshallingtests.c |   97 ++++++++++++++++++++++++++++++++++++++++++++++
 gir/gimarshallingtests.h |   15 +++++++
 2 files changed, 112 insertions(+), 0 deletions(-)
---
diff --git a/gir/gimarshallingtests.c b/gir/gimarshallingtests.c
index 5f09633..cf509a7 100644
--- a/gir/gimarshallingtests.c
+++ b/gir/gimarshallingtests.c
@@ -2503,6 +2503,103 @@ g_i_marshalling_tests__boxed_struct_inout (GIMarshallingTestsBoxedStruct **struc
     (*struct_)->long_ = 0;
 }
 
+static GIMarshallingTestsUnion *
+g_i_marshalling_tests_union_copy (GIMarshallingTestsUnion *union_)
+{
+    GIMarshallingTestsUnion *new_union;
+
+    new_union = g_slice_new (GIMarshallingTestsUnion);
+
+    *new_union = *union_;
+
+    return new_union;
+}
+
+static void
+g_i_marshalling_tests_union_free (GIMarshallingTestsUnion *union_)
+{
+    g_slice_free (GIMarshallingTestsUnion, union_);
+}
+
+GType
+g_i_marshalling_tests_union_get_type (void)
+{
+    static GType type = 0;
+
+    if (type == 0) {
+        type = g_boxed_type_register_static ("GIMarshallingTestsUnion",
+                (GBoxedCopyFunc) g_i_marshalling_tests_union_copy,
+                (GBoxedFreeFunc) g_i_marshalling_tests_union_free);
+    }
+
+    return type;
+}
+
+/**
+ * g_i_marshalling_tests__union_return:
+ * Returns: (transfer none):
+ */
+GIMarshallingTestsUnion *
+g_i_marshalling_tests__union_return (void)
+{
+    static GIMarshallingTestsUnion *union_ = NULL;
+
+    if (union_ == NULL) {
+        union_ = g_new(GIMarshallingTestsUnion, 1);
+
+        union_->long_ = 42;
+    }
+
+    return union_;
+}
+
+/**
+ * g_i_marshalling_tests__union_in:
+ * @union_: (transfer none):
+ */
+void
+g_i_marshalling_tests__union_in (GIMarshallingTestsUnion *union_)
+{
+    g_assert(union_->long_ == 42);
+}
+
+/**
+ * g_i_marshalling_tests__union_out:
+ * @union_: (out) (transfer none):
+ */
+void
+g_i_marshalling_tests__union_out (GIMarshallingTestsUnion **union_)
+{
+    static GIMarshallingTestsUnion *new_union = NULL;
+
+    if (new_union == NULL) {
+        new_union = g_new(GIMarshallingTestsUnion, 1);
+
+        new_union->long_ = 42;
+    }
+
+    *union_ = new_union;
+}
+
+/**
+ * g_i_marshalling_tests__union_inout:
+ * @union_: (inout) (transfer none):
+ */
+void
+g_i_marshalling_tests__union_inout (GIMarshallingTestsUnion **union_)
+{
+    g_assert((*union_)->long_ == 42);
+
+    (*union_)->long_ = 0;
+}
+
+void
+g_i_marshalling_tests_union_method (GIMarshallingTestsUnion *union_)
+{
+    g_assert(union_->long_ == 42);
+}
+
+
 
 enum
 {
diff --git a/gir/gimarshallingtests.h b/gir/gimarshallingtests.h
index b38c9c9..678ab36 100644
--- a/gir/gimarshallingtests.h
+++ b/gir/gimarshallingtests.h
@@ -497,6 +497,21 @@ void g_i_marshalling_tests__boxed_struct_out (GIMarshallingTestsBoxedStruct **st
 
 void g_i_marshalling_tests__boxed_struct_inout (GIMarshallingTestsBoxedStruct **struct_);
 
+typedef union {
+    glong long_;
+} GIMarshallingTestsUnion;
+
+GType g_i_marshalling_tests_union_get_type (void) G_GNUC_CONST;
+
+GIMarshallingTestsUnion *g_i_marshalling_tests__union_return (void);
+
+void g_i_marshalling_tests__union_in (GIMarshallingTestsUnion *union_);
+
+void g_i_marshalling_tests__union_out (GIMarshallingTestsUnion **union_);
+
+void g_i_marshalling_tests__union_inout (GIMarshallingTestsUnion **union_);
+
+void g_i_marshalling_tests_union_method (GIMarshallingTestsUnion *union_);
 
 /* Object */
 



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