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
|
/* asynchronous_bug661961.c generated by valac, the Vala compiler
* generated from asynchronous_bug661961.vala, do not modify */
#include <gio/gio.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif
typedef struct _FooData FooData;
typedef struct _Block1Data Block1Data;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#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 _FooData {
int _state_;
GObject* _source_object_;
GAsyncResult* _res_;
GTask* _async_result;
gpointer bar;
GType t_type;
GBoxedCopyFunc t_dup_func;
GDestroyNotify t_destroy_func;
gpointer result;
gpointer _tmp0_;
};
struct _Block1Data {
int _ref_count_;
GMainLoop* loop;
};
static void foo_data_free (gpointer _data);
VALA_EXTERN void foo (GType t_type,
GBoxedCopyFunc t_dup_func,
GDestroyNotify t_destroy_func,
gconstpointer bar,
GAsyncReadyCallback _callback_,
gpointer _user_data_);
VALA_EXTERN gpointer foo_finish (GAsyncResult* _res_);
static gboolean foo_co (FooData* _data_);
static void _vala_main (void);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void __lambda4_ (Block1Data* _data1_,
GObject* s,
GAsyncResult* r);
static void ___lambda4__gasync_ready_callback (GObject* source_object,
GAsyncResult* res,
gpointer self);
static void
foo_data_free (gpointer _data)
{
FooData* _data_;
_data_ = _data;
((_data_->bar == NULL) || (_data_->t_destroy_func == NULL)) ? NULL : (_data_->bar = (_data_->t_destroy_func (_data_->bar), NULL));
((_data_->result == NULL) || (_data_->t_destroy_func == NULL)) ? NULL : (_data_->result = (_data_->t_destroy_func (_data_->result), NULL));
g_slice_free (FooData, _data_);
}
void
foo (GType t_type,
GBoxedCopyFunc t_dup_func,
GDestroyNotify t_destroy_func,
gconstpointer bar,
GAsyncReadyCallback _callback_,
gpointer _user_data_)
{
FooData* _data_;
gpointer _tmp0_;
_data_ = g_slice_new0 (FooData);
_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
g_task_set_task_data (_data_->_async_result, _data_, foo_data_free);
_tmp0_ = ((bar != NULL) && (t_dup_func != NULL)) ? t_dup_func ((gpointer) bar) : ((gpointer) bar);
((_data_->bar == NULL) || (_data_->t_destroy_func == NULL)) ? NULL : (_data_->bar = (_data_->t_destroy_func (_data_->bar), NULL));
_data_->bar = _tmp0_;
_data_->t_type = t_type;
_data_->t_dup_func = t_dup_func;
_data_->t_destroy_func = t_destroy_func;
foo_co (_data_);
}
gpointer
foo_finish (GAsyncResult* _res_)
{
gpointer result;
FooData* _data_;
_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
result = _data_->result;
_data_->result = NULL;
return result;
}
static gboolean
foo_co (FooData* _data_)
{
switch (_data_->_state_) {
case 0:
goto _state_0;
default:
g_assert_not_reached ();
}
_state_0:
_data_->_tmp0_ = ((_data_->bar != NULL) && (_data_->t_dup_func != NULL)) ? _data_->t_dup_func ((gpointer) _data_->bar) : ((gpointer) _data_->bar);
_data_->result = _data_->_tmp0_;
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 Block1Data*
block1_data_ref (Block1Data* _data1_)
{
g_atomic_int_inc (&_data1_->_ref_count_);
return _data1_;
}
static void
block1_data_unref (void * _userdata_)
{
Block1Data* _data1_;
_data1_ = (Block1Data*) _userdata_;
if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
_g_main_loop_unref0 (_data1_->loop);
g_slice_free (Block1Data, _data1_);
}
}
static void
__lambda4_ (Block1Data* _data1_,
GObject* s,
GAsyncResult* r)
{
gpointer _tmp0_;
gchar* _tmp1_;
g_return_if_fail ((s == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (s, G_TYPE_OBJECT));
g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (r, g_async_result_get_type ()));
_tmp0_ = foo_finish (r);
_tmp1_ = (gchar*) _tmp0_;
_vala_assert (g_strcmp0 (_tmp1_, "test") == 0, "foo.end<string> (r) == \"test\"");
_g_free0 (_tmp1_);
g_main_loop_quit (_data1_->loop);
}
static void
___lambda4__gasync_ready_callback (GObject* source_object,
GAsyncResult* res,
gpointer self)
{
__lambda4_ (self, source_object, res);
block1_data_unref (self);
}
static void
_vala_main (void)
{
Block1Data* _data1_;
GMainLoop* _tmp0_;
_data1_ = g_slice_new0 (Block1Data);
_data1_->_ref_count_ = 1;
_tmp0_ = g_main_loop_new (NULL, FALSE);
_data1_->loop = _tmp0_;
foo (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, "test", ___lambda4__gasync_ready_callback, block1_data_ref (_data1_));
g_main_loop_run (_data1_->loop);
block1_data_unref (_data1_);
_data1_ = NULL;
}
int
main (int argc,
char ** argv)
{
_vala_main ();
return 0;
}
|