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
|
/* parser_tuple.c generated by valac, the Vala compiler
* generated from parser_tuple.vala, do not modify */
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#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);
static void _vala_main (void);
static gchar** _vala_array_dup1 (gchar** self,
gssize length);
static gint* _vala_array_dup2 (gint* self,
gssize 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);
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;
}
static gint*
_vala_array_dup2 (gint* self,
gssize length)
{
if (length > 0) {
return _vala_memdup2 (self, length * sizeof (gint));
}
return NULL;
}
static void
_vala_main (void)
{
gchar** FOO = NULL;
gchar* _tmp0_;
gchar** _tmp1_;
gint FOO_length1;
gint _FOO_size_;
gint* BAR = NULL;
gint* _tmp2_;
gint BAR_length1;
gint _BAR_size_;
const gchar* s = NULL;
const gchar* n = NULL;
gchar** _tmp3_ = NULL;
gchar** _tmp4_;
gint _tmp4__length1;
gint _tmp3__length1;
gint __tmp3__size_;
const gchar* _tmp5_;
const gchar* _tmp6_;
gint i = 0;
gint j = 0;
gint* _tmp7_ = NULL;
gint* _tmp8_;
gint _tmp8__length1;
gint _tmp7__length1;
gint __tmp7__size_;
gint _tmp9_;
gint _tmp10_;
gint* _tmp11_ = NULL;
gint* _tmp12_;
gint _tmp11__length1;
gint __tmp11__size_;
gint test = 0;
gint _tmp13_;
gint test2 = 0;
gint _tmp14_;
_tmp0_ = g_strdup ("foo");
_tmp1_ = g_new0 (gchar*, 2 + 1);
_tmp1_[0] = _tmp0_;
_tmp1_[1] = NULL;
FOO = _tmp1_;
FOO_length1 = 2;
_FOO_size_ = FOO_length1;
_tmp2_ = g_new0 (gint, 2);
_tmp2_[0] = 42;
_tmp2_[1] = 4711;
BAR = _tmp2_;
BAR_length1 = 2;
_BAR_size_ = BAR_length1;
_tmp4_ = (FOO != NULL) ? _vala_array_dup1 (FOO, FOO_length1) : FOO;
_tmp4__length1 = FOO_length1;
_tmp3_ = _tmp4_;
_tmp3__length1 = _tmp4__length1;
__tmp3__size_ = _tmp3__length1;
_tmp5_ = _tmp3_[0];
s = _tmp5_;
_tmp6_ = _tmp3_[1];
n = _tmp6_;
_vala_assert (g_strcmp0 (s, "foo") == 0, "s == \"foo\"");
_vala_assert (n == NULL, "n == null");
_tmp8_ = (BAR != NULL) ? _vala_array_dup2 (BAR, BAR_length1) : BAR;
_tmp8__length1 = BAR_length1;
_tmp7_ = _tmp8_;
_tmp7__length1 = _tmp8__length1;
__tmp7__size_ = _tmp7__length1;
_tmp9_ = _tmp7_[0];
i = _tmp9_;
_tmp10_ = _tmp7_[1];
j = _tmp10_;
_vala_assert (i == 42, "i == 42");
_vala_assert (j == 4711, "j == 4711");
_tmp12_ = g_new0 (gint, 2);
_tmp12_[0] = 23;
_tmp12_[1] = 51;
_tmp11_ = _tmp12_;
_tmp11__length1 = 2;
__tmp11__size_ = _tmp11__length1;
_tmp13_ = _tmp11_[0];
test = _tmp13_;
_tmp14_ = _tmp11_[1];
test2 = _tmp14_;
_vala_assert (test == 23, "test == 23");
_vala_assert (test2 == 51, "test2 == 51");
_tmp11_ = (g_free (_tmp11_), NULL);
_tmp7_ = (g_free (_tmp7_), NULL);
_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
BAR = (g_free (BAR), NULL);
FOO = (_vala_array_free (FOO, FOO_length1, (GDestroyNotify) g_free), 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;
}
|