summaryrefslogtreecommitdiff
path: root/tests/asynchronous/bug742621.c-expected
blob: 54f7f424d02f6a811481750e0b5f5f26b680084c (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
/* asynchronous_bug742621.c generated by valac, the Vala compiler
 * generated from asynchronous_bug742621.vala, do not modify */

#include <glib-object.h>
#include <glib.h>
#include <gio/gio.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_XYZZY (xyzzy_get_type ())
#define XYZZY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_XYZZY, Xyzzy))
#define XYZZY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_XYZZY, XyzzyClass))
#define IS_XYZZY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_XYZZY))
#define IS_XYZZY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_XYZZY))
#define XYZZY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_XYZZY, XyzzyClass))

typedef struct _Xyzzy Xyzzy;
typedef struct _XyzzyClass XyzzyClass;
typedef struct _XyzzyPrivate XyzzyPrivate;
enum  {
	XYZZY_0_PROPERTY,
	XYZZY_B_PROPERTY,
	XYZZY_NUM_PROPERTIES
};
static GParamSpec* xyzzy_properties[XYZZY_NUM_PROPERTIES];
typedef struct _GoAsyncData GoAsyncData;

struct _Xyzzy {
	GObject parent_instance;
	XyzzyPrivate * priv;
};

struct _XyzzyClass {
	GObjectClass parent_class;
};

struct _XyzzyPrivate {
	gboolean _b;
};

struct _GoAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	Xyzzy* _tmp0_;
	guint _tmp1_;
	GQuark _tmp2_;
};

static gint Xyzzy_private_offset;
static gpointer xyzzy_parent_class = NULL;
VALA_EXTERN Xyzzy* xyzzy;
Xyzzy* xyzzy = NULL;

VALA_EXTERN GType xyzzy_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (Xyzzy, g_object_unref)
VALA_EXTERN Xyzzy* xyzzy_new (void);
VALA_EXTERN Xyzzy* xyzzy_construct (GType object_type);
VALA_EXTERN gboolean xyzzy_get_b (Xyzzy* self);
VALA_EXTERN void xyzzy_set_b (Xyzzy* self,
                  gboolean value);
static void xyzzy_finalize (GObject * obj);
static GType xyzzy_get_type_once (void);
static void _vala_xyzzy_get_property (GObject * object,
                               guint property_id,
                               GValue * value,
                               GParamSpec * pspec);
static void _vala_xyzzy_set_property (GObject * object,
                               guint property_id,
                               const GValue * value,
                               GParamSpec * pspec);
VALA_EXTERN void on_b (void);
static void go_async_data_free (gpointer _data);
VALA_EXTERN void go_async (GAsyncReadyCallback _callback_,
               gpointer _user_data_);
VALA_EXTERN void go_finish (GAsyncResult* _res_,
                GError** error);
static gboolean go_async_co (GoAsyncData* _data_);
static void _on_b_g_object_notify (GObject* _sender,
                            GParamSpec* pspec,
                            gpointer self);
static void _vala_main (void);

static inline gpointer
xyzzy_get_instance_private (Xyzzy* self)
{
	return G_STRUCT_MEMBER_P (self, Xyzzy_private_offset);
}

Xyzzy*
xyzzy_construct (GType object_type)
{
	Xyzzy * self = NULL;
	self = (Xyzzy*) g_object_new (object_type, NULL);
	return self;
}

Xyzzy*
xyzzy_new (void)
{
	return xyzzy_construct (TYPE_XYZZY);
}

gboolean
xyzzy_get_b (Xyzzy* self)
{
	gboolean result;
	g_return_val_if_fail (IS_XYZZY (self), FALSE);
	result = self->priv->_b;
	return result;
}

void
xyzzy_set_b (Xyzzy* self,
             gboolean value)
{
	gboolean old_value;
	g_return_if_fail (IS_XYZZY (self));
	old_value = xyzzy_get_b (self);
	if (old_value != value) {
		self->priv->_b = value;
		g_object_notify_by_pspec ((GObject *) self, xyzzy_properties[XYZZY_B_PROPERTY]);
	}
}

static void
xyzzy_class_init (XyzzyClass * klass,
                  gpointer klass_data)
{
	xyzzy_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &Xyzzy_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_xyzzy_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_xyzzy_set_property;
	G_OBJECT_CLASS (klass)->finalize = xyzzy_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), XYZZY_B_PROPERTY, xyzzy_properties[XYZZY_B_PROPERTY] = g_param_spec_boolean ("b", "b", "b", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
xyzzy_instance_init (Xyzzy * self,
                     gpointer klass)
{
	self->priv = xyzzy_get_instance_private (self);
}

static void
xyzzy_finalize (GObject * obj)
{
	Xyzzy * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_XYZZY, Xyzzy);
	G_OBJECT_CLASS (xyzzy_parent_class)->finalize (obj);
}

static GType
xyzzy_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XyzzyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xyzzy_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (Xyzzy), 0, (GInstanceInitFunc) xyzzy_instance_init, NULL };
	GType xyzzy_type_id;
	xyzzy_type_id = g_type_register_static (G_TYPE_OBJECT, "Xyzzy", &g_define_type_info, 0);
	Xyzzy_private_offset = g_type_add_instance_private (xyzzy_type_id, sizeof (XyzzyPrivate));
	return xyzzy_type_id;
}

GType
xyzzy_get_type (void)
{
	static volatile gsize xyzzy_type_id__once = 0;
	if (g_once_init_enter (&xyzzy_type_id__once)) {
		GType xyzzy_type_id;
		xyzzy_type_id = xyzzy_get_type_once ();
		g_once_init_leave (&xyzzy_type_id__once, xyzzy_type_id);
	}
	return xyzzy_type_id__once;
}

static void
_vala_xyzzy_get_property (GObject * object,
                          guint property_id,
                          GValue * value,
                          GParamSpec * pspec)
{
	Xyzzy * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_XYZZY, Xyzzy);
	switch (property_id) {
		case XYZZY_B_PROPERTY:
		g_value_set_boolean (value, xyzzy_get_b (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_xyzzy_set_property (GObject * object,
                          guint property_id,
                          const GValue * value,
                          GParamSpec * pspec)
{
	Xyzzy * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, TYPE_XYZZY, Xyzzy);
	switch (property_id) {
		case XYZZY_B_PROPERTY:
		xyzzy_set_b (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

void
on_b (void)
{
}

static void
go_async_data_free (gpointer _data)
{
	GoAsyncData* _data_;
	_data_ = _data;
	g_slice_free (GoAsyncData, _data_);
}

void
go_async (GAsyncReadyCallback _callback_,
          gpointer _user_data_)
{
	GoAsyncData* _data_;
	_data_ = g_slice_new0 (GoAsyncData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, go_async_data_free);
	go_async_co (_data_);
}

void
go_finish (GAsyncResult* _res_,
           GError** error)
{
	GoAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
_on_b_g_object_notify (GObject* _sender,
                       GParamSpec* pspec,
                       gpointer self)
{
	on_b ();
}

static gboolean
go_async_co (GoAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = xyzzy;
	g_signal_parse_name ("notify::b", G_TYPE_OBJECT, &_data_->_tmp1_, &_data_->_tmp2_, TRUE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, G_TYPE_OBJECT, GObject), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp1_, _data_->_tmp2_, NULL, (GCallback) _on_b_g_object_notify, NULL);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
_vala_main (void)
{
}

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