/* methods_params_array_with_throws.c generated by valac, the Vala compiler * generated from methods_params_array_with_throws.vala, do not modify */ #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_ERROR (foo_error_get_type ()) #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; typedef struct _ParamSpecFoo ParamSpecFoo; #define _foo_unref0(var) ((var == NULL) ? NULL : (var = (foo_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); typedef enum { FOO_ERROR_BAD, FOO_ERROR_WORSE } FooError; #define FOO_ERROR foo_error_quark () struct _Foo { GTypeInstance parent_instance; volatile int ref_count; FooPrivate * priv; }; struct _FooClass { GTypeClass parent_class; void (*finalize) (Foo *self); }; struct _ParamSpecFoo { GParamSpec parent_instance; }; static gpointer foo_parent_class = NULL; VALA_EXTERN GQuark foo_error_quark (void); GType foo_error_get_type (void) G_GNUC_CONST ; VALA_EXTERN void foo (GError** error, const gchar* _first_array, ...); static void _vala_array_add1 (const gchar** * array, gint* length, gint* size, const gchar* value); VALA_EXTERN void bar (GError** error, const gchar* _first_array, ...); static void _vala_array_add2 (const gchar** * array, gint* length, gint* size, const gchar* value); VALA_EXTERN gpointer foo_ref (gpointer instance); VALA_EXTERN void foo_unref (gpointer instance); VALA_EXTERN GParamSpec* param_spec_foo (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags); VALA_EXTERN void value_set_foo (GValue* value, gpointer v_object); VALA_EXTERN void value_take_foo (GValue* value, gpointer v_object); VALA_EXTERN gpointer value_get_foo (const GValue* value); VALA_EXTERN GType foo_get_type (void) G_GNUC_CONST ; G_DEFINE_AUTOPTR_CLEANUP_FUNC (Foo, foo_unref) VALA_EXTERN void foo_foo (Foo* self, GError** error, const gchar* _first_array, ...); static void _vala_array_add3 (const gchar** * array, gint* length, gint* size, const gchar* value); VALA_EXTERN void foo_bar (Foo* self, GError** error, const gchar* _first_array, ...); static void _vala_array_add4 (const gchar** * array, gint* length, gint* size, const gchar* value); VALA_EXTERN Foo* foo_new (void); VALA_EXTERN Foo* foo_construct (GType object_type); static void foo_finalize (Foo * obj); static GType foo_get_type_once (void); static void _vala_main (void); GQuark foo_error_quark (void) { return g_quark_from_static_string ("foo-error-quark"); } static GType foo_error_get_type_once (void) { static const GEnumValue values[] = {{FOO_ERROR_BAD, "FOO_ERROR_BAD", "bad"}, {FOO_ERROR_WORSE, "FOO_ERROR_WORSE", "worse"}, {0, NULL, NULL}}; GType foo_error_type_id; foo_error_type_id = g_enum_register_static ("FooError", values); return foo_error_type_id; } GType foo_error_get_type (void) { static volatile gsize foo_error_type_id__once = 0; if (g_once_init_enter (&foo_error_type_id__once)) { GType foo_error_type_id; foo_error_type_id = foo_error_get_type_once (); g_once_init_leave (&foo_error_type_id__once, foo_error_type_id); } return foo_error_type_id__once; } static void _vala_array_add1 (const gchar** * array, gint* length, gint* size, const gchar* value) { if ((*length) == (*size)) { *size = (*size) ? (2 * (*size)) : 4; *array = g_renew (const gchar*, *array, (*size) + 1); } (*array)[(*length)++] = value; (*array)[*length] = NULL; } void foo (GError** error, const gchar* _first_array, ...) { const gchar* _array_element; va_list _va_list_array; const gchar** array = NULL; gint array_length1 = 0; gint _array_size_ = 0; const gchar* _tmp0_; const gchar* _tmp1_; const gchar* _tmp2_; array = g_new0 (const gchar*, array_length1 + 1); va_start (_va_list_array, _first_array); _array_element = _first_array; while (_array_element != NULL) { _vala_array_add1 (&array, &array_length1, &_array_size_, _array_element); _array_element = va_arg (_va_list_array, const gchar*); } va_end (_va_list_array); _vala_assert (array_length1 == 3, "array.length == 3"); _tmp0_ = array[0]; _vala_assert (g_strcmp0 (_tmp0_, "foo") == 0, "array[0] == \"foo\""); _tmp1_ = array[1]; _vala_assert (g_strcmp0 (_tmp1_, "bar") == 0, "array[1] == \"bar\""); _tmp2_ = array[2]; _vala_assert (g_strcmp0 (_tmp2_, "manam") == 0, "array[2] == \"manam\""); array = (g_free (array), NULL); } static void _vala_array_add2 (const gchar** * array, gint* length, gint* size, const gchar* value) { if ((*length) == (*size)) { *size = (*size) ? (2 * (*size)) : 4; *array = g_renew (const gchar*, *array, (*size) + 1); } (*array)[(*length)++] = value; (*array)[*length] = NULL; } void bar (GError** error, const gchar* _first_array, ...) { const gchar* _array_element; va_list _va_list_array; const gchar** array = NULL; gint array_length1 = 0; gint _array_size_ = 0; GError* _tmp0_; GError* _inner_error0_ = NULL; array = g_new0 (const gchar*, array_length1 + 1); va_start (_va_list_array, _first_array); _array_element = _first_array; while (_array_element != NULL) { _vala_array_add2 (&array, &array_length1, &_array_size_, _array_element); _array_element = va_arg (_va_list_array, const gchar*); } va_end (_va_list_array); _tmp0_ = g_error_new_literal (FOO_ERROR, FOO_ERROR_BAD, "bad"); _inner_error0_ = _tmp0_; if (_inner_error0_->domain == FOO_ERROR) { g_propagate_error (error, _inner_error0_); array = (g_free (array), NULL); return; } else { array = (g_free (array), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return; } } static void _vala_array_add3 (const gchar** * array, gint* length, gint* size, const gchar* value) { if ((*length) == (*size)) { *size = (*size) ? (2 * (*size)) : 4; *array = g_renew (const gchar*, *array, (*size) + 1); } (*array)[(*length)++] = value; (*array)[*length] = NULL; } void foo_foo (Foo* self, GError** error, const gchar* _first_array, ...) { const gchar* _array_element; va_list _va_list_array; const gchar** array = NULL; gint array_length1 = 0; gint _array_size_ = 0; const gchar* _tmp0_; const gchar* _tmp1_; const gchar* _tmp2_; g_return_if_fail (IS_FOO (self)); array = g_new0 (const gchar*, array_length1 + 1); va_start (_va_list_array, _first_array); _array_element = _first_array; while (_array_element != NULL) { _vala_array_add3 (&array, &array_length1, &_array_size_, _array_element); _array_element = va_arg (_va_list_array, const gchar*); } va_end (_va_list_array); _vala_assert (array_length1 == 3, "array.length == 3"); _tmp0_ = array[0]; _vala_assert (g_strcmp0 (_tmp0_, "foo") == 0, "array[0] == \"foo\""); _tmp1_ = array[1]; _vala_assert (g_strcmp0 (_tmp1_, "bar") == 0, "array[1] == \"bar\""); _tmp2_ = array[2]; _vala_assert (g_strcmp0 (_tmp2_, "manam") == 0, "array[2] == \"manam\""); array = (g_free (array), NULL); } static void _vala_array_add4 (const gchar** * array, gint* length, gint* size, const gchar* value) { if ((*length) == (*size)) { *size = (*size) ? (2 * (*size)) : 4; *array = g_renew (const gchar*, *array, (*size) + 1); } (*array)[(*length)++] = value; (*array)[*length] = NULL; } void foo_bar (Foo* self, GError** error, const gchar* _first_array, ...) { const gchar* _array_element; va_list _va_list_array; const gchar** array = NULL; gint array_length1 = 0; gint _array_size_ = 0; GError* _tmp0_; GError* _inner_error0_ = NULL; g_return_if_fail (IS_FOO (self)); array = g_new0 (const gchar*, array_length1 + 1); va_start (_va_list_array, _first_array); _array_element = _first_array; while (_array_element != NULL) { _vala_array_add4 (&array, &array_length1, &_array_size_, _array_element); _array_element = va_arg (_va_list_array, const gchar*); } va_end (_va_list_array); _tmp0_ = g_error_new_literal (FOO_ERROR, FOO_ERROR_BAD, "bad"); _inner_error0_ = _tmp0_; if (_inner_error0_->domain == FOO_ERROR) { g_propagate_error (error, _inner_error0_); array = (g_free (array), NULL); return; } else { array = (g_free (array), NULL); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return; } } Foo* foo_construct (GType object_type) { Foo* self = NULL; self = (Foo*) g_type_create_instance (object_type); return self; } Foo* foo_new (void) { return foo_construct (TYPE_FOO); } static void value_foo_init (GValue* value) { value->data[0].v_pointer = NULL; } static void value_foo_free_value (GValue* value) { if (value->data[0].v_pointer) { foo_unref (value->data[0].v_pointer); } } static void value_foo_copy_value (const GValue* src_value, GValue* dest_value) { if (src_value->data[0].v_pointer) { dest_value->data[0].v_pointer = foo_ref (src_value->data[0].v_pointer); } else { dest_value->data[0].v_pointer = NULL; } } static gpointer value_foo_peek_pointer (const GValue* value) { return value->data[0].v_pointer; } static gchar* value_foo_collect_value (GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { if (collect_values[0].v_pointer) { Foo * object; object = collect_values[0].v_pointer; if (object->parent_instance.g_class == NULL) { return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL); } else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) { return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL); } value->data[0].v_pointer = foo_ref (object); } else { value->data[0].v_pointer = NULL; } return NULL; } static gchar* value_foo_lcopy_value (const GValue* value, guint n_collect_values, GTypeCValue* collect_values, guint collect_flags) { Foo ** object_p; object_p = collect_values[0].v_pointer; if (!object_p) { return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value)); } if (!value->data[0].v_pointer) { *object_p = NULL; } else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) { *object_p = value->data[0].v_pointer; } else { *object_p = foo_ref (value->data[0].v_pointer); } return NULL; } GParamSpec* param_spec_foo (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags) { ParamSpecFoo* spec; g_return_val_if_fail (g_type_is_a (object_type, TYPE_FOO), NULL); spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags); G_PARAM_SPEC (spec)->value_type = object_type; return G_PARAM_SPEC (spec); } gpointer value_get_foo (const GValue* value) { g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_FOO), NULL); return value->data[0].v_pointer; } void value_set_foo (GValue* value, gpointer v_object) { Foo * old; g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_FOO)); old = value->data[0].v_pointer; if (v_object) { g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_FOO)); g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value))); value->data[0].v_pointer = v_object; foo_ref (value->data[0].v_pointer); } else { value->data[0].v_pointer = NULL; } if (old) { foo_unref (old); } } void value_take_foo (GValue* value, gpointer v_object) { Foo * old; g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_FOO)); old = value->data[0].v_pointer; if (v_object) { g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_FOO)); g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value))); value->data[0].v_pointer = v_object; } else { value->data[0].v_pointer = NULL; } if (old) { foo_unref (old); } } static void foo_class_init (FooClass * klass, gpointer klass_data) { foo_parent_class = g_type_class_peek_parent (klass); ((FooClass *) klass)->finalize = foo_finalize; } static void foo_instance_init (Foo * self, gpointer klass) { self->ref_count = 1; } static void foo_finalize (Foo * obj) { Foo * self; self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FOO, Foo); g_signal_handlers_destroy (self); } static GType foo_get_type_once (void) { static const GTypeValueTable g_define_type_value_table = { value_foo_init, value_foo_free_value, value_foo_copy_value, value_foo_peek_pointer, "p", value_foo_collect_value, "p", value_foo_lcopy_value }; 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, &g_define_type_value_table }; static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) }; GType foo_type_id; foo_type_id = g_type_register_fundamental (g_type_fundamental_next (), "Foo", &g_define_type_info, &g_define_type_fundamental_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; } gpointer foo_ref (gpointer instance) { Foo * self; self = instance; g_atomic_int_inc (&self->ref_count); return instance; } void foo_unref (gpointer instance) { Foo * self; self = instance; if (g_atomic_int_dec_and_test (&self->ref_count)) { FOO_GET_CLASS (self)->finalize (self); g_type_free_instance ((GTypeInstance *) self); } } static void _vala_main (void) { GError* _inner_error0_ = NULL; { foo (&_inner_error0_, "foo", "bar", "manam", NULL); if (G_UNLIKELY (_inner_error0_ != NULL)) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return; } } { { bar (&_inner_error0_, "foo", "bar", "manam", NULL); if (G_UNLIKELY (_inner_error0_ != NULL)) { if (g_error_matches (_inner_error0_, FOO_ERROR, FOO_ERROR_BAD)) { goto __catch0_foo_error_bad; } goto __catch0_g_error; } g_assert_not_reached (); } goto __finally0; __catch0_foo_error_bad: { g_clear_error (&_inner_error0_); } goto __finally0; __catch0_g_error: { g_clear_error (&_inner_error0_); g_assert_not_reached (); } __finally0: if (G_UNLIKELY (_inner_error0_ != NULL)) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return; } } { Foo* foo = NULL; Foo* _tmp0_; Foo* _tmp1_; _tmp0_ = foo_new (); foo = _tmp0_; _tmp1_ = foo; foo_foo (_tmp1_, &_inner_error0_, "foo", "bar", "manam", NULL); if (G_UNLIKELY (_inner_error0_ != NULL)) { _foo_unref0 (foo); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return; } _foo_unref0 (foo); } { { Foo* foo = NULL; Foo* _tmp2_; Foo* _tmp3_; _tmp2_ = foo_new (); foo = _tmp2_; _tmp3_ = foo; foo_bar (_tmp3_, &_inner_error0_, "foo", "bar", "manam", NULL); if (G_UNLIKELY (_inner_error0_ != NULL)) { _foo_unref0 (foo); if (g_error_matches (_inner_error0_, FOO_ERROR, FOO_ERROR_BAD)) { goto __catch1_foo_error_bad; } goto __catch1_g_error; } g_assert_not_reached (); _foo_unref0 (foo); } goto __finally1; __catch1_foo_error_bad: { g_clear_error (&_inner_error0_); } goto __finally1; __catch1_g_error: { g_clear_error (&_inner_error0_); g_assert_not_reached (); } __finally1: if (G_UNLIKELY (_inner_error0_ != NULL)) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code); g_clear_error (&_inner_error0_); return; } } } int main (int argc, char ** argv) { _vala_main (); return 0; }