summaryrefslogtreecommitdiff
path: root/tests/arrays/empty-length-0.c-expected
blob: 7ed37eed4ba550ecf697cde135641d3161615824 (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
/* arrays_empty_length_0.c generated by valac, the Vala compiler
 * generated from arrays_empty_length_0.vala, do not modify */

#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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

#define TYPE_MANAM (manam_get_type ())
typedef struct _Manam Manam;
#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);

struct _Manam {
	gchar* s;
};

VALA_EXTERN gchar** foo;
VALA_EXTERN gint foo_length1;
gchar** foo = NULL;
gint foo_length1 = 0;
static gint _foo_size_ = 0;
VALA_EXTERN gint* bar;
VALA_EXTERN gint bar_length1;
gint* bar = NULL;
gint bar_length1 = 0;
static gint _bar_size_ = 0;
VALA_EXTERN Manam* manam;
VALA_EXTERN gint manam_length1;
Manam* manam = NULL;
gint manam_length1 = 0;
static gint _manam_size_ = 0;

VALA_EXTERN GType manam_get_type (void) G_GNUC_CONST ;
VALA_EXTERN Manam* manam_dup (const Manam* self);
VALA_EXTERN void manam_free (Manam* self);
VALA_EXTERN void manam_copy (const Manam* self,
                 Manam* dest);
VALA_EXTERN void manam_destroy (Manam* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (Manam, manam_destroy)
VALA_EXTERN gchar** get_foo (gint* result_length1);
static gchar** _vala_array_dup1 (gchar** self,
                          gssize length);
VALA_EXTERN gint* get_bar (gint* result_length1);
static gint* _vala_array_dup2 (gint* self,
                        gssize length);
VALA_EXTERN Manam* get_manam (gint* result_length1);
static Manam* _vala_array_dup3 (Manam* self,
                         gssize length);
static void _vala_main (void);
static void _vala_Manam_array_free (Manam * array,
                             gssize array_length);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
manam_copy (const Manam* self,
            Manam* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	_tmp0_ = (*self).s;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).s);
	(*dest).s = _tmp1_;
}

void
manam_destroy (Manam* self)
{
	_g_free0 ((*self).s);
}

Manam*
manam_dup (const Manam* self)
{
	Manam* dup;
	dup = g_new0 (Manam, 1);
	manam_copy (self, dup);
	return dup;
}

void
manam_free (Manam* self)
{
	manam_destroy (self);
	g_free (self);
}

static GType
manam_get_type_once (void)
{
	GType manam_type_id;
	manam_type_id = g_boxed_type_register_static ("Manam", (GBoxedCopyFunc) manam_dup, (GBoxedFreeFunc) manam_free);
	return manam_type_id;
}

GType
manam_get_type (void)
{
	static volatile gsize manam_type_id__once = 0;
	if (g_once_init_enter (&manam_type_id__once)) {
		GType manam_type_id;
		manam_type_id = manam_get_type_once ();
		g_once_init_leave (&manam_type_id__once, manam_type_id);
	}
	return manam_type_id__once;
}

static gchar**
_vala_array_dup1 (gchar** self,
                  gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

gchar**
get_foo (gint* result_length1)
{
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	gchar** _tmp2_;
	gint _tmp2__length1;
	gchar** result;
	_tmp0_ = foo;
	_tmp0__length1 = foo_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup1 (_tmp0_, _tmp0__length1) : _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static gint*
_vala_array_dup2 (gint* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (gint));
	}
	return NULL;
}

gint*
get_bar (gint* result_length1)
{
	gint* _tmp0_;
	gint _tmp0__length1;
	gint* _tmp1_;
	gint _tmp1__length1;
	gint* _tmp2_;
	gint _tmp2__length1;
	gint* result;
	_tmp0_ = bar;
	_tmp0__length1 = bar_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup2 (_tmp0_, _tmp0__length1) : _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static Manam*
_vala_array_dup3 (Manam* self,
                  gssize length)
{
	if (length > 0) {
		Manam* result;
		gssize i;
		result = g_new0 (Manam, length);
		for (i = 0; i < length; i++) {
			Manam _tmp0_;
			Manam _tmp1_ = {0};
			_tmp0_ = self[i];
			manam_copy (&_tmp0_, &_tmp1_);
			result[i] = _tmp1_;
		}
		return result;
	}
	return NULL;
}

Manam*
get_manam (gint* result_length1)
{
	Manam* _tmp0_;
	gint _tmp0__length1;
	Manam* _tmp1_;
	gint _tmp1__length1;
	Manam* _tmp2_;
	gint _tmp2__length1;
	Manam* result;
	_tmp0_ = manam;
	_tmp0__length1 = manam_length1;
	_tmp1_ = (_tmp0_ != NULL) ? _vala_array_dup3 (_tmp0_, _tmp0__length1) : _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	_tmp2_ = _tmp1_;
	_tmp2__length1 = _tmp1__length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

static void
_vala_Manam_array_free (Manam * array,
                        gssize array_length)
{
	if (array != NULL) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			manam_destroy (&array[i]);
		}
	}
	g_free (array);
}

