/* basic_types_garray.c generated by valac, the Vala compiler * generated from basic_types_garray.vala, do not modify */ #include #include #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_FOO (foo_get_type ()) #define FOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FOO, Foo)) #define FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FOO, FooClass)) #define IS_FOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FOO)) #define IS_FOO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FOO)) #define FOO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FOO, FooClass)) typedef struct _Foo Foo; typedef struct _FooClass FooClass; typedef struct _FooPrivate FooPrivate; enum { FOO_0_PROPERTY, FOO_NUM_PROPERTIES }; static GParamSpec* foo_properties[FOO_NUM_PROPERTIES]; #define TYPE_FOO_STRUCT (foo_struct_get_type ()) typedef struct _FooStruct FooStruct; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) #define _g_array_unref0(var) ((var == NULL) ? NULL : (var = (g_array_unref (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 { GObject parent_instance; FooPrivate * priv; }; struct _FooClass { GObjectClass parent_class; }; struct _FooStruct { gchar* content; Foo* object; }; static gpointer foo_parent_class = NULL; VALA_EXTERN GType foo_get_type (void) G_GNUC_CONST ; G_DEFINE_AUTOPTR_CLEANUP_FUNC (Foo, g_object_unref) VALA_EXTERN Foo* foo_new (void); VALA_EXTERN Foo* foo_construct (GType object_type); static GType foo_get_type_once (void); VALA_EXTERN GType foo_struct_get_type (void) G_GNUC_CONST ; VALA_EXTERN FooStruct* foo_struct_dup (const FooStruct* self); VALA_EXTERN void foo_struct_free (FooStruct* self); VALA_EXTERN void foo_struct_copy (const FooStruct* self, FooStruct* dest); VALA_EXTERN void foo_struct_destroy (FooStruct* self); G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (FooStruct, foo_struct_destroy) VALA_EXTERN void test_garray (void); static void _g_object_unref0_ (gpointer var); static void _vala_Foo_free_function_content_of (gpointer data); VALA_EXTERN void test_garray_foreach (void); VALA_EXTERN void test_int_garray (void); VALA_EXTERN GArray* create_struct_garray (void); static void _foo_struct_free0_ (gpointer var); static void _vala_FooStruct_free_function_content_of (gpointer data); VALA_EXTERN void test_struct_garray (void); VALA_EXTERN void test_object_garray (void); VALA_EXTERN GArray* check_gvalue_garray (GArray* vals); VALA_EXTERN void test_gvalue_garray (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); Foo* foo_construct (GType object_type) { Foo * self = NULL; self = (Foo*) g_object_new (object_type, NULL); return self; } Foo* foo_new (void) { return foo_construct (TYPE_FOO); } static void foo_class_init (FooClass * klass, gpointer klass_data) { foo_parent_class = g_type_class_peek_parent (klass); } static void foo_instance_init (Foo * self, gpointer klass) { } static GType foo_get_type_once (void) { static const GTypeInfo g_define_type_info = { sizeof (FooClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) foo_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Foo), 0, (GInstanceInitFunc) foo_instance_init, NULL }; GType foo_type_id; foo_type_id = g_type_register_static (G_TYPE_OBJECT, "Foo", &g_define_type_info, 0); 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 _g_object_ref0 (gpointer self) { return self ? g_object_ref (self) : NULL; } void foo_struct_copy (const FooStruct* self, FooStruct* dest) { const gchar* _tmp0_; gchar* _tmp1_; Foo* _tmp2_; Foo* _tmp3_; _tmp0_ = (*self).content; _tmp1_ = g_strdup (_tmp0_); _g_free0 ((*dest).content); (*dest).content = _tmp1_; _tmp2_ = (*self).object; _tmp3_ = _g_object_ref0 (_tmp2_); _g_object_unref0 ((*dest).object); (*dest).object = _tmp3_; } void foo_struct_destroy (FooStruct* self) { _g_free0 ((*self).content); _g_object_unref0 ((*self).object); } FooStruct* foo_struct_dup (const FooStruct* self) { FooStruct* dup; dup = g_new0 (FooStruct, 1); foo_struct_copy (self, dup); return dup; } void foo_struct_free (FooStruct* self) { foo_struct_destroy (self); g_free (self); } static GType foo_struct_get_type_once (void) { GType foo_struct_type_id; foo_struct_type_id = g_boxed_type_register_static ("FooStruct", (GBoxedCopyFunc) foo_struct_dup, (GBoxedFreeFunc) foo_struct_free); return foo_struct_type_id; } GType foo_struct_get_type (void) { static volatile gsize foo_struct_type_id__once = 0; if (g_once_init_enter (&foo_struct_type_id__once)) { GType foo_struct_type_id; foo_struct_type_id = foo_struct_get_type_once (); g_once_init_leave (&foo_struct_type_id__once, foo_struct_type_id); } return foo_struct_type_id__once; } static void _g_object_unref0_ (gpointer var) { (var == NULL) ? NULL : (var = (g_object_unref (var), NULL)); } static void _vala_Foo_free_function_content_of (gpointer data) { Foo* self; self = *((Foo**) data); _g_object_unref0_ (self); } static gpointer vala_g_array_remove_index (GArray* self, guint index) { gpointer g = NULL; gpointer* _tmp0_; gint _tmp0__length1; gpointer _tmp1_; gpointer result; g_return_val_if_fail (self != NULL, NULL); _vala_assert (self->len > index, "length > index"); _tmp0_ = self->data; _tmp0__length1 = self->len; _tmp1_ = _tmp0_[index]; _tmp0_[index] = NULL; g = _tmp1_; g_array_remove_index (self, index); result = g; return result; } static gpointer vala_g_array_remove_index_fast (GArray* self, guint index) { gpointer g = NULL; gpointer* _tmp0_; gint _tmp0__length1; gpointer _tmp1_; gpointer result; g_return_val_if_fail (self != NULL, NULL); _vala_assert (self->len > index, "length > index"); _tmp0_ = self->data; _tmp0__length1 = self->len; _tmp1_ = _tmp0_[index]; _tmp0_[index] = NULL; g = _tmp1_; g_array_remove_index_fast (self, index); result = g; return result; } static gpointer* vala_g_array_remove_range (GArray* self, guint index, guint length, gint* result_length1) { gpointer* ga = NULL; gpointer* _tmp0_; gint ga_length1; gint _ga_size_; gpointer* _tmp6_; gint _tmp6__length1; gpointer* result; g_return_val_if_fail (self != NULL, NULL); _vala_assert (self->len >= (index + length), "this.length >= index + length"); _tmp0_ = g_new0 (gpointer, length); ga = _tmp0_; ga_length1 = length; _ga_size_ = ga_length1; { guint i = 0U; i = (guint) 0; { gboolean _tmp1_ = FALSE; _tmp1_ = TRUE; while (TRUE) { gpointer* _tmp3_; gint _tmp3__length1; gpointer* _tmp4_; gint _tmp4__length1; gpointer _tmp5_; if (!_tmp1_) { guint _tmp2_; _tmp2_ = i; i = _tmp2_ + 1; } _tmp1_ = FALSE; if (!(i < length)) { break; } _tmp3_ = ga; _tmp3__length1 = ga_length1; _tmp4_ = self->data; _tmp4__length1 = self->len; _tmp5_ = _tmp4_[i + index]; _tmp4_[i + index] = NULL; _tmp3_[i] = _tmp5_; } } } g_array_remove_range (self, index, length); _tmp6_ = ga; _tmp6__length1 = ga_length1; if (result_length1) { *result_length1 = _tmp6__length1; } result = _tmp6_; return result; } void test_garray (void) { GArray* array = NULL; GArray* _tmp0_; Foo* foo = NULL; Foo* _tmp1_; Foo* _tmp2_; Foo* _tmp3_; Foo* _tmp4_; Foo* _tmp5_; Foo* _tmp6_; Foo* _tmp7_; Foo* _tmp8_; Foo* _tmp9_; Foo* _tmp10_; Foo* _tmp11_; Foo* _tmp12_; Foo* _tmp13_; gint _tmp14_ = 0; gpointer* _tmp15_; Foo** _tmp16_; gint _tmp16__length1; _tmp0_ = g_array_new (TRUE, TRUE, sizeof (Foo*)); g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_Foo_free_function_content_of); array = _tmp0_; _tmp1_ = foo_new (); foo = _tmp1_; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "foo.ref_count == 1"); _tmp2_ = _g_object_ref0 (foo); g_array_append_val (array, _tmp2_); _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo.ref_count == 2"); _tmp3_ = g_array_index (array, Foo*, (guint) 0); _vala_assert (_tmp3_ == foo, "array.index (0) == foo"); _tmp4_ = vala_g_array_remove_index (array, (guint) 0); _tmp5_ = _tmp4_; _g_object_unref0 (_tmp5_); _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "foo.ref_count == 1"); _tmp6_ = _g_object_ref0 (foo); g_array_append_val (array, _tmp6_); _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo.ref_count == 2"); _tmp7_ = g_array_index (array, Foo*, (guint) 0); _vala_assert (_tmp7_ == foo, "array.index (0) == foo"); _tmp8_ = vala_g_array_remove_index_fast (array, (guint) 0); _tmp9_ = _tmp8_; _g_object_unref0 (_tmp9_); _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "foo.ref_count == 1"); _tmp10_ = _g_object_ref0 (foo); g_array_append_val (array, _tmp10_); _tmp11_ = _g_object_ref0 (foo); g_array_append_val (array, _tmp11_); _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 3), "foo.ref_count == 3"); _tmp12_ = g_array_index (array, Foo*, (guint) 0); _vala_assert (_tmp12_ == foo, "array.index (0) == foo"); _tmp13_ = g_array_index (array, Foo*, (guint) 1); _vala_assert (_tmp13_ == foo, "array.index (1) == foo"); _tmp15_ = vala_g_array_remove_range (array, (guint) 0, (guint) 2, &_tmp14_); _tmp16_ = _tmp15_; _tmp16__length1 = _tmp14_; _tmp16_ = (_vala_array_free (_tmp16_, _tmp16__length1, (GDestroyNotify) g_object_unref), NULL); _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "foo.ref_count == 1"); _g_object_unref0 (foo); _g_array_unref0 (array); } void test_garray_foreach (void) { GArray* array = NULL; GArray* _tmp0_; Foo* foo1 = NULL; Foo* _tmp1_; Foo* foo2 = NULL; Foo* _tmp2_; Foo* foo3 = NULL; Foo* _tmp3_; GArray* _tmp4_; Foo* _tmp5_; Foo* _tmp6_; Foo* _tmp7_; GArray* _tmp8_; Foo* _tmp9_; Foo* _tmp10_; Foo* _tmp11_; GArray* _tmp12_; Foo* _tmp13_; Foo* _tmp14_; Foo* _tmp15_; GArray* _tmp16_; gint loop_size = 0; GArray* _tmp17_; GArray* _tmp26_; Foo* _tmp36_; Foo* _tmp37_; Foo* _tmp38_; _tmp0_ = g_array_new (TRUE, TRUE, sizeof (Foo*)); g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_Foo_free_function_content_of); array = _tmp0_; _tmp1_ = foo_new (); foo1 = _tmp1_; _tmp2_ = foo_new (); foo2 = _tmp2_; _tmp3_ = foo_new (); foo3 = _tmp3_; _tmp4_ = array; _tmp5_ = foo1; _tmp6_ = _g_object_ref0 (_tmp5_); g_array_append_val (_tmp4_, _tmp6_); _tmp7_ = foo1; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo1.ref_count == 2"); _tmp8_ = array; _tmp9_ = foo2; _tmp10_ = _g_object_ref0 (_tmp9_); g_array_append_val (_tmp8_, _tmp10_); _tmp11_ = foo2; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo2.ref_count == 2"); _tmp12_ = array; _tmp13_ = foo3; _tmp14_ = _g_object_ref0 (_tmp13_); g_array_append_val (_tmp12_, _tmp14_); _tmp15_ = foo3; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo3.ref_count == 2"); _tmp16_ = array; _vala_assert (_tmp16_->len == ((guint) 3), "array.length == 3"); loop_size = 0; _tmp17_ = array; { GArray* element_collection = NULL; guint element_index = 0U; element_collection = _tmp17_; for (element_index = 0; element_index < element_collection->len; element_index = element_index + 1) { Foo* element = NULL; element = g_array_index (element_collection, Foo*, element_index); { gint _tmp18_; Foo* _tmp19_; _tmp18_ = loop_size; loop_size = _tmp18_ + 1; _tmp19_ = element; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp19_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "element.ref_count == 2"); switch (loop_size) { case 1: { Foo* _tmp20_; Foo* _tmp21_; _tmp20_ = element; _tmp21_ = foo1; _vala_assert (_tmp20_ == _tmp21_, "element == foo1"); break; } case 2: { Foo* _tmp22_; Foo* _tmp23_; _tmp22_ = element; _tmp23_ = foo2; _vala_assert (_tmp22_ == _tmp23_, "element == foo2"); break; } case 3: { Foo* _tmp24_; Foo* _tmp25_; _tmp24_ = element; _tmp25_ = foo3; _vala_assert (_tmp24_ == _tmp25_, "element == foo3"); break; } default: break; } } } } _vala_assert (loop_size == 3, "loop_size == 3"); loop_size = 0; _tmp26_ = array; { GArray* element_collection = NULL; guint element_index = 0U; element_collection = _tmp26_; for (element_index = 0; element_index < element_collection->len; element_index = element_index + 1) { Foo* _tmp27_; Foo* element = NULL; _tmp27_ = _g_object_ref0 (g_array_index (element_collection, Foo*, element_index)); element = _tmp27_; { gint _tmp28_; Foo* _tmp29_; _tmp28_ = loop_size; loop_size = _tmp28_ + 1; _tmp29_ = element; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 3), "element.ref_count == 3"); switch (loop_size) { case 1: { Foo* _tmp30_; Foo* _tmp31_; _tmp30_ = element; _tmp31_ = foo1; _vala_assert (_tmp30_ == _tmp31_, "element == foo1"); break; } case 2: { Foo* _tmp32_; Foo* _tmp33_; _tmp32_ = element; _tmp33_ = foo2; _vala_assert (_tmp32_ == _tmp33_, "element == foo2"); break; } case 3: { Foo* _tmp34_; Foo* _tmp35_; _tmp34_ = element; _tmp35_ = foo3; _vala_assert (_tmp34_ == _tmp35_, "element == foo3"); break; } default: break; } _g_object_unref0 (element); } } } _vala_assert (loop_size == 3, "loop_size == 3"); _tmp36_ = foo1; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp36_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo1.ref_count == 2"); _tmp37_ = foo2; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo2.ref_count == 2"); _tmp38_ = foo3; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp38_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo3.ref_count == 2"); _g_object_unref0 (foo3); _g_object_unref0 (foo2); _g_object_unref0 (foo1); _g_array_unref0 (array); } void test_int_garray (void) { GArray* array = NULL; GArray* _tmp0_; gint val = 0; gint _tmp1_; gint _tmp2_; _tmp0_ = g_array_new (TRUE, TRUE, sizeof (gint)); array = _tmp0_; val = 1; g_array_prepend_val (array, val); _tmp1_ = val; val = _tmp1_ + 1; g_array_append_val (array, val); _tmp2_ = val; val = _tmp2_ + 1; g_array_insert_val (array, (guint) 2, val); _vala_assert (g_array_index (array, gint, (guint) 0) == 1, "array.index (0) == 1"); _vala_assert (g_array_index (array, gint, (guint) 1) == 2, "array.index (1) == 2"); _vala_assert (g_array_index (array, gint, (guint) 2) == 3, "array.index (2) == 3"); _vala_assert (array->len == ((guint) 3), "array.length == 3"); _g_array_unref0 (array); } static void _foo_struct_free0_ (gpointer var) { (var == NULL) ? NULL : (var = (foo_struct_free (var), NULL)); } static void _vala_FooStruct_free_function_content_of (gpointer data) { FooStruct* self; self = *((FooStruct**) data); _foo_struct_free0_ (self); } static gpointer _foo_struct_dup0 (gpointer self) { return self ? foo_struct_dup (self) : NULL; } GArray* create_struct_garray (void) { GArray* array = NULL; GArray* _tmp0_; FooStruct foo1 = {0}; gchar* _tmp1_; Foo* _tmp2_; FooStruct _tmp3_ = {0}; FooStruct _tmp4_; FooStruct _tmp5_; FooStruct* _tmp6_; FooStruct foo2 = {0}; gchar* _tmp7_; Foo* _tmp8_; FooStruct _tmp9_ = {0}; FooStruct _tmp10_; FooStruct _tmp11_; FooStruct* _tmp12_; GArray* result; _tmp0_ = g_array_new (TRUE, TRUE, sizeof (FooStruct*)); g_array_set_clear_func (_tmp0_, (GDestroyNotify) _vala_FooStruct_free_function_content_of); array = _tmp0_; _tmp1_ = g_strdup ("foo"); _tmp2_ = foo_new (); _g_free0 (_tmp3_.content); _tmp3_.content = _tmp1_; _g_object_unref0 (_tmp3_.object); _tmp3_.object = _tmp2_; foo1 = _tmp3_; _tmp4_ = foo1; _tmp5_ = _tmp4_; _tmp6_ = _foo_struct_dup0 (&_tmp5_); g_array_append_val (array, _tmp6_); _tmp7_ = g_strdup ("bar"); _tmp8_ = foo_new (); _g_free0 (_tmp9_.content); _tmp9_.content = _tmp7_; _g_object_unref0 (_tmp9_.object); _tmp9_.object = _tmp8_; foo2 = _tmp9_; _tmp10_ = foo2; _tmp11_ = _tmp10_; _tmp12_ = _foo_struct_dup0 (&_tmp11_); g_array_append_val (array, _tmp12_); result = array; foo_struct_destroy (&foo2); foo_struct_destroy (&foo1); return result; } void test_struct_garray (void) { GArray* array = NULL; GArray* _tmp0_; GArray* _tmp1_; GArray* _tmp2_; const gchar* _tmp3_; GArray* _tmp4_; Foo* _tmp5_; GArray* _tmp6_; const gchar* _tmp7_; GArray* _tmp8_; Foo* _tmp9_; Foo* f = NULL; GArray* _tmp10_; Foo* _tmp11_; Foo* _tmp12_; _tmp0_ = create_struct_garray (); array = _tmp0_; _tmp1_ = array; _vala_assert (_tmp1_->len == ((guint) 2), "array.length == 2"); _tmp2_ = array; _tmp3_ = (*g_array_index (_tmp2_, FooStruct*, (guint) 0)).content; _vala_assert (g_strcmp0 (_tmp3_, "foo") == 0, "array.index (0).content == \"foo\""); _tmp4_ = array; _tmp5_ = (*g_array_index (_tmp4_, FooStruct*, (guint) 0)).object; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "array.index (0).object.ref_count == 1"); _tmp6_ = array; _tmp7_ = (*g_array_index (_tmp6_, FooStruct*, (guint) 1)).content; _vala_assert (g_strcmp0 (_tmp7_, "bar") == 0, "array.index (1).content == \"bar\""); _tmp8_ = array; _tmp9_ = (*g_array_index (_tmp8_, FooStruct*, (guint) 1)).object; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "array.index (1).object.ref_count == 1"); _tmp10_ = array; _tmp11_ = (*g_array_index (_tmp10_, FooStruct*, (guint) 0)).object; _tmp12_ = _g_object_ref0 (_tmp11_); f = _tmp12_; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (f, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "f.ref_count == 2"); _g_array_unref0 (array); array = NULL; _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (f, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "f.ref_count == 1"); _g_object_unref0 (f); _g_array_unref0 (array); } void test_object_garray (void) { Foo* foo = NULL; Foo* _tmp0_; _tmp0_ = foo_new (); foo = _tmp0_; { GArray* array = NULL; GArray* _tmp1_; GArray* _tmp2_; Foo* _tmp3_; _tmp1_ = g_array_new (TRUE, TRUE, sizeof (Foo*)); g_array_set_clear_func (_tmp1_, (GDestroyNotify) _vala_Foo_free_function_content_of); array = _tmp1_; _tmp2_ = array; _tmp3_ = _g_object_ref0 (foo); g_array_append_val (_tmp2_, _tmp3_); _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 2), "foo.ref_count == 2"); _g_array_unref0 (array); array = NULL; _g_array_unref0 (array); } _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "foo.ref_count == 1"); { GArray* array = NULL; GArray* _tmp4_; GArray* _tmp5_; _tmp4_ = g_array_new (TRUE, TRUE, sizeof (Foo*)); array = _tmp4_; _tmp5_ = array; g_array_append_val (_tmp5_, foo); _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "foo.ref_count == 1"); _g_array_unref0 (array); array = NULL; _g_array_unref0 (array); } _vala_assert (G_TYPE_CHECK_INSTANCE_CAST (foo, G_TYPE_OBJECT, GObject)->ref_count == ((guint) 1), "foo.ref_count == 1"); _g_object_unref0 (foo); } GArray* check_gvalue_garray (GArray* vals) { GArray* result; g_return_val_if_fail (vals != NULL, NULL); _vala_assert (g_strcmp0 (g_value_get_string (&g_array_index (vals, GValue, (guint) 0)), "foo") == 0, "vals.index (0) == \"foo\""); _vala_assert (g_value_get_int (&g_array_index (vals, GValue, (guint) 1)) == 42, "vals.index (1) == 42"); _vala_assert (g_value_get_double (&g_array_index (vals, GValue, (guint) 2)) == 3.1415, "vals.index (2) == 3.1415"); result = vals; return result; } void test_gvalue_garray (void) { { GArray* foo = NULL; GArray* _tmp0_; GValue _tmp1_ = {0}; GValue _tmp2_ = {0}; GValue _tmp3_ = {0}; _tmp0_ = g_array_new (TRUE, TRUE, sizeof (GValue)); g_array_set_clear_func (_tmp0_, (GDestroyNotify) g_value_unset); foo = _tmp0_; g_value_init (&_tmp1_, G_TYPE_STRING); g_value_set_string (&_tmp1_, "foo"); g_array_append_val (foo, _tmp1_); g_value_init (&_tmp2_, G_TYPE_INT); g_value_set_int (&_tmp2_, 42); g_array_append_val (foo, _tmp2_); g_value_init (&_tmp3_, G_TYPE_DOUBLE); g_value_set_double (&_tmp3_, 3.1415); g_array_append_val (foo, _tmp3_); check_gvalue_garray (foo); _g_array_unref0 (foo); } { GArray* foo = NULL; GArray* _tmp4_; GValue _tmp5_ = {0}; GValue _tmp6_ = {0}; GValue _tmp7_ = {0}; _tmp4_ = g_array_new (TRUE, TRUE, sizeof (GValue)); g_array_set_clear_func (_tmp4_, (GDestroyNotify) g_value_unset); foo = _tmp4_; g_value_init (&_tmp5_, G_TYPE_STRING); g_value_set_string (&_tmp5_, "foo"); g_array_append_val (foo, _tmp5_); g_value_init (&_tmp6_, G_TYPE_INT); g_value_set_int (&_tmp6_, 42); g_array_append_val (foo, _tmp6_); g_value_init (&_tmp7_, G_TYPE_DOUBLE); g_value_set_double (&_tmp7_, 3.1415); g_array_append_val (foo, _tmp7_); check_gvalue_garray (foo); _g_array_unref0 (foo); } } static void _vala_main (void) { test_garray (); test_garray_foreach (); test_int_garray (); test_struct_garray (); test_object_garray (); test_gvalue_garray (); } 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); }