summaryrefslogtreecommitdiffstats
path: root/python_modules/demarshal.py
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2010-06-29 21:42:59 +0200
committerMarc-André Lureau <marcandre.lureau@gmail.com>2012-03-20 15:25:46 +0100
commite42c910b5cb5e6de734064fb57832a6e73e34092 (patch)
tree382bd8140c47a44ac502f9183cd67e893f81e167 /python_modules/demarshal.py
parent140cf2aa795abf20482eb6684f15aef5d187ebca (diff)
downloadspice-protocol-e42c910b5cb5e6de734064fb57832a6e73e34092.tar.gz
spice-protocol-e42c910b5cb5e6de734064fb57832a6e73e34092.tar.xz
spice-protocol-e42c910b5cb5e6de734064fb57832a6e73e34092.zip
Store SpicePath segment count rather than size
Internally and in the network protocol (for the new version) we now store the actual number of segments rather than the size of the full segments array in bytes. This change consists of multiple changes to handle this: * Make the qxl parser calculate num_segments * Make the canvas stroke code handle the new SpicePath layout. * Fix up is_equal_path in red_worker.c for the new layout * replace multiple calls to spice_marshall_PathSegment with a single spice_marshall_Path call * Make the byte_size() array size handling do the conversion from network size to number of elements when marshalling/demarshalling. * Update the current spice protocol to send the segment count rather than the size * Update the old spice protocol to use the new byte_size functionallity to calculate the size sent and the number of elements recieved
Diffstat (limited to 'python_modules/demarshal.py')
-rw-r--r--python_modules/demarshal.py16
1 files changed, 14 insertions, 2 deletions
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py
index faaf862..48b4e73 100644
--- a/python_modules/demarshal.py
+++ b/python_modules/demarshal.py
@@ -604,7 +604,7 @@ def read_array_len(writer, prefix, array, dest, scope, handles_bytes = False):
elif array.is_bytes_length():
if not handles_bytes:
raise NotImplementedError("handling of bytes() not supported here yet")
- writer.assign(nelements, dest.get_ref(array.size[1]))
+ writer.assign(nelements, array.size[1])
else:
raise NotImplementedError("TODO array size type not handled yet")
return nelements
@@ -714,10 +714,15 @@ def write_array_parser(writer, nelements, array, dest, scope):
writer.increment("end", nelements)
else:
if is_byte_size:
+ real_nelements = nelements[:-len("nbytes")] + "nelements"
scope.variable_def("uint8_t *", "array_end")
+ scope.variable_def("uint32_t", real_nelements)
writer.assign("array_end", "end + %s" % nelements)
+ writer.assign(real_nelements, 0)
with writer.index(no_block = is_byte_size) as index:
with writer.while_loop("end < array_end") if is_byte_size else writer.for_loop(index, nelements) as array_scope:
+ if is_byte_size:
+ writer.increment(real_nelements, 1)
if element_type.is_primitive():
writer.statement("*(%s *)end = consume_%s(&in)" % (element_type.c_type(), element_type.primitive_type()))
writer.increment("end", element_type.sizeof())
@@ -725,6 +730,8 @@ def write_array_parser(writer, nelements, array, dest, scope):
dest2 = dest.child_at_end(writer, element_type)
dest2.reuse_scope = array_scope
write_container_parser(writer, element_type, dest2)
+ if is_byte_size:
+ writer.assign(dest.get_ref(array.size[2]), real_nelements)
def write_parse_pointer(writer, t, at_end, as_c_ptr, dest, member_name, scope):
target_type = t.target_type
@@ -766,7 +773,12 @@ def write_member_parser(writer, container, member, dest, scope):
writer.statement("*(%s *)end = consume_%s(&in)" % (t.c_type(), t.primitive_type()))
writer.increment("end", t.sizeof())
else:
- writer.assign(dest.get_ref(member.name), "consume_%s(&in)" % (t.primitive_type()))
+ if member.has_attr("bytes_count"):
+ scope.variable_def("uint32_t", member.name);
+ dest_var = member.name
+ else:
+ dest_var = dest.get_ref(member.name)
+ writer.assign(dest_var, "consume_%s(&in)" % (t.primitive_type()))
#TODO validate e.g. flags and enums
elif t.is_array():
nelements = read_array_len(writer, member.name, t, dest, scope, handles_bytes = True)