static void
_vala_main (void)
{
	{
		gchar** _tmp0_;
		gchar** _tmp1_;
		gint _tmp1__length1;
		gint _tmp2_ = 0;
		gchar** _tmp3_;
		gchar** _tmp4_;
		gint _tmp4__length1;
		_tmp0_ = g_new0 (gchar*, 0 + 1);
		foo = (_vala_array_free (foo, foo_length1, (GDestroyNotify) g_free), NULL);
		foo = _tmp0_;
		foo_length1 = 0;
		_foo_size_ = foo_length1;
		_tmp1_ = foo;
		_tmp1__length1 = foo_length1;
		_vala_assert (_tmp1_ != NULL, "foo != null");
		_tmp3_ = get_foo (&_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp4__length1 = _tmp2_;
		_vala_assert (_tmp4_ != NULL, "get_foo () != null");
		_tmp4_ = (_vala_array_free (_tmp4_, _tmp4__length1, (GDestroyNotify) g_free), NULL);
	}
	{
		gchar** _tmp5_;
		gchar** _tmp6_;
		gint _tmp6__length1;
		gint _tmp7_ = 0;
		gchar** _tmp8_;
		gchar** _tmp9_;
		gint _tmp9__length1;
		_tmp5_ = g_new0 (gchar*, 0 + 1);
		foo = (_vala_array_free (foo, foo_length1, (GDestroyNotify) g_free), NULL);
		foo = _tmp5_;
		foo_length1 = 0;
		_foo_size_ = foo_length1;
		_tmp6_ = foo;
		_tmp6__length1 = foo_length1;
		_vala_assert (_tmp6_ != NULL, "foo != null");
		_tmp8_ = get_foo (&_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp9__length1 = _tmp7_;
		_vala_assert (_tmp9_ != NULL, "get_foo () != null");
		_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) g_free), NULL);
	}
	{
		gint* _tmp10_;
		gint _tmp11_ = 0;
		gint* _tmp12_;
		gint* _tmp13_;
		gint _tmp13__length1;
		_tmp10_ = g_new0 (gint, 0);
		bar = (g_free (bar), NULL);
		bar = _tmp10_;
		bar_length1 = 0;
		_bar_size_ = bar_length1;
		_tmp12_ = get_bar (&_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp13__length1 = _tmp11_;
		_vala_assert (_tmp13_ == NULL, "get_bar () == null");
		_tmp13_ = (g_free (_tmp13_), NULL);
	}
	{
		gint* _tmp14_;
		gint _tmp15_ = 0;
		gint* _tmp16_;
		gint* _tmp17_;
		gint _tmp17__length1;
		_tmp14_ = g_new0 (gint, 0);
		bar = (g_free (bar), NULL);
		bar = _tmp14_;
		bar_length1 = 0;
		_bar_size_ = bar_length1;
		_tmp16_ = get_bar (&_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp17__length1 = _tmp15_;
		_vala_assert (_tmp17_ == NULL, "get_bar () == null");
		_tmp17_ = (g_free (_tmp17_), NULL);
	}
	{
		Manam* _tmp18_;
		gint _tmp19_ = 0;
		Manam* _tmp20_;
		Manam* _tmp21_;
		gint _tmp21__length1;
		_tmp18_ = g_new0 (Manam, 0);
		manam = (_vala_Manam_array_free (manam, manam_length1), NULL);
		manam = _tmp18_;
		manam_length1 = 0;
		_manam_size_ = manam_length1;
		_tmp20_ = get_manam (&_tmp19_);
		_tmp21_ = _tmp20_;
		_tmp21__length1 = _tmp19_;
		_vala_assert (_tmp21_ == NULL, "get_manam () == null");
		_tmp21_ = (_vala_Manam_array_free (_tmp21_, _tmp21__length1), NULL);
	}
	{
		Manam* _tmp22_;
		gint _tmp23_ = 0;
		Manam* _tmp24_;
		Manam* _tmp25_;
		gint _tmp25__length1;
		_tmp22_ = g_new0 (Manam, 0);
		manam = (_vala_Manam_array_free (manam, manam_length1), NULL);
		manam = _tmp22_;
		manam_length1 = 0;
		_manam_size_ = manam_length1;
		_tmp24_ = get_manam (&_tmp23_);
		_tmp25_ = _tmp24_;
		_tmp25__length1 = _tmp23_;
		_vala_assert (_tmp25_ == NULL, "get_manam () == null");
		_tmp25_ = (_vala_Manam_array_free (_tmp25_, _tmp25__length1), NULL);
	}
}

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

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}