/* structs_structs.c generated by valac, the Vala compiler * generated from structs_structs.vala, do not modify */ #include #include #include #include #if !defined(VALA_EXTERN) #if defined(_WIN32) || defined(__CYGWIN__) #define VALA_EXTERN __declspec(dllexport) extern #elif __GNUC__ >= 4 #define VALA_EXTERN __attribute__((visibility("default"))) extern #else #define VALA_EXTERN extern #endif #endif #define TYPE_SIMPLE_STRUCT (simple_struct_get_type ()) typedef struct _SimpleStruct SimpleStruct; #define TYPE_PUBLIC_STRUCT (public_struct_get_type ()) typedef struct _PublicStruct PublicStruct; #define TYPE_STRUCT_WITH_CREATION_METHOD (struct_with_creation_method_get_type ()) typedef struct _StructWithCreationMethod StructWithCreationMethod; #define TYPE_STRUCT_WITH_NAMED_CREATION_METHOD (struct_with_named_creation_method_get_type ()) typedef struct _StructWithNamedCreationMethod StructWithNamedCreationMethod; typedef void (*Func) (gpointer user_data); #define TYPE_STRUCT_WITH_FUNC (struct_with_func_get_type ()) typedef struct _StructWithFunc StructWithFunc; #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); #define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; } #define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; } #define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg); struct _SimpleStruct { gint field; gint array[10]; }; struct _PublicStruct { gint field; }; struct _StructWithCreationMethod { gint field; }; struct _StructWithNamedCreationMethod { gint field; }; struct _StructWithFunc { Func foo; gpointer foo_target; GDestroyNotify foo_target_destroy_notify; }; VALA_EXTERN GType simple_struct_get_type (void) G_GNUC_CONST ; VALA_EXTERN SimpleStruct* simple_struct_dup (const SimpleStruct* self); VALA_EXTERN void simple_struct_free (SimpleStruct* self); VALA_EXTERN GType public_struct_get_type (void) G_GNUC_CONST ; VALA_EXTERN PublicStruct* public_struct_dup (const PublicStruct* self); VALA_EXTERN void public_struct_free (PublicStruct* self); VALA_EXTERN GType struct_with_creation_method_get_type (void) G_GNUC_CONST ; VALA_EXTERN StructWithCreationMethod* struct_with_creation_method_dup (const StructWithCreationMethod* self); VALA_EXTERN void struct_with_creation_method_free (StructWithCreationMethod* self); VALA_EXTERN void struct_with_creation_method_init (StructWithCreationMethod *self); VALA_EXTERN GType struct_with_named_creation_method_get_type (void) G_GNUC_CONST ; VALA_EXTERN StructWithNamedCreationMethod* struct_with_named_creation_method_dup (const StructWithNamedCreationMethod* self); VALA_EXTERN void struct_with_named_creation_method_free (StructWithNamedCreationMethod* self); VALA_EXTERN void struct_with_named_creation_method_init_named (StructWithNamedCreationMethod *self); VALA_EXTERN GType struct_with_func_get_type (void) G_GNUC_CONST ; VALA_EXTERN StructWithFunc* struct_with_func_dup (const StructWithFunc* self); VALA_EXTERN void struct_with_func_free (StructWithFunc* self); VALA_EXTERN void struct_with_func_copy (const StructWithFunc* self, StructWithFunc* dest); VALA_EXTERN void struct_with_func_destroy (StructWithFunc* self); G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (StructWithFunc, struct_with_func_destroy) VALA_EXTERN void struct_with_func_init (StructWithFunc *self, Func f, gpointer f_target, GDestroyNotify f_target_destroy_notify); VALA_EXTERN void test_in_parameter (SimpleStruct* st); VALA_EXTERN void test_in_nullable_parameter (SimpleStruct* st); VALA_EXTERN void test_ref_parameter (SimpleStruct* st); VALA_EXTERN void test_out_parameter (SimpleStruct* st); VALA_EXTERN void test_struct_with_func (void); static void _vala_lambda0_ (void); static void __vala_lambda0__func (gpointer self); static void _vala_StructWithFunc_array_free (StructWithFunc * array, gssize array_length); static void _vala_main (void); SimpleStruct* simple_struct_dup (const SimpleStruct* self) { SimpleStruct* dup; dup = g_new0 (SimpleStruct, 1); memcpy (dup, self, sizeof (SimpleStruct)); return dup; } void simple_struct_free (SimpleStruct* self) { g_free (self); } static GType simple_struct_get_type_once (void) { GType simple_struct_type_id; simple_struct_type_id = g_boxed_type_register_static ("SimpleStruct", (GBoxedCopyFunc) simple_struct_dup, (GBoxedFreeFunc) simple_struct_free); return simple_struct_type_id; } GType simple_struct_get_type (void) { static volatile gsize simple_struct_type_id__once = 0; if (g_once_init_enter (&simple_struct_type_id__once)) { GType simple_struct_type_id; simple_struct_type_id = simple_struct_get_type_once (); g_once_init_leave (&simple_struct_type_id__once, simple_struct_type_id); } return simple_struct_type_id__once; } PublicStruct* public_struct_dup (const PublicStruct* self) { PublicStruct* dup; dup = g_new0 (PublicStruct, 1); memcpy (dup, self, sizeof (PublicStruct)); return dup; } void public_struct_free (PublicStruct* self) { g_free (self); } static GType public_struct_get_type_once (void) { GType public_struct_type_id; public_struct_type_id = g_boxed_type_register_static ("PublicStruct", (GBoxedCopyFunc) public_struct_dup, (GBoxedFreeFunc) public_struct_free); return public_struct_type_id; } GType public_struct_get_type (void) { static volatile gsize public_struct_type_id__once = 0; if (g_once_init_enter (&public_struct_type_id__once)) { GType public_struct_type_id; public_struct_type_id = public_struct_get_type_once (); g_once_init_leave (&public_struct_type_id__once, public_struct_type_id); } return public_struct_type_id__once; } void struct_with_creation_method_init (StructWithCreationMethod *self) { FILE* _tmp0_; memset (self, 0, sizeof (StructWithCreationMethod)); _tmp0_ = stdout; fprintf (_tmp0_, "StructWithCreationMethod\n"); } StructWithCreationMethod* struct_with_creation_method_dup (const StructWithCreationMethod* self) { StructWithCreationMethod* dup; dup = g_new0 (StructWithCreationMethod, 1); memcpy (dup, self, sizeof (StructWithCreationMethod)); return dup; } void struct_with_creation_method_free (StructWithCreationMethod* self) { g_free (self); } static GType struct_with_creation_method_get_type_once (void) { GType struct_with_creation_method_type_id; struct_with_creation_method_type_id = g_boxed_type_register_static ("StructWithCreationMethod", (GBoxedCopyFunc) struct_with_creation_method_dup, (GBoxedFreeFunc) struct_with_creation_method_free); return struct_with_creation_method_type_id; } GType struct_with_creation_method_get_type (void) { static volatile gsize struct_with_creation_method_type_id__once = 0; if (g_once_init_enter (&struct_with_creation_method_type_id__once)) { GType struct_with_creation_method_type_id; struct_with_creation_method_type_id = struct_with_creation_method_get_type_once (); g_once_init_leave (&struct_with_creation_method_type_id__once, struct_with_creation_method_type_id); } return struct_with_creation_method_type_id__once; } void struct_with_named_creation_method_init_named (StructWithNamedCreationMethod *self) { FILE* _tmp0_; memset (self, 0, sizeof (StructWithNamedCreationMethod)); _tmp0_ = stdout; fprintf (_tmp0_, "StructWithNamedCreationMethod\n"); } StructWithNamedCreationMethod* struct_with_named_creation_method_dup (const StructWithNamedCreationMethod* self) { StructWithNamedCreationMethod* dup; dup = g_new0 (StructWithNamedCreationMethod, 1); memcpy (dup, self, sizeof (StructWithNamedCreationMethod)); return dup; } void struct_with_named_creation_method_free (StructWithNamedCreationMethod* self) { g_free (self); } static GType struct_with_named_creation_method_get_type_once (void) { GType struct_with_named_creation_method_type_id; struct_with_named_creation_method_type_id = g_boxed_type_register_static ("StructWithNamedCreationMethod", (GBoxedCopyFunc) struct_with_named_creation_method_dup, (GBoxedFreeFunc) struct_with_named_creation_method_free); return struct_with_named_creation_method_type_id; } GType struct_with_named_creation_method_get_type (void) { static volatile gsize struct_with_named_creation_method_type_id__once = 0; if (g_once_init_enter (&struct_with_named_creation_method_type_id__once)) { GType struct_with_named_creation_method_type_id; struct_with_named_creation_method_type_id = struct_with_named_creation_method_get_type_once (); g_once_init_leave (&struct_with_named_creation_method_type_id__once, struct_with_named_creation_method_type_id); } return struct_with_named_creation_method_type_id__once; } void struct_with_func_init (StructWithFunc *self, Func f, gpointer f_target, GDestroyNotify f_target_destroy_notify) { Func _tmp0_; gpointer _tmp0__target; GDestroyNotify _tmp0__target_destroy_notify; memset (self, 0, sizeof (StructWithFunc)); _tmp0_ = f; _tmp0__target = f_target; _tmp0__target_destroy_notify = f_target_destroy_notify; f = NULL; f_target = NULL; f_target_destroy_notify = NULL; ((*self).foo_target_destroy_notify == NULL) ? NULL : ((*self).foo_target_destroy_notify ((*self).foo_target), NULL); (*self).foo = NULL; (*self).foo_target = NULL; (*self).foo_target_destroy_notify = NULL; (*self).foo = _tmp0_; (*self).foo_target = _tmp0__target; (*self).foo_target_destroy_notify = _tmp0__target_destroy_notify; (f_target_destroy_notify == NULL) ? NULL : (f_target_destroy_notify (f_target), NULL); f = NULL; f_target = NULL; f_target_destroy_notify = NULL; } void struct_with_func_copy (const StructWithFunc* self, StructWithFunc* dest) { Func _tmp0_; gpointer _tmp0__target; _tmp0_ = (*self).foo; _tmp0__target = (*self).foo_target; ((*dest).foo_target_destroy_notify == NULL) ? NULL : ((*dest).foo_target_destroy_notify ((*dest).foo_target), NULL); (*dest).foo = NULL; (*dest).foo_target = NULL; (*dest).foo_target_destroy_notify = NULL; (*dest).foo = _tmp0_; (*dest).foo_target = _tmp0__target; (*dest).foo_target_destroy_notify = NULL; } void struct_with_func_destroy (StructWithFunc* self) { ((*self).foo_target_destroy_notify == NULL) ? NULL : ((*self).foo_target_destroy_notify ((*self).foo_target), NULL); (*self).foo = NULL; (*self).foo_target = NULL; (*self).foo_target_destroy_notify = NULL; } StructWithFunc* struct_with_func_dup (const StructWithFunc* self) { StructWithFunc* dup; dup = g_new0 (StructWithFunc, 1); struct_with_func_copy (self, dup); return dup; } void struct_with_func_free (StructWithFunc* self) { struct_with_func_destroy (self); g_free (self); } static GType struct_with_func_get_type_once (void) { GType struct_with_func_type_id; struct_with_func_type_id = g_boxed_type_register_static ("StructWithFunc", (GBoxedCopyFunc) struct_with_func_dup, (GBoxedFreeFunc) struct_with_func_free); return struct_with_func_type_id; } GType struct_with_func_get_type (void) { static volatile gsize struct_with_func_type_id__once = 0; if (g_once_init_enter (&struct_with_func_type_id__once)) { GType struct_with_func_type_id; struct_with_func_type_id = struct_with_func_get_type_once (); g_once_init_leave (&struct_with_func_type_id__once, struct_with_func_type_id); } return struct_with_func_type_id__once; } void test_in_parameter (SimpleStruct* st) { FILE* _tmp0_; SimpleStruct _tmp1_; g_return_if_fail (st != NULL); _tmp0_ = stdout; _tmp1_ = *st; fprintf (_tmp0_, "test_in_parameter: st.field = %d\n", _tmp1_.field); } void test_in_nullable_parameter (SimpleStruct* st) { _vala_assert ((*st).field == 1, "st.field == 1"); } void test_ref_parameter (SimpleStruct* st) { FILE* _tmp0_; SimpleStruct _tmp1_; gint _tmp2_; g_return_if_fail (st != NULL); _tmp0_ = stdout; _tmp1_ = *st; fprintf (_tmp0_, "test_ref_parameter: st.field = %d\n", _tmp1_.field); _tmp2_ = (*st).field; (*st).field = _tmp2_ + 1; (*st).array[0] = 10; } void test_out_parameter (SimpleStruct* st) { SimpleStruct _vala_st = {0}; memset (&_vala_st, 0, sizeof (SimpleStruct)); _vala_st.field = 3; if (st) { *st = _vala_st; } } static void _vala_lambda0_ (void) { } static void __vala_lambda0__func (gpointer self) { _vala_lambda0_ (); } static void _vala_StructWithFunc_array_free (StructWithFunc * array, gssize array_length) { if (array != NULL) { gssize i; for (i = 0; i < array_length; i = i + 1) { struct_with_func_destroy (&array[i]); } } g_free (array); } void test_struct_with_func (void) { StructWithFunc* foes = NULL; StructWithFunc _tmp0_ = {0}; StructWithFunc* _tmp1_; gint foes_length1; gint _foes_size_; struct_with_func_init (&_tmp0_, __vala_lambda0__func, NULL, NULL); _tmp1_ = g_new0 (StructWithFunc, 1); _tmp1_[0] = _tmp0_; foes = _tmp1_; foes_length1 = 1; _foes_size_ = foes_length1; foes = (_vala_StructWithFunc_array_free (foes, foes_length1), NULL); } static void _vala_main (void) { FILE* _tmp0_; FILE* _tmp1_; SimpleStruct simple_struct = {0}; FILE* _tmp2_; PublicStruct public_struct = {0}; FILE* _tmp3_; StructWithCreationMethod struct_with_creation_method = {0}; FILE* _tmp4_; StructWithNamedCreationMethod struct_with_named_creation_method = {0}; FILE* _tmp5_; SimpleStruct _tmp6_ = {0}; FILE* _tmp7_; SimpleStruct _tmp8_; SimpleStruct _tmp9_; SimpleStruct _tmp10_ = {0}; SimpleStruct _tmp11_; FILE* _tmp12_; SimpleStruct _tmp13_; SimpleStruct _tmp14_; gint _tmp15_; SimpleStruct _tmp16_ = {0}; FILE* _tmp17_; SimpleStruct _tmp18_; FILE* _tmp19_; _tmp0_ = stdout; fprintf (_tmp0_, "Structs Test:\n"); _tmp1_ = stdout; fprintf (_tmp1_, "new SimpleStruct ()\n"); memset (&simple_struct, 0, sizeof (SimpleStruct)); _tmp2_ = stdout; fprintf (_tmp2_, "new PublicStruct ()\n"); memset (&public_struct, 0, sizeof (PublicStruct)); _tmp3_ = stdout; fprintf (_tmp3_, "new StructWithCreationMethod ()\n"); struct_with_creation_method_init (&struct_with_creation_method); _tmp4_ = stdout; fprintf (_tmp4_, "new StructWithNamedCreationMethod ()\n"); struct_with_named_creation_method_init_named (&struct_with_named_creation_method); _tmp5_ = stdout; fprintf (_tmp5_, "new SimpleStruct () { field = 1 }\n"); memset (&_tmp6_, 0, sizeof (SimpleStruct)); _tmp6_.field = 1; simple_struct = _tmp6_; _tmp7_ = stdout; _tmp8_ = simple_struct; fprintf (_tmp7_, "simple_struct.field = %d\n", _tmp8_.field); _tmp9_ = simple_struct; test_in_parameter (&_tmp9_); _tmp10_.field = 1; test_in_parameter (&_tmp10_); _tmp11_ = simple_struct; test_in_nullable_parameter (&_tmp11_); test_ref_parameter (&simple_struct); _tmp12_ = stdout; _tmp13_ = simple_struct; fprintf (_tmp12_, "after test_ref_parameter: st.field = %d\n", _tmp13_.field); _tmp14_ = simple_struct; _tmp15_ = _tmp14_.array[0]; _vala_assert (_tmp15_ == 10, "simple_struct.array[0] == 10"); test_out_parameter (&_tmp16_); simple_struct = _tmp16_; _tmp17_ = stdout; _tmp18_ = simple_struct; fprintf (_tmp17_, "after test_out_parameter: st.field = %d\n", _tmp18_.field); _tmp19_ = stdout; fprintf (_tmp19_, ".\n"); } int main (int argc, char ** argv) { _vala_main (); return 0; }