From 95b9f1832daee474d439f680d80a6538649e7aef Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Fri, 23 Apr 2010 16:32:08 +0200 Subject: Add tests for unions --- gir/gimarshallingtests.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ gir/gimarshallingtests.h | 15 ++++++++ 2 files changed, 112 insertions(+) diff --git a/gir/gimarshallingtests.c b/gir/gimarshallingtests.c index 5f09633b..cf509a79 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 b38c9c9c..678ab360 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 */ -- cgit v1.2.1