summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2012-05-04 12:19:19 +0100
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-05-07 14:14:40 +0100
commited4ed83ec28ff130afbf28c5c4dc8f76614bccc3 (patch)
treec8d6b6ca31499090821e67898fdd81d76c696a14 /tools
parent34752d004ced4ce4ac75e7ab0c601bf444bed864 (diff)
downloadtelepathy-glib-ed4ed83ec28ff130afbf28c5c4dc8f76614bccc3.tar.gz
Add multiple-inclusion guards to generated client-side code
Reviewed-by: Xavier Claessens <xavier.claessens@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=49384
Diffstat (limited to 'tools')
-rw-r--r--tools/glib-client-gen.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py
index c94bd2c31..6b2b97f1d 100644
--- a/tools/glib-client-gen.py
+++ b/tools/glib-client-gen.py
@@ -71,6 +71,8 @@ class Generator(object):
self.deprecation_attribute = opts.get('--deprecation-attribute',
'G_GNUC_DEPRECATED')
+ self.guard = opts.get('--guard', None)
+
def h(self, s):
if isinstance(s, unicode):
s = s.encode('utf-8')
@@ -1171,6 +1173,11 @@ class Generator(object):
def __call__(self):
+ if self.guard is not None:
+ self.h('#ifndef %s' % self.guard)
+ self.h('#define %s' % self.guard)
+ self.h('')
+
self.h('G_BEGIN_DECLS')
self.h('')
@@ -1229,6 +1236,10 @@ class Generator(object):
self.h('G_END_DECLS')
self.h('')
+ if self.guard is not None:
+ self.h('#endif /* defined (%s) */' % self.guard)
+ self.h('')
+
file_set_contents(self.basename + '.h', '\n'.join(self.__header))
file_set_contents(self.basename + '-body.h', '\n'.join(self.__body))
file_set_contents(self.basename + '-gtk-doc.h', '\n'.join(self.__docs))
@@ -1242,7 +1253,7 @@ if __name__ == '__main__':
['group=', 'subclass=', 'subclass-assert=',
'iface-quark-prefix=', 'tp-proxy-api=',
'generate-reentrant=', 'deprecate-reentrant=',
- 'deprecation-attribute='])
+ 'deprecation-attribute=', 'guard='])
opts = {}