/* delegates_variadic.c generated by valac, the Vala compiler * generated from delegates_variadic.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 typedef void (*FooFunc) (const gchar* first, ...); typedef void (*BarFunc) (const gchar* first, ...); #define TYPE_BAZ_ERROR (baz_error_get_type ()) typedef void (*BazFunc) (const gchar* first, GError** error, ...); #define _g_free0(var) (var = (g_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); typedef enum { BAZ_ERROR_BAD, BAZ_ERROR_WORSE } BazError; #define BAZ_ERROR baz_error_quark () VALA_EXTERN GQuark baz_error_quark (void); GType baz_error_get_type (void) G_GNUC_CONST ; VALA_EXTERN void foo (const gchar* first, ...); VALA_EXTERN void baz (const gchar* first, GError** error, ...); VALA_EXTERN void baz_fail (const gchar* first, GError** error, ...); VALA_EXTERN void mamam (FooFunc func); static void _vala_main (void); GQuark baz_error_quark (void) { return g_quark_from_static_string ("baz-error-quark"); } static GType baz_error_get_type_once (void) { static const GEnumValue values[] = {{BAZ_ERROR_BAD, "BAZ_ERROR_BAD", "bad"}, {BAZ_ERROR_WORSE, "BAZ_ERROR_WORSE", "worse"}, {0, NULL, NULL}}; GType baz_error_type_id; baz_error_type_id = g_enum_register_static ("BazError", values); return baz_error_type_id; } GType baz_error_get_type (void) { static volatile gsize baz_error_type_id__once = 0; if (g_once_init_enter (&baz_error_type_id__once)) { GType baz_error_type_id; baz_error_type_id = baz_error_get_type_once (); g_once_init_leave (&baz_error_type_id__once, baz_error_type_id); } return baz_error_type_id__once; } void foo (const gchar* first, ...) { va_list args = {0}; gint i = 0; gchar* s = NULL; const gchar* _tmp0_; gchar* _tmp1_; g_return_if_fail (first != NULL); _vala_assert (g_strcmp0 (first, "foo") == 0, "first == \"foo\""); va_start (args, first); i = va_arg (args, gint); _vala_assert (i == 42, "i == 42"); _tmp0_ = va_arg (args, gchar*); _tmp1_ = g_strdup (_tmp0_); s = _tmp1_; _vala_assert (g_strcmp0 (s, "bar") == 0, "s == \"bar\""); _g_free0 (s); va_end (args); } void baz (const gchar* first, GError** error, ...) { va_list args = {0}; gint i = 0; gchar* s = NULL; const gchar* _tmp0_; gchar* _tmp1_; g_return_if_fail (first != NULL); _vala_assert (g_strcmp0 (first, "baz") == 0, "first == \"baz\""); va_start (args, error); i = va_arg (args, gint); _vala_assert (i == 23, "i == 23"); _tmp0_ = va_arg (args, gchar*); _tmp1_ = g_strdup (_tmp0_); s = _tmp1_; _vala_assert (g_strcmp0 (s, "bar") == 0, "s == \"bar\""); _g_free0 (s); va_end (args); } void baz_fail (const gchar* first, GError** error, ...) { GError* _tmp0_; GError* _inner_error0_ = NULL; g_return_if_fail (first != NULL); _tmp0_ = g_error_new_literal (BAZ_ERROR, BAZ_ERROR_BAD, "bad"); _inner_error0_ = _tmp0_; if (_inner_error0_->domain == BAZ_ERROR) { g_propagate_error (error, _inner_error0_); return; } else { 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; } } void mamam (FooFunc func) { func ("foo", 42, "bar", NULL); } static void _vala_main (void) { GError* _inner_error0_ = NULL; { FooFunc func = NULL; func = (FooFunc) foo; func ("foo", 42, "bar", NULL); } { FooFunc func = NULL; BarFunc f = NULL; func = (FooFunc) foo; f = func; } { FooFunc func = NULL; BarFunc f = NULL; func = (FooFunc) foo; f = (BarFunc) func; } { BazFunc func = NULL; func = (BazFunc) baz; func ("baz", &_inner_error0_, 23, "bar", 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; } } { BazFunc func = NULL; func = (BazFunc) baz_fail; { BazFunc _tmp0_; _tmp0_ = func; _tmp0_ ("baz", &_inner_error0_, 23, "bar", NULL); if (G_UNLIKELY (_inner_error0_ != NULL)) { if (g_error_matches (_inner_error0_, BAZ_ERROR, BAZ_ERROR_BAD)) { goto __catch0_baz_error_bad; } goto __catch0_g_error; } g_assert_not_reached (); } goto __finally0; __catch0_baz_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; } } { mamam ((FooFunc) foo); } { mamam ((FooFunc) foo); } } int main (int argc, char ** argv) { _vala_main (); return 0; }