]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
gdbus: Allow GLib.VariantDict for a{sv}
authorSergey Bugaev <bugaevc@gmail.com>
Fri, 6 Mar 2026 08:23:44 +0000 (11:23 +0300)
committerRico Tzschichholz <ricotz@ubuntu.com>
Fri, 6 Mar 2026 15:51:06 +0000 (16:51 +0100)
codegen/valagvariantmodule.vala
tests/dbus/dicts.test
tests/dbus/dicts_client.c-expected
tests/dbus/dicts_server.c-expected
vapi/glib-2.0.vapi

index be13d35b92da7c52aeaf590ed94ca7bb6751f4a3..596db9508dcdf9112d5730dc106c839c3ae8296d 100644 (file)
@@ -590,6 +590,10 @@ public class Vala.GVariantModule : GValueModule {
                                result = variant_get;
                        } else if (type.type_symbol.get_full_name () == "GLib.HashTable") {
                                result = deserialize_hash_table ((ObjectType) type, variant_expr);
+                       } else if (type.type_symbol.get_full_name () == "GLib.VariantDict") {
+                               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_variant_dict_new"));
+                               ccall.add_argument (variant_expr);
+                               result = ccall;
                        }
                }
 
@@ -894,6 +898,10 @@ public class Vala.GVariantModule : GValueModule {
                                result = variant_new;
                        } else if (type.type_symbol.get_full_name () == "GLib.HashTable") {
                                result = serialize_hash_table ((ObjectType) type, expr);
+                       } else if (type.type_symbol.get_full_name () == "GLib.VariantDict") {
+                               var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_variant_dict_end"));
+                               ccall.add_argument (expr);
+                               result = ccall;
                        }
                }
 
