/* structs_struct_initializer_list_nested.c generated by valac, the Vala compiler * generated from structs_struct_initializer_list_nested.vala, do not modify */ #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_FOO (foo_get_type ()) typedef struct _Foo Foo; #define TYPE_BAR (bar_get_type ()) typedef struct _Bar Bar; #define _foo_free0(var) ((var == NULL) ? NULL : (var = (foo_free (var), NULL))) #define TYPE_MANAM (manam_get_type ()) typedef struct _Manam Manam; #define TYPE_BAZ (baz_get_type ()) typedef struct _Baz Baz; #define _bar_free0(var) ((var == NULL) ? NULL : (var = (bar_free (var), NULL))) #define _manam_free0(var) ((var == NULL) ? NULL : (var = (manam_free (var), NULL))) #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 _Foo { gint i; gint j; }; struct _Bar { Foo a; Foo* b; }; struct _Manam { Foo a; Bar b; }; struct _Baz { Foo f; }; VALA_EXTERN GType foo_get_type (void) G_GNUC_CONST ; VALA_EXTERN Foo* foo_dup (const Foo* self); VALA_EXTERN void foo_free (Foo* self); VALA_EXTERN GType bar_get_type (void) G_GNUC_CONST ; VALA_EXTERN Bar* bar_dup (const Bar* self); VALA_EXTERN void bar_free (Bar* self); VALA_EXTERN void bar_copy (const Bar* self, Bar* dest); VALA_EXTERN void bar_destroy (Bar* self); G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (Bar, bar_destroy) VALA_EXTERN GType manam_get_type (void) G_GNUC_CONST ; VALA_EXTERN Manam* manam_dup (const Manam* self); VALA_EXTERN void manam_free (Manam* self); VALA_EXTERN void manam_copy (const Manam* self, Manam* dest); VALA_EXTERN void manam_destroy (Manam* self); G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (Manam, manam_destroy) VALA_EXTERN GType baz_get_type (void) G_GNUC_CONST ; VALA_EXTERN Baz* baz_dup (const Baz* self); VALA_EXTERN void baz_free (Baz* self); static void _vala_main (void); const Baz BAZ = {{23, 42}}; const Baz BAZ_A[2] = {{{23, 42}}, {{47, 11}}}; Foo* foo_dup (const Foo* self) { Foo* dup; dup = g_new0 (Foo, 1); memcpy (dup, self, sizeof (Foo)); return dup; } void foo_free (Foo* self) { g_free (self); } static GType foo_get_type_once (void) { GType foo_type_id; foo_type_id = g_boxed_type_register_static ("Foo", (GBoxedCopyFunc) foo_dup, (GBoxedFreeFunc) foo_free); return foo_type_id; } GType foo_get_type (void) { static volatile gsize foo_type_id__once = 0; if (g_once_init_enter (&foo_type_id__once)) { GType foo_type_id; foo_type_id = foo_get_type_once (); g_once_init_leave (&foo_type_id__once, foo_type_id); } return foo_type_id__once; } static gpointer _foo_dup0 (gpointer self) { return self ? foo_dup (self) : NULL; } void bar_copy (const Bar* self, Bar* dest) { Foo _tmp0_; Foo* _tmp1_; Foo* _tmp2_; _tmp0_ = (*self).a; (*dest).a = _tmp0_; _tmp1_ = (*self).b; _tmp2_ = _foo_dup0 (_tmp1_); _foo_free0 ((*dest).b); (*dest).b = _tmp2_; } void bar_destroy (Bar* self) { _foo_free0 ((*self).b); } Bar* bar_dup (const Bar* self) { Bar* dup; dup = g_new0 (Bar, 1); bar_copy (self, dup); return dup; } void bar_free (Bar* self) { bar_destroy (self); g_free (self); } static GType bar_get_type_once (void) { GType bar_type_id; bar_type_id = g_boxed_type_register_static ("Bar", (GBoxedCopyFunc) bar_dup, (GBoxedFreeFunc) bar_free); return bar_type_id; } GType bar_get_type (void) { static volatile gsize bar_type_id__once = 0; if (g_once_init_enter (&bar_type_id__once)) { GType bar_type_id; bar_type_id = bar_get_type_once (); g_once_init_leave (&bar_type_id__once, bar_type_id); } return bar_type_id__once; } void manam_copy (const Manam* self, Manam* dest) { Foo _tmp0_; Bar _tmp1_; Bar _tmp2_; Bar _tmp3_ = {0}; _tmp0_ = (*self).a; (*dest).a = _tmp0_; _tmp1_ = (*self).b; _tmp2_ = _tmp1_; bar_copy (&_tmp2_, &_tmp3_); bar_destroy (&(*dest).b); (*dest).b = _tmp3_; } void manam_destroy (Manam* self) { bar_destroy (&(*self).b); } Manam* manam_dup (const Manam* self) { Manam* dup; dup = g_new0 (Manam, 1); manam_copy (self, dup); return dup; } void manam_free (Manam* self) { manam_destroy (self); g_free (self); } static GType manam_get_type_once (void) { GType manam_type_id; manam_type_id = g_boxed_type_register_static ("Manam", (GBoxedCopyFunc) manam_dup, (GBoxedFreeFunc) manam_free); return manam_type_id; } GType manam_get_type (void) { static volatile gsize manam_type_id__once = 0; if (g_once_init_enter (&manam_type_id__once)) { GType manam_type_id; manam_type_id = manam_get_type_once (); g_once_init_leave (&manam_type_id__once, manam_type_id); } return manam_type_id__once; } Baz* baz_dup (const Baz* self) { Baz* dup; dup = g_new0 (Baz, 1); memcpy (dup, self, sizeof (Baz)); return dup; } void baz_free (Baz* self) { g_free (self); } static GType baz_get_type_once (void) { GType baz_type_id; baz_type_id = g_boxed_type_register_static ("Baz", (GBoxedCopyFunc) baz_dup, (GBoxedFreeFunc) baz_free); return baz_type_id; } GType baz_get_type (void) { static volatile gsize baz_type_id__once = 0; if (g_once_init_enter (&baz_type_id__once)) { GType baz_type_id; baz_type_id = baz_get_type_once (); g_once_init_leave (&baz_type_id__once, baz_type_id); } return baz_type_id__once; } static gpointer _bar_dup0 (gpointer self) { return self ? bar_dup (self) : NULL; } static gpointer _manam_dup0 (gpointer self) { return self ? manam_dup (self) : NULL; } static void _vala_main (void) { { static const Baz LOCAL_BAZ = {{23, 42}}; } { static const Baz LOCAL_BAZ_A[2] = {{{23, 42}}, {{47, 11}}}; } { Bar bar = {0}; Foo _tmp0_; Foo* _tmp1_; Bar _tmp2_ = {0}; Bar _tmp3_; Foo _tmp4_; Bar _tmp5_; Foo* _tmp6_; _tmp0_ = (Foo) {42, 11}; _tmp1_ = _foo_dup0 (&_tmp0_); _tmp2_.a = (Foo) {23, 47}; _foo_free0 (_tmp2_.b); _tmp2_.b = _tmp1_; bar = _tmp2_; _tmp3_ = bar; _tmp4_ = _tmp3_.a; _vala_assert (_tmp4_.j == 47, "bar.a.j == 47"); _tmp5_ = bar; _tmp6_ = _tmp5_.b; _vala_assert ((*_tmp6_).i == 42, "bar.b.i == 42"); bar_destroy (&bar); } { Bar* bar = NULL; Foo _tmp7_; Foo* _tmp8_; Bar _tmp9_ = {0}; Bar _tmp10_; Bar* _tmp11_; Bar* _tmp12_; Foo _tmp13_; Foo* _tmp14_; _tmp7_ = (Foo) {42, 11}; _tmp8_ = _foo_dup0 (&_tmp7_); _tmp9_.a = (Foo) {23, 47}; _foo_free0 (_tmp9_.b); _tmp9_.b = _tmp8_; _tmp10_ = _tmp9_; _tmp11_ = _bar_dup0 (&_tmp10_); _tmp12_ = _tmp11_; bar_destroy (&_tmp10_); bar = _tmp12_; _tmp13_ = (*bar).a; _vala_assert (_tmp13_.i == 23, "bar.a.i == 23"); _tmp14_ = (*bar).b; _vala_assert ((*_tmp14_).j == 11, "bar.b.j == 11"); _bar_free0 (bar); } { Bar bar = {0}; Bar _tmp15_ = {0}; Foo _tmp16_; Foo* _tmp17_; Bar _tmp18_ = {0}; Bar _tmp19_; Foo _tmp20_; Bar _tmp21_; Foo* _tmp22_; bar = _tmp15_; _tmp16_ = (Foo) {42, 11}; _tmp17_ = _foo_dup0 (&_tmp16_); _tmp18_.a = (Foo) {23, 47}; _foo_free0 (_tmp18_.b); _tmp18_.b = _tmp17_; bar_destroy (&bar); bar = _tmp18_; _tmp19_ = bar; _tmp20_ = _tmp19_.a; _vala_assert (_tmp20_.j == 47, "bar.a.j == 47"); _tmp21_ = bar; _tmp22_ = _tmp21_.b; _vala_assert ((*_tmp22_).i == 42, "bar.b.i == 42"); bar_destroy (&bar); } { Manam manam = {0}; Foo _tmp23_; Foo* _tmp24_; Manam _tmp25_ = {0}; Manam _tmp26_; Foo _tmp27_; Manam _tmp28_; Bar _tmp29_; Foo* _tmp30_; _tmp23_ = (Foo) {42, 11}; _tmp24_ = _foo_dup0 (&_tmp23_); _tmp25_.a = (Foo) {23, 42}; bar_destroy (&_tmp25_.b); _tmp25_.b = (Bar) {(Foo) {23, 47}, _tmp24_}; manam = _tmp25_; _tmp26_ = manam; _tmp27_ = _tmp26_.a; _vala_assert (_tmp27_.i == 23, "manam.a.i == 23"); _tmp28_ = manam; _tmp29_ = _tmp28_.b; _tmp30_ = _tmp29_.b; _vala_assert ((*_tmp30_).j == 11, "manam.b.b.j == 11"); manam_destroy (&manam); } { Manam manam = {0}; Manam _tmp31_ = {0}; Foo _tmp32_; Foo* _tmp33_; Manam _tmp34_ = {0}; Manam _tmp35_; Foo _tmp36_; Manam _tmp37_; Bar _tmp38_; Foo* _tmp39_; manam = _tmp31_; _tmp32_ = (Foo) {42, 11}; _tmp33_ = _foo_dup0 (&_tmp32_); _tmp34_.a = (Foo) {23, 42}; bar_destroy (&_tmp34_.b); _tmp34_.b = (Bar) {(Foo) {23, 47}, _tmp33_}; manam_destroy (&manam); manam = _tmp34_; _tmp35_ = manam; _tmp36_ = _tmp35_.a; _vala_assert (_tmp36_.i == 23, "manam.a.i == 23"); _tmp37_ = manam; _tmp38_ = _tmp37_.b; _tmp39_ = _tmp38_.b; _vala_assert ((*_tmp39_).j == 11, "manam.b.b.j == 11"); manam_destroy (&manam); } { Manam* manam = NULL; Foo _tmp40_; Foo* _tmp41_; Manam _tmp42_ = {0}; Manam _tmp43_; Manam* _tmp44_; Manam* _tmp45_; Foo _tmp46_; Bar _tmp47_; Foo _tmp48_; _tmp40_ = (Foo) {42, 11}; _tmp41_ = _foo_dup0 (&_tmp40_); _tmp42_.a = (Foo) {23, 42}; bar_destroy (&_tmp42_.b); _tmp42_.b = (Bar) {(Foo) {23, 47}, _tmp41_}; _tmp43_ = _tmp42_; _tmp44_ = _manam_dup0 (&_tmp43_); _tmp45_ = _tmp44_; manam_destroy (&_tmp43_); manam = _tmp45_; _tmp46_ = (*manam).a; _vala_assert (_tmp46_.j == 42, "manam.a.j == 42"); _tmp47_ = (*manam).b; _tmp48_ = _tmp47_.a; _vala_assert (_tmp48_.i == 23, "manam.b.a.i == 23"); _manam_free0 (manam); } } int main (int argc, char ** argv) { _vala_main (); return 0; }