[Telepathy-commits] [telepathy-glib/master] Only include properties mixin if required

Ross Burton ross at linux.intel.com
Wed Nov 19 07:20:25 PST 2008


Check if there are any properties in the nodes, if there are none then don't
include the properties mixin header because it won't be used.  This means if
properties are not used the GInterface is standalone.
---
 tools/glib-ginterface-gen.py |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/glib-ginterface-gen.py b/tools/glib-ginterface-gen.py
index 1b17155..fd7ad41 100644
--- a/tools/glib-ginterface-gen.py
+++ b/tools/glib-ginterface-gen.py
@@ -619,10 +619,21 @@ class Generator(object):
 
         return in_base_init
 
+    def have_properties(self, nodes):
+        for node in nodes:
+            interface =  node.getElementsByTagName('interface')[0]
+            if interface.getElementsByTagName('property'):
+                return True
+        return False
+
     def __call__(self):
+        nodes = self.dom.getElementsByTagName('node')
+        nodes.sort(cmp_by_name)
+
         self.h('#include <glib-object.h>')
         self.h('#include <dbus/dbus-glib.h>')
-        self.h('#include <telepathy-glib/dbus-properties-mixin.h>')
+        if (self.have_properties (nodes)):
+            self.h('#include <telepathy-glib/dbus-properties-mixin.h>')
         self.h('')
         self.h('G_BEGIN_DECLS')
         self.h('')
@@ -633,9 +644,6 @@ class Generator(object):
             self.b('#include %s' % header)
         self.b('')
 
-        nodes = self.dom.getElementsByTagName('node')
-        nodes.sort(cmp_by_name)
-
         for node in nodes:
             self.do_node(node)
 
-- 
1.5.6.5




More information about the Telepathy-commits mailing list