[Telepathy-commits] [telepathy-spec/master] Support the Struct type

Davyd Madeley davyd at madeley.id.au
Mon Mar 23 12:29:21 PDT 2009


---
 doc/templates/interface.html |    5 +++--
 tools/specparser.py          |   26 +++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/doc/templates/interface.html b/doc/templates/interface.html
index d82ad54..7fce7ba 100644
--- a/doc/templates/interface.html
+++ b/doc/templates/interface.html
@@ -123,11 +123,12 @@
     <h1>Types</h1>
     #for $type in $interface.types
      <div id="$type.name" class="inset type">
-      <span class="permalink">(<a href="$type.get_url()">Permalink</a>)</span>
+      <span class="permalink">$type.get_type_name() (<a href="$type.get_url()">Permalink</a>)</span>
       <h2>
-       $type.short_name &mdash; $type.dbus_type ($type.get_type_name())
+       $type.short_name &mdash; $type.dbus_type
       </h2>
       $type.get_docstring()
+      $type.get_breakdown()
      </div>
     #end for
    </div>
diff --git a/tools/specparser.py b/tools/specparser.py
index 348ea20..f30813f 100644
--- a/tools/specparser.py
+++ b/tools/specparser.py
@@ -279,6 +279,9 @@ class DBusType (base):
 
         self.dbus_type = dom.getAttribute ('type')
 
+    def get_breakdown (self):
+        return ''
+
     def get_title (self):
         return "%s %s" % (self.get_type_name (), self.name)
 
@@ -294,7 +297,28 @@ class SimpleType (DBusType):
 
 class Mapping (DBusType): pass
 
-class Struct (DBusType): pass
+class Struct (DBusType):
+    class StructMember (DBusType): pass
+    
+    def __init__ (self, parent, namespace, dom):
+        super (Struct, self).__init__ (parent, namespace, dom)
+        
+        self.members = build_list (self, Struct.StructMember, None,
+                        dom.getElementsByTagNameNS (XMLNS_TP, 'member'))
+
+        # rewrite the D-Bus type
+        self.dbus_type = '(%s)' % ''.join (map (lambda m: m.dbus_type, self.members))
+
+    def get_breakdown (self):
+        str = ''
+        str += '<ul>\n'
+        for member in self.members:
+            # attempt to lookup the member.name as a type in the type system
+            str += '<li>%s &mdash; %s</li>\n' % (member.name, member.dbus_type)
+            str += member.get_docstring ()
+        str += '</ul>\n'
+
+        return str
 
 class Enum (DBusType): pass
 
-- 
1.5.6.5




More information about the telepathy-commits mailing list