[telepathy-glib/master] glib-client-gen: mark deprecated D-Bus methods as deprecated

Jonny Lamb jonny.lamb at collabora.co.uk
Sat Nov 28 11:36:31 PST 2009


Don't include the version string from the spec because it just makes
things confusing.

Signed-off-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
---
 tools/glib-client-gen.py |   23 ++++++++++++++++++++++-
 tools/libglibcodegen.py  |    3 ++-
 tools/libtpcodegen.py    |   10 ++++++++++
 3 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/tools/glib-client-gen.py b/tools/glib-client-gen.py
index 6988596..938a6fa 100644
--- a/tools/glib-client-gen.py
+++ b/tools/glib-client-gen.py
@@ -28,7 +28,7 @@ import xml.dom.minidom
 from getopt import gnu_getopt
 
 from libglibcodegen import Signature, type_to_gtype, cmp_by_name, \
-        get_docstring, xml_escape
+        get_docstring, xml_escape, get_deprecated
 
 
 NS_TP = "http://telepathy.freedesktop.org/wiki/DbusSpec#extensions-v0"
@@ -432,6 +432,13 @@ class Generator(object):
         self.b(' * Signature of the callback called when a %s method call'
                % member)
         self.b(' * succeeds or fails.')
+
+        deprecated = method.getElementsByTagName('tp:deprecated')
+        if deprecated:
+            d = deprecated[0]
+            self.b(' *')
+            self.b(' * Deprecated: %s' % xml_escape(get_deprecated(d)))
+
         self.b(' */')
 
         callback_name = '%s_%s_callback_for_%s' % (self.prefix_lc, iface_lc,
@@ -692,6 +699,13 @@ class Generator(object):
         self.b(' *  progress. It is borrowed from the object, and will become')
         self.b(' *  invalid when the callback is called, the call is')
         self.b(' *  cancelled or the #TpProxy becomes invalid.')
+
+        deprecated = method.getElementsByTagName('tp:deprecated')
+        if deprecated:
+            d = deprecated[0]
+            self.b(' *')
+            self.b(' * Deprecated: %s' % xml_escape(get_deprecated(d)))
+
         self.b(' */')
         self.b('TpProxyPendingCall *\n%s_%s_call_%s (%sproxy,'
                % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg))
@@ -942,6 +956,13 @@ class Generator(object):
         self.b(' * %s' % xml_escape(get_docstring(method) or '(Undocumented)'))
         self.b(' *')
         self.b(' * Returns: TRUE on success, FALSE and sets @error on error')
+
+        deprecated = method.getElementsByTagName('tp:deprecated')
+        if deprecated:
+            d = deprecated[0]
+            self.b(' *')
+            self.b(' * Deprecated: %s' % xml_escape(get_deprecated(d)))
+
         self.b(' */')
         self.b('gboolean\n%s_%s_run_%s (%sproxy,'
                % (self.prefix_lc, iface_lc, member_lc, self.proxy_arg))
diff --git a/tools/libglibcodegen.py b/tools/libglibcodegen.py
index 0cf52a8..6a9d214 100644
--- a/tools/libglibcodegen.py
+++ b/tools/libglibcodegen.py
@@ -28,7 +28,8 @@ from libtpcodegen import NS_TP, \
                          get_by_path, \
                          get_descendant_text, \
                          get_docstring, \
-                         xml_escape
+                         xml_escape, \
+                         get_deprecated
 
 def dbus_gutils_wincaps_to_uscore(s):
     """Bug-for-bug compatible Python port of _dbus_gutils_wincaps_to_uscore
diff --git a/tools/libtpcodegen.py b/tools/libtpcodegen.py
index e5114b7..837ff2f 100644
--- a/tools/libtpcodegen.py
+++ b/tools/libtpcodegen.py
@@ -120,6 +120,16 @@ def get_docstring(element):
             docstring = ''
     return docstring
 
+def get_deprecated(element):
+    text = []
+    for x in element.childNodes:
+        if hasattr(x, 'data'):
+            text.append(x.data.replace('\n', ' ').strip())
+        else:
+            # This caters for tp:dbus-ref elements, but little else.
+            if x.childNodes and hasattr(x.childNodes[0], 'data'):
+                text.append(x.childNodes[0].data.replace('\n', ' ').strip())
+    return ' '.join(text)
 
 def get_descendant_text(element_or_elements):
     if not element_or_elements:
-- 
1.5.6.5



More information about the telepathy-commits mailing list