1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235
|
/* delegates_variadic.c generated by valac, the Vala compiler
* generated from delegates_variadic.vala, do not modify */
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <stdarg.h>
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#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
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);
VALA_EXTERN 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;
}
|