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

Frediano Ziglio fziglio at redhat.com
Thu Jul 23 08:54:29 PDT 2015


Parse all members of the containers

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

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()
-- 
2.1.0



More information about the Spice-devel mailing list