summaryrefslogtreecommitdiff
path: root/tests/annotations/deprecated.c-expected
blob: 808df998388c585bdaae165b0d39bdf4259e06e1 (plain)
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
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
/* annotations_deprecated.c generated by valac, the Vala compiler
 * generated from annotations_deprecated.vala, do not modify */

#include <glib.h>
#include <glib-object.h>
#include <string.h>

#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 (*FooDelegate) (gpointer user_data) G_GNUC_DEPRECATED ;

#define TYPE_FOO_STRUCT (foo_struct_get_type ())
typedef struct _FooStruct FooStruct;

#define TYPE_FOOCLASS (fooclass_get_type ())
#define FOOCLASS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FOOCLASS, FooClass))
#define FOOCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FOOCLASS, FooClassClass))
#define IS_FOOCLASS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FOOCLASS))
#define IS_FOOCLASS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FOOCLASS))
#define FOOCLASS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FOOCLASS, FooClassClass))

typedef struct _FooClass FooClass;
typedef struct _FooClassClass FooClassClass;
typedef struct _FooClassPrivate FooClassPrivate;
enum  {
	FOOCLASS_0_PROPERTY,
	FOOCLASS_BAR_PROPERTY,
	FOOCLASS_NUM_PROPERTIES
};
static GParamSpec* fooclass_properties[FOOCLASS_NUM_PROPERTIES];

#define TYPE_AFOO (afoo_get_type ())
#define AFOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_AFOO, AFoo))
#define AFOO_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_AFOO, AFooClass))
#define IS_AFOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_AFOO))
#define IS_AFOO_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_AFOO))
#define AFOO_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_AFOO, AFooClass))

typedef struct _AFoo AFoo;
typedef struct _AFooClass AFooClass;
typedef struct _AFooPrivate AFooPrivate;
enum  {
	AFOO_0_PROPERTY,
	AFOO_NUM_PROPERTIES
};
static GParamSpec* afoo_properties[AFOO_NUM_PROPERTIES];

#define TYPE_IFOO (ifoo_get_type ())
#define IFOO(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_IFOO, IFoo))
#define IS_IFOO(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_IFOO))
#define IFOO_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_IFOO, IFooIface))

typedef struct _IFoo IFoo;
typedef struct _IFooIface IFooIface;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef enum  {
	FOO_ENUM_BAR = 0,
	FOO_ENUM_FOO,
	FOO_ENUM_BAZ
} FooEnum G_GNUC_DEPRECATED ;

#define TYPE_FOO_ENUM (foo_enum_get_type ())
#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 _FooStruct {
	gint bar G_GNUC_DEPRECATED ;
} G_GNUC_DEPRECATED ;

struct _FooClass {
	GObject parent_instance;
	FooClassPrivate * priv;
	gint baz G_GNUC_DEPRECATED ;
};

struct _FooClassClass {
	GObjectClass parent_class;
	gint (*foov) (FooClass* self) G_GNUC_DEPRECATED ;
};

struct _FooClassPrivate {
	gint _bar;
};

struct _AFoo {
	GObject parent_instance;
	AFooPrivate * priv;
};

struct _AFooClass {
	GObjectClass parent_class;
	gint (*fooa) (AFoo* self) G_GNUC_DEPRECATED ;
};

struct _IFooIface {
	GTypeInterface parent_iface;
	void (*fooa) (IFoo* self) G_GNUC_DEPRECATED ;
};

VALA_EXTERN gint bar;
gint bar = 42;
static gint FooClass_private_offset;
static gpointer fooclass_parent_class = NULL;
VALA_EXTERN gint fooclass_manam;
gint fooclass_manam = 42;
static gpointer afoo_parent_class = NULL;

