diff options
author | Alexander Larsson <alexl@redhat.com> | 2010-06-23 16:20:33 +0200 |
---|---|---|
committer | Alexander Larsson <alexl@redhat.com> | 2010-06-23 16:33:07 +0200 |
commit | dc8625c7e156a2b1eff16397b4be039ac5da9089 (patch) | |
tree | 8d80846ac35bdd7df83ca76fd2e2f4e4c442d609 /python_modules | |
parent | 929245bacd8e9f1ba170e019f107738e75a599ad (diff) |
Make pointers 32bit in new protocol format
Diffstat (limited to 'python_modules')
-rw-r--r-- | python_modules/demarshal.py | 15 | ||||
-rw-r--r-- | python_modules/marshal.py | 4 | ||||
-rw-r--r-- | python_modules/ptypes.py | 4 |
3 files changed, 11 insertions, 12 deletions
diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py index a0697a9..0138ebe 100644 --- a/python_modules/demarshal.py +++ b/python_modules/demarshal.py @@ -184,7 +184,7 @@ def write_validate_struct_function(writer, struct): def write_validate_pointer_item(writer, container, item, scope, parent_scope, start, want_nw_size, want_mem_size, want_extra_size): if want_nw_size: - writer.assign(item.nw_size(), 8) + writer.assign(item.nw_size(), item.type.get_fixed_nw_size()) if want_mem_size or want_extra_size: target_type = item.type.target_type @@ -636,7 +636,7 @@ def write_switch_parser(writer, container, switch, dest, scope): if t.is_struct(): write_container_parser(writer, t, dest2) elif t.is_pointer(): - write_parse_pointer(writer, t, False, dest2, m.name, not m.has_attr("ptr32"), block) + write_parse_pointer(writer, t, False, dest2, m.name, block) elif t.is_primitive(): writer.assign(dest2.get_ref(m.name), "consume_%s(&in)" % (t.primitive_type())) #TODO validate e.g. flags and enums @@ -724,12 +724,9 @@ def write_array_parser(writer, nelements, array, dest, scope): dest2.reuse_scope = array_scope write_container_parser(writer, element_type, dest2) -def write_parse_pointer(writer, t, at_end, dest, member_name, is_64bit, scope): +def write_parse_pointer(writer, t, at_end, dest, member_name, scope): target_type = t.target_type - if is_64bit: - writer.assign("ptr_info[n_ptr].offset", "consume_uint64(&in)") - else: - writer.assign("ptr_info[n_ptr].offset", "consume_uint32(&in)") + writer.assign("ptr_info[n_ptr].offset", "consume_%s(&in)" % t.primitive_type()) writer.assign("ptr_info[n_ptr].parse", write_parse_ptr_function(writer, target_type)) if at_end: writer.assign("ptr_info[n_ptr].dest", "end") @@ -756,9 +753,9 @@ def write_member_parser(writer, container, member, dest, scope): if t.is_pointer(): if member.has_attr("nocopy"): writer.comment("Reuse data from network message").newline() - writer.assign(dest.get_ref(member.name), "(size_t)(message_start + consume_uint64(&in))") + writer.assign(dest.get_ref(member.name), "(size_t)(message_start + consume_%s(&in))" % t.primitive_type()) else: - write_parse_pointer(writer, t, member.has_end_attr(), dest, member.name, not member.has_attr("ptr32"), scope) + write_parse_pointer(writer, t, member.has_end_attr(), dest, member.name, scope) elif t.is_primitive(): if member.has_end_attr(): writer.statement("*(%s *)end = consume_%s(&in)" % (t.c_type(), t.primitive_type())) diff --git a/python_modules/marshal.py b/python_modules/marshal.py index c5afd7c..ef1a47c 100644 --- a/python_modules/marshal.py +++ b/python_modules/marshal.py @@ -239,7 +239,7 @@ def write_switch_marshaller(writer, container, switch, src, scope): write_container_marshaller(writer, t, src2) elif t.is_pointer(): ptr_func = write_marshal_ptr_function(writer, t.target_type) - writer.assign("*%s_out" % (writer.out_prefix + m.name), "spice_marshaller_get_ptr_submarshaller(m, %s)" % ("0" if m.has_attr("ptr32") else "1")) + writer.assign("*%s_out" % (writer.out_prefix + m.name), "spice_marshaller_get_ptr_submarshaller(m, %d)" % (1 if m.get_fixed_nw_size() == 8 else 0)) elif t.is_primitive(): if m.has_attr("zero"): writer.statement("spice_marshaller_add_%s(m, 0)" % (t.primitive_type())) @@ -285,7 +285,7 @@ def write_member_marshaller(writer, container, member, src, scope): # else: # write_parse_pointer(writer, t, member.has_end_attr(), src, member.name, scope) ptr_func = write_marshal_ptr_function(writer, t.target_type) - writer.assign("*%s_out" % (writer.out_prefix + member.name), "spice_marshaller_get_ptr_submarshaller(m, %s)" % ("0" if member.has_attr("ptr32") else "1")) + writer.assign("*%s_out" % (writer.out_prefix + member.name), "spice_marshaller_get_ptr_submarshaller(m, %d)" % (1 if member.get_fixed_nw_size() == 8 else 0)) elif t.is_primitive(): if member.has_attr("zero"): writer.statement("spice_marshaller_add_%s(m, 0)" % (t.primitive_type())) diff --git a/python_modules/ptypes.py b/python_modules/ptypes.py index 2ee1789..f4126a5 100644 --- a/python_modules/ptypes.py +++ b/python_modules/ptypes.py @@ -4,6 +4,8 @@ import types _types_by_name = {} _types = [] +default_pointer_size = 4 + def type_exists(name): return _types_by_name.has_key(name) @@ -426,7 +428,7 @@ class PointerType(Type): Type.__init__(self) self.name = None self.target_type = target_type - self.pointer_size = 8 + self.pointer_size = default_pointer_size def __str__(self): return "%s*" % (str(self.target_type)) |