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
|
/* asynchronous_method_main_async_void.c generated by valac, the Vala compiler
* generated from asynchronous_method_main_async_void.vala, do not modify */
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
typedef struct _ValaMainAsyncData ValaMainAsyncData;
struct _ValaMainAsyncData {
int _state_;
GObject* _source_object_;
GAsyncResult* _res_;
GTask* _async_result;
gchar** args;
gint args_length1;
};
static void _vala_main_async_data_free (gpointer _data);
static void _vala_main_async (gchar** args,
gint args_length1,
GAsyncReadyCallback _callback_,
gpointer _user_data_);
static void _vala_main_finish (GAsyncResult* _res_);
static gboolean _vala_main_async_co (ValaMainAsyncData* _data_);
static gboolean __vala_main_async_co_gsource_func (gpointer self);
static void
_vala_main_async_data_free (gpointer _data)
{
ValaMainAsyncData* _data_;
_data_ = _data;
g_slice_free (ValaMainAsyncData, _data_);
}
void
_vala_main_async (gchar** args,
gint args_length1,
GAsyncReadyCallback _callback_,
gpointer _user_data_)
{
ValaMainAsyncData* _data_;
_data_ = g_slice_new0 (ValaMainAsyncData);
_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
g_task_set_task_data (_data_->_async_result, _data_, _vala_main_async_data_free);
_data_->args = args;
_data_->args_length1 = args_length1;
_vala_main_async_co (_data_);
}
void
_vala_main_finish (GAsyncResult* _res_)
{
ValaMainAsyncData* _data_;
_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}
static gboolean
__vala_main_async_co_gsource_func (gpointer self)
{
gboolean result;
result = _vala_main_async_co (self);
return result;
}
static gboolean
_vala_main_async_co (ValaMainAsyncData* _data_)
{
switch (_data_->_state_) {
case 0:
goto _state_0;
case 1:
goto _state_1;
default:
g_assert_not_reached ();
}
_state_0:
g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, __vala_main_async_co_gsource_func, _data_, NULL);
_data_->_state_ = 1;
return FALSE;
_state_1:
;
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_async_callback (GObject* source_object,
GAsyncResult* res,
gpointer user_data)
{
GMainLoop* loop = user_data;
_vala_main_finish (res);
g_main_loop_quit (loop);
}
int
main (int argc,
char ** argv)
{
GMainLoop* loop = g_main_loop_new (NULL, FALSE);
_vala_main_async (argv, argc, _vala_main_async_callback, loop);
g_main_loop_run (loop);
g_main_loop_unref (loop);
return 0;
}
|