[Spice-devel,v4,12/41] dissector: Parse containers

Submitted by Frediano Ziglio on July 23, 2015, 3:54 p.m.

Details

Message ID 1437666898-27863-13-git-send-email-fziglio@redhat.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 23, 2015, 3:54 p.m.
Parse all members of the containers

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 python_modules/dissector.py | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Patch hide | download patch | download mbox

diff --git a/python_modules/dissector.py b/python_modules/dissector.py
index 10da2e7..b6dd203 100644
--- a/python_modules/dissector.py
+++ b/python_modules/dissector.py
@@ -167,6 +167,24 @@  class SubDestination(Destination):
         return self.parent_dest.get_ref(self.member + "." + member, writer)
 
 
+def write_member_parser(writer, container, member, dest, scope):
+    pass
+
+def write_container_parser(writer, container, dest):
+    if container.has_attr('ws_as'):
+        type_name = container.attributes['ws_as'][0]
+        assert(ptypes.type_exists(type_name))
+        container = ptypes.lookup_type(type_name)
+
+    with dest.declare(writer) as scope:
+        for m in container.members:
+            if m.has_minor_attr():
+                writer.begin_block("if (minor >= %s)" % m.get_minor_attr())
+            write_member_parser(writer, container, m, dest, scope)
+            if m.has_minor_attr():
+                writer.end_block()
+
+
 def write_msg_parser(writer, message, server):
     msg_name = message.c_name()
     function_name = "dissect_spice_%s_%s" % ('server' if server else 'client', msg_name)
@@ -184,6 +202,7 @@  def write_msg_parser(writer, message, server):
                                    "GlobalInfo *glb _U_, proto_tree *tree _U_, guint32 offset", True)
 
     dest = RootDestination(parent_scope)
+    write_container_parser(writer, message, dest)
 
     writer.statement("return offset")
     writer.end_block()