Commit fd6ca66c authored by Philip Withnall's avatar Philip Withnall

codegen: Add support for g_autoptr to gdbus-codegen–generated objects

This means that any code generated by gdbus-codegen will now require
GLib 2.44 or newer.

https://bugzilla.gnome.org/show_bug.cgi?id=763379
parent 4569161f
......@@ -450,6 +450,10 @@ class CodeGenerator:
self.h.write('};\n')
self.h.write('\n')
self.h.write('GType %s_proxy_get_type (void) G_GNUC_CONST;\n'%(i.name_lower))
self.h.write('\n')
self.h.write('#if GLIB_CHECK_VERSION(2, 44, 0)\n')
self.h.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sProxy, g_object_unref)\n' % (i.camel_name))
self.h.write('#endif\n')
self.h.write('\n')
if i.deprecated:
......@@ -538,6 +542,10 @@ class CodeGenerator:
self.h.write('\n')
self.h.write('GType %s_skeleton_get_type (void) G_GNUC_CONST;\n'%(i.name_lower))
self.h.write('\n')
self.h.write('#if GLIB_CHECK_VERSION(2, 44, 0)\n')
self.h.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sSkeleton, g_object_unref)\n' % (i.camel_name))
self.h.write('#endif\n')
self.h.write('\n')
if i.deprecated:
self.h.write('G_GNUC_DEPRECATED ')
self.h.write('%s *%s_skeleton_new (void);\n'%(i.camel_name, i.name_lower))
......@@ -601,6 +609,11 @@ class CodeGenerator:
self.h.write('};\n')
self.h.write('\n')
self.h.write('GType %sobject_proxy_get_type (void) G_GNUC_CONST;\n'%(self.ns_lower))
self.h.write('\n')
self.h.write('#if GLIB_CHECK_VERSION(2, 44, 0)\n')
self.h.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sObjectProxy, g_object_unref)\n' % (self.namespace))
self.h.write('#endif\n')
self.h.write('\n')
self.h.write('%sObjectProxy *%sobject_proxy_new (GDBusConnection *connection, const gchar *object_path);\n'%(self.namespace, self.ns_lower))
self.h.write('\n')
self.h.write('#define %sTYPE_OBJECT_SKELETON (%sobject_skeleton_get_type ())\n'%(self.ns_upper, self.ns_lower))
......@@ -627,6 +640,11 @@ class CodeGenerator:
self.h.write('};\n')
self.h.write('\n')
self.h.write('GType %sobject_skeleton_get_type (void) G_GNUC_CONST;\n'%(self.ns_lower))
self.h.write('\n')
self.h.write('#if GLIB_CHECK_VERSION(2, 44, 0)\n')
self.h.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sObjectSkeleton, g_object_unref)\n' % (self.namespace))
self.h.write('#endif\n')
self.h.write('\n')
self.h.write('%sObjectSkeleton *%sobject_skeleton_new (const gchar *object_path);\n'
%(self.namespace, self.ns_lower))
for i in self.ifaces:
......@@ -661,6 +679,10 @@ class CodeGenerator:
self.h.write(' GDBusObjectManagerClientClass parent_class;\n')
self.h.write('};\n')
self.h.write('\n')
self.h.write('#if GLIB_CHECK_VERSION(2, 44, 0)\n')
self.h.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sObjectManagerClient, g_object_unref)\n' % (self.namespace))
self.h.write('#endif\n')
self.h.write('\n')
self.h.write('GType %sobject_manager_client_get_type (void) G_GNUC_CONST;\n'%(self.ns_lower))
self.h.write('\n')
self.h.write('GType %sobject_manager_client_get_proxy_type (GDBusObjectManagerClient *manager, const gchar *object_path, const gchar *interface_name, gpointer user_data);\n'%(self.ns_lower))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment