[PATCH v3 23/51] Write function to write members

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Check members are all of a giver type and call stubs for each type.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 python_modules/dissector.py | 50 +++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 48 insertions(+), 2 deletions(-)

diff --git a/python_modules/dissector.py b/python_modules/dissector.py
index ed3b939..cd653b3 100644
--- a/python_modules/dissector.py
+++ b/python_modules/dissector.py
@@ -166,9 +166,55 @@ class SubDestination(Destination):
         return self.parent_dest.get_ref(self.member + "." + member, writer)
 
 
-def write_member_parser(writer, container, member, dest, scope):
+def write_switch(writer, container, switch, dest, scope):
     pass
 
+def write_array(writer, container, member, array, dest, scope):
+    assert(container and member)
+
+def write_pointer(writer, container, member, t, dest, scope):
+    assert(t.is_pointer())
+
+def write_struct(writer, member, t, index, dest, scope):
+    assert(t.is_struct())
+
+def write_member_primitive(writer, container, member, t, dest, scope):
+    assert(t.is_primitive())
+
+def write_member(writer, container, member, dest, scope):
+
+    if member.has_attr("virtual"):
+        dest.write_ref(writer, 32, member.name, member.attributes["virtual"][0])
+        return
+
+    writer.comment(member.name)
+    writer.newline()
+
+    if member.is_switch():
+        write_switch(writer, container, member, dest, scope)
+        return
+
+    if member.has_attr('ws_as'):
+        type_name = member.attributes['ws_as'][0]
+        assert(ptypes.type_exists(type_name))
+        t = ptypes.lookup_type(type_name)
+    else:
+        t = member.member_type
+
+    if t.is_pointer():
+        # TODO case not handled
+        if not member.has_attr("nocopy"):
+            write_pointer(writer, container, member, t, dest, scope)
+    elif t.is_primitive():
+        write_member_primitive(writer, container, member, t, dest, scope)
+    elif t.is_array():
+        write_array(writer, container, member, t, dest, scope)
+
+    elif t.is_struct():
+        write_struct(writer, member, t, '-1', dest, scope)
+    else:
+        raise NotImplementedError("TODO can't handle parsing of %s" % t)
+
 def write_container_parser(writer, container, dest):
     if container.has_attr('ws_as'):
         type_name = container.attributes['ws_as'][0]
@@ -179,7 +225,7 @@ def write_container_parser(writer, container, dest):
         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)
+            write_member(writer, container, m, dest, scope)
             if m.has_minor_attr():
                 writer.end_block()
 
-- 
2.1.0

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]