VALA_EXTERN void baz (void) G_GNUC_DEPRECATED ;
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 test_struct_field (void);
VALA_EXTERN GType fooclass_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (FooClass, g_object_unref)
VALA_EXTERN gint fooclass_foov (FooClass* self) G_GNUC_DEPRECATED ;
VALA_EXTERN gint fooclass_foo (FooClass* self) G_GNUC_DEPRECATED ;
static gint fooclass_real_foov (FooClass* self) G_GNUC_DEPRECATED ;
VALA_EXTERN FooClass* fooclass_new (void);
VALA_EXTERN FooClass* fooclass_construct (GType object_type);
VALA_EXTERN gint fooclass_get_bar (FooClass* self) G_GNUC_DEPRECATED ;
VALA_EXTERN void fooclass_set_bar (FooClass* self,
                       gint value) G_GNUC_DEPRECATED ;
static void fooclass_finalize (GObject * obj);
static GType fooclass_get_type_once (void);
static void _vala_fooclass_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec);
static void _vala_fooclass_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec);
VALA_EXTERN GType afoo_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (AFoo, g_object_unref)
VALA_EXTERN gint afoo_fooa (AFoo* self) G_GNUC_DEPRECATED ;
VALA_EXTERN gint afoo_foo (AFoo* self) G_GNUC_DEPRECATED ;
static gint afoo_real_fooa (AFoo* self) G_GNUC_DEPRECATED ;
VALA_EXTERN AFoo* afoo_construct (GType object_type);
static GType afoo_get_type_once (void);
VALA_EXTERN GType ifoo_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (IFoo, g_object_unref)
VALA_EXTERN gint ifoo_foo (IFoo* self) G_GNUC_DEPRECATED ;
VALA_EXTERN void ifoo_fooa (IFoo* self) G_GNUC_DEPRECATED ;
static GType ifoo_get_type_once (void);
VALA_EXTERN void test_class_property (void);
VALA_EXTERN GType foo_enum_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void test_enum (void);
static void _vala_main (void);

void
baz (void)
{
}

FooStruct*
foo_struct_dup (const FooStruct* self)
{
	FooStruct* dup;
	dup = g_new0 (FooStruct, 1);
	memcpy (dup, self, sizeof (FooStruct));
	return dup;
}

void
foo_struct_free (FooStruct* 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;
}

void
test_struct_field (void)
{
	FooStruct foo = {0};
	FooStruct _tmp0_ = {0};
	gint i = 0;
	FooStruct _tmp1_;
	FooStruct _tmp2_;
	_tmp0_.bar = 42;
	foo = _tmp0_;
	_tmp1_ = foo;
	i = _tmp1_.bar;
	foo.bar = i;
	_tmp2_ = foo;
	_vala_assert (_tmp2_.bar == 42, "foo.bar == 42");
}

static inline gpointer
fooclass_get_instance_private (FooClass* self)
{
	return G_STRUCT_MEMBER_P (self, FooClass_private_offset);
}

gint
fooclass_foo (FooClass* self)
{
	gint result;
	g_return_val_if_fail (IS_FOOCLASS (self), 0);
	result = 42;
	return result;
}

static gint
fooclass_real_foov (FooClass* self)
{
	gint result;
	result = 42;
	return result;
}

gint
fooclass_foov (FooClass* self)
{
	FooClassClass* _klass_;
	g_return_val_if_fail (IS_FOOCLASS (self), 0);
	_klass_ = FOOCLASS_GET_CLASS (self);
	if (_klass_->foov) {
		return _klass_->foov (self);
	}
	return -1;
}

FooClass*
fooclass_construct (GType object_type)
{
	FooClass * self = NULL;
	self = (FooClass*) g_object_new (object_type, NULL);
	return self;
}

FooClass*
fooclass_new (void)
{
	return fooclass_construct (TYPE_FOOCLASS);
}

gint
fooclass_get_bar (FooClass* self)
{
	gint result;
	g_return_val_if_fail (IS_FOOCLASS (self), 0);
	result = self->priv->_bar;
	return result;
}