index 9837f933d45d78b7416c226ad1b337c82f4b34d2..6464a046a61018c3d7d3986a02f3b2bb5ad3d18c 100644 (file)
@@ -6,6 +6,7 @@ Program: client
 [DBus (name = "org.example.Test")]
 interface Test : Object {
        public abstract HashTable<string, Variant> test_dict () throws IOError;
+       public abstract VariantDict test_variant_dict () throws IOError;
 }
 
 void main () {
@@ -18,6 +19,16 @@ void main () {
        assert (v != null);
        string[] s = (string[]) v;
        assert (s.length == 1 && s[0] == "hello");
+
+       VariantDict vardict = test.test_variant_dict ();
+       v = vardict.lookup_value ("hello", VariantType.INT32);
+       assert (v != null);
+       int i = (int) v;
+       assert (i == 42);
+       v = vardict.lookup_value ("hello again", VariantType.DOUBLE);
+       assert (v != null);
+       double d = (double) v;
+       assert (d == 47.11);
 }
 
 Program: server
@@ -30,6 +41,13 @@ class Test : Object {
                dict.insert ("hello", s);
                return dict;
        }
+
+       public VariantDict test_variant_dict () {
+               var vardict = new VariantDict ();
+               vardict.insert_value ("hello", new Variant.int32 (42));
+               vardict.insert_value ("hello again", 47.11);
+               return vardict;
+       }
 }
 
 namespace TestInterface {
index a7095eba3597c6d8b8e7211552cda8162760d5dc..393a102a1bead2270445899a2c5f097420931de3 100644 (file)
@@ -6,6 +6,8 @@
 #include <glib.h>
 #include <stdlib.h>
 #include <string.h>
+#include <float.h>
+#include <math.h>
 
 #if !defined(VALA_STRICT_C)
 #if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
@@ -37,6 +39,7 @@ typedef struct _TestIface TestIface;
 typedef GDBusProxy TestProxy;
 typedef GDBusProxyClass TestProxyClass;
 #define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
+#define _g_variant_dict_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_dict_unref (var), NULL)))
 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
 #define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
@@ -47,6 +50,7 @@ typedef GDBusProxyClass TestProxyClass;
 struct _TestIface {
        GTypeInterface parent_iface;
        GHashTable* (*test_dict) (Test* self, GError** error);
+       GVariantDict* (*test_variant_dict) (Test* self, GError** error);
 };
 
 VALA_EXTERN GType test_proxy_get_type (void) G_GNUC_CONST ;
@@ -58,6 +62,8 @@ VALA_EXTERN GType test_get_type (void) G_GNUC_CONST ;
 G_DEFINE_AUTOPTR_CLEANUP_FUNC (Test, g_object_unref)
 VALA_EXTERN GHashTable* test_test_dict (Test* self,
                             GError** error);
+VALA_EXTERN GVariantDict* test_test_variant_dict (Test* self,
+                                      GError** error);
 static GType test_get_type_once (void);
 static void test_proxy_g_signal (GDBusProxy* proxy,
                           const gchar* sender_name,
@@ -65,10 +71,15 @@ static void test_proxy_g_signal (GDBusProxy* proxy,
                           GVariant* parameters);
 static GHashTable* test_proxy_test_dict (Test* self,
                                   GError** error);
+static GVariantDict* test_proxy_test_variant_dict (Test* self,
+                                            GError** error);
 static void test_proxy_test_interface_init (TestIface* iface);
 static void _dbus_test_test_dict (Test* self,
                            GVariant* _parameters_,
                            GDBusMethodInvocation* invocation);
+static void _dbus_test_test_variant_dict (Test* self,
+                                   GVariant* _parameters_,
+                                   GDBusMethodInvocation* invocation);
 static void test_dbus_interface_method_call (GDBusConnection* connection,
                                       const gchar* sender,
                                       const gchar* object_path,
@@ -96,6 +107,8 @@ static void _test_unregister_object (gpointer user_data);
 static void _vala_main (void);
 static gchar** _variant_get1 (GVariant* value,
                        gint* result_length1);
+static gint _variant_get2 (GVariant* value);
+static gdouble _variant_get3 (GVariant* value);
 static void _vala_array_destroy (gpointer array,
                           gssize array_length,
                           GDestroyNotify destroy_func);
@@ -107,7 +120,11 @@ static const GDBusArgInfo _test_dbus_arg_info_test_dict_result = {-1, "result",
 static const GDBusArgInfo * const _test_dbus_arg_info_test_dict_in[] = {NULL};
 static const GDBusArgInfo * const _test_dbus_arg_info_test_dict_out[] = {&_test_dbus_arg_info_test_dict_result, NULL};
 static const GDBusMethodInfo _test_dbus_method_info_test_dict = {-1, "TestDict", (GDBusArgInfo **) (&_test_dbus_arg_info_test_dict_in), (GDBusArgInfo **) (&_test_dbus_arg_info_test_dict_out), NULL};
-static const GDBusMethodInfo * const _test_dbus_method_info[] = {&_test_dbus_method_info_test_dict, NULL};
+static const GDBusArgInfo _test_dbus_arg_info_test_variant_dict_result = {-1, "result", "a{sv}", NULL};
+static const GDBusArgInfo * const _test_dbus_arg_info_test_variant_dict_in[] = {NULL};
+static const GDBusArgInfo * const _test_dbus_arg_info_test_variant_dict_out[] = {&_test_dbus_arg_info_test_variant_dict_result, NULL};
+static const GDBusMethodInfo _test_dbus_method_info_test_variant_dict = {-1, "TestVariantDict", (GDBusArgInfo **) (&_test_dbus_arg_info_test_variant_dict_in), (GDBusArgInfo **) (&_test_dbus_arg_info_test_variant_dict_out), NULL};
+static const GDBusMethodInfo * const _test_dbus_method_info[] = {&_test_dbus_method_info_test_dict, &_test_dbus_method_info_test_variant_dict, 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};
@@ -126,6 +143,19 @@ test_test_dict (Test* self,
        return NULL;
 }
 
+GVariantDict*
+test_test_variant_dict (Test* self,
+                        GError** error)
+{
+       TestIface* _iface_;
+       g_return_val_if_fail (IS_TEST (self), NULL);
+       _iface_ = TEST_GET_INTERFACE (self);
+       if (_iface_->test_variant_dict) {
+               return _iface_->test_variant_dict (self, error);
+       }
+       return NULL;
+}
+
 static void
 test_default_init (TestIface * iface,
                    gpointer iface_data)
@@ -223,10 +253,46 @@ test_proxy_test_dict (Test* self,
        return _result;
 }
 
+static GVariantDict*
+test_proxy_test_variant_dict (Test* self,
+                              GError** error)
+{
+       GDBusMessage *_message;
+       GVariant *_arguments;
+       GVariantBuilder _arguments_builder;
+       GDBusMessage *_reply_message;
+       GVariant *_reply;
+       GVariantIter _reply_iter;
+       GVariantDict* _result = NULL;
+       GVariant* _tmp5_;
+       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", "TestVariantDict");
+       g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
+       _arguments = g_variant_builder_end (&_arguments_builder);
+       g_dbus_message_set_body (_message, _arguments);
+       _reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error);
+       g_object_unref (_message);
+       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);
+       _tmp5_ = g_variant_iter_next_value (&_reply_iter);
+       _result = g_variant_dict_new (_tmp5_);
+       g_variant_unref (_tmp5_);
+       g_object_unref (_reply_message);
+       return _result;
+}
+
 static void
 test_proxy_test_interface_init (TestIface* iface)
 {
        iface->test_dict = test_proxy_test_dict;
+       iface->test_variant_dict = test_proxy_test_variant_dict;
 }
 
 static void
@@ -240,10 +306,10 @@ _dbus_test_test_dict (Test* self,
        GVariant* _reply;
        GVariantBuilder _reply_builder;
        GHashTable* result;
-       GVariantBuilder _tmp5_;
-       GHashTableIter _tmp6_;
-       gpointer _tmp7_;
+       GVariantBuilder _tmp6_;
+       GHashTableIter _tmp7_;
        gpointer _tmp8_;
+       gpointer _tmp9_;
        g_variant_iter_init (&_arguments_iter, _parameters_);
        result = test_test_dict (self, &error);
        if (error) {
@@ -252,16 +318,16 @@ _dbus_test_test_dict (Test* self,
        }
        _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_hash_table_iter_init (&_tmp6_, result);
-       g_variant_builder_init (&_tmp5_, G_VARIANT_TYPE ("a{sv}"));
-       while (g_hash_table_iter_next (&_tmp6_, &_tmp7_, &_tmp8_)) {
+       g_hash_table_iter_init (&_tmp7_, result);
+       g_variant_builder_init (&_tmp6_, G_VARIANT_TYPE ("a{sv}"));
+       while (g_hash_table_iter_next (&_tmp7_, &_tmp8_, &_tmp9_)) {
                gchar* _key;
                GVariant* _value;
-               _key = (gchar*) _tmp7_;
-               _value = (GVariant*) _tmp8_;
-               g_variant_builder_add (&_tmp5_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value));
+               _key = (gchar*) _tmp8_;
+               _value = (GVariant*) _tmp9_;
+               g_variant_builder_add (&_tmp6_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value));
        }
-       g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp5_));
+       g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp6_));
        _g_hash_table_unref0 (result);
        _reply = g_variant_builder_end (&_reply_builder);
        g_dbus_message_set_body (_reply_message, _reply);
