diff options
author | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-06-07 15:41:06 +0200 |
---|---|---|
committer | Xavier Claessens <xavier.claessens@collabora.co.uk> | 2012-06-26 12:21:11 +0200 |
commit | 9bcf8a2dde664c05d4a4919901012b52ce1c1b72 (patch) | |
tree | 224844bae597d47f28f2688073ffdda896dd69c8 | |
parent | 402734546fddcee4c9226a6574dc4c886376d536 (diff) |
Make sure to not use single includes in generated code
If an extension iface has properties, its header will include
dbus-properties-mixin.h, which is not allowed outside tp-glib itself.
Since the generated header does not expose the mixin, move the include
to .c file, and use the meta header if single includes are not allowed.
-rw-r--r-- | examples/extensions/Makefile.am | 1 | ||||
-rw-r--r-- | telepathy-glib/base-contact-list.c | 1 | ||||
-rw-r--r-- | telepathy-glib/codegen.am | 2 | ||||
-rw-r--r-- | telepathy-glib/presence-mixin.c | 1 | ||||
-rw-r--r-- | tools/glib-ginterface-gen.py | 24 |
5 files changed, 21 insertions, 8 deletions
diff --git a/examples/extensions/Makefile.am b/examples/extensions/Makefile.am index 5f8d2fd64..a916d327f 100644 --- a/examples/extensions/Makefile.am +++ b/examples/extensions/Makefile.am @@ -139,7 +139,6 @@ _gen/svc-connection.c: _gen/connection.xml \ $(AM_V_GEN)$(PYTHON) $(tools_dir)/glib-ginterface-gen.py \ --filename=_gen/svc-connection \ --signal-marshal-prefix=_example_ext \ - --include='<telepathy-glib/telepathy-glib.h>' \ --not-implemented-func='tp_dbus_g_method_return_not_implemented' \ --allow-unstable \ $< Example_Svc_ diff --git a/telepathy-glib/base-contact-list.c b/telepathy-glib/base-contact-list.c index d2d1bfd1e..8af54b5ab 100644 --- a/telepathy-glib/base-contact-list.c +++ b/telepathy-glib/base-contact-list.c @@ -25,6 +25,7 @@ #include <telepathy-glib/contacts-mixin.h> #include <telepathy-glib/dbus.h> +#include <telepathy-glib/dbus-properties-mixin.h> #include <telepathy-glib/handle-repo-dynamic.h> #include <telepathy-glib/handle-repo-static.h> #include <telepathy-glib/interfaces.h> diff --git a/telepathy-glib/codegen.am b/telepathy-glib/codegen.am index 4135d16e4..9f7118f25 100644 --- a/telepathy-glib/codegen.am +++ b/telepathy-glib/codegen.am @@ -250,7 +250,7 @@ _gen/tp-svc-%.c: _gen/tp-spec-%.xml \ $(AM_V_GEN)$(PYTHON) $(tools_dir)/glib-ginterface-gen.py \ --filename=_gen/tp-svc-$* \ --signal-marshal-prefix=_tp \ - --include='<telepathy-glib/dbus.h>' \ + --allow-single-include \ --not-implemented-func='tp_dbus_g_method_return_not_implemented' \ $< Tp_Svc_ diff --git a/telepathy-glib/presence-mixin.c b/telepathy-glib/presence-mixin.c index 1408e9879..95d8d526f 100644 --- a/telepathy-glib/presence-mixin.c +++ b/telepathy-glib/presence-mixin.c @@ -253,6 +253,7 @@ #include <string.h> #include <telepathy-glib/base-connection.h> +#include <telepathy-glib/dbus-properties-mixin.h> #include <telepathy-glib/enums.h> #include <telepathy-glib/errors.h> #include <telepathy-glib/gtypes.h> diff --git a/tools/glib-ginterface-gen.py b/tools/glib-ginterface-gen.py index 87fa6f5db..39d6c021c 100644 --- a/tools/glib-ginterface-gen.py +++ b/tools/glib-ginterface-gen.py @@ -47,7 +47,7 @@ class Generator(object): def __init__(self, dom, prefix, basename, signal_marshal_prefix, headers, end_headers, not_implemented_func, - allow_havoc): + allow_havoc, allow_single_include): self.dom = dom self.__header = [] self.__body = [] @@ -83,6 +83,7 @@ class Generator(object): self.end_headers = end_headers self.not_implemented_func = not_implemented_func self.allow_havoc = allow_havoc + self.allow_single_include = allow_single_include def h(self, s): if isinstance(s, unicode): @@ -741,15 +742,21 @@ class Generator(object): self.h('#include <glib-object.h>') self.h('#include <dbus/dbus-glib.h>') - if self.have_properties(nodes): - self.h('#include <telepathy-glib/dbus-properties-mixin.h>') - self.h('') self.h('G_BEGIN_DECLS') self.h('') self.b('#include "%s.h"' % self.basename) self.b('') + + if self.allow_single_include: + self.b('#include <telepathy-glib/dbus.h>') + if self.have_properties(nodes): + self.b('#include <telepathy-glib/dbus-properties-mixin.h>') + else: + self.b('#include <telepathy-glib/telepathy-glib.h>') + self.b('') + for header in self.headers: self.b('#include %s' % header) self.b('') @@ -802,7 +809,8 @@ if __name__ == '__main__': ['filename=', 'signal-marshal-prefix=', 'include=', 'include-end=', 'allow-unstable', - 'not-implemented-func=']) + 'not-implemented-func=', + "allow-single-include"]) try: prefix = argv[1] @@ -815,6 +823,7 @@ if __name__ == '__main__': end_headers = [] not_implemented_func = '' allow_havoc = False + allow_single_include = False for option, value in options: if option == '--filename': @@ -833,6 +842,8 @@ if __name__ == '__main__': not_implemented_func = value elif option == '--allow-unstable': allow_havoc = True + elif option == '--allow-single-include': + allow_single_include = True try: dom = xml.dom.minidom.parse(argv[0]) @@ -840,4 +851,5 @@ if __name__ == '__main__': cmdline_error() Generator(dom, prefix, basename, signal_marshal_prefix, headers, - end_headers, not_implemented_func, allow_havoc)() + end_headers, not_implemented_func, allow_havoc, + allow_single_include)() |