void
fooclass_set_bar (FooClass* self,
                  gint value)
{
	gint old_value;
	g_return_if_fail (IS_FOOCLASS (self));
	old_value = fooclass_get_bar (self);
	if (old_value != value) {
		self->priv->_bar = value;
		g_object_notify_by_pspec ((GObject *) self, fooclass_properties[FOOCLASS_BAR_PROPERTY]);
	}
}

static void
fooclass_class_init (FooClassClass * klass,
                     gpointer klass_data)
{
	fooclass_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FooClass_private_offset);
	((FooClassClass *) klass)->foov = (gint (*) (FooClass*)) fooclass_real_foov;
	G_OBJECT_CLASS (klass)->get_property = _vala_fooclass_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_fooclass_set_property;
	G_OBJECT_CLASS (klass)->finalize = fooclass_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FOOCLASS_BAR_PROPERTY, fooclass_properties[FOOCLASS_BAR_PROPERTY] = g_param_spec_int ("bar", "bar", "bar", G_MININT, G_MAXINT, 42, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_DEPRECATED));
}

static void
fooclass_instance_init (FooClass * self,
                        gpointer klass)
{
	self->priv = fooclass_get_instance_private (self);
	self->priv->_bar = 42;
}

static void
fooclass_finalize (GObject * obj)
{
	FooClass * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FOOCLASS, FooClass);
	G_OBJECT_CLASS (fooclass_parent_class)->finalize (obj);
}

static GType
fooclass_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FooClassClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) fooclass_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FooClass), 0, (GInstanceInitFunc) fooclass_instance_init, NULL };
	GType fooclass_type_id;
	fooclass_type_id = g_type_register_static (G_TYPE_OBJECT, "FooClass", &g_define_type_info, 0);
	FooClass_private_offset = g_type_add_instance_private (fooclass_type_id, sizeof (FooClassPrivate));
	return fooclass_type_id;
}

GType
fooclass_get_type (void)
{
	static volatile gsize fooclass_type_id__once = 0;
	if (g_once_init_enter (&fooclass_type_id__once)) {
		GType fooclass_type_id;
		fooclass_type_id = fooclass_get_type_once ();
		g_once_init_leave (&fooclass_type_id__once, fooclass_type_id);
	}
	return fooclass_type_id__once;
}

