|
|
4845a0 |
From 04e6f6ec79ed653ef691c7c6ac5f7ae7c40433aa Mon Sep 17 00:00:00 2001
|
|
|
4845a0 |
From: Robert Ancell <robert.ancell@canonical.com>
|
|
|
4845a0 |
Date: Fri, 7 Sep 2018 10:19:05 +1200
|
|
|
4845a0 |
Subject: [PATCH 1/2] codegen: Change pointer casting to remove type-punning
|
|
|
4845a0 |
warnings
|
|
|
4845a0 |
|
|
|
4845a0 |
The existing code was generating code with undefined results that modern compilers warn about:
|
|
|
4845a0 |
|
|
|
4845a0 |
accounts-generated.c:204:23: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
|
|
|
4845a0 |
(GDBusArgInfo **) &_accounts_accounts_method_info_list_cached_users_OUT_ARG_pointers,
|
|
|
4845a0 |
---
|
|
|
4845a0 |
gio/gdbus-2.0/codegen/codegen.py | 22 +++++++++++-----------
|
|
|
4845a0 |
1 file changed, 11 insertions(+), 11 deletions(-)
|
|
|
4845a0 |
|
|
|
4845a0 |
diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py
|
|
|
4845a0 |
index d98f8973b..f6892af95 100644
|
|
|
4845a0 |
--- a/gio/gdbus-2.0/codegen/codegen.py
|
|
|
4845a0 |
+++ b/gio/gdbus-2.0/codegen/codegen.py
|
|
|
4845a0 |
@@ -817,186 +817,186 @@ class CodeGenerator:
|
|
|
4845a0 |
self.outfile.write(' &%s_%d,\n'%(prefix, m))
|
|
|
4845a0 |
m += 1
|
|
|
4845a0 |
self.outfile.write(' NULL\n'
|
|
|
4845a0 |
'};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
return n
|
|
|
4845a0 |
|
|
|
4845a0 |
def generate_args(self, prefix, args):
|
|
|
4845a0 |
for a in args:
|
|
|
4845a0 |
num_anno = self.generate_annotations('%s_arg_%s_annotation_info'%(prefix, a.name), a.annotations)
|
|
|
4845a0 |
|
|
|
4845a0 |
self.outfile.write('static const _ExtendedGDBusArgInfo %s_%s =\n'
|
|
|
4845a0 |
'{\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' -1,\n'
|
|
|
4845a0 |
' (gchar *) "%s",\n'
|
|
|
4845a0 |
' (gchar *) "%s",\n'%(prefix, a.name, a.name, a.signature))
|
|
|
4845a0 |
if num_anno == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusAnnotationInfo **) &%s_arg_%s_annotation_info_pointers\n'%(prefix, a.name))
|
|
|
4845a0 |
self.outfile.write(' },\n')
|
|
|
4845a0 |
if not utils.lookup_annotation(a.annotations, 'org.gtk.GDBus.C.ForceGVariant'):
|
|
|
4845a0 |
self.outfile.write(' FALSE\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' TRUE\n')
|
|
|
4845a0 |
self.outfile.write('};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
if len(args) > 0:
|
|
|
4845a0 |
- self.outfile.write('static const _ExtendedGDBusArgInfo * const %s_pointers[] =\n'
|
|
|
4845a0 |
+ self.outfile.write('static const GDBusArgInfo * const %s_pointers[] =\n'
|
|
|
4845a0 |
'{\n'%(prefix))
|
|
|
4845a0 |
for a in args:
|
|
|
4845a0 |
- self.outfile.write(' &%s_%s,\n'%(prefix, a.name))
|
|
|
4845a0 |
+ self.outfile.write(' &%s_%s.parent_struct,\n'%(prefix, a.name))
|
|
|
4845a0 |
self.outfile.write(' NULL\n'
|
|
|
4845a0 |
'};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
def generate_introspection_for_interface(self, i):
|
|
|
4845a0 |
self.outfile.write('/* ---- Introspection data for %s ---- */\n'
|
|
|
4845a0 |
'\n'%(i.name))
|
|
|
4845a0 |
|
|
|
4845a0 |
if len(i.methods) > 0:
|
|
|
4845a0 |
for m in i.methods:
|
|
|
4845a0 |
unix_fd = False
|
|
|
4845a0 |
if utils.lookup_annotation(m.annotations, 'org.gtk.GDBus.C.UnixFD'):
|
|
|
4845a0 |
unix_fd = True
|
|
|
4845a0 |
self.generate_args('_%s_method_info_%s_IN_ARG'%(i.name_lower, m.name_lower), m.in_args)
|
|
|
4845a0 |
self.generate_args('_%s_method_info_%s_OUT_ARG'%(i.name_lower, m.name_lower), m.out_args)
|
|
|
4845a0 |
|
|
|
4845a0 |
num_anno = self.generate_annotations('_%s_method_%s_annotation_info'%(i.name_lower, m.name_lower), m.annotations)
|
|
|
4845a0 |
|
|
|
4845a0 |
self.outfile.write('static const _ExtendedGDBusMethodInfo _%s_method_info_%s =\n'
|
|
|
4845a0 |
'{\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' -1,\n'
|
|
|
4845a0 |
' (gchar *) "%s",\n'%(i.name_lower, m.name_lower, m.name))
|
|
|
4845a0 |
if len(m.in_args) == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL,\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusArgInfo **) &_%s_method_info_%s_IN_ARG_pointers,\n'%(i.name_lower, m.name_lower))
|
|
|
4845a0 |
if len(m.out_args) == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL,\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusArgInfo **) &_%s_method_info_%s_OUT_ARG_pointers,\n'%(i.name_lower, m.name_lower))
|
|
|
4845a0 |
if num_anno == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusAnnotationInfo **) &_%s_method_%s_annotation_info_pointers\n'%(i.name_lower, m.name_lower))
|
|
|
4845a0 |
self.outfile.write(' },\n'
|
|
|
4845a0 |
' "handle-%s",\n'
|
|
|
4845a0 |
' %s\n'
|
|
|
4845a0 |
%(m.name_hyphen, 'TRUE' if unix_fd else 'FALSE'))
|
|
|
4845a0 |
self.outfile.write('};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
- self.outfile.write('static const _ExtendedGDBusMethodInfo * const _%s_method_info_pointers[] =\n'
|
|
|
4845a0 |
+ self.outfile.write('static const GDBusMethodInfo * const _%s_method_info_pointers[] =\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
for m in i.methods:
|
|
|
4845a0 |
- self.outfile.write(' &_%s_method_info_%s,\n'%(i.name_lower, m.name_lower))
|
|
|
4845a0 |
+ self.outfile.write(' &_%s_method_info_%s.parent_struct,\n'%(i.name_lower, m.name_lower))
|
|
|
4845a0 |
self.outfile.write(' NULL\n'
|
|
|
4845a0 |
'};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
# ---
|
|
|
4845a0 |
|
|
|
4845a0 |
if len(i.signals) > 0:
|
|
|
4845a0 |
for s in i.signals:
|
|
|
4845a0 |
self.generate_args('_%s_signal_info_%s_ARG'%(i.name_lower, s.name_lower), s.args)
|
|
|
4845a0 |
|
|
|
4845a0 |
num_anno = self.generate_annotations('_%s_signal_%s_annotation_info'%(i.name_lower, s.name_lower), s.annotations)
|
|
|
4845a0 |
self.outfile.write('static const _ExtendedGDBusSignalInfo _%s_signal_info_%s =\n'
|
|
|
4845a0 |
'{\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' -1,\n'
|
|
|
4845a0 |
' (gchar *) "%s",\n'%(i.name_lower, s.name_lower, s.name))
|
|
|
4845a0 |
if len(s.args) == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL,\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusArgInfo **) &_%s_signal_info_%s_ARG_pointers,\n'%(i.name_lower, s.name_lower))
|
|
|
4845a0 |
if num_anno == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusAnnotationInfo **) &_%s_signal_%s_annotation_info_pointers\n'%(i.name_lower, s.name_lower))
|
|
|
4845a0 |
self.outfile.write(' },\n'
|
|
|
4845a0 |
' "%s"\n'
|
|
|
4845a0 |
%(s.name_hyphen))
|
|
|
4845a0 |
self.outfile.write('};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
- self.outfile.write('static const _ExtendedGDBusSignalInfo * const _%s_signal_info_pointers[] =\n'
|
|
|
4845a0 |
+ self.outfile.write('static const GDBusSignalInfo * const _%s_signal_info_pointers[] =\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
for s in i.signals:
|
|
|
4845a0 |
- self.outfile.write(' &_%s_signal_info_%s,\n'%(i.name_lower, s.name_lower))
|
|
|
4845a0 |
+ self.outfile.write(' &_%s_signal_info_%s.parent_struct,\n'%(i.name_lower, s.name_lower))
|
|
|
4845a0 |
self.outfile.write(' NULL\n'
|
|
|
4845a0 |
'};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
# ---
|
|
|
4845a0 |
|
|
|
4845a0 |
if len(i.properties) > 0:
|
|
|
4845a0 |
for p in i.properties:
|
|
|
4845a0 |
if p.readable and p.writable:
|
|
|
4845a0 |
access = 'G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE'
|
|
|
4845a0 |
elif p.readable:
|
|
|
4845a0 |
access = 'G_DBUS_PROPERTY_INFO_FLAGS_READABLE'
|
|
|
4845a0 |
elif p.writable:
|
|
|
4845a0 |
access = 'G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE'
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
access = 'G_DBUS_PROPERTY_INFO_FLAGS_NONE'
|
|
|
4845a0 |
num_anno = self.generate_annotations('_%s_property_%s_annotation_info'%(i.name_lower, p.name_lower), p.annotations)
|
|
|
4845a0 |
self.outfile.write('static const _ExtendedGDBusPropertyInfo _%s_property_info_%s =\n'
|
|
|
4845a0 |
'{\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' -1,\n'
|
|
|
4845a0 |
' (gchar *) "%s",\n'
|
|
|
4845a0 |
' (gchar *) "%s",\n'
|
|
|
4845a0 |
' %s,\n'%(i.name_lower, p.name_lower, p.name, p.arg.signature, access))
|
|
|
4845a0 |
if num_anno == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusAnnotationInfo **) &_%s_property_%s_annotation_info_pointers\n'%(i.name_lower, p.name_lower))
|
|
|
4845a0 |
self.outfile.write(' },\n'
|
|
|
4845a0 |
' "%s",\n'
|
|
|
4845a0 |
%(p.name_hyphen))
|
|
|
4845a0 |
if not utils.lookup_annotation(p.annotations, 'org.gtk.GDBus.C.ForceGVariant'):
|
|
|
4845a0 |
self.outfile.write(' FALSE\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' TRUE\n')
|
|
|
4845a0 |
self.outfile.write('};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
- self.outfile.write('static const _ExtendedGDBusPropertyInfo * const _%s_property_info_pointers[] =\n'
|
|
|
4845a0 |
+ self.outfile.write('static const GDBusPropertyInfo * const _%s_property_info_pointers[] =\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
for p in i.properties:
|
|
|
4845a0 |
- self.outfile.write(' &_%s_property_info_%s,\n'%(i.name_lower, p.name_lower))
|
|
|
4845a0 |
+ self.outfile.write(' &_%s_property_info_%s.parent_struct,\n'%(i.name_lower, p.name_lower))
|
|
|
4845a0 |
self.outfile.write(' NULL\n'
|
|
|
4845a0 |
'};\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
num_anno = self.generate_annotations('_%s_annotation_info'%(i.name_lower), i.annotations)
|
|
|
4845a0 |
self.outfile.write('static const _ExtendedGDBusInterfaceInfo _%s_interface_info =\n'
|
|
|
4845a0 |
'{\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' -1,\n'
|
|
|
4845a0 |
' (gchar *) "%s",\n'%(i.name_lower, i.name))
|
|
|
4845a0 |
if len(i.methods) == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL,\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusMethodInfo **) &_%s_method_info_pointers,\n'%(i.name_lower))
|
|
|
4845a0 |
if len(i.signals) == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL,\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusSignalInfo **) &_%s_signal_info_pointers,\n'%(i.name_lower))
|
|
|
4845a0 |
if len(i.properties) == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL,\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusPropertyInfo **) &_%s_property_info_pointers,\n'%(i.name_lower))
|
|
|
4845a0 |
if num_anno == 0:
|
|
|
4845a0 |
self.outfile.write(' NULL\n')
|
|
|
4845a0 |
else:
|
|
|
4845a0 |
self.outfile.write(' (GDBusAnnotationInfo **) &_%s_annotation_info_pointers\n'%(i.name_lower))
|
|
|
4845a0 |
self.outfile.write(' },\n'
|
|
|
4845a0 |
' "%s",\n'
|
|
|
4845a0 |
'};\n'
|
|
|
4845a0 |
'\n'
|
|
|
4845a0 |
@@ -1636,114 +1636,114 @@ class CodeGenerator:
|
|
|
4845a0 |
self.outfile.write('#else\n')
|
|
|
4845a0 |
self.outfile.write('G_DEFINE_TYPE_WITH_CODE (%sProxy, %s_proxy, G_TYPE_DBUS_PROXY,\n'%(i.camel_name, i.name_lower))
|
|
|
4845a0 |
self.outfile.write(' G_IMPLEMENT_INTERFACE (%sTYPE_%s, %s_proxy_iface_init))\n\n'%(i.ns_upper, i.name_upper, i.name_lower))
|
|
|
4845a0 |
self.outfile.write('#endif\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
# finalize
|
|
|
4845a0 |
self.outfile.write('static void\n'
|
|
|
4845a0 |
'%s_proxy_finalize (GObject *object)\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
self.outfile.write(' %sProxy *proxy = %s%s_PROXY (object);\n'%(i.camel_name, i.ns_upper, i.name_upper))
|
|
|
4845a0 |
self.outfile.write(' g_datalist_clear (&proxy->priv->qdata);\n')
|
|
|
4845a0 |
self.outfile.write(' G_OBJECT_CLASS (%s_proxy_parent_class)->finalize (object);\n'
|
|
|
4845a0 |
'}\n'
|
|
|
4845a0 |
'\n'%(i.name_lower))
|
|
|
4845a0 |
|
|
|
4845a0 |
# property accessors
|
|
|
4845a0 |
#
|
|
|
4845a0 |
# Note that we are guaranteed that prop_id starts at 1 and is
|
|
|
4845a0 |
# laid out in the same order as introspection data pointers
|
|
|
4845a0 |
#
|
|
|
4845a0 |
self.outfile.write('static void\n'
|
|
|
4845a0 |
'%s_proxy_get_property (GObject *object,\n'
|
|
|
4845a0 |
' guint prop_id,\n'
|
|
|
4845a0 |
' GValue *value,\n'
|
|
|
4845a0 |
' GParamSpec *pspec G_GNUC_UNUSED)\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
if len(i.properties) > 0:
|
|
|
4845a0 |
self.outfile.write(' const _ExtendedGDBusPropertyInfo *info;\n'
|
|
|
4845a0 |
' GVariant *variant;\n'
|
|
|
4845a0 |
' g_assert (prop_id != 0 && prop_id - 1 < %d);\n'
|
|
|
4845a0 |
- ' info = _%s_property_info_pointers[prop_id - 1];\n'
|
|
|
4845a0 |
+ ' info = (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1];\n'
|
|
|
4845a0 |
' variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (object), info->parent_struct.name);\n'
|
|
|
4845a0 |
' if (info->use_gvariant)\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' g_value_set_variant (value, variant);\n'
|
|
|
4845a0 |
' }\n'
|
|
|
4845a0 |
' else\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
# could be that we don't have the value in cache - in that case, we do
|
|
|
4845a0 |
# nothing and the user gets the default value for the GType
|
|
|
4845a0 |
' if (variant != NULL)\n'
|
|
|
4845a0 |
' g_dbus_gvariant_to_gvalue (variant, value);\n'
|
|
|
4845a0 |
' }\n'
|
|
|
4845a0 |
' if (variant != NULL)\n'
|
|
|
4845a0 |
' g_variant_unref (variant);\n'
|
|
|
4845a0 |
%(len(i.properties), i.name_lower))
|
|
|
4845a0 |
self.outfile.write('}\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
if len(i.properties) > 0:
|
|
|
4845a0 |
self.outfile.write('static void\n'
|
|
|
4845a0 |
'%s_proxy_set_property_cb (GDBusProxy *proxy,\n'
|
|
|
4845a0 |
' GAsyncResult *res,\n'
|
|
|
4845a0 |
' gpointer user_data)\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
self.outfile.write(' const _ExtendedGDBusPropertyInfo *info = user_data;\n'
|
|
|
4845a0 |
' GError *error;\n'
|
|
|
4845a0 |
' GVariant *_ret;\n'
|
|
|
4845a0 |
' error = NULL;\n'
|
|
|
4845a0 |
' _ret = g_dbus_proxy_call_finish (proxy, res, &error);\n'
|
|
|
4845a0 |
' if (!_ret)\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' g_warning ("Error setting property \'%%s\' on interface %s: %%s (%%s, %%d)",\n'
|
|
|
4845a0 |
' info->parent_struct.name, \n'
|
|
|
4845a0 |
' error->message, g_quark_to_string (error->domain), error->code);\n'
|
|
|
4845a0 |
' g_error_free (error);\n'
|
|
|
4845a0 |
' }\n'
|
|
|
4845a0 |
' else\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' g_variant_unref (_ret);\n'
|
|
|
4845a0 |
' }\n'
|
|
|
4845a0 |
%(i.name))
|
|
|
4845a0 |
self.outfile.write('}\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
self.outfile.write('static void\n'
|
|
|
4845a0 |
'%s_proxy_set_property (GObject *object,\n'
|
|
|
4845a0 |
' guint prop_id,\n'
|
|
|
4845a0 |
' const GValue *value,\n'
|
|
|
4845a0 |
' GParamSpec *pspec G_GNUC_UNUSED)\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
if len(i.properties) > 0:
|
|
|
4845a0 |
self.outfile.write(' const _ExtendedGDBusPropertyInfo *info;\n'
|
|
|
4845a0 |
' GVariant *variant;\n'
|
|
|
4845a0 |
' g_assert (prop_id != 0 && prop_id - 1 < %d);\n'
|
|
|
4845a0 |
- ' info = _%s_property_info_pointers[prop_id - 1];\n'
|
|
|
4845a0 |
+ ' info = (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1];\n'
|
|
|
4845a0 |
' variant = g_dbus_gvalue_to_gvariant (value, G_VARIANT_TYPE (info->parent_struct.signature));\n'
|
|
|
4845a0 |
' g_dbus_proxy_call (G_DBUS_PROXY (object),\n'
|
|
|
4845a0 |
' "org.freedesktop.DBus.Properties.Set",\n'
|
|
|
4845a0 |
' g_variant_new ("(ssv)", "%s", info->parent_struct.name, variant),\n'
|
|
|
4845a0 |
' G_DBUS_CALL_FLAGS_NONE,\n'
|
|
|
4845a0 |
' -1,\n'
|
|
|
4845a0 |
' NULL, (GAsyncReadyCallback) %s_proxy_set_property_cb, (GDBusPropertyInfo *) &info->parent_struct);\n'
|
|
|
4845a0 |
' g_variant_unref (variant);\n'
|
|
|
4845a0 |
%(len(i.properties), i.name_lower, i.name, i.name_lower))
|
|
|
4845a0 |
self.outfile.write('}\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
# signal received
|
|
|
4845a0 |
self.outfile.write('static void\n'
|
|
|
4845a0 |
'%s_proxy_g_signal (GDBusProxy *proxy,\n'
|
|
|
4845a0 |
' const gchar *sender_name G_GNUC_UNUSED,\n'
|
|
|
4845a0 |
' const gchar *signal_name,\n'
|
|
|
4845a0 |
' GVariant *parameters)\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
self.outfile.write(' _ExtendedGDBusSignalInfo *info;\n'
|
|
|
4845a0 |
' GVariantIter iter;\n'
|
|
|
4845a0 |
' GVariant *child;\n'
|
|
|
4845a0 |
' GValue *paramv;\n'
|
|
|
4845a0 |
' gsize num_params;\n'
|
|
|
4845a0 |
' gsize n;\n'
|
|
|
4845a0 |
' guint signal_id;\n');
|
|
|
4845a0 |
# Note: info could be NULL if we are talking to a newer version of the interface
|
|
|
4845a0 |
self.outfile.write(' info = (_ExtendedGDBusSignalInfo *) g_dbus_interface_info_lookup_signal ((GDBusInterfaceInfo *) &_%s_interface_info.parent_struct, signal_name);\n'
|
|
|
4845a0 |
' if (info == NULL)\n'
|
|
|
4845a0 |
' return;\n'
|
|
|
4845a0 |
@@ -2575,61 +2575,61 @@ class CodeGenerator:
|
|
|
4845a0 |
' %sSkeleton *skeleton = %s%s_SKELETON (object);\n'
|
|
|
4845a0 |
' g_mutex_lock (&skeleton->priv->lock);\n'
|
|
|
4845a0 |
' if (skeleton->priv->changed_properties != NULL &&\n'
|
|
|
4845a0 |
' skeleton->priv->changed_properties_idle_source == NULL)\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' skeleton->priv->changed_properties_idle_source = g_idle_source_new ();\n'
|
|
|
4845a0 |
' g_source_set_priority (skeleton->priv->changed_properties_idle_source, G_PRIORITY_DEFAULT);\n'
|
|
|
4845a0 |
' g_source_set_callback (skeleton->priv->changed_properties_idle_source, _%s_emit_changed, g_object_ref (skeleton), (GDestroyNotify) g_object_unref);\n'
|
|
|
4845a0 |
' g_source_set_name (skeleton->priv->changed_properties_idle_source, "[generated] _%s_emit_changed");\n'
|
|
|
4845a0 |
' g_source_attach (skeleton->priv->changed_properties_idle_source, skeleton->priv->context);\n'
|
|
|
4845a0 |
' g_source_unref (skeleton->priv->changed_properties_idle_source);\n'
|
|
|
4845a0 |
' }\n'
|
|
|
4845a0 |
' g_mutex_unlock (&skeleton->priv->lock);\n'
|
|
|
4845a0 |
'}\n'
|
|
|
4845a0 |
'\n'
|
|
|
4845a0 |
%(i.name_lower, i.camel_name, i.ns_upper, i.name_upper, i.name_lower, i.name_lower))
|
|
|
4845a0 |
|
|
|
4845a0 |
self.outfile.write('static void\n'
|
|
|
4845a0 |
'%s_skeleton_set_property (GObject *object,\n'
|
|
|
4845a0 |
' guint prop_id,\n'
|
|
|
4845a0 |
' const GValue *value,\n'
|
|
|
4845a0 |
' GParamSpec *pspec)\n'
|
|
|
4845a0 |
'{\n'%(i.name_lower))
|
|
|
4845a0 |
self.outfile.write(' %sSkeleton *skeleton = %s%s_SKELETON (object);\n'
|
|
|
4845a0 |
' g_assert (prop_id != 0 && prop_id - 1 < %d);\n'
|
|
|
4845a0 |
' g_mutex_lock (&skeleton->priv->lock);\n'
|
|
|
4845a0 |
' g_object_freeze_notify (object);\n'
|
|
|
4845a0 |
' if (!_g_value_equal (value, &skeleton->priv->properties[prop_id - 1]))\n'
|
|
|
4845a0 |
' {\n'
|
|
|
4845a0 |
' if (g_dbus_interface_skeleton_get_connection (G_DBUS_INTERFACE_SKELETON (skeleton)) != NULL)\n'
|
|
|
4845a0 |
- ' _%s_schedule_emit_changed (skeleton, _%s_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);\n'
|
|
|
4845a0 |
+ ' _%s_schedule_emit_changed (skeleton, (const _ExtendedGDBusPropertyInfo *) _%s_property_info_pointers[prop_id - 1], prop_id, &skeleton->priv->properties[prop_id - 1]);\n'
|
|
|
4845a0 |
' g_value_copy (value, &skeleton->priv->properties[prop_id - 1]);\n'
|
|
|
4845a0 |
' g_object_notify_by_pspec (object, pspec);\n'
|
|
|
4845a0 |
' }\n'
|
|
|
4845a0 |
' g_mutex_unlock (&skeleton->priv->lock);\n'
|
|
|
4845a0 |
' g_object_thaw_notify (object);\n'
|
|
|
4845a0 |
%(i.camel_name, i.ns_upper, i.name_upper, len(i.properties), i.name_lower, i.name_lower))
|
|
|
4845a0 |
self.outfile.write('}\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
|
|
|
4845a0 |
self.outfile.write('static void\n'
|
|
|
4845a0 |
'%s_skeleton_init (%sSkeleton *skeleton)\n'
|
|
|
4845a0 |
'{\n'
|
|
|
4845a0 |
'#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38\n'
|
|
|
4845a0 |
' skeleton->priv = %s_skeleton_get_instance_private (skeleton);\n'
|
|
|
4845a0 |
'#else\n'
|
|
|
4845a0 |
' skeleton->priv = G_TYPE_INSTANCE_GET_PRIVATE (skeleton, %sTYPE_%s_SKELETON, %sSkeletonPrivate);\n'
|
|
|
4845a0 |
'#endif\n\n'
|
|
|
4845a0 |
%(i.name_lower, i.camel_name,
|
|
|
4845a0 |
i.name_lower,
|
|
|
4845a0 |
i.ns_upper, i.name_upper, i.camel_name))
|
|
|
4845a0 |
self.outfile.write(' g_mutex_init (&skeleton->priv->lock);\n')
|
|
|
4845a0 |
self.outfile.write(' skeleton->priv->context = g_main_context_ref_thread_default ();\n')
|
|
|
4845a0 |
if len(i.properties) > 0:
|
|
|
4845a0 |
self.outfile.write(' skeleton->priv->properties = g_new0 (GValue, %d);\n'%(len(i.properties)))
|
|
|
4845a0 |
n = 0
|
|
|
4845a0 |
for p in i.properties:
|
|
|
4845a0 |
self.outfile.write(' g_value_init (&skeleton->priv->properties[%d], %s);\n'%(n, p.arg.gtype))
|
|
|
4845a0 |
n += 1
|
|
|
4845a0 |
self.outfile.write('}\n'
|
|
|
4845a0 |
'\n')
|
|
|
4845a0 |
--
|
|
|
4845a0 |
2.21.0
|
|
|
4845a0 |
|