From 87e6db8deb96565cf4336c187e0dcec8b014cae2 Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Tue, 29 Oct 2013 14:55:27 +0800 Subject: [PATCH] codegen.py: Rearrange GLib Version Check ...so that the generated code will build on all platforms, as compilers like Visual C++ does not like #ifdef checks during a definition/use of a macro. https://bugzilla.gnome.org/show_bug.cgi?id=711049 --- gio/gdbus-2.0/codegen/codegen.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gio/gdbus-2.0/codegen/codegen.py b/gio/gdbus-2.0/codegen/codegen.py index 1789cb33a..82e57872b 100644 --- a/gio/gdbus-2.0/codegen/codegen.py +++ b/gio/gdbus-2.0/codegen/codegen.py @@ -1569,11 +1569,14 @@ class CodeGenerator: self.c.write('static void %s_proxy_iface_init (%sIface *iface);\n' '\n'%(i.name_lower, i.camel_name)) - self.c.write('G_DEFINE_TYPE_WITH_CODE (%sProxy, %s_proxy, G_TYPE_DBUS_PROXY,\n'%(i.camel_name, i.name_lower)) self.c.write('#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38\n') + self.c.write('G_DEFINE_TYPE_WITH_CODE (%sProxy, %s_proxy, G_TYPE_DBUS_PROXY,\n'%(i.camel_name, i.name_lower)) self.c.write(' G_ADD_PRIVATE (%sProxy)\n'%(i.camel_name)) - self.c.write('#endif\n') self.c.write(' G_IMPLEMENT_INTERFACE (%sTYPE_%s, %s_proxy_iface_init));\n\n'%(i.ns_upper, i.name_upper, i.name_lower)) + self.c.write('#else\n') + self.c.write('G_DEFINE_TYPE_WITH_CODE (%sProxy, %s_proxy, G_TYPE_DBUS_PROXY,\n'%(i.camel_name, i.name_lower)) + self.c.write(' G_IMPLEMENT_INTERFACE (%sTYPE_%s, %s_proxy_iface_init));\n\n'%(i.ns_upper, i.name_upper, i.name_lower)) + self.c.write('#endif\n') # finalize self.c.write('static void\n' @@ -2347,11 +2350,14 @@ class CodeGenerator: self.c.write('static void %s_skeleton_iface_init (%sIface *iface);\n' %(i.name_lower, i.camel_name)) - self.c.write('G_DEFINE_TYPE_WITH_CODE (%sSkeleton, %s_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,\n'%(i.camel_name, i.name_lower)) self.c.write('#if GLIB_VERSION_MAX_ALLOWED >= GLIB_VERSION_2_38\n') + self.c.write('G_DEFINE_TYPE_WITH_CODE (%sSkeleton, %s_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,\n'%(i.camel_name, i.name_lower)) self.c.write(' G_ADD_PRIVATE (%sSkeleton)\n'%(i.camel_name)) - self.c.write('#endif\n') self.c.write(' G_IMPLEMENT_INTERFACE (%sTYPE_%s, %s_skeleton_iface_init));\n\n'%(i.ns_upper, i.name_upper, i.name_lower)) + self.c.write('#else\n') + self.c.write('G_DEFINE_TYPE_WITH_CODE (%sSkeleton, %s_skeleton, G_TYPE_DBUS_INTERFACE_SKELETON,\n'%(i.camel_name, i.name_lower)) + self.c.write(' G_IMPLEMENT_INTERFACE (%sTYPE_%s, %s_skeleton_iface_init));\n\n'%(i.ns_upper, i.name_upper, i.name_lower)) + self.c.write('#endif\n') # finalize self.c.write('static void\n'