static void
_vala_fooclass_get_property (GObject * object,
                             guint property_id,
                             GValue * value,
                             GParamSpec * pspec)
{
	FooClass * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOOCLASS, FooClass);
	switch (property_id) {
		case FOOCLASS_BAR_PROPERTY:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
		g_value_set_int (value, fooclass_get_bar (self));
G_GNUC_END_IGNORE_DEPRECATIONS
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_fooclass_set_property (GObject * object,
                             guint property_id,
                             const GValue * value,
                             GParamSpec * pspec)
{
	FooClass * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_FOOCLASS, FooClass);
	switch (property_id) {
		case FOOCLASS_BAR_PROPERTY:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
		fooclass_set_bar (self, g_value_get_int (value));
G_GNUC_END_IGNORE_DEPRECATIONS
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

gint
afoo_foo (AFoo* self)
{
	gint result;
	g_return_val_if_fail (IS_AFOO (self), 0);
	result = 42;
	return result;
}

static gint
afoo_real_fooa (AFoo* self)
{
	gint _tmp0_ = 0;
	g_critical ("Type `%s' does not implement abstract method `afoo_fooa'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gint
afoo_fooa (AFoo* self)
{
	AFooClass* _klass_;
	g_return_val_if_fail (IS_AFOO (self), 0);
	_klass_ = AFOO_GET_CLASS (self);
	if (_klass_->fooa) {
		return _klass_->fooa (self);
	}
	return -1;
}

AFoo*
afoo_construct (GType object_type)
{
	AFoo * self = NULL;
	self = (AFoo*) g_object_new (object_type, NULL);
	return self;
}

static void
afoo_class_init (AFooClass * klass,
                 gpointer klass_data)
{
	afoo_parent_class = g_type_class_peek_parent (klass);
	((AFooClass *) klass)->fooa = (gint (*) (AFoo*)) afoo_real_fooa;
}

static void
afoo_instance_init (AFoo * self,
                    gpointer klass)
{
}

static GType
afoo_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (AFooClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) afoo_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AFoo), 0, (GInstanceInitFunc) afoo_instance_init, NULL };
	GType afoo_type_id;
	afoo_type_id = g_type_register_static (G_TYPE_OBJECT, "AFoo", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return afoo_type_id;
}

GType
afoo_get_type (void)
{
	static volatile gsize afoo_type_id__once = 0;
	if (g_once_init_enter (&afoo_type_id__once)) {
		GType afoo_type_id;
		afoo_type_id = afoo_get_type_once ();
		g_once_init_leave (&afoo_type_id__once, afoo_type_id);
	}
	return afoo_type_id__once;
}

gint
ifoo_foo (IFoo* self)
{
	gint result;
	result = 42;
	return result;
}

void
ifoo_fooa (IFoo* self)
{
	IFooIface* _iface_;
	g_return_if_fail (IS_IFOO (self));
	_iface_ = IFOO_GET_INTERFACE (self);
	if (_iface_->fooa) {
		_iface_->fooa (self);
	}
}

static void
ifoo_default_init (IFooIface * iface,
                   gpointer iface_data)
{
}

static GType
ifoo_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (IFooIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ifoo_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType ifoo_type_id;
	ifoo_type_id = g_type_register_static (G_TYPE_INTERFACE, "IFoo", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (ifoo_type_id, G_TYPE_OBJECT);
	return ifoo_type_id;
}

GType
ifoo_get_type (void)
{
	static volatile gsize ifoo_type_id__once = 0;
	if (g_once_init_enter (&ifoo_type_id__once)) {
		GType ifoo_type_id;
		ifoo_type_id = ifoo_get_type_once ();
		g_once_init_leave (&ifoo_type_id__once, ifoo_type_id);
	}
	return ifoo_type_id__once;
}

void
test_class_property (void)
{
	FooClass* foo = NULL;
	FooClass* _tmp0_;
	gint i = 0;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	_tmp0_ = fooclass_new ();
	foo = _tmp0_;
	_tmp1_ = fooclass_get_bar (foo);
	_tmp2_ = _tmp1_;
	i = _tmp2_;
	fooclass_set_bar (foo, i);
	_tmp3_ = fooclass_get_bar (foo);
	_tmp4_ = _tmp3_;
	_vala_assert (_tmp4_ == 42, "foo.bar == 42");
	_g_object_unref0 (foo);
}

static GType
foo_enum_get_type_once (void)
{
	static const GEnumValue values[] = {{FOO_ENUM_BAR, "FOO_ENUM_BAR", "bar"}, {FOO_ENUM_FOO, "FOO_ENUM_FOO", "foo"}, {FOO_ENUM_BAZ, "FOO_ENUM_BAZ", "baz"}, {0, NULL, NULL}};
	GType foo_enum_type_id;
	foo_enum_type_id = g_enum_register_static ("FooEnum", values);
	return foo_enum_type_id;
}

GType
foo_enum_get_type (void)
{
	static volatile gsize foo_enum_type_id__once = 0;
	if (g_once_init_enter (&foo_enum_type_id__once)) {
		GType foo_enum_type_id;
		foo_enum_type_id = foo_enum_get_type_once ();
		g_once_init_leave (&foo_enum_type_id__once, foo_enum_type_id);
	}
	return foo_enum_type_id__once;
}

void
test_enum (void)
{
	FooEnum foo = 0;
	foo = FOO_ENUM_BAR;
	_vala_assert (foo == 0, "foo == 0");
}

static void
_vala_main (void)
{
	test_class_property ();
	test_struct_field ();
	test_enum ();
}

int
main (int argc,
      char ** argv)
{
	_vala_main ();
	return 0;
}