mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-26 15:36:14 +01:00
Merge branch 'gdbus-codegen-exporting' into 'master'
Make symbols generated by gdbus-codegen exportable on Visual Studio-style builds See merge request GNOME/glib!1452
This commit is contained in:
commit
caec84ae1e
@ -41,6 +41,9 @@
|
||||
<arg><option>--body</option></arg>
|
||||
<arg><option>--interface-info-header</option></arg>
|
||||
<arg><option>--interface-info-body</option></arg>
|
||||
<arg><option>--symbol-decorator</option> <replaceable>DECORATOR</replaceable></arg>
|
||||
<arg><option>--symbol-decorator-header</option> <replaceable>HEADER</replaceable></arg>
|
||||
<arg><option>--symbol-decorator-define</option> <replaceable>DEFINE</replaceable></arg>
|
||||
<arg><option>--output</option> <replaceable>OUTFILE</replaceable></arg>
|
||||
<group choice="plain" rep="repeat">
|
||||
<arg>
|
||||
@ -372,6 +375,52 @@
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--symbol-decorator</option> <replaceable>DECORATOR</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If a <literal>DECORATOR</literal> is passed in with this option, all the
|
||||
generated function prototypes in the generated header will be marked with
|
||||
<literal>DECORATOR</literal>. This can be used, for instance, to export
|
||||
symbols from code generated with <command>gdbus-codegen</command>.
|
||||
This option is added in GLib-2.66
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--symbol-decorator-header</option> <replaceable>HEADER</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If a <literal>HEADER</literal> is passed in with this option, the
|
||||
generated header will put a <literal>#include HEADER</literal> before the rest of the
|
||||
items, except for the inclusion guards or <literal>#pragma once</literal>
|
||||
(if <option>--pragma-once</option> is used). This is used if using another header file is
|
||||
needed for the decorator passed in via <option>--symbol-decorator</option> to be defined.
|
||||
This option is added in GLib-2.66.
|
||||
</para>
|
||||
<para>
|
||||
This option can only be used if <option>--symbol-decorator</option> is used.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--symbol-decorator-define</option> <replaceable>DEFINE</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If a <literal>DEFINE</literal> is passed in with this option, the
|
||||
generated source will add a <literal>#define DEFINE</literal> before the rest of the
|
||||
items. This is used if a particular macro is needed to ensure the decorator
|
||||
passed in via <option>--symbol-decorator</option> uses the correct definition when the
|
||||
generated source is being compiled. This option is added in GLib-2.66.
|
||||
</para>
|
||||
<para>
|
||||
This option can only be used if <option>--symbol-decorator</option> is used.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--output</option> <replaceable>OUTFILE</replaceable></term>
|
||||
<listitem>
|
||||
|
@ -62,7 +62,8 @@ def generate_header_guard(header_name):
|
||||
class HeaderCodeGenerator:
|
||||
def __init__(self, ifaces, namespace, generate_objmanager,
|
||||
generate_autocleanup, header_name, input_files_basenames,
|
||||
use_pragma, glib_min_required, outfile):
|
||||
use_pragma, glib_min_required,
|
||||
symbol_decorator, symbol_decorator_header, outfile):
|
||||
self.ifaces = ifaces
|
||||
self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace)
|
||||
self.generate_objmanager = generate_objmanager
|
||||
@ -71,6 +72,8 @@ class HeaderCodeGenerator:
|
||||
self.input_files_basenames = input_files_basenames
|
||||
self.use_pragma = use_pragma
|
||||
self.glib_min_required = glib_min_required
|
||||
self.symbol_decorator = symbol_decorator
|
||||
self.symbol_decorator_header = symbol_decorator_header
|
||||
self.outfile = outfile
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
@ -86,6 +89,10 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('#ifndef __{!s}__\n'.format(self.header_guard))
|
||||
self.outfile.write('#define __{!s}__\n'.format(self.header_guard))
|
||||
|
||||
if self.symbol_decorator_header is not None:
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#include "%s"\n' % self.symbol_decorator_header)
|
||||
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#include <gio/gio.h>\n')
|
||||
self.outfile.write('\n')
|
||||
@ -171,9 +178,15 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%s, g_object_unref)\n' % (i.camel_name))
|
||||
self.outfile.write('#endif\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GType %s_get_type (void) G_GNUC_CONST;\n'%(i.name_lower))
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GDBusInterfaceInfo *%s_interface_info (void);\n'%(i.name_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('guint %s_override_properties (GObjectClass *klass, guint property_id_begin);\n'%(i.name_lower))
|
||||
self.outfile.write('\n')
|
||||
|
||||
@ -182,6 +195,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('/* D-Bus method call completion functions: */\n')
|
||||
for m in i.methods:
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if m.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('void %s_complete_%s (\n'
|
||||
@ -200,6 +215,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('/* D-Bus signal emissions functions: */\n')
|
||||
for s in i.signals:
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if s.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('void %s_emit_%s (\n'
|
||||
@ -216,6 +233,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('/* D-Bus method calls: */\n')
|
||||
for m in i.methods:
|
||||
# async begin
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if m.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('void %s_call_%s (\n'
|
||||
@ -233,6 +252,8 @@ class HeaderCodeGenerator:
|
||||
' gpointer user_data);\n')
|
||||
self.outfile.write('\n')
|
||||
# async finish
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if m.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('gboolean %s_call_%s_finish (\n'
|
||||
@ -246,6 +267,8 @@ class HeaderCodeGenerator:
|
||||
' GError **error);\n')
|
||||
self.outfile.write('\n')
|
||||
# sync
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if m.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('gboolean %s_call_%s_sync (\n'
|
||||
@ -273,14 +296,20 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('/* D-Bus property accessors: */\n')
|
||||
for p in i.properties:
|
||||
# getter
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if p.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s%s_get_%s (%s *object);\n'%(p.arg.ctype_in, i.name_lower, p.name_lower, i.camel_name))
|
||||
if p.arg.free_func != None:
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if p.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s%s_dup_%s (%s *object);\n'%(p.arg.ctype_in_dup, i.name_lower, p.name_lower, i.camel_name))
|
||||
# setter
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if p.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('void %s_set_%s (%s *object, %svalue);\n'%(i.name_lower, p.name_lower, i.camel_name, p.arg.ctype_in, ))
|
||||
@ -313,6 +342,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write(' GDBusProxyClass parent_class;\n')
|
||||
self.outfile.write('};\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GType %s_proxy_get_type (void) G_GNUC_CONST;\n'%(i.name_lower))
|
||||
self.outfile.write('\n')
|
||||
if self.generate_autocleanup in ('objects', 'all'):
|
||||
@ -320,6 +351,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sProxy, g_object_unref)\n' % (i.camel_name))
|
||||
self.outfile.write('#endif\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('void %s_proxy_new (\n'
|
||||
@ -331,12 +364,16 @@ class HeaderCodeGenerator:
|
||||
' GAsyncReadyCallback callback,\n'
|
||||
' gpointer user_data);\n'
|
||||
%(i.name_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s *%s_proxy_new_finish (\n'
|
||||
' GAsyncResult *res,\n'
|
||||
' GError **error);\n'
|
||||
%(i.camel_name, i.name_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s *%s_proxy_new_sync (\n'
|
||||
@ -348,6 +385,8 @@ class HeaderCodeGenerator:
|
||||
' GError **error);\n'
|
||||
%(i.camel_name, i.name_lower))
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('void %s_proxy_new_for_bus (\n'
|
||||
@ -359,12 +398,16 @@ class HeaderCodeGenerator:
|
||||
' GAsyncReadyCallback callback,\n'
|
||||
' gpointer user_data);\n'
|
||||
%(i.name_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s *%s_proxy_new_for_bus_finish (\n'
|
||||
' GAsyncResult *res,\n'
|
||||
' GError **error);\n'
|
||||
%(i.camel_name, i.name_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s *%s_proxy_new_for_bus_sync (\n'
|
||||
@ -404,6 +447,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write(' GDBusInterfaceSkeletonClass parent_class;\n')
|
||||
self.outfile.write('};\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GType %s_skeleton_get_type (void) G_GNUC_CONST;\n'%(i.name_lower))
|
||||
self.outfile.write('\n')
|
||||
if self.generate_autocleanup in ('objects', 'all'):
|
||||
@ -411,6 +456,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sSkeleton, g_object_unref)\n' % (i.camel_name))
|
||||
self.outfile.write('#endif\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s *%s_skeleton_new (void);\n'%(i.camel_name, i.name_lower))
|
||||
@ -436,6 +483,8 @@ class HeaderCodeGenerator:
|
||||
' GTypeInterface parent_iface;\n'
|
||||
'};\n'
|
||||
'\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GType %sobject_get_type (void) G_GNUC_CONST;\n'
|
||||
'\n'
|
||||
%(self.ns_lower))
|
||||
@ -445,11 +494,15 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('#endif\n')
|
||||
self.outfile.write('\n')
|
||||
for i in self.ifaces:
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s *%sobject_get_%s (%sObject *object);\n'
|
||||
%(i.camel_name, self.ns_lower, i.name_upper.lower(), self.namespace))
|
||||
for i in self.ifaces:
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('%s *%sobject_peek_%s (%sObject *object);\n'
|
||||
@ -478,6 +531,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write(' GDBusObjectProxyClass parent_class;\n')
|
||||
self.outfile.write('};\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GType %sobject_proxy_get_type (void) G_GNUC_CONST;\n'%(self.ns_lower))
|
||||
self.outfile.write('\n')
|
||||
if self.generate_autocleanup in ('objects', 'all'):
|
||||
@ -485,6 +540,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sObjectProxy, g_object_unref)\n' % (self.namespace))
|
||||
self.outfile.write('#endif\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('%sObjectProxy *%sobject_proxy_new (GDBusConnection *connection, const gchar *object_path);\n'%(self.namespace, self.ns_lower))
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#define %sTYPE_OBJECT_SKELETON (%sobject_skeleton_get_type ())\n'%(self.ns_upper, self.ns_lower))
|
||||
@ -510,6 +567,8 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write(' GDBusObjectSkeletonClass parent_class;\n')
|
||||
self.outfile.write('};\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GType %sobject_skeleton_get_type (void) G_GNUC_CONST;\n'%(self.ns_lower))
|
||||
self.outfile.write('\n')
|
||||
if self.generate_autocleanup in ('objects', 'all'):
|
||||
@ -517,9 +576,13 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sObjectSkeleton, g_object_unref)\n' % (self.namespace))
|
||||
self.outfile.write('#endif\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('%sObjectSkeleton *%sobject_skeleton_new (const gchar *object_path);\n'
|
||||
%(self.namespace, self.ns_lower))
|
||||
for i in self.ifaces:
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
if i.deprecated:
|
||||
self.outfile.write('G_GNUC_DEPRECATED ')
|
||||
self.outfile.write('void %sobject_skeleton_set_%s (%sObjectSkeleton *object, %s *interface_);\n'
|
||||
@ -556,10 +619,16 @@ class HeaderCodeGenerator:
|
||||
self.outfile.write('G_DEFINE_AUTOPTR_CLEANUP_FUNC (%sObjectManagerClient, g_object_unref)\n' % (self.namespace))
|
||||
self.outfile.write('#endif\n')
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GType %sobject_manager_client_get_type (void) G_GNUC_CONST;\n'%(self.ns_lower))
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.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))
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('void %sobject_manager_client_new (\n'
|
||||
' GDBusConnection *connection,\n'
|
||||
' GDBusObjectManagerClientFlags flags,\n'
|
||||
@ -569,10 +638,14 @@ class HeaderCodeGenerator:
|
||||
' GAsyncReadyCallback callback,\n'
|
||||
' gpointer user_data);\n'
|
||||
%(self.ns_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GDBusObjectManager *%sobject_manager_client_new_finish (\n'
|
||||
' GAsyncResult *res,\n'
|
||||
' GError **error);\n'
|
||||
%(self.ns_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GDBusObjectManager *%sobject_manager_client_new_sync (\n'
|
||||
' GDBusConnection *connection,\n'
|
||||
' GDBusObjectManagerClientFlags flags,\n'
|
||||
@ -582,6 +655,8 @@ class HeaderCodeGenerator:
|
||||
' GError **error);\n'
|
||||
%(self.ns_lower))
|
||||
self.outfile.write('\n')
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('void %sobject_manager_client_new_for_bus (\n'
|
||||
' GBusType bus_type,\n'
|
||||
' GDBusObjectManagerClientFlags flags,\n'
|
||||
@ -591,10 +666,14 @@ class HeaderCodeGenerator:
|
||||
' GAsyncReadyCallback callback,\n'
|
||||
' gpointer user_data);\n'
|
||||
%(self.ns_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GDBusObjectManager *%sobject_manager_client_new_for_bus_finish (\n'
|
||||
' GAsyncResult *res,\n'
|
||||
' GError **error);\n'
|
||||
%(self.ns_lower))
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write('%s\n' % self.symbol_decorator)
|
||||
self.outfile.write('GDBusObjectManager *%sobject_manager_client_new_for_bus_sync (\n'
|
||||
' GBusType bus_type,\n'
|
||||
' GDBusObjectManagerClientFlags flags,\n'
|
||||
@ -625,13 +704,18 @@ class HeaderCodeGenerator:
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
|
||||
class InterfaceInfoHeaderCodeGenerator:
|
||||
def __init__(self, ifaces, namespace, header_name, input_files_basenames, use_pragma, glib_min_required, outfile):
|
||||
def __init__(self, ifaces, namespace, header_name, input_files_basenames, use_pragma,
|
||||
glib_min_required, symbol_decorator, symbol_decorator_header, outfile):
|
||||
self.ifaces = ifaces
|
||||
self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace)
|
||||
self.header_guard = generate_header_guard(header_name)
|
||||
self.input_files_basenames = input_files_basenames
|
||||
self.use_pragma = use_pragma
|
||||
self.glib_min_required = glib_min_required
|
||||
self.symbol_decorator = symbol_decorator
|
||||
if self.symbol_decorator is None:
|
||||
self.symbol_decorator = ''
|
||||
self.symbol_decorator_header = symbol_decorator_header
|
||||
self.outfile = outfile
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
@ -647,6 +731,10 @@ class InterfaceInfoHeaderCodeGenerator:
|
||||
self.outfile.write('#ifndef __{!s}__\n'.format(self.header_guard))
|
||||
self.outfile.write('#define __{!s}__\n'.format(self.header_guard))
|
||||
|
||||
if self.symbol_decorator_header is not None:
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#include "%s"\n' % self.symbol_decorator_header)
|
||||
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#include <gio/gio.h>\n')
|
||||
self.outfile.write('\n')
|
||||
@ -657,7 +745,8 @@ class InterfaceInfoHeaderCodeGenerator:
|
||||
|
||||
def declare_infos(self):
|
||||
for i in self.ifaces:
|
||||
self.outfile.write('extern const GDBusInterfaceInfo %s_interface;\n' % i.name_lower)
|
||||
self.outfile.write('extern %s const GDBusInterfaceInfo %s_interface;\n' %
|
||||
(self.symbol_decorator, i.name_lower))
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -679,12 +768,14 @@ class InterfaceInfoHeaderCodeGenerator:
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
|
||||
class InterfaceInfoBodyCodeGenerator:
|
||||
def __init__(self, ifaces, namespace, header_name, input_files_basenames, glib_min_required, outfile):
|
||||
def __init__(self, ifaces, namespace, header_name, input_files_basenames,
|
||||
glib_min_required, symbol_decoration_define, outfile):
|
||||
self.ifaces = ifaces
|
||||
self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace)
|
||||
self.header_name = header_name
|
||||
self.input_files_basenames = input_files_basenames
|
||||
self.glib_min_required = glib_min_required
|
||||
self.symbol_decoration_define = symbol_decoration_define
|
||||
self.outfile = outfile
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
@ -692,6 +783,11 @@ class InterfaceInfoBodyCodeGenerator:
|
||||
def generate_body_preamble(self):
|
||||
basenames = ', '.join(self.input_files_basenames)
|
||||
self.outfile.write(LICENSE_STR.format(config.VERSION, basenames))
|
||||
|
||||
if self.symbol_decoration_define is not None:
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#define %s\n' % self.symbol_decoration_define)
|
||||
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#ifdef HAVE_CONFIG_H\n'
|
||||
'# include "config.h"\n'
|
||||
@ -912,7 +1008,8 @@ class InterfaceInfoBodyCodeGenerator:
|
||||
|
||||
class CodeGenerator:
|
||||
def __init__(self, ifaces, namespace, generate_objmanager, header_name,
|
||||
input_files_basenames, docbook_gen, glib_min_required, outfile):
|
||||
input_files_basenames, docbook_gen, glib_min_required,
|
||||
symbol_decoration_define, outfile):
|
||||
self.ifaces = ifaces
|
||||
self.namespace, self.ns_upper, self.ns_lower = generate_namespace(namespace)
|
||||
self.generate_objmanager = generate_objmanager
|
||||
@ -920,6 +1017,7 @@ class CodeGenerator:
|
||||
self.input_files_basenames = input_files_basenames
|
||||
self.docbook_gen = docbook_gen
|
||||
self.glib_min_required = glib_min_required
|
||||
self.symbol_decoration_define = symbol_decoration_define
|
||||
self.outfile = outfile
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
@ -927,6 +1025,9 @@ class CodeGenerator:
|
||||
def generate_body_preamble(self):
|
||||
basenames = ', '.join(self.input_files_basenames)
|
||||
self.outfile.write(LICENSE_STR.format(config.VERSION, basenames))
|
||||
if self.symbol_decoration_define is not None:
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#define %s\n' % self.symbol_decoration_define)
|
||||
self.outfile.write('\n')
|
||||
self.outfile.write('#ifdef HAVE_CONFIG_H\n'
|
||||
'# include "config.h"\n'
|
||||
|
@ -171,6 +171,12 @@ def codegen_main():
|
||||
help='Minimum version of GLib to be supported by the outputted code (default: 2.30)')
|
||||
arg_parser.add_argument('--glib-max-allowed', metavar='VERSION',
|
||||
help='Maximum version of GLib to be used by the outputted code (default: current GLib version)')
|
||||
arg_parser.add_argument('--symbol-decorator',
|
||||
help='Macro used to decorate a symbol in the outputted header, possibly to export symbols')
|
||||
arg_parser.add_argument('--symbol-decorator-header',
|
||||
help='Additional header required for decorator specified by --symbol-decorator')
|
||||
arg_parser.add_argument('--symbol-decorator-define',
|
||||
help='Additional define required for decorator specified by --symbol-decorator')
|
||||
|
||||
group = arg_parser.add_mutually_exclusive_group()
|
||||
group.add_argument('--generate-c-code', metavar='OUTFILES',
|
||||
@ -271,6 +277,11 @@ def codegen_main():
|
||||
else:
|
||||
glib_max_allowed = (config.MAJOR_VERSION, config.MINOR_VERSION)
|
||||
|
||||
# Only allow --symbol-decorator-define and --symbol-decorator-header if --symbol-decorator is used
|
||||
if args.symbol_decorator is None:
|
||||
if args.symbol_decorator_header or args.symbol_decorator_define:
|
||||
print_error('--symbol-decorator-define and --symbol-decorator-header must be used with --symbol-decorator')
|
||||
|
||||
# Round --glib-max-allowed up to the next stable release.
|
||||
glib_max_allowed = \
|
||||
(glib_max_allowed[0], glib_max_allowed[1] + (glib_max_allowed[1] % 2))
|
||||
@ -310,6 +321,8 @@ def codegen_main():
|
||||
input_files_basenames,
|
||||
args.pragma_once,
|
||||
glib_min_required,
|
||||
args.symbol_decorator,
|
||||
args.symbol_decorator_header,
|
||||
outfile)
|
||||
gen.generate()
|
||||
|
||||
@ -322,6 +335,7 @@ def codegen_main():
|
||||
input_files_basenames,
|
||||
docbook_gen,
|
||||
glib_min_required,
|
||||
args.symbol_decorator_define,
|
||||
outfile)
|
||||
gen.generate()
|
||||
|
||||
@ -333,6 +347,8 @@ def codegen_main():
|
||||
input_files_basenames,
|
||||
args.pragma_once,
|
||||
glib_min_required,
|
||||
args.symbol_decorator,
|
||||
args.symbol_decorator_header,
|
||||
outfile)
|
||||
gen.generate()
|
||||
|
||||
@ -343,6 +359,7 @@ def codegen_main():
|
||||
header_name,
|
||||
input_files_basenames,
|
||||
glib_min_required,
|
||||
args.symbol_decorator_define,
|
||||
outfile)
|
||||
gen.generate()
|
||||
|
||||
|
@ -13,6 +13,8 @@ gdbus_example_objectmanager_generated = custom_target('objectmanager-gen',
|
||||
'--output-directory', '@OUTDIR@',
|
||||
'--generate-c-code', 'objectmanager-gen',
|
||||
'--generate-docbook', 'objectmanager-gen',
|
||||
'--symbol-decorator', '_GLIB_EXTERN',
|
||||
'--symbol-decorator-define', 'HAVE_CONFIG_H',
|
||||
'@INPUT@'])
|
||||
|
||||
libgdbus_example_objectmanager = library('gdbus-example-objectmanager',
|
||||
|
Loading…
Reference in New Issue
Block a user