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 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
|
/* structs_structs.c generated by valac, the Vala compiler
* generated from structs_structs.vala, do not modify */
#include <glib-object.h>
#include <glib.h>
#include <string.h>
#include <stdio.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
#define TYPE_SIMPLE_STRUCT (simple_struct_get_type ())
typedef struct _SimpleStruct SimpleStruct;
#define TYPE_PUBLIC_STRUCT (public_struct_get_type ())
typedef struct _PublicStruct PublicStruct;
#define TYPE_STRUCT_WITH_CREATION_METHOD (struct_with_creation_method_get_type ())
typedef struct _StructWithCreationMethod StructWithCreationMethod;
#define TYPE_STRUCT_WITH_NAMED_CREATION_METHOD (struct_with_named_creation_method_get_type ())
typedef struct _StructWithNamedCreationMethod StructWithNamedCreationMethod;
typedef void (*Func) (gpointer user_data);
#define TYPE_STRUCT_WITH_FUNC (struct_with_func_get_type ())
typedef struct _StructWithFunc StructWithFunc;
#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 _SimpleStruct {
gint field;
gint array[10];
};
struct _PublicStruct {
gint field;
};
struct _StructWithCreationMethod {
gint field;
};
struct _StructWithNamedCreationMethod {
gint field;
};
struct _StructWithFunc {
Func foo;
gpointer foo_target;
GDestroyNotify foo_target_destroy_notify;
};
VALA_EXTERN GType simple_struct_get_type (void) G_GNUC_CONST ;
VALA_EXTERN SimpleStruct* simple_struct_dup (const SimpleStruct* self);
VALA_EXTERN void simple_struct_free (SimpleStruct* self);
VALA_EXTERN GType public_struct_get_type (void) G_GNUC_CONST ;
VALA_EXTERN PublicStruct* public_struct_dup (const PublicStruct* self);
VALA_EXTERN void public_struct_free (PublicStruct* self);
VALA_EXTERN GType struct_with_creation_method_get_type (void) G_GNUC_CONST ;
VALA_EXTERN StructWithCreationMethod* struct_with_creation_method_dup (const StructWithCreationMethod* self);
VALA_EXTERN void struct_with_creation_method_free (StructWithCreationMethod* self);
VALA_EXTERN void struct_with_creation_method_init (StructWithCreationMethod *self);
VALA_EXTERN GType struct_with_named_creation_method_get_type (void) G_GNUC_CONST ;
VALA_EXTERN StructWithNamedCreationMethod* struct_with_named_creation_method_dup (const StructWithNamedCreationMethod* self);
VALA_EXTERN void struct_with_named_creation_method_free (StructWithNamedCreationMethod* self);
VALA_EXTERN void struct_with_named_creation_method_init_named (StructWithNamedCreationMethod *self);
VALA_EXTERN GType struct_with_func_get_type (void) G_GNUC_CONST ;
VALA_EXTERN StructWithFunc* struct_with_func_dup (const StructWithFunc* self);
VALA_EXTERN void struct_with_func_free (StructWithFunc* self);
VALA_EXTERN void struct_with_func_copy (const StructWithFunc* self,
StructWithFunc* dest);
VALA_EXTERN void struct_with_func_destroy (StructWithFunc* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (StructWithFunc, struct_with_func_destroy)
VALA_EXTERN void struct_with_func_init (StructWithFunc *self,
Func f,
gpointer f_target,
GDestroyNotify f_target_destroy_notify);
VALA_EXTERN void test_in_parameter (SimpleStruct* st);
VALA_EXTERN void test_in_nullable_parameter (SimpleStruct* st);
VALA_EXTERN void test_ref_parameter (SimpleStruct* st);
VALA_EXTERN void test_out_parameter (SimpleStruct* st);
VALA_EXTERN void test_struct_with_func (void);
static void __lambda4_ (void);
static void ___lambda4__func (gpointer self);
static void _vala_StructWithFunc_array_free (StructWithFunc * array,
gssize array_length);
static void _vala_main (void);
SimpleStruct*
simple_struct_dup (const SimpleStruct* self)
{
SimpleStruct* dup;
dup = g_new0 (SimpleStruct, 1);
memcpy (dup, self, sizeof (SimpleStruct));
return dup;
}
void
simple_struct_free (SimpleStruct* self)
{
g_free (self);
}
static GType
simple_struct_get_type_once (void)
{
GType simple_struct_type_id;
simple_struct_type_id = g_boxed_type_register_static ("SimpleStruct", (GBoxedCopyFunc) simple_struct_dup, (GBoxedFreeFunc) simple_struct_free);
return simple_struct_type_id;
}
GType
simple_struct_get_type (void)
{
static volatile gsize simple_struct_type_id__once = 0;
if (g_once_init_enter (&simple_struct_type_id__once)) {
GType simple_struct_type_id;
simple_struct_type_id = simple_struct_get_type_once ();
g_once_init_leave (&simple_struct_type_id__once, simple_struct_type_id);
}
return simple_struct_type_id__once;
}
PublicStruct*
public_struct_dup (const PublicStruct* self)
{
PublicStruct* dup;
dup = g_new0 (PublicStruct, 1);
memcpy (dup, self, sizeof (PublicStruct));
return dup;
}
void
public_struct_free (PublicStruct* self)
{
g_free (self);
}
static GType
public_struct_get_type_once (void)
{
GType public_struct_type_id;
public_struct_type_id = g_boxed_type_register_static ("PublicStruct", (GBoxedCopyFunc) public_struct_dup, (GBoxedFreeFunc) public_struct_free);
return public_struct_type_id;
}
GType
public_struct_get_type (void)
{
static volatile gsize public_struct_type_id__once = 0;
if (g_once_init_enter (&public_struct_type_id__once)) {
GType public_struct_type_id;
public_struct_type_id = public_struct_get_type_once ();
g_once_init_leave (&public_struct_type_id__once, public_struct_type_id);
}
return public_struct_type_id__once;
}
void
struct_with_creation_method_init (StructWithCreationMethod *self)
{
FILE* _tmp0_;
memset (self, 0, sizeof (StructWithCreationMethod));
_tmp0_ = stdout;
fprintf (_tmp0_, "StructWithCreationMethod\n");
}
StructWithCreationMethod*
struct_with_creation_method_dup (const StructWithCreationMethod* self)
{
StructWithCreationMethod* dup;
dup = g_new0 (StructWithCreationMethod, 1);
memcpy (dup, self, sizeof (StructWithCreationMethod));
return dup;
}
void
struct_with_creation_method_free (StructWithCreationMethod* self)
{
g_free (self);
}
static GType
struct_with_creation_method_get_type_once (void)
{
GType struct_with_creation_method_type_id;
struct_with_creation_method_type_id = g_boxed_type_register_static ("StructWithCreationMethod", (GBoxedCopyFunc) struct_with_creation_method_dup, (GBoxedFreeFunc) struct_with_creation_method_free);
return struct_with_creation_method_type_id;
}
GType
struct_with_creation_method_get_type (void)
{
static volatile gsize struct_with_creation_method_type_id__once = 0;
if (g_once_init_enter (&struct_with_creation_method_type_id__once)) {
GType struct_with_creation_method_type_id;
struct_with_creation_method_type_id = struct_with_creation_method_get_type_once ();
g_once_init_leave (&struct_with_creation_method_type_id__once, struct_with_creation_method_type_id);
}
return struct_with_creation_method_type_id__once;
}
void
struct_with_named_creation_method_init_named (StructWithNamedCreationMethod *self)
{
FILE* _tmp0_;
memset (self, 0, sizeof (StructWithNamedCreationMethod));
_tmp0_ = stdout;
fprintf (_tmp0_, "StructWithNamedCreationMethod\n");
}
StructWithNamedCreationMethod*
struct_with_named_creation_method_dup (const StructWithNamedCreationMethod* self)
{
StructWithNamedCreationMethod* dup;
dup = g_new0 (StructWithNamedCreationMethod, 1);
memcpy (dup, self, sizeof (StructWithNamedCreationMethod));
return dup;
}
void
struct_with_named_creation_method_free (StructWithNamedCreationMethod* self)
{
g_free (self);
}
static GType
struct_with_named_creation_method_get_type_once (void)
{
GType struct_with_named_creation_method_type_id;
struct_with_named_creation_method_type_id = g_boxed_type_register_static ("StructWithNamedCreationMethod", (GBoxedCopyFunc) struct_with_named_creation_method_dup, (GBoxedFreeFunc) struct_with_named_creation_method_free);
return struct_with_named_creation_method_type_id;
}
GType
struct_with_named_creation_method_get_type (void)
{
static volatile gsize struct_with_named_creation_method_type_id__once = 0;
if (g_once_init_enter (&struct_with_named_creation_method_type_id__once)) {
GType struct_with_named_creation_method_type_id;
struct_with_named_creation_method_type_id = struct_with_named_creation_method_get_type_once ();
g_once_init_leave (&struct_with_named_creation_method_type_id__once, struct_with_named_creation_method_type_id);
}
return struct_with_named_creation_method_type_id__once;
}
void
struct_with_func_init (StructWithFunc *self,
Func f,
gpointer f_target,
GDestroyNotify f_target_destroy_notify)
{
Func _tmp0_;
gpointer _tmp0__target;
GDestroyNotify _tmp0__target_destroy_notify;
memset (self, 0, sizeof (StructWithFunc));
_tmp0_ = f;
_tmp0__target = f_target;
_tmp0__target_destroy_notify = f_target_destroy_notify;
f = NULL;
f_target = NULL;
f_target_destroy_notify = NULL;
((*self).foo_target_destroy_notify == NULL) ? NULL : ((*self).foo_target_destroy_notify ((*self).foo_target), NULL);
(*self).foo = NULL;
(*self).foo_target = NULL;
(*self).foo_target_destroy_notify = NULL;
(*self).foo = _tmp0_;
(*self).foo_target = _tmp0__target;
(*self).foo_target_destroy_notify = _tmp0__target_destroy_notify;
(f_target_destroy_notify == NULL) ? NULL : (f_target_destroy_notify (f_target), NULL);
f = NULL;
f_target = NULL;
f_target_destroy_notify = NULL;
}
void
struct_with_func_copy (const StructWithFunc* self,
StructWithFunc* dest)
{
Func _tmp0_;
gpointer _tmp0__target;
_tmp0_ = (*self).foo;
_tmp0__target = (*self).foo_target;
((*dest).foo_target_destroy_notify == NULL) ? NULL : ((*dest).foo_target_destroy_notify ((*dest).foo_target), NULL);
(*dest).foo = NULL;
(*dest).foo_target = NULL;
(*dest).foo_target_destroy_notify = NULL;
(*dest).foo = _tmp0_;
(*dest).foo_target = _tmp0__target;
(*dest).foo_target_destroy_notify = NULL;
}
void
struct_with_func_destroy (StructWithFunc* self)
{
((*self).foo_target_destroy_notify == NULL) ? NULL : ((*self).foo_target_destroy_notify ((*self).foo_target), NULL);
(*self).foo = NULL;
(*self).foo_target = NULL;
(*self).foo_target_destroy_notify = NULL;
}
StructWithFunc*
struct_with_func_dup (const StructWithFunc* self)
{
StructWithFunc* dup;
dup = g_new0 (StructWithFunc, 1);
struct_with_func_copy (self, dup);
return dup;
}
void
struct_with_func_free (StructWithFunc* self)
{
struct_with_func_destroy (self);
g_free (self);
}
static GType
struct_with_func_get_type_once (void)
{
GType struct_with_func_type_id;
struct_with_func_type_id = g_boxed_type_register_static ("StructWithFunc", (GBoxedCopyFunc) struct_with_func_dup, (GBoxedFreeFunc) struct_with_func_free);
return struct_with_func_type_id;
}
GType
struct_with_func_get_type (void)
{
static volatile gsize struct_with_func_type_id__once = 0;
if (g_once_init_enter (&struct_with_func_type_id__once)) {
GType struct_with_func_type_id;
struct_with_func_type_id = struct_with_func_get_type_once ();
g_once_init_leave (&struct_with_func_type_id__once, struct_with_func_type_id);
}
return struct_with_func_type_id__once;
}
void
test_in_parameter (SimpleStruct* st)
{
FILE* _tmp0_;
SimpleStruct _tmp1_;
g_return_if_fail (st != NULL);
_tmp0_ = stdout;
_tmp1_ = *st;
fprintf (_tmp0_, "test_in_parameter: st.field = %d\n", _tmp1_.field);
}
void
test_in_nullable_parameter (SimpleStruct* st)
{
_vala_assert ((*st).field == 1, "st.field == 1");
}
void
test_ref_parameter (SimpleStruct* st)
{
FILE* _tmp0_;
SimpleStruct _tmp1_;
gint _tmp2_;
g_return_if_fail (st != NULL);
_tmp0_ = stdout;
_tmp1_ = *st;
fprintf (_tmp0_, "test_ref_parameter: st.field = %d\n", _tmp1_.field);
_tmp2_ = (*st).field;
(*st).field = _tmp2_ + 1;
(*st).array[0] = 10;
}
void
test_out_parameter (SimpleStruct* st)
{
SimpleStruct _vala_st = {0};
memset (&_vala_st, 0, sizeof (SimpleStruct));
_vala_st.field = 3;
if (st) {
*st = _vala_st;
}
}
static void
__lambda4_ (void)
{
}
static void
___lambda4__func (gpointer self)
{
__lambda4_ ();
}
static void
_vala_StructWithFunc_array_free (StructWithFunc * array,
gssize array_length)
{
if (array != NULL) {
gssize i;
for (i = 0; i < array_length; i = i + 1) {
struct_with_func_destroy (&array[i]);
}
}
g_free (array);
}
void
test_struct_with_func (void)
{
StructWithFunc* foes = NULL;
StructWithFunc _tmp0_ = {0};
StructWithFunc* _tmp1_;
gint foes_length1;
gint _foes_size_;
struct_with_func_init (&_tmp0_, ___lambda4__func, NULL, NULL);
_tmp1_ = g_new0 (StructWithFunc, 1);
_tmp1_[0] = _tmp0_;
foes = _tmp1_;
foes_length1 = 1;
_foes_size_ = foes_length1;
foes = (_vala_StructWithFunc_array_free (foes, foes_length1), NULL);
}
static void
_vala_main (void)
{
FILE* _tmp0_;
FILE* _tmp1_;
SimpleStruct simple_struct = {0};
FILE* _tmp2_;
PublicStruct public_struct = {0};
FILE* _tmp3_;
StructWithCreationMethod struct_with_creation_method = {0};
FILE* _tmp4_;
StructWithNamedCreationMethod struct_with_named_creation_method = {0};
FILE* _tmp5_;
SimpleStruct _tmp6_ = {0};
FILE* _tmp7_;
SimpleStruct _tmp8_;
SimpleStruct _tmp9_;
SimpleStruct _tmp10_ = {0};
SimpleStruct _tmp11_;
FILE* _tmp12_;
SimpleStruct _tmp13_;
SimpleStruct _tmp14_;
gint _tmp15_;
SimpleStruct _tmp16_ = {0};
FILE* _tmp17_;
SimpleStruct _tmp18_;
FILE* _tmp19_;
_tmp0_ = stdout;
fprintf (_tmp0_, "Structs Test:\n");
_tmp1_ = stdout;
fprintf (_tmp1_, "new SimpleStruct ()\n");
memset (&simple_struct, 0, sizeof (SimpleStruct));
_tmp2_ = stdout;
fprintf (_tmp2_, "new PublicStruct ()\n");
memset (&public_struct, 0, sizeof (PublicStruct));
_tmp3_ = stdout;
fprintf (_tmp3_, "new StructWithCreationMethod ()\n");
struct_with_creation_method_init (&struct_with_creation_method);
_tmp4_ = stdout;
fprintf (_tmp4_, "new StructWithNamedCreationMethod ()\n");
struct_with_named_creation_method_init_named (&struct_with_named_creation_method);
_tmp5_ = stdout;
fprintf (_tmp5_, "new SimpleStruct () { field = 1 }\n");
memset (&_tmp6_, 0, sizeof (SimpleStruct));
_tmp6_.field = 1;
simple_struct = _tmp6_;
_tmp7_ = stdout;
_tmp8_ = simple_struct;
fprintf (_tmp7_, "simple_struct.field = %d\n", _tmp8_.field);
_tmp9_ = simple_struct;
test_in_parameter (&_tmp9_);
_tmp10_.field = 1;
test_in_parameter (&_tmp10_);
_tmp11_ = simple_struct;
test_in_nullable_parameter (&_tmp11_);
test_ref_parameter (&simple_struct);
_tmp12_ = stdout;
_tmp13_ = simple_struct;
fprintf (_tmp12_, "after test_ref_parameter: st.field = %d\n", _tmp13_.field);
_tmp14_ = simple_struct;
_tmp15_ = _tmp14_.array[0];
_vala_assert (_tmp15_ == 10, "simple_struct.array[0] == 10");
test_out_parameter (&_tmp16_);
simple_struct = _tmp16_;
_tmp17_ = stdout;
_tmp18_ = simple_struct;
fprintf (_tmp17_, "after test_out_parameter: st.field = %d\n", _tmp18_.field);
_tmp19_ = stdout;
fprintf (_tmp19_, ".\n");
}
int
main (int argc,
char ** argv)
{
_vala_main ();
return 0;
}
|