void rbgio_gasyncinitable_new_async(GType type, VALUE parameters, VALUE io_priority, VALUE cancellable, VALUE block) { static ID s_id_length; struct rbgio_gasyncinitable_new_async_data data; if (s_id_length == 0) s_id_length = rb_intern("length"); if (!g_type_is_a(type, G_TYPE_OBJECT)) rb_raise(rb_eArgError, "%s is not a descendant of GObject", g_type_name(type)); if (NIL_P(parameters)) { SAVE_BLOCK(block); g_async_initable_newv_async(type, 0, NULL, RVAL2IOPRIORITYDEFAULT(io_priority), RVAL2GCANCELLABLE(cancellable), rbgio_async_ready_callback, (gpointer)block); return; } else { parameters = rb_convert_type(parameters, T_HASH, "Hash", "to_hash"); } data.gclass = G_OBJECT_CLASS(g_type_class_ref(type)); data.io_priority = RVAL2IOPRIORITYDEFAULT(io_priority); data.cancellable = RVAL2GCANCELLABLE(cancellable); data.block = block; data.rbparameters = parameters; data.index = 0; data.n_parameters = RVAL2GUINT(rb_funcall(parameters, s_id_length, 0)); data.parameters = ALLOCA_N(GParameter, data.n_parameters); rb_ensure(rbgio_gasyncinitable_new_async_body, (VALUE)&data, rbgio_gasyncinitable_new_async_ensure, (VALUE)&data); return; }
GObject * rbgio_ginitable_new(GType type, VALUE parameters, VALUE cancellable) { static ID s_id_length; GError *error = NULL; GObject *object; struct rbgio_ginitable_new_data data; if (s_id_length == 0) s_id_length = rb_intern("length"); if (!g_type_is_a(type, G_TYPE_OBJECT)) rb_raise(rb_eArgError, "%s is not a descendant of GObject", g_type_name(type)); if (NIL_P(parameters)) { object = g_initable_newv(type, 0, NULL, RVAL2GCANCELLABLE(cancellable), &error); if (object == NULL) rbgio_raise_error(error); return object; } else { parameters = rb_convert_type(parameters, T_HASH, "Hash", "to_hash"); } data.gclass = G_OBJECT_CLASS(g_type_class_ref(type)); data.cancellable = RVAL2GCANCELLABLE(cancellable); data.rbparameters = parameters; data.index = 0; data.n_parameters = RVAL2GUINT(rb_funcall(parameters, s_id_length, 0)); data.parameters = g_new(GParameter, data.n_parameters); data.error = NULL; object = (GObject *)rb_ensure(rbgio_ginitable_new_body, (VALUE)&data, rbgio_ginitable_new_ensure, (VALUE)&data); if (object == NULL) rbgio_raise_error(data.error); return object; }