diff options
Diffstat (limited to 'tests/basic-types/arrays.c-expected')
-rw-r--r-- | tests/basic-types/arrays.c-expected | 1699 |
1 files changed, 1699 insertions, 0 deletions
diff --git a/tests/basic-types/arrays.c-expected b/tests/basic-types/arrays.c-expected new file mode 100644 index 000000000..e760db8c1 --- /dev/null +++ b/tests/basic-types/arrays.c-expected @@ -0,0 +1,1699 @@ +/* basic_types_arrays.c generated by valac, the Vala compiler + * generated from basic_types_arrays.vala, do not modify */ + +#include <glib.h> +#include <string.h> +#include <stdlib.h> +#include <glib-object.h> + +#if !defined(VALA_EXTERN) +#if defined(_MSC_VER) +#define VALA_EXTERN __declspec(dllexport) extern +#elif __GNUC__ >= 4 +#define VALA_EXTERN __attribute__((visibility("default"))) extern +#else +#define VALA_EXTERN extern +#endif +#endif + +#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL))) +typedef gint (*SimpleFunc) (void); + +#define TYPE_FOO (foo_get_type ()) +typedef struct _Foo Foo; + +#define TYPE_BAR (bar_get_type ()) +typedef struct _Bar Bar; + +#define TYPE_MANAM (manam_get_type ()) +typedef struct _Manam Manam; +#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 { + const gchar* array[2]; + gint bar; +}; + +struct _Bar { + gint bar; +}; + +struct _Manam { + Bar array[1024]; + Bar manam; +}; + +VALA_EXTERN gint* foo; +gint* foo = NULL; +VALA_EXTERN gint* bar; +gint* bar = NULL; +VALA_EXTERN SimpleFunc* simple_delegates; +VALA_EXTERN gint simple_delegates_length1; +SimpleFunc* simple_delegates = NULL; +gint simple_delegates_length1 = 0; +static gint _simple_delegates_size_ = 0; + +VALA_EXTERN void test_integer_array (void); +static gint* _vala_array_dup1 (gint* self, + gssize length); +static void _vala_array_add1 (gint* * array, + gint* length, + gint* size, + gint value); +static gint* _vala_array_dup2 (gint* self, + gssize length); +static gint* _vala_array_dup3 (gint* self, + gssize length); +static gint* _vala_array_dup4 (gint* self, + gssize length); +static gint* _vala_array_dup5 (gint* self, + gssize length); +static gint* _vala_array_dup6 (gint* self, + gssize length); +static gboolean _vala_int_array_contains (gint * stack, + gssize stack_length, + const gint needle); +static gint* _int_dup (gint* self); +static gboolean _int_equal (const gint * s1, + const gint * s2); +VALA_EXTERN void test_string_array (void); +static gchar** _vala_array_dup7 (gchar** self, + gssize length); +VALA_EXTERN gint* pass_helper (gint* a, + gint a_length1, + gint** b, + gint* b_length1, + gint* result_length1); +static gint* _vala_array_dup8 (gint* self, + gssize length); +VALA_EXTERN void test_array_pass (void); +#define FOO 2 +VALA_EXTERN void test_static_array (void); +VALA_EXTERN void test_reference_transfer (void); +VALA_EXTERN void test_length_assignment (void); +VALA_EXTERN void test_inline_array (void); +VALA_EXTERN gint* nd_array_pass (gint* a, + gint a_length1, + gint a_length2, + gint a_length3, + gint** b, + gint* b_length1, + gint* b_length2, + gint* b_length3, + gint* result_length1, + gint* result_length2, + gint* result_length3); +static gint* _vala_array_dup9 (gint* self, + gssize length); +static gint* _vala_array_dup10 (gint* self, + gssize length); +VALA_EXTERN void test_nd_array (void); +VALA_EXTERN gint simple_func (void); +VALA_EXTERN void test_delegate_array (void); +static void _vala_array_add2 (SimpleFunc* * array, + gint* length, + gint* size, + SimpleFunc value); +static gboolean _vala_simple_func_array_contains (SimpleFunc * stack, + gssize stack_length, + const SimpleFunc needle); +VALA_EXTERN void test_void_array (void); +static void _vala_array_add3 (void** * array, + gint* length, + gint* size, + void* value); +static void _vala_array_add4 (void** * array, + gint* length, + gint* size, + void* value); +static gboolean _vala_valavoid_array_contains (void* * stack, + gssize stack_length, + const void* needle); +VALA_EXTERN void test_explicit_copying (void); +static gint* _vala_array_dup11 (gint* self, + gssize length); +VALA_EXTERN void test_array_move (void); +VALA_EXTERN void test_array_resize (void); +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 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 test_struct_array (void); +static gboolean _bar_equal (const Bar * s1, + const Bar * s2); +static gboolean _vala_bar_array_contains (Bar * stack, + gssize stack_length, + const Bar * needle); +VALA_EXTERN void give_fixed_array (gint** i); +VALA_EXTERN void take_fixed_array (gint* i); +VALA_EXTERN void change_fixed_array (gint** i); +VALA_EXTERN void test_fixed_array (void); +static void _vala_main (void); +static void _vala_array_destroy (gpointer array, + gssize array_length, + GDestroyNotify destroy_func); +static void _vala_array_free (gpointer array, + gssize array_length, + GDestroyNotify destroy_func); +static void _vala_array_move (gpointer array, + gsize element_size, + gssize src, + gssize dest, + gssize length); +static gssize _vala_array_length (gpointer array); +static inline gpointer _vala_memdup2 (gconstpointer mem, + gsize byte_size); + +const Foo FOO_ARRAY_CONST[1] = {{{"foo", "bar"}, 42}}; + +static gint* +_vala_array_dup1 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +static void +_vala_array_add1 (gint* * array, + gint* length, + gint* size, + gint value) +{ + if ((*length) == (*size)) { + *size = (*size) ? (2 * (*size)) : 4; + *array = g_renew (gint, *array, *size); + } + (*array)[(*length)++] = value; +} + +static gint* +_vala_array_dup2 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +static gint* +_vala_array_dup3 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +static gint* +_vala_array_dup4 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +static gint* +_vala_array_dup5 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +static gint* +_vala_array_dup6 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +static gboolean +_vala_int_array_contains (gint * stack, + gssize stack_length, + const gint needle) +{ + gssize i; + for (i = 0; i < stack_length; i++) { + if (needle == stack[i]) { + return TRUE; + } + } + return FALSE; +} + +static gint* +_int_dup (gint* self) +{ + gint* dup; + dup = g_new0 (gint, 1); + memcpy (dup, self, sizeof (gint)); + return dup; +} + +static gpointer +__int_dup0 (gpointer self) +{ + return self ? _int_dup (self) : NULL; +} + +static gboolean +_int_equal (const gint * s1, + const gint * s2) +{ + if (s1 == s2) { + return TRUE; + } + if (s1 == NULL) { + return FALSE; + } + if (s2 == NULL) { + return FALSE; + } + return (*s1) == (*s2); +} + +void +test_integer_array (void) +{ + gint* a = NULL; + gint* _tmp0_; + gint a_length1; + gint _a_size_; + gint* _tmp1_; + gint _tmp1__length1; + gint* _tmp2_; + gint _tmp2__length1; + gint _tmp3_; + gint* _tmp4_; + gint* _tmp5_; + gint _tmp5__length1; + gint* _tmp6_; + gint _tmp6__length1; + gint _tmp7_; + gint* _tmp8_; + gint _tmp8__length1; + gint _tmp9_; + gint* b = NULL; + gint* _tmp10_; + gint _tmp10__length1; + gint* _tmp11_; + gint _tmp11__length1; + gint b_length1; + gint _b_size_; + gint _tmp12_; + gint _tmp13_; + gint* _tmp14_; + gint _tmp14__length1; + gint* _tmp15_; + gint _tmp15__length1; + gint _tmp16_; + gint* _tmp17_; + gint _tmp17__length1; + gint _tmp18_; + gint* _tmp19_; + gint _tmp19__length1; + gint _tmp20_; + gint _tmp21_; + gint _tmp22_; + gint* c = NULL; + gint* _tmp23_; + gint _tmp23__length1; + gint* _tmp24_; + gint _tmp24__length1; + gint c_length1; + gint _c_size_; + gint _tmp25_; + gint _tmp26_; + gint* c0 = NULL; + gint* _tmp27_; + gint _tmp27__length1; + gint* _tmp28_; + gint _tmp28__length1; + gint c0_length1; + gint _c0_size_; + gint* c1 = NULL; + gint* _tmp29_; + gint _tmp29__length1; + gint* _tmp30_; + gint _tmp30__length1; + gint* _tmp31_; + gint _tmp31__length1; + gint c1_length1; + gint _c1_size_; + gint _tmp32_; + gint _tmp33_; + gint* c2 = NULL; + gint* _tmp34_; + gint _tmp34__length1; + gint* _tmp35_; + gint _tmp35__length1; + gint c2_length1; + gint _c2_size_; + gint _tmp36_; + gint _tmp37_; + gint* c3 = NULL; + gint* _tmp38_; + gint _tmp38__length1; + gint* _tmp39_; + gint _tmp39__length1; + gint* _tmp40_; + gint _tmp40__length1; + gint c3_length1; + gint _c3_size_; + gint _tmp41_; + gint _tmp42_; + gint _tmp43_; + gint* _tmp44_; + gint _tmp44__length1; + gint* _tmp45_; + gint _tmp45__length1; + gint** d = NULL; + gint** _tmp46_; + gint d_length1; + gint _d_size_; + gint _tmp47_; + gint* _tmp48_; + gint* _tmp49_; + gint _tmp50_; + gint* _tmp51_; + gint* e = NULL; + gint* _tmp52_; + gint e_length1; + gint _e_size_; + gint _tmp53_; + gint _tmp54_; + gint _tmp55_; + gint _tmp56_; + gint _tmp57_; + _tmp0_ = g_new0 (gint, 1); + _tmp0_[0] = 42; + a = _tmp0_; + a_length1 = 1; + _a_size_ = a_length1; + _tmp1_ = a; + _tmp1__length1 = a_length1; + _vala_assert (_tmp1__length1 == 1, "a.length == 1"); + _tmp2_ = a; + _tmp2__length1 = a_length1; + _tmp3_ = _tmp2_[0]; + _vala_assert (_tmp3_ == 42, "a[0] == 42"); + _tmp4_ = g_new0 (gint, 2); + _tmp4_[0] = 42; + _tmp4_[1] = 23; + a = (g_free (a), NULL); + a = _tmp4_; + a_length1 = 2; + _a_size_ = a_length1; + _tmp5_ = a; + _tmp5__length1 = a_length1; + _vala_assert (_tmp5__length1 == 2, "a.length == 2"); + _tmp6_ = a; + _tmp6__length1 = a_length1; + _tmp7_ = _tmp6_[0]; + _vala_assert (_tmp7_ == 42, "a[0] == 42"); + _tmp8_ = a; + _tmp8__length1 = a_length1; + _tmp9_ = _tmp8_[1]; + _vala_assert (_tmp9_ == 23, "a[1] == 23"); + _tmp10_ = a; + _tmp10__length1 = a_length1; + _tmp11_ = (_tmp10_ != NULL) ? _vala_array_dup1 (_tmp10_, _tmp10__length1) : _tmp10_; + _tmp11__length1 = _tmp10__length1; + b = _tmp11_; + b_length1 = _tmp11__length1; + _b_size_ = b_length1; + _vala_assert (b_length1 == 2, "b.length == 2"); + _tmp12_ = b[0]; + _vala_assert (_tmp12_ == 42, "b[0] == 42"); + _tmp13_ = b[1]; + _vala_assert (_tmp13_ == 23, "b[1] == 23"); + _vala_array_add1 (&a, &a_length1, &_a_size_, 11); + _tmp14_ = a; + _tmp14__length1 = a_length1; + _vala_assert (_tmp14__length1 == 3, "a.length == 3"); + _tmp15_ = a; + _tmp15__length1 = a_length1; + _tmp16_ = _tmp15_[0]; + _vala_assert (_tmp16_ == 42, "a[0] == 42"); + _tmp17_ = a; + _tmp17__length1 = a_length1; + _tmp18_ = _tmp17_[1]; + _vala_assert (_tmp18_ == 23, "a[1] == 23"); + _tmp19_ = a; + _tmp19__length1 = a_length1; + _tmp20_ = _tmp19_[2]; + _vala_assert (_tmp20_ == 11, "a[2] == 11"); + _vala_assert (b_length1 == 2, "b.length == 2"); + _tmp21_ = b[0]; + _vala_assert (_tmp21_ == 42, "b[0] == 42"); + _tmp22_ = b[1]; + _vala_assert (_tmp22_ == 23, "b[1] == 23"); + _tmp23_ = a; + _tmp23__length1 = a_length1; + _tmp24_ = ((_tmp23_ + 1) != NULL) ? _vala_array_dup2 (_tmp23_ + 1, 3 - 1) : (_tmp23_ + 1); + _tmp24__length1 = 3 - 1; + c = _tmp24_; + c_length1 = _tmp24__length1; + _c_size_ = c_length1; + _vala_assert (c_length1 == 2, "c.length == 2"); + _tmp25_ = c[0]; + _vala_assert (_tmp25_ == 23, "c[0] == 23"); + _tmp26_ = c[1]; + _vala_assert (_tmp26_ == 11, "c[1] == 11"); + _tmp27_ = a; + _tmp27__length1 = a_length1; + _tmp28_ = ((_tmp27_ + 0) != NULL) ? _vala_array_dup3 (_tmp27_ + 0, 0 - 0) : (_tmp27_ + 0); + _tmp28__length1 = 0 - 0; + c0 = _tmp28_; + c0_length1 = _tmp28__length1; + _c0_size_ = c0_length1; + _vala_assert (c0 == NULL, "c0 == null"); + _vala_assert (c0_length1 == 0, "c0.length == 0"); + _tmp29_ = a; + _tmp29__length1 = a_length1; + _tmp30_ = a; + _tmp30__length1 = a_length1; + _tmp31_ = ((_tmp30_ + 1) != NULL) ? _vala_array_dup4 (_tmp30_ + 1, _tmp30__length1 - 1) : (_tmp30_ + 1); + _tmp31__length1 = _tmp30__length1 - 1; + c1 = _tmp31_; + c1_length1 = _tmp31__length1; + _c1_size_ = c1_length1; + _vala_assert (c1_length1 == 2, "c1.length == 2"); + _tmp32_ = c1[0]; + _vala_assert (_tmp32_ == 23, "c1[0] == 23"); + _tmp33_ = c1[1]; + _vala_assert (_tmp33_ == 11, "c1[1] == 11"); + _tmp34_ = a; + _tmp34__length1 = a_length1; + _tmp35_ = ((_tmp34_ + 0) != NULL) ? _vala_array_dup5 (_tmp34_ + 0, 2 - 0) : (_tmp34_ + 0); + _tmp35__length1 = 2 - 0; + c2 = _tmp35_; + c2_length1 = _tmp35__length1; + _c2_size_ = c2_length1; + _vala_assert (c2_length1 == 2, "c2.length == 2"); + _tmp36_ = c2[0]; + _vala_assert (_tmp36_ == 42, "c2[0] == 42"); + _tmp37_ = c2[1]; + _vala_assert (_tmp37_ == 23, "c2[1] == 23"); + _tmp38_ = a; + _tmp38__length1 = a_length1; + _tmp39_ = a; + _tmp39__length1 = a_length1; + _tmp40_ = ((_tmp39_ + 0) != NULL) ? _vala_array_dup6 (_tmp39_ + 0, _tmp39__length1 - 0) : (_tmp39_ + 0); + _tmp40__length1 = _tmp39__length1 - 0; + c3 = _tmp40_; + c3_length1 = _tmp40__length1; + _c3_size_ = c3_length1; + _vala_assert (c3_length1 == 3, "c3.length == 3"); + _tmp41_ = c3[0]; + _vala_assert (_tmp41_ == 42, "c3[0] == 42"); + _tmp42_ = c3[1]; + _vala_assert (_tmp42_ == 23, "c3[1] == 23"); + _tmp43_ = c3[2]; + _vala_assert (_tmp43_ == 11, "c3[2] == 11"); + _tmp44_ = a; + _tmp44__length1 = a_length1; + _vala_assert (_vala_int_array_contains (_tmp44_, _tmp44__length1, 23), "23 in a"); + _tmp45_ = a; + _tmp45__length1 = a_length1; + _vala_assert (!_vala_int_array_contains (_tmp45_, _tmp45__length1, -1), "!(-1 in a)"); + _tmp46_ = g_new0 (gint*, 2); + d = _tmp46_; + d_length1 = 2; + _d_size_ = d_length1; + _tmp47_ = 10; + _tmp48_ = __int_dup0 (&_tmp47_); + _g_free0 (d[0]); + d[0] = _tmp48_; + _g_free0 (d[1]); + d[1] = NULL; + _tmp49_ = d[0]; + _tmp50_ = 10; + _vala_assert (_int_equal (_tmp49_, &_tmp50_) == TRUE, "d[0] == 10"); + _tmp51_ = d[1]; + _vala_assert (_tmp51_ == NULL, "d[1] == null"); + _tmp52_ = g_new0 (gint, 2); + _tmp52_[0] = 13; + _tmp52_[1] = 47; + e = _tmp52_; + e_length1 = 2; + _e_size_ = e_length1; + e[0] = 96; + _tmp53_ = e[0]; + _vala_assert (_tmp53_ == 96, "e[0] == 96"); + e[0] /= 24; + _tmp54_ = e[0]; + _vala_assert (_tmp54_ == 4, "e[0] == 4"); + e[0] += 2; + _tmp55_ = e[0]; + _vala_assert (_tmp55_ == 6, "e[0] == 6"); + e[0] *= 4; + _tmp56_ = e[0]; + _vala_assert (_tmp56_ == 24, "e[0] == 24"); + e[0] -= 23; + _tmp57_ = e[0]; + _vala_assert (_tmp57_ == 1, "e[0] == 1"); + e = (g_free (e), NULL); + d = (_vala_array_free (d, d_length1, (GDestroyNotify) g_free), NULL); + c3 = (g_free (c3), NULL); + c2 = (g_free (c2), NULL); + c1 = (g_free (c1), NULL); + c0 = (g_free (c0), NULL); + c = (g_free (c), NULL); + b = (g_free (b), NULL); + a = (g_free (a), NULL); +} + +static gchar** +_vala_array_dup7 (gchar** self, + gssize length) +{ + if (length >= 0) { + gchar** result; + gssize i; + result = g_new0 (gchar*, length + 1); + for (i = 0; i < length; i++) { + gchar* _tmp0_; + _tmp0_ = g_strdup (self[i]); + result[i] = _tmp0_; + } + return result; + } + return NULL; +} + +void +test_string_array (void) +{ + gchar** a = NULL; + gchar* _tmp0_; + gchar** _tmp1_; + gint a_length1; + gint _a_size_; + gchar** _tmp2_; + gint _tmp2__length1; + gchar** _tmp3_; + gint _tmp3__length1; + const gchar* _tmp4_; + gchar* _tmp5_; + gchar* _tmp6_; + gchar** _tmp7_; + gchar** _tmp8_; + gint _tmp8__length1; + gchar** _tmp9_; + gint _tmp9__length1; + const gchar* _tmp10_; + gchar** _tmp11_; + gint _tmp11__length1; + const gchar* _tmp12_; + gchar** b = NULL; + gchar** _tmp13_; + gint _tmp13__length1; + gchar** _tmp14_; + gint _tmp14__length1; + gint b_length1; + gint _b_size_; + const gchar* _tmp15_; + const gchar* _tmp16_; + _tmp0_ = g_strdup ("hello"); + _tmp1_ = g_new0 (gchar*, 1 + 1); + _tmp1_[0] = _tmp0_; + a = _tmp1_; + a_length1 = 1; + _a_size_ = a_length1; + _tmp2_ = a; + _tmp2__length1 = a_length1; + _vala_assert (_tmp2__length1 == 1, "a.length == 1"); + _tmp3_ = a; + _tmp3__length1 = a_length1; + _tmp4_ = _tmp3_[0]; + _vala_assert (g_strcmp0 (_tmp4_, "hello") == 0, "a[0] == \"hello\""); + _tmp5_ = g_strdup ("hello"); + _tmp6_ = g_strdup ("world"); + _tmp7_ = g_new0 (gchar*, 2 + 1); + _tmp7_[0] = _tmp5_; + _tmp7_[1] = _tmp6_; + a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL); + a = _tmp7_; + a_length1 = 2; + _a_size_ = a_length1; + _tmp8_ = a; + _tmp8__length1 = a_length1; + _vala_assert (_tmp8__length1 == 2, "a.length == 2"); + _tmp9_ = a; + _tmp9__length1 = a_length1; + _tmp10_ = _tmp9_[0]; + _vala_assert (g_strcmp0 (_tmp10_, "hello") == 0, "a[0] == \"hello\""); + _tmp11_ = a; + _tmp11__length1 = a_length1; + _tmp12_ = _tmp11_[1]; + _vala_assert (g_strcmp0 (_tmp12_, "world") == 0, "a[1] == \"world\""); + _tmp13_ = a; + _tmp13__length1 = a_length1; + _tmp14_ = (_tmp13_ != NULL) ? _vala_array_dup7 (_tmp13_, _tmp13__length1) : _tmp13_; + _tmp14__length1 = _tmp13__length1; + b = _tmp14_; + b_length1 = _tmp14__length1; + _b_size_ = b_length1; + _vala_assert (b_length1 == 2, "b.length == 2"); + _tmp15_ = b[0]; + _vala_assert (g_strcmp0 (_tmp15_, "hello") == 0, "b[0] == \"hello\""); + _tmp16_ = b[1]; + _vala_assert (g_strcmp0 (_tmp16_, "world") == 0, "b[1] == \"world\""); + b = (_vala_array_free (b, b_length1, (GDestroyNotify) g_free), NULL); + a = (_vala_array_free (a, a_length1, (GDestroyNotify) g_free), NULL); +} + +static gint* +_vala_array_dup8 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +gint* +pass_helper (gint* a, + gint a_length1, + gint** b, + gint* b_length1, + gint* result_length1) +{ + gint* _vala_b = NULL; + gint _vala_b_length1 = 0; + gint* _tmp0_; + gint _tmp0__length1; + gint* _tmp1_; + gint* _tmp2_; + gint _tmp2__length1; + gint* result = NULL; + _tmp0_ = (a != NULL) ? _vala_array_dup8 (a, a_length1) : a; + _tmp0__length1 = a_length1; + _vala_b = (g_free (_vala_b), NULL); + _vala_b = _tmp0_; + _vala_b_length1 = _tmp0__length1; + _tmp1_ = g_new0 (gint, 2); + _tmp1_[0] = 42; + _tmp1_[1] = 23; + _tmp2_ = _tmp1_; + _tmp2__length1 = 2; + if (result_length1) { + *result_length1 = _tmp2__length1; + } + result = _tmp2_; + if (b) { + *b = _vala_b; + } else { + _vala_b = (g_free (_vala_b), NULL); + } + if (b_length1) { + *b_length1 = _vala_b_length1; + } + return result; +} + +void +test_array_pass (void) +{ + gint* a = NULL; + gint a_length1 = 0; + gint _a_size_ = 0; + gint* b = NULL; + gint b_length1 = 0; + gint _b_size_ = 0; + gint* _tmp0_; + gint* _tmp1_; + gint _tmp1__length1; + gint* _tmp2_ = NULL; + gint _tmp3_ = 0; + gint _tmp4_ = 0; + gint* _tmp5_; + gint _tmp6_; + gint _tmp7_; + gint _tmp8_; + _tmp0_ = g_new0 (gint, 1); + _tmp0_[0] = 42; + _tmp1_ = _tmp0_; + _tmp1__length1 = 1; + _tmp5_ = pass_helper (_tmp1_, (gint) 1, &_tmp2_, &_tmp3_, &_tmp4_); + b = (g_free (b), NULL); + b = _tmp2_; + b_length1 = _tmp3_; + _b_size_ = b_length1; + a = (g_free (a), NULL); + a = _tmp5_; + a_length1 = _tmp4_; + _a_size_ = a_length1; + _tmp1_ = (g_free (_tmp1_), NULL); + _vala_assert (a_length1 == 2, "a.length == 2"); + _tmp6_ = a[0]; + _vala_assert (_tmp6_ == 42, "a[0] == 42"); + _tmp7_ = a[1]; + _vala_assert (_tmp7_ == 23, "a[1] == 23"); + _vala_assert (b_length1 == 1, "b.length == 1"); + _tmp8_ = b[0]; + _vala_assert (_tmp8_ == 42, "b[0] == 42"); + b = (g_free (b), NULL); + a = (g_free (a), NULL); +} + +void +test_static_array (void) +{ + gint a[2] = {0}; + gint _tmp0_; + gint _tmp1_[2] = {0}; + gboolean _tmp2_ = FALSE; + gint _tmp3_; + gint b[(FOO * 1) << 3]; + _vala_assert (2 == 2, "a.length == 2"); + a[1] = 23; + _tmp0_ = a[1]; + _vala_assert (_tmp0_ == 23, "a[1] == 23"); + _tmp1_[0] = 23; + _tmp1_[1] = 34; + memcpy (a, _tmp1_, 2 * sizeof (gint)); + _tmp3_ = a[0]; + if (_tmp3_ == 23) { + gint _tmp4_; + _tmp4_ = a[1]; + _tmp2_ = _tmp4_ == 34; + } else { + _tmp2_ = FALSE; + } + _vala_assert (_tmp2_, "a[0] == 23 && a[1] == 34"); + memset (b, 0, ((FOO * 1) << 3) * sizeof (gint)); + _vala_assert (((FOO * 1) << 3) == ((FOO * 1) << 3), "b.length == FOO * 1 << 3"); +} + +void +test_reference_transfer (void) +{ + gint* baz = NULL; + gint* _tmp0_; + gint _tmp0__length1; + gint baz_length1; + gint _baz_size_; + gint* _tmp1_; + gint _tmp1__length1; + gchar** data = NULL; + gchar* _tmp2_; + gchar** _tmp3_; + gint data_length1; + gint _data_size_; + gchar** data2 = NULL; + gchar** _tmp4_; + gint _tmp4__length1; + gint data2_length1; + gint _data2_size_; + gchar** _tmp5_; + gint _tmp5__length1; + _tmp0_ = foo; + _tmp0__length1 = _vala_array_length (foo); + foo = NULL; + baz = _tmp0_; + baz_length1 = _tmp0__length1; + _baz_size_ = baz_length1; + _tmp1_ = bar; + _tmp1__length1 = -1; + bar = NULL; + baz = (g_free (baz), NULL); + baz = _tmp1_; + baz_length1 = _tmp1__length1; + _baz_size_ = baz_length1; + _tmp2_ = g_strdup ("foo"); + _tmp3_ = g_new0 (gchar*, 1 + 1); + _tmp3_[0] = _tmp2_; + data = _tmp3_; + data_length1 = 1; + _data_size_ = data_length1; + _tmp4_ = data; + _tmp4__length1 = data_length1; + data = NULL; + data_length1 = 0; + data2 = _tmp4_; + data2_length1 = _tmp4__length1; + _data2_size_ = data2_length1; + _tmp5_ = data; + _tmp5__length1 = data_length1; + _vala_assert (_tmp5__length1 == 0, "data.length == 0"); + data2 = (_vala_array_free (data2, data2_length1, (GDestroyNotify) g_free), NULL); + data = (_vala_array_free (data, data_length1, (GDestroyNotify) g_free), NULL); + baz = (g_free (baz), NULL); +} + +void +test_length_assignment (void) +{ + gint* a = NULL; + gint* _tmp0_; + gint a_length1; + gint _a_size_; + gint* b = NULL; + gint* _tmp1_; + gint b_length1; + gint b_length2; + gint _tmp2_; + _tmp0_ = g_new0 (gint, 10); + a = _tmp0_; + a_length1 = 10; + _a_size_ = a_length1; + _tmp1_ = g_new0 (gint, 20 * 30); + b = _tmp1_; + b_length1 = 20; + b_length2 = 30; + a_length1 = 8; + b_length1 = 5; + _vala_assert (a_length1 == 8, "a.length == 8"); + _tmp2_ = b_length1; + _vala_assert (_tmp2_ == 5, "b.length[0] == 5"); + b = (g_free (b), NULL); + a = (g_free (a), NULL); +} + +void +test_inline_array (void) +{ + static const gint a[3] = {1, 2, 3}; + _vala_assert (_vala_int_array_contains (a, G_N_ELEMENTS (a), 1), "1 in a"); +} + +static gint* +_vala_array_dup9 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +static gint* +_vala_array_dup10 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +gint* +nd_array_pass (gint* a, + gint a_length1, + gint a_length2, + gint a_length3, + gint** b, + gint* b_length1, + gint* b_length2, + gint* b_length3, + gint* result_length1, + gint* result_length2, + gint* result_length3) +{ + gint* _vala_b = NULL; + gint _vala_b_length1 = 0; + gint _vala_b_length2 = 0; + gint _vala_b_length3 = 0; + gint _tmp0_; + gint _tmp1_; + gint _tmp2_; + gint _tmp3_; + gint* _tmp4_; + gint _tmp4__length1; + gint _tmp4__length2; + gint _tmp4__length3; + gint* _tmp5_; + gint _tmp5__length1; + gint _tmp5__length2; + gint _tmp5__length3; + gint* _tmp6_; + gint _tmp6__length1; + gint _tmp6__length2; + gint _tmp6__length3; + gint* result = NULL; + _tmp0_ = a_length1; + _vala_assert (_tmp0_ == 2, "a.length[0] == 2"); + _tmp1_ = a_length2; + _vala_assert (_tmp1_ == 2, "a.length[1] == 2"); + _tmp2_ = a_length3; + _vala_assert (_tmp2_ == 2, "a.length[2] == 2"); + _tmp3_ = a[(((1 * a_length2) + 1) * a_length3) + 0]; + _vala_assert (_tmp3_ == 7, "a[1,1,0] == 7"); + _tmp4_ = (a != NULL) ? _vala_array_dup9 (a, (a_length1 * a_length2) * a_length3) : a; + _tmp4__length1 = a_length1; + _tmp4__length2 = a_length2; + _tmp4__length3 = a_length3; + _vala_b = (g_free (_vala_b), NULL); + _vala_b = _tmp4_; + _vala_b_length1 = _tmp4__length1; + _vala_b_length2 = _tmp4__length2; + _vala_b_length3 = _tmp4__length3; + _tmp5_ = (a != NULL) ? _vala_array_dup10 (a, (a_length1 * a_length2) * a_length3) : a; + _tmp5__length1 = a_length1; + _tmp5__length2 = a_length2; + _tmp5__length3 = a_length3; + _tmp6_ = _tmp5_; + _tmp6__length1 = _tmp5__length1; + _tmp6__length2 = _tmp5__length2; + _tmp6__length3 = _tmp5__length3; + if (result_length1) { + *result_length1 = _tmp6__length1; + } + if (result_length2) { + *result_length2 = _tmp6__length2; + } + if (result_length3) { + *result_length3 = _tmp6__length3; + } + result = _tmp6_; + if (b) { + *b = _vala_b; + } else { + _vala_b = (g_free (_vala_b), NULL); + } + if (b_length1) { + *b_length1 = _vala_b_length1; + } + if (b_length2) { + *b_length2 = _vala_b_length2; + } + if (b_length3) { + *b_length3 = _vala_b_length3; + } + return result; +} + +void +test_nd_array (void) +{ + gint* a = NULL; + gint* _tmp0_; + gint a_length1; + gint a_length2; + gint a_length3; + gint _tmp1_; + gint* b = NULL; + gint b_length1 = 0; + gint b_length2 = 0; + gint b_length3 = 0; + gint* c = NULL; + gint c_length1 = 0; + gint c_length2 = 0; + gint c_length3 = 0; + gint* _tmp2_ = NULL; + gint _tmp3_ = 0; + gint _tmp4_ = 0; + gint _tmp5_ = 0; + gint _tmp6_ = 0; + gint _tmp7_ = 0; + gint _tmp8_ = 0; + gint* _tmp9_; + gint _tmp10_; + gint _tmp11_; + gint _tmp12_; + gint _tmp13_; + gint _tmp14_; + gint _tmp15_; + gint _tmp16_; + gint _tmp17_; + gchar** s = NULL; + gchar* _tmp18_; + gchar* _tmp19_; + gchar* _tmp20_; + gchar* _tmp21_; + gchar* _tmp22_; + gchar* _tmp23_; + gchar** _tmp24_; + gint s_length1; + gint s_length2; + gint s_length3; + const gchar* _tmp25_; + _tmp0_ = g_new0 (gint, (2 * 2) * 2); + _tmp0_[0] = 1; + _tmp0_[1] = 2; + _tmp0_[2] = 3; + _tmp0_[3] = 4; + _tmp0_[4] = 5; + _tmp0_[5] = 6; + _tmp0_[6] = 7; + _tmp0_[7] = 8; + a = _tmp0_; + a_length1 = 2; + a_length2 = 2; + a_length3 = 2; + _tmp1_ = a[(((1 * a_length2) + 0) * a_length3) + 1]; + _vala_assert (_tmp1_ == 6, "a[1,0,1] == 6"); + _tmp9_ = nd_array_pass (a, (gint) a_length1, (gint) a_length2, (gint) a_length3, &_tmp2_, &_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_, &_tmp8_); + b = (g_free (b), NULL); + b = _tmp2_; + b_length1 = _tmp3_; + b_length2 = _tmp4_; + b_length3 = _tmp5_; + c = (g_free (c), NULL); + c = _tmp9_; + c_length1 = _tmp6_; + c_length2 = _tmp7_; + c_length3 = _tmp8_; + _tmp10_ = b_length1; + _vala_assert (_tmp10_ == 2, "b.length[0] == 2"); + _tmp11_ = b_length2; + _vala_assert (_tmp11_ == 2, "b.length[1] == 2"); + _tmp12_ = b_length3; + _vala_assert (_tmp12_ == 2, "b.length[2] == 2"); + _tmp13_ = b[(((0 * b_length2) + 1) * b_length3) + 0]; + _vala_assert (_tmp13_ == 3, "b[0,1,0] == 3"); + _tmp14_ = c_length1; + _vala_assert (_tmp14_ == 2, "c.length[0] == 2"); + _tmp15_ = c_length2; + _vala_assert (_tmp15_ == 2, "c.length[1] == 2"); + _tmp16_ = c_length3; + _vala_assert (_tmp16_ == 2, "c.length[2] == 2"); + _tmp17_ = c[(((0 * c_length2) + 1) * c_length3) + 1]; + _vala_assert (_tmp17_ == 4, "c[0,1,1] == 4"); + _tmp18_ = g_strdup ("a"); + _tmp19_ = g_strdup ("b"); + _tmp20_ = g_strdup ("c"); + _tmp21_ = g_strdup ("d"); + _tmp22_ = g_strdup ("e"); + _tmp23_ = g_strdup ("f"); + _tmp24_ = g_new0 (gchar*, ((1 * 2) * 3) + 1); + _tmp24_[0] = _tmp18_; + _tmp24_[1] = _tmp19_; + _tmp24_[2] = _tmp20_; + _tmp24_[3] = _tmp21_; + _tmp24_[4] = _tmp22_; + _tmp24_[5] = _tmp23_; + s = _tmp24_; + s_length1 = 1; + s_length2 = 2; + s_length3 = 3; + _tmp25_ = s[(((0 * s_length2) + 0) * s_length3) + 2]; + _vala_assert (g_strcmp0 (_tmp25_, "c") == 0, "s[0,0,2] == \"c\""); + s = (_vala_array_free (s, (s_length1 * s_length2) * s_length3, (GDestroyNotify) g_free), NULL); + c = (g_free (c), NULL); + b = (g_free (b), NULL); + a = (g_free (a), NULL); +} + +gint +simple_func (void) +{ + gint result = 0; + result = 0; + return result; +} + +static void +_vala_array_add2 (SimpleFunc* * array, + gint* length, + gint* size, + SimpleFunc value) +{ + if ((*length) == (*size)) { + *size = (*size) ? (2 * (*size)) : 4; + *array = g_renew (SimpleFunc, *array, *size); + } + (*array)[(*length)++] = value; +} + +static gboolean +_vala_simple_func_array_contains (SimpleFunc * stack, + gssize stack_length, + const SimpleFunc needle) +{ + gssize i; + for (i = 0; i < stack_length; i++) { + if (needle == stack[i]) { + return TRUE; + } + } + return FALSE; +} + +void +test_delegate_array (void) +{ + SimpleFunc* a = NULL; + SimpleFunc* _tmp0_; + gint a_length1; + gint _a_size_; + SimpleFunc* _tmp1_; + gint _tmp1__length1; + SimpleFunc* _tmp2_; + gint _tmp2__length1; + SimpleFunc* _tmp3_; + gint _tmp3__length1; + _tmp0_ = g_new0 (SimpleFunc, 0); + a = _tmp0_; + a_length1 = 0; + _a_size_ = a_length1; + _tmp1_ = simple_delegates; + _tmp1__length1 = simple_delegates_length1; + simple_delegates = NULL; + simple_delegates_length1 = 0; + a = (g_free (a), NULL); + a = _tmp1_; + a_length1 = _tmp1__length1; + _a_size_ = a_length1; + _vala_array_add2 (&a, &a_length1, &_a_size_, (SimpleFunc) simple_func); + _tmp2_ = a; + _tmp2__length1 = a_length1; + _vala_assert (_tmp2__length1 == 1, "a.length == 1"); + _tmp3_ = a; + _tmp3__length1 = a_length1; + _vala_assert (_vala_simple_func_array_contains (_tmp3_, _tmp3__length1, simple_func), "simple_func in a"); + a = (g_free (a), NULL); +} + +static void +_vala_array_add3 (void** * array, + gint* length, + gint* size, + void* value) +{ + if ((*length) == (*size)) { + *size = (*size) ? (2 * (*size)) : 4; + *array = g_renew (void*, *array, *size); + } + (*array)[(*length)++] = value; +} + +static void +_vala_array_add4 (void** * array, + gint* length, + gint* size, + void* value) +{ + if ((*length) == (*size)) { + *size = (*size) ? (2 * (*size)) : 4; + *array = g_renew (void*, *array, *size); + } + (*array)[(*length)++] = value; +} + +static gboolean +_vala_valavoid_array_contains (void* * stack, + gssize stack_length, + const void* needle) +{ + gssize i; + for (i = 0; i < stack_length; i++) { + if (needle == stack[i]) { + return TRUE; + } + } + return FALSE; +} + +void +test_void_array (void) +{ + void** a = NULL; + void** _tmp0_; + gint a_length1; + gint _a_size_; + void** _tmp1_; + gint _tmp1__length1; + void** _tmp2_; + gint _tmp2__length1; + _tmp0_ = g_new0 (void*, 0); + a = _tmp0_; + a_length1 = 0; + _a_size_ = a_length1; + _vala_array_add3 (&a, &a_length1, &_a_size_, (void*) NULL); + _vala_array_add4 (&a, &a_length1, &_a_size_, (void*) NULL); + _tmp1_ = a; + _tmp1__length1 = a_length1; + _vala_assert (_tmp1__length1 == 2, "a.length == 2"); + _tmp2_ = a; + _tmp2__length1 = a_length1; + _vala_assert (_vala_valavoid_array_contains (_tmp2_, _tmp2__length1, (void*) NULL), "(void*) null in a"); + a = (g_free (a), NULL); +} + +static gint* +_vala_array_dup11 (gint* self, + gssize length) +{ + if (length > 0) { + return _vala_memdup2 (self, length * sizeof (gint)); + } + return NULL; +} + +void +test_explicit_copying (void) +{ + gint* a0 = NULL; + gint* _tmp0_; + gint a0_length1; + gint _a0_size_; + gint* a1 = NULL; + gint* _tmp1_; + gint _tmp1__length1; + gint a1_length1; + gint _a1_size_; + gint _tmp2_; + gint _tmp3_; + _tmp0_ = g_new0 (gint, 3); + _tmp0_[0] = 1; + _tmp0_[1] = 2; + _tmp0_[2] = 3; + a0 = _tmp0_; + a0_length1 = 3; + _a0_size_ = a0_length1; + _tmp1_ = (a0 != NULL) ? _vala_array_dup11 (a0, a0_length1) : a0; + _tmp1__length1 = a0_length1; + a1 = _tmp1_; + a1_length1 = _tmp1__length1; + _a1_size_ = a1_length1; + _vala_assert (a1_length1 == 3, "a1.length == 3"); + _tmp2_ = a0[1]; + _tmp3_ = a1[1]; + _vala_assert (_tmp2_ == _tmp3_, "a0[1] == a1[1]"); + a1 = (g_free (a1), NULL); + a0 = (g_free (a0), NULL); +} + +void +test_array_move (void) +{ + gint* a = NULL; + gint* _tmp0_; + gint a_length1; + gint _a_size_; + gint _tmp1_; + gint _tmp2_; + _tmp0_ = g_new0 (gint, 9); + _tmp0_[0] = 1; + _tmp0_[1] = 2; + _tmp0_[2] = 3; + _tmp0_[3] = 4; + _tmp0_[4] = 5; + _tmp0_[5] = 6; + _tmp0_[6] = 7; + _tmp0_[7] = 8; + _tmp0_[8] = 9; + a = _tmp0_; + a_length1 = 9; + _a_size_ = a_length1; + _tmp1_ = a[4]; + _vala_assert (_tmp1_ == 5, "a[4] == 5"); + _vala_array_move (a, sizeof (gint), 4, 0, 5); + _tmp2_ = a[4]; + _vala_assert (_tmp2_ == 9, "a[4] == 9"); + a = (g_free (a), NULL); +} + +void +test_array_resize (void) +{ + gint* a = NULL; + gint* _tmp0_; + gint a_length1; + gint _a_size_; + gint _tmp1_; + gint _tmp2_; + gint _tmp3_; + _tmp0_ = g_new0 (gint, 9); + _tmp0_[0] = 1; + _tmp0_[1] = 2; + _tmp0_[2] = 3; + _tmp0_[3] = 4; + _tmp0_[4] = 5; + _tmp0_[5] = 6; + _tmp0_[6] = 7; + _tmp0_[7] = 8; + _tmp0_[8] = 9; + a = _tmp0_; + a_length1 = 9; + _a_size_ = a_length1; + _tmp1_ = a[a_length1 - 1]; + _vala_assert (_tmp1_ == 9, "a[a.length - 1] == 9"); + _tmp2_ = 5; + a = g_renew (gint, a, 5); + (_tmp2_ > a_length1) ? memset (a + a_length1, 0, sizeof (gint) * (_tmp2_ - a_length1)) : NULL; + a_length1 = _tmp2_; + _a_size_ = _tmp2_; + _tmp3_ = a[a_length1 - 1]; + _vala_assert (_tmp3_ == 5, "a[a.length - 1] == 5"); + a = (g_free (a), NULL); +} + +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__volatile = 0; + if (g_once_init_enter (&foo_type_id__volatile)) { + GType foo_type_id; + foo_type_id = foo_get_type_once (); + g_once_init_leave (&foo_type_id__volatile, foo_type_id); + } + return foo_type_id__volatile; +} + +Bar* +bar_dup (const Bar* self) +{ + Bar* dup; + dup = g_new0 (Bar, 1); + memcpy (dup, self, sizeof (Bar)); + return dup; +} + +void +bar_free (Bar* 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__volatile = 0; + if (g_once_init_enter (&bar_type_id__volatile)) { + GType bar_type_id; + bar_type_id = bar_get_type_once (); + g_once_init_leave (&bar_type_id__volatile, bar_type_id); + } + return bar_type_id__volatile; +} + +Manam* +manam_dup (const Manam* self) +{ + Manam* dup; + dup = g_new0 (Manam, 1); + memcpy (dup, self, sizeof (Manam)); + return dup; +} + +void +manam_free (Manam* 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__volatile = 0; + if (g_once_init_enter (&manam_type_id__volatile)) { + GType manam_type_id; + manam_type_id = manam_get_type_once (); + g_once_init_leave (&manam_type_id__volatile, manam_type_id); + } + return manam_type_id__volatile; +} + +static gboolean +_bar_equal (const Bar * s1, + const Bar * s2) +{ + if (s1 == s2) { + return TRUE; + } + if (s1 == NULL) { + return FALSE; + } + if (s2 == NULL) { + return FALSE; + } + if (s1->bar != s2->bar) { + return FALSE; + } + return TRUE; +} + +static gboolean +_vala_bar_array_contains (Bar * stack, + gssize stack_length, + const Bar * needle) +{ + gssize i; + for (i = 0; i < stack_length; i++) { + if (_bar_equal (&stack[i], needle) == TRUE) { + return TRUE; + } + } + return FALSE; +} + +static gpointer +_manam_dup0 (gpointer self) +{ + return self ? manam_dup (self) : NULL; +} + +void +test_struct_array (void) +{ + Foo _tmp0_; + Bar b = {0}; + Bar _tmp1_ = {0}; + Bar* bar = NULL; + Bar* _tmp2_; + gint bar_length1; + gint _bar_size_; + Bar _tmp3_; + Bar _tmp4_; + Manam* manam = NULL; + Manam _tmp5_ = {0}; + Manam* _tmp6_; + Manam* manam_copy = NULL; + Manam* _tmp7_; + _tmp0_ = FOO_ARRAY_CONST[0]; + _vala_assert (_tmp0_.bar == 42, "FOO_ARRAY_CONST[0].bar == 42"); + _tmp1_.bar = 4711; + b = _tmp1_; + _tmp2_ = g_new0 (Bar, 23); + bar = _tmp2_; + bar_length1 = 23; + _bar_size_ = bar_length1; + _tmp3_ = b; + bar[7] = _tmp3_; + _tmp4_ = b; + _vala_assert (_vala_bar_array_contains (bar, bar_length1, &_tmp4_), "b in bar"); + _tmp6_ = _manam_dup0 (&_tmp5_); + manam = _tmp6_; + _tmp7_ = _manam_dup0 (manam); + manam_copy = _tmp7_; + _manam_free0 (manam_copy); + _manam_free0 (manam); + bar = (g_free (bar), NULL); +} + +void +give_fixed_array (gint** i) +{ + gint _vala_i[3] = {0}; + gint _tmp0_[3] = {0}; + _tmp0_[0] = 3; + _tmp0_[1] = 4; + _tmp0_[2] = 5; + memcpy (_vala_i, _tmp0_, 3 * sizeof (gint)); + if (i) { + *i = _vala_i; + } +} + +void +take_fixed_array (gint* i) +{ + gint _tmp0_; + _vala_assert (3 == 3, "i.length == 3"); + _tmp0_ = i[1]; + _vala_assert (_tmp0_ == 2, "i[1] == 2"); +} + +void +change_fixed_array (gint** i) +{ + _vala_assert (3 == 3, "i.length == 3"); +} + +void +test_fixed_array (void) +{ + gint i[3] = {0}; + gint _tmp0_[3] = {0}; + gint k[3] = {0}; + gint _tmp1_[3] = {0}; + gint j[3] = {0}; + gint _tmp2_[3] = {0}; + _tmp0_[0] = 1; + _tmp0_[1] = 2; + _tmp0_[2] = 3; + memcpy (i, _tmp0_, 3 * sizeof (gint)); + _vala_assert (3 == 3, "i.length == 3"); + take_fixed_array (i); + _tmp1_[0] = 6; + _tmp1_[1] = 7; + _tmp1_[2] = 8; + memcpy (k, _tmp1_, 3 * sizeof (gint)); + change_fixed_array (&k); + _vala_assert (3 == 3, "k.length == 3"); + give_fixed_array (&_tmp2_); + memcpy (j, _tmp2_, 3 * sizeof (gint)); + _vala_assert (3 == 3, "j.length == 3"); +} + +static void +_vala_main (void) +{ + test_integer_array (); + test_string_array (); + test_array_pass (); + test_static_array (); + test_reference_transfer (); + test_length_assignment (); + test_inline_array (); + test_nd_array (); + test_delegate_array (); + test_void_array (); + test_explicit_copying (); + test_array_move (); + test_array_resize (); + test_struct_array (); + test_fixed_array (); +} + +int +main (int argc, + char ** argv) +{ + _vala_main (); + return 0; +} + +static void +_vala_array_destroy (gpointer array, + gssize array_length, + GDestroyNotify destroy_func) +{ + if ((array != NULL) && (destroy_func != NULL)) { + gssize i; + for (i = 0; i < array_length; i = i + 1) { + if (((gpointer*) array)[i] != NULL) { + destroy_func (((gpointer*) array)[i]); + } + } + } +} + +static void +_vala_array_free (gpointer array, + gssize array_length, + GDestroyNotify destroy_func) +{ + _vala_array_destroy (array, array_length, destroy_func); + g_free (array); +} + +static void +_vala_array_move (gpointer array, + gsize element_size, + gssize src, + gssize dest, + gssize length) +{ + memmove (((char*) array) + (dest * element_size), ((char*) array) + (src * element_size), length * element_size); + if ((src < dest) && ((src + length) > dest)) { + memset (((char*) array) + (src * element_size), 0, (dest - src) * element_size); + } else if ((src > dest) && (src < (dest + length))) { + memset (((char*) array) + ((dest + length) * element_size), 0, (src - dest) * element_size); + } else if (src != dest) { + memset (((char*) array) + (src * element_size), 0, length * element_size); + } +} + +static gssize +_vala_array_length (gpointer array) +{ + gssize length; + length = 0; + if (array) { + while (((gpointer*) array)[length]) { + length++; + } + } + return length; +} + +static inline gpointer +_vala_memdup2 (gconstpointer mem, + gsize byte_size) +{ + gpointer new_mem; + if (mem && byte_size != 0) { + new_mem = g_malloc (byte_size); + memcpy (new_mem, mem, byte_size); + } else { + new_mem = NULL; + } + return new_mem; +} + |