/* dbus_bug783002_client.c generated by valac, the Vala compiler * generated from dbus_bug783002_client.vala, do not modify */ #include #include #include #include #include #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 #define TYPE_TEST (test_get_type ()) #define TEST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_TEST, Test)) #define IS_TEST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_TEST)) #define TEST_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_TEST, TestIface)) typedef struct _Test Test; typedef struct _TestIface TestIface; #define TYPE_TEST_PROXY (test_proxy_get_type ()) typedef GDBusProxy TestProxy; typedef GDBusProxyClass TestProxyClass; typedef struct _TestTestArrayLifetimeReadyData TestTestArrayLifetimeReadyData; #define _g_free0(var) (var = (g_free (var), NULL)) #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL))) #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL))) typedef struct _RunData RunData; #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 _TestIface { GTypeInterface parent_iface; void (*test_array_lifetime) (Test* self, gchar** items, gint items_length1, GAsyncReadyCallback _callback_, gpointer _user_data_); gchar* (*test_array_lifetime_finish) (Test* self, GAsyncResult* _res_, GError** error); }; struct _TestTestArrayLifetimeReadyData { GDBusMethodInvocation* _invocation_; gchar** items; gint items_length1; }; struct _RunData { int _state_; GObject* _source_object_; GAsyncResult* _res_; GTask* _async_result; Test* test; Test* _tmp0_; gchar* _result_; Test* _tmp1_; gchar* _tmp2_; gchar* _tmp3_; gchar* _tmp4_; gchar** _tmp5_; gchar** _tmp6_; gint _tmp6__length1; gchar* _tmp7_; gchar* _tmp8_; const gchar* _tmp9_; GMainLoop* _tmp10_; GError* _inner_error0_; }; VALA_EXTERN GMainLoop* main_loop; GMainLoop* main_loop = NULL; VALA_EXTERN GType test_proxy_get_type (void) G_GNUC_CONST ; VALA_EXTERN guint test_register_object (void* object, GDBusConnection* connection, const gchar* path, GError** error); VALA_EXTERN GType test_get_type (void) G_GNUC_CONST ; VALA_EXTERN void test_test_array_lifetime (Test* self, gchar** items, gint items_length1, GAsyncReadyCallback _callback_, gpointer _user_data_); VALA_EXTERN gchar* test_test_array_lifetime_finish (Test* self, GAsyncResult* _res_, GError** error); static GType test_get_type_once (void); static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters); static void _vala_g_async_ready_callback (GObject *source_object, GAsyncResult *res, void *user_data); static void test_proxy_test_array_lifetime_async (Test* self, gchar** items, gint items_length1, GAsyncReadyCallback _callback_, gpointer _user_data_); static gchar* test_proxy_test_array_lifetime_finish (Test* self, GAsyncResult* _res_, GError** error); static void test_proxy_test_interface_init (TestIface* iface); static void _dbus_test_test_array_lifetime (Test* self, GVariant* _parameters_, GDBusMethodInvocation* invocation); static void _dbus_test_test_array_lifetime_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_); static void test_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data); static GVariant* test_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data); static gboolean test_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data); static void _test_unregister_object (gpointer user_data); static void _vala_main (void); VALA_EXTERN void run (GAsyncReadyCallback _callback_, gpointer _user_data_); VALA_EXTERN void run_finish (GAsyncResult* _res_); static void run_data_free (gpointer _data); static gboolean run_co (RunData* _data_); static void run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_); 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 const GDBusArgInfo _test_dbus_arg_info_test_array_lifetime_items = {-1, "items", "as", NULL}; static const GDBusArgInfo _test_dbus_arg_info_test_array_lifetime_result = {-1, "result", "s", NULL}; static const GDBusArgInfo * const _test_dbus_arg_info_test_array_lifetime_in[] = {&_test_dbus_arg_info_test_array_lifetime_items, NULL}; static const GDBusArgInfo * const _test_dbus_arg_info_test_array_lifetime_out[] = {&_test_dbus_arg_info_test_array_lifetime_result, NULL}; static const GDBusMethodInfo _test_dbus_method_info_test_array_lifetime = {-1, "TestArrayLifetime", (GDBusArgInfo **) (&_test_dbus_arg_info_test_array_lifetime_in), (GDBusArgInfo **) (&_test_dbus_arg_info_test_array_lifetime_out), NULL}; static const GDBusMethodInfo * const _test_dbus_method_info[] = {&_test_dbus_method_info_test_array_lifetime, NULL}; static const GDBusSignalInfo * const _test_dbus_signal_info[] = {NULL}; static const GDBusPropertyInfo * const _test_dbus_property_info[] = {NULL}; static const GDBusInterfaceInfo _test_dbus_interface_info = {-1, "org.example.Test", (GDBusMethodInfo **) (&_test_dbus_method_info), (GDBusSignalInfo **) (&_test_dbus_signal_info), (GDBusPropertyInfo **) (&_test_dbus_property_info), NULL}; static const GDBusInterfaceVTable _test_dbus_interface_vtable = {test_dbus_interface_method_call, test_dbus_interface_get_property, test_dbus_interface_set_property}; void test_test_array_lifetime (Test* self, gchar** items, gint items_length1, GAsyncReadyCallback _callback_, gpointer _user_data_) { TestIface* _iface_; _iface_ = TEST_GET_INTERFACE (self); if (_iface_->test_array_lifetime) { _iface_->test_array_lifetime (self, items, items_length1, _callback_, _user_data_); } } gchar* test_test_array_lifetime_finish (Test* self, GAsyncResult* _res_, GError** error) { TestIface* _iface_; _iface_ = TEST_GET_INTERFACE (self); if (_iface_->test_array_lifetime_finish) { return _iface_->test_array_lifetime_finish (self, _res_, error); } return NULL; } static void test_default_init (TestIface * iface, gpointer iface_data) { } static GType test_get_type_once (void) { static const GTypeInfo g_define_type_info = { sizeof (TestIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) test_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL }; GType test_type_id; test_type_id = g_type_register_static (G_TYPE_INTERFACE, "Test", &g_define_type_info, 0); g_type_interface_add_prerequisite (test_type_id, G_TYPE_OBJECT); g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) test_proxy_get_type); g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.example.Test"); g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_test_dbus_interface_info)); g_type_set_qdata (test_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) test_register_object); return test_type_id; } GType test_get_type (void) { static volatile gsize test_type_id__volatile = 0; if (g_once_init_enter (&test_type_id__volatile)) { GType test_type_id; test_type_id = test_get_type_once (); g_once_init_leave (&test_type_id__volatile, test_type_id); } return test_type_id__volatile; } G_DEFINE_TYPE_EXTENDED (TestProxy, test_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_TEST, test_proxy_test_interface_init) ) static void test_proxy_class_init (TestProxyClass* klass) { G_DBUS_PROXY_CLASS (klass)->g_signal = test_proxy_g_signal; } static void test_proxy_g_signal (GDBusProxy* proxy, const gchar* sender_name, const gchar* signal_name, GVariant* parameters) { } static void test_proxy_init (TestProxy* self) { g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_test_dbus_interface_info)); } static void _vala_g_async_ready_callback (GObject *source_object, GAsyncResult *res, void *user_data) { g_task_return_pointer (user_data, g_object_ref (res), g_object_unref); g_object_unref (user_data); } static void test_proxy_test_array_lifetime_async (Test* self, gchar** items, gint items_length1, GAsyncReadyCallback _callback_, gpointer _user_data_) { GDBusMessage *_message; GVariant *_arguments; GVariantBuilder _arguments_builder; gchar** _tmp0_; GVariantBuilder _tmp1_; gint _tmp2_; G_IO_ERROR; _message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.example.Test", "TestArrayLifetime"); g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE); _tmp0_ = items; g_variant_builder_init (&_tmp1_, G_VARIANT_TYPE ("as")); for (_tmp2_ = 0; _tmp2_ < items_length1; _tmp2_++) { g_variant_builder_add_value (&_tmp1_, g_variant_new_string (*_tmp0_)); _tmp0_++; } g_variant_builder_add_value (&_arguments_builder, g_variant_builder_end (&_tmp1_)); _arguments = g_variant_builder_end (&_arguments_builder); g_dbus_message_set_body (_message, _arguments); if (_callback_ != NULL) { g_dbus_connection_send_message_with_reply (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, _vala_g_async_ready_callback, g_task_new ((GObject *) self, NULL, _callback_, _user_data_)); } else { g_dbus_message_set_flags (_message, G_DBUS_MESSAGE_FLAGS_NO_REPLY_EXPECTED); g_dbus_connection_send_message (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); } g_object_unref (_message); } static gchar* test_proxy_test_array_lifetime_finish (Test* self, GAsyncResult* _res_, GError** error) { GAsyncResult *_inner_res; GDBusMessage *_reply_message; GVariant *_reply; GVariantIter _reply_iter; gchar* _result = NULL; GVariant* _tmp3_; _inner_res = g_task_propagate_pointer ((GTask *) _res_, NULL); _reply_message = g_dbus_connection_send_message_with_reply_finish (g_dbus_proxy_get_connection ((GDBusProxy *) self), _inner_res, error); g_object_unref (_inner_res); if (!_reply_message) { return NULL; } if (g_dbus_message_to_gerror (_reply_message, error)) { g_object_unref (_reply_message); return NULL; } _reply = g_dbus_message_get_body (_reply_message); g_variant_iter_init (&_reply_iter, _reply); _tmp3_ = g_variant_iter_next_value (&_reply_iter); _result = g_variant_dup_string (_tmp3_, NULL); g_variant_unref (_tmp3_); g_object_unref (_reply_message); return _result; } static void test_proxy_test_interface_init (TestIface* iface) { iface->test_array_lifetime = test_proxy_test_array_lifetime_async; iface->test_array_lifetime_finish = test_proxy_test_array_lifetime_finish; } static void _dbus_test_test_array_lifetime (Test* self, GVariant* _parameters_, GDBusMethodInvocation* invocation) { GVariantIter _arguments_iter; TestTestArrayLifetimeReadyData* _ready_data; GVariant* _tmp4_; gchar** _tmp5_; gint _tmp5__length; gint _tmp5__size; gint _tmp5__length1; GVariantIter _tmp6_; GVariant* _tmp7_; g_variant_iter_init (&_arguments_iter, _parameters_); _ready_data = g_slice_new0 (TestTestArrayLifetimeReadyData); _ready_data->_invocation_ = invocation; _tmp4_ = g_variant_iter_next_value (&_arguments_iter); _tmp5_ = g_new (gchar*, 5); _tmp5__length = 0; _tmp5__size = 4; _tmp5__length1 = 0; g_variant_iter_init (&_tmp6_, _tmp4_); for (; (_tmp7_ = g_variant_iter_next_value (&_tmp6_)) != NULL; _tmp5__length1++) { if (_tmp5__size == _tmp5__length) { _tmp5__size = 2 * _tmp5__size; _tmp5_ = g_renew (gchar*, _tmp5_, _tmp5__size + 1); } _tmp5_[_tmp5__length++] = g_variant_dup_string (_tmp7_, NULL); g_variant_unref (_tmp7_); } _ready_data->items_length1 = _tmp5__length1; _tmp5_[_tmp5__length] = NULL; _ready_data->items = _tmp5_; g_variant_unref (_tmp4_); test_test_array_lifetime (self, _ready_data->items, _ready_data->items_length1, (GAsyncReadyCallback) _dbus_test_test_array_lifetime_ready, _ready_data); _error: ; } static void _dbus_test_test_array_lifetime_ready (GObject * source_object, GAsyncResult * _res_, gpointer _user_data_) { TestTestArrayLifetimeReadyData* _ready_data; GDBusMethodInvocation* invocation; GError* error = NULL; GDBusMessage* _reply_message = NULL; GVariant* _reply; GVariantBuilder _reply_builder; gchar* result; _ready_data = _user_data_; invocation = _ready_data->_invocation_; result = test_test_array_lifetime_finish ((Test*) source_object, _res_, &error); if (error) { g_dbus_method_invocation_take_error (invocation, error); goto _error; } _reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation)); g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE); g_variant_builder_add_value (&_reply_builder, g_variant_new_string (result)); _g_free0 (result); _reply = g_variant_builder_end (&_reply_builder); g_dbus_message_set_body (_reply_message, _reply); g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL); g_object_unref (invocation); g_object_unref (_reply_message); _error: _ready_data->items = (_vala_array_free (_ready_data->items, _ready_data->items_length1, (GDestroyNotify) g_free), NULL); g_slice_free (TestTestArrayLifetimeReadyData, _ready_data); } static void test_dbus_interface_method_call (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer user_data) { gpointer* data; gpointer object; data = user_data; object = data[0]; if (strcmp (method_name, "TestArrayLifetime") == 0) { _dbus_test_test_array_lifetime (object, parameters, invocation); } else { g_object_unref (invocation); } } static GVariant* test_dbus_interface_get_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GError** error, gpointer user_data) { gpointer* data; gpointer object; data = user_data; object = data[0]; return NULL; } static gboolean test_dbus_interface_set_property (GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* property_name, GVariant* value, GError** error, gpointer user_data) { gpointer* data; gpointer object; data = user_data; object = data[0]; return FALSE; } guint test_register_object (gpointer object, GDBusConnection* connection, const gchar* path, GError** error) { guint result; gpointer *data; data = g_new (gpointer, 3); data[0] = g_object_ref (object); data[1] = g_object_ref (connection); data[2] = g_strdup (path); result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_test_dbus_interface_info), &_test_dbus_interface_vtable, data, _test_unregister_object, error); if (!result) { return 0; } return result; } static void _test_unregister_object (gpointer user_data) { gpointer* data; data = user_data; g_object_unref (data[0]); g_object_unref (data[1]); g_free (data[2]); g_free (data); } static void _vala_main (void) { GMainLoop* _tmp0_; GMainLoop* _tmp1_; _tmp0_ = g_main_loop_new (NULL, FALSE); _g_main_loop_unref0 (main_loop); main_loop = _tmp0_; run (NULL, NULL); _tmp1_ = main_loop; g_main_loop_run (_tmp1_); } int main (int argc, char ** argv) { _vala_main (); return 0; } static void run_data_free (gpointer _data) { RunData* _data_; _data_ = _data; g_slice_free (RunData, _data_); } void run (GAsyncReadyCallback _callback_, gpointer _user_data_) { RunData* _data_; _data_ = g_slice_new0 (RunData); _data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_); g_task_set_task_data (_data_->_async_result, _data_, run_data_free); run_co (_data_); } void run_finish (GAsyncResult* _res_) { RunData* _data_; _data_ = g_task_propagate_pointer (G_TASK (_res_), NULL); } static void run_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) { RunData* _data_; _data_ = _user_data_; _data_->_source_object_ = source_object; _data_->_res_ = _res_; run_co (_data_); } static gboolean run_co (RunData* _data_) { switch (_data_->_state_) { case 0: goto _state_0; case 1: goto _state_1; case 2: goto _state_2; default: g_assert_not_reached (); } _state_0: _data_->_state_ = 1; g_async_initable_new_async (TYPE_TEST_PROXY, 0, NULL, run_ready, _data_, "g-flags", 0, "g-name", "org.example.Test", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/example/test", "g-interface-name", "org.example.Test", NULL); return FALSE; _state_1: _data_->_tmp0_ = (Test*) g_async_initable_new_finish ((GAsyncInitable *) _data_->_source_object_, _data_->_res_, &_data_->_inner_error0_); _data_->test = (Test*) _data_->_tmp0_; if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code); g_clear_error (&_data_->_inner_error0_); g_object_unref (_data_->_async_result); return FALSE; } _data_->_tmp1_ = _data_->test; _data_->_tmp2_ = g_strdup ("Badger"); _data_->_tmp3_ = g_strdup ("Snake"); _data_->_tmp4_ = g_strdup ("Mushroom"); _data_->_tmp5_ = g_new0 (gchar*, 3 + 1); _data_->_tmp5_[0] = _data_->_tmp2_; _data_->_tmp5_[1] = _data_->_tmp3_; _data_->_tmp5_[2] = _data_->_tmp4_; _data_->_tmp6_ = _data_->_tmp5_; _data_->_tmp6__length1 = 3; _data_->_state_ = 2; test_test_array_lifetime (_data_->_tmp1_, _data_->_tmp6_, (gint) 3, run_ready, _data_); return FALSE; _state_2: _data_->_tmp7_ = test_test_array_lifetime_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_); _data_->_tmp8_ = _data_->_tmp7_; _data_->_tmp6_ = (_vala_array_free (_data_->_tmp6_, _data_->_tmp6__length1, (GDestroyNotify) g_free), NULL); _data_->_result_ = _data_->_tmp8_; if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) { _g_object_unref0 (_data_->test); g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code); g_clear_error (&_data_->_inner_error0_); g_object_unref (_data_->_async_result); return FALSE; } _data_->_tmp9_ = _data_->_result_; _vala_assert (g_strcmp0 (_data_->_tmp9_, "BadgerSnakeMushroom") == 0, "result == \"BadgerSnakeMushroom\""); _data_->_tmp10_ = main_loop; g_main_loop_quit (_data_->_tmp10_); _g_free0 (_data_->_result_); _g_object_unref0 (_data_->test); 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_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); }