[PATCH 25/33] Handle array

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

 



If just data increment the pointer if not handle the items with
a loop.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 python_modules/dissector.py | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/python_modules/dissector.py b/python_modules/dissector.py
index c9331cd..6e9f0d6 100644
--- a/python_modules/dissector.py
+++ b/python_modules/dissector.py
@@ -227,6 +227,20 @@ def write_switch(writer, container, switch, dest, scope):
 def write_array(writer, container, member, nelements, array, dest, scope):
     assert(container and member)
 
+    element_type = array.element_type
+
+    if element_type == ptypes.uint8 or element_type == ptypes.int8:
+        writer.increment("offset", nelements)
+        return
+
+    with writer.index() as index:
+        with writer.for_loop(index, nelements) as array_scope:
+            if element_type.is_primitive():
+                write_member_primitive(writer, container, member, element_type, dest, scope)
+            else:
+                assert(element_type.is_struct())
+                write_struct(writer, member, element_type, index, dest, scope)
+
 def write_pointer(writer, container, member, t, dest, scope):
     assert(t.is_pointer())
 
@@ -245,7 +259,6 @@ def write_struct_func(writer, t, func_name, index):
     writer.statement('return offset')
     writer.end_block()
 
-
 def write_struct(writer, member, t, index, dest, scope):
     assert(t.is_struct())
 
-- 
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]