@@ -270,6 +336,34 @@ _dbus_test_test_dict (Test* self,
        g_object_unref (_reply_message);
 }
 
+static void
+_dbus_test_test_variant_dict (Test* self,
+                              GVariant* _parameters_,
+                              GDBusMethodInvocation* invocation)
+{
+       GError* error = NULL;
+       GVariantIter _arguments_iter;
+       GDBusMessage* _reply_message = NULL;
+       GVariant* _reply;
+       GVariantBuilder _reply_builder;
+       GVariantDict* result;
+       g_variant_iter_init (&_arguments_iter, _parameters_);
+       result = test_test_variant_dict (self, &error);
+       if (error) {
+               g_dbus_method_invocation_take_error (invocation, error);
+               return;
+       }
+       _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_dict_end (result));
+       _g_variant_dict_unref0 (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);
+}
+
 static void
 test_dbus_interface_method_call (GDBusConnection* connection,
                                  const gchar* sender,
@@ -286,6 +380,8 @@ test_dbus_interface_method_call (GDBusConnection* connection,
        object = data[0];
        if (strcmp (method_name, "TestDict") == 0) {
                _dbus_test_test_dict (object, parameters, invocation);
+       } else if (strcmp (method_name, "TestVariantDict") == 0) {
+               _dbus_test_test_variant_dict (object, parameters, invocation);
        } else {
                g_object_unref (invocation);
        }
@@ -380,6 +476,18 @@ _variant_get1 (GVariant* value,
        return _tmp0_;
 }
 
+static gint
+_variant_get2 (GVariant* value)
+{
+       return g_variant_get_int32 (value);
+}
+
+static gdouble
+_variant_get3 (GVariant* value)
+{
+       return g_variant_get_double (value);
+}
+
 static void
 _vala_main (void)
 {
@@ -403,6 +511,23 @@ _vala_main (void)
        gboolean _tmp10_ = FALSE;
        gchar** _tmp11_;
        gint _tmp11__length1;
+       GVariantDict* vardict = NULL;
+       Test* _tmp14_;
+       GVariantDict* _tmp15_;
+       GVariantDict* _tmp16_;
+       const GVariantType* _tmp17_;
+       GVariant* _tmp18_;
+       GVariant* _tmp19_;
+       gint i = 0;
+       GVariant* _tmp20_;
+       gint _tmp21_;
+       GVariantDict* _tmp22_;
+       const GVariantType* _tmp23_;
+       GVariant* _tmp24_;
+       GVariant* _tmp25_;
+       gdouble d = 0.0;
+       GVariant* _tmp26_;
+       gdouble _tmp27_;
        GError* _inner_error0_ = NULL;
        _tmp0_ = (Test*) g_initable_new (TYPE_TEST_PROXY, NULL, &_inner_error0_, "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);
        test = (Test*) _tmp0_;
@@ -447,6 +572,41 @@ _vala_main (void)
                _tmp10_ = FALSE;
        }
        _vala_assert (_tmp10_, "s.length == 1 && s[0] == \"hello\"");
+       _tmp14_ = test;
+       _tmp15_ = test_test_variant_dict (_tmp14_, &_inner_error0_);
+       vardict = _tmp15_;
+       if (G_UNLIKELY (_inner_error0_ != NULL)) {
+               s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
+               _g_variant_unref0 (v);
+               _g_hash_table_unref0 (dict);
+               _g_object_unref0 (test);
+               g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
+               g_clear_error (&_inner_error0_);
+               return;
+       }
+       _tmp16_ = vardict;
+       _tmp17_ = G_VARIANT_TYPE_INT32;
+       _tmp18_ = g_variant_dict_lookup_value (_tmp16_, "hello", _tmp17_);
+       _g_variant_unref0 (v);
+       v = _tmp18_;
+       _tmp19_ = v;
+       _vala_assert (_tmp19_ != NULL, "v != null");
+       _tmp20_ = v;
+       _tmp21_ = _variant_get2 (_tmp20_);
+       i = _tmp21_;
+       _vala_assert (i == 42, "i == 42");
+       _tmp22_ = vardict;
+       _tmp23_ = G_VARIANT_TYPE_DOUBLE;
+       _tmp24_ = g_variant_dict_lookup_value (_tmp22_, "hello again", _tmp23_);
+       _g_variant_unref0 (v);
+       v = _tmp24_;
+       _tmp25_ = v;
+       _vala_assert (_tmp25_ != NULL, "v != null");
+       _tmp26_ = v;
+       _tmp27_ = _variant_get3 (_tmp26_);
+       d = _tmp27_;
+       _vala_assert (d == 47.11, "d == 47.11");
+       _g_variant_dict_unref0 (vardict);
        s = (_vala_array_free (s, s_length1, (GDestroyNotify) g_free), NULL);
        _g_variant_unref0 (v);
        _g_hash_table_unref0 (dict);
index 5f53e86e6caac8140e8f3473311aeccec95b383e..06795f64354a7bb7310f2acff51b87718dbcfaef 100644 (file)
@@ -40,7 +40,9 @@ enum  {
        TEST_NUM_PROPERTIES
 };
 static GParamSpec* test_properties[TEST_NUM_PROPERTIES];
+#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
 #define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
+#define _g_variant_dict_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_dict_unref (var), NULL)))
 
 #define TEST_INTERFACE_TYPE_BAR (test_interface_bar_get_type ())
 #define TEST_INTERFACE_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_INTERFACE_TYPE_BAR, TestInterfaceBar))
@@ -70,7 +72,6 @@ enum  {
 };
 static GParamSpec* test_interface_foo_properties[TEST_INTERFACE_FOO_NUM_PROPERTIES];
 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
-#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
 #define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (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; }
@@ -117,12 +118,17 @@ static void _g_free0_ (gpointer var);
 static void _g_variant_unref0_ (gpointer var);
 static GVariant* _variant_new1 (gchar** value,
                          gint value_length1);
+VALA_EXTERN GVariantDict* test_test_variant_dict (Test* self);
+static GVariant* _variant_new2 (gdouble value);
 VALA_EXTERN Test* test_new (void);
 VALA_EXTERN Test* test_construct (GType object_type);
 static GType test_get_type_once (void);
 static void _dbus_test_test_dict (Test* self,
                            GVariant* _parameters_,
                            GDBusMethodInvocation* invocation);
+static void _dbus_test_test_variant_dict (Test* self,
+                                   GVariant* _parameters_,
+                                   GDBusMethodInvocation* invocation);
 static void test_dbus_interface_method_call (GDBusConnection* connection,
                                       const gchar* sender,
                                       const gchar* object_path,
@@ -216,7 +222,11 @@ static const GDBusArgInfo _test_dbus_arg_info_test_dict_result = {-1, "result",
 static const GDBusArgInfo * const _test_dbus_arg_info_test_dict_in[] = {NULL};
 static const GDBusArgInfo * const _test_dbus_arg_info_test_dict_out[] = {&_test_dbus_arg_info_test_dict_result, NULL};
 static const GDBusMethodInfo _test_dbus_method_info_test_dict = {-1, "TestDict", (GDBusArgInfo **) (&_test_dbus_arg_info_test_dict_in), (GDBusArgInfo **) (&_test_dbus_arg_info_test_dict_out), NULL};
-static const GDBusMethodInfo * const _test_dbus_method_info[] = {&_test_dbus_method_info_test_dict, NULL};
+static const GDBusArgInfo _test_dbus_arg_info_test_variant_dict_result = {-1, "result", "a{sv}", NULL};
+static const GDBusArgInfo * const _test_dbus_arg_info_test_variant_dict_in[] = {NULL};
+static const GDBusArgInfo * const _test_dbus_arg_info_test_variant_dict_out[] = {&_test_dbus_arg_info_test_variant_dict_result, NULL};
+static const GDBusMethodInfo _test_dbus_method_info_test_variant_dict = {-1, "TestVariantDict", (GDBusArgInfo **) (&_test_dbus_arg_info_test_variant_dict_in), (GDBusArgInfo **) (&_test_dbus_arg_info_test_variant_dict_out), NULL};
+static const GDBusMethodInfo * const _test_dbus_method_info[] = {&_test_dbus_method_info_test_dict, &_test_dbus_method_info_test_variant_dict, 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};
@@ -291,6 +301,36 @@ test_test_dict (Test* self)
        return result;
 }
 
+static GVariant*
+_variant_new2 (gdouble value)
+{
+       return g_variant_ref_sink (g_variant_new_double (value));
+}
+
+GVariantDict*
+test_test_variant_dict (Test* self)
+{
+       GVariantDict* vardict = NULL;
+       GVariantDict* _tmp0_;
+       GVariant* _tmp1_;
+       GVariant* _tmp2_;
+       GVariant* _tmp3_;
+       GVariantDict* result;
+       g_return_val_if_fail (IS_TEST (self), NULL);
+       _tmp0_ = g_variant_dict_new (NULL);
+       vardict = _tmp0_;
+       _tmp1_ = g_variant_new_int32 ((gint32) 42);
+       g_variant_ref_sink (_tmp1_);
+       _tmp2_ = _tmp1_;
+       g_variant_dict_insert_value (vardict, "hello", _tmp2_);
+       _g_variant_unref0 (_tmp2_);
+       _tmp3_ = _variant_new2 (47.11);
+       g_variant_dict_insert_value (vardict, "hello again", _tmp3_);
+       _g_variant_unref0 (_tmp3_);
+       result = vardict;
+       return result;
+}
+
 Test*
 test_construct (GType object_type)
 {
@@ -377,6 +417,30 @@ _dbus_test_test_dict (Test* self,
        g_object_unref (_reply_message);
 }
 
+static void
+_dbus_test_test_variant_dict (Test* self,
+                              GVariant* _parameters_,
+                              GDBusMethodInvocation* invocation)
+{
+       GError* error = NULL;
+       GVariantIter _arguments_iter;
+       GDBusMessage* _reply_message = NULL;
+       GVariant* _reply;
+       GVariantBuilder _reply_builder;
+       GVariantDict* result;
+       g_variant_iter_init (&_arguments_iter, _parameters_);
+       result = test_test_variant_dict (self);
+       _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_dict_end (result));
+       _g_variant_dict_unref0 (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);
+}
+
 static void
 test_dbus_interface_method_call (GDBusConnection* connection,
                                  const gchar* sender,
@@ -393,6 +457,8 @@ test_dbus_interface_method_call (GDBusConnection* connection,
        object = data[0];
        if (strcmp (method_name, "TestDict") == 0) {
                _dbus_test_test_dict (object, parameters, invocation);
+       } else if (strcmp (method_name, "TestVariantDict") == 0) {
+               _dbus_test_test_variant_dict (object, parameters, invocation);
        } else {
                g_object_unref (invocation);
        }
index 359ed872a49b6f3b3b55fcbec91eba74440ee7e2..bd75f0edd48183ef429c550a599073b8393188aa 100644 (file)
@@ -6770,7 +6770,7 @@ namespace GLib {
        }
 
        [Version (since = "2.40")]
-       [Compact, CCode (ref_function = "g_variant_dict_ref", unref_function = "g_variant_dict_unref", type_id = "G_TYPE_VARIANT_DICT")]
+       [Compact, CCode (ref_function = "g_variant_dict_ref", unref_function = "g_variant_dict_unref", type_id = "G_TYPE_VARIANT_DICT", type_signature = "a{sv}")]
        public class VariantDict {
                public VariantDict (GLib.Variant? from_asv = null);
                public bool lookup (string key, string format_string, ...);