From f0f623ddc0f0cc6b647ed432af23bb8564fb4f5c Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Thu, 8 Jul 2010 13:07:17 +0200 Subject: codegen: No SPICE_ADDRESS types left, drop @c_ptr --- python_modules/demarshal.py | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) (limited to 'python_modules/demarshal.py') diff --git a/python_modules/demarshal.py b/python_modules/demarshal.py index 1ae1911b..e8afabb2 100644 --- a/python_modules/demarshal.py +++ b/python_modules/demarshal.py @@ -82,9 +82,8 @@ def write_parser_helpers(writer): writer.begin_block("struct PointerInfo") writer.variable_def("uint64_t", "offset") writer.variable_def("parse_func_t", "parse") - writer.variable_def("void *", "dest") + writer.variable_def("void **", "dest") writer.variable_def("uint32_t", "nelements") - writer.variable_def("int", "is_ptr") writer.end_block(semicolon=True) def write_read_primitive(writer, start, container, name, scope): @@ -195,7 +194,7 @@ def write_validate_struct_function(writer, struct): writer.set_is_generated("validator", validate_function) writer = writer.function_helper() - scope = writer.function(validate_function, "static intptr_t", "uint8_t *message_start, uint8_t *message_end, SPICE_ADDRESS offset, int minor") + scope = writer.function(validate_function, "static intptr_t", "uint8_t *message_start, uint8_t *message_end, uint64_t offset, int minor") scope.variable_def("uint8_t *", "start = message_start + offset") scope.variable_def("SPICE_GNUC_UNUSED uint8_t *", "pos"); scope.variable_def("size_t", "mem_size", "nw_size"); @@ -809,16 +808,14 @@ def write_array_parser(writer, nelements, array, dest, scope): writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)") def write_parse_pointer(writer, t, at_end, dest, member_name, scope): - as_c_ptr = t.has_attr("c_ptr") target_type = t.target_type 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") - writer.increment("end", "sizeof(void *)" if as_c_ptr else "sizeof(SPICE_ADDRESS)"); + writer.assign("ptr_info[n_ptr].dest", "(void **)end") + writer.increment("end", "sizeof(void *)"); else: - writer.assign("ptr_info[n_ptr].dest", "&%s" % dest.get_ref(member_name)) - writer.assign("ptr_info[n_ptr].is_ptr", "1" if as_c_ptr else "0") + writer.assign("ptr_info[n_ptr].dest", "(void **)&%s" % dest.get_ref(member_name)) if target_type.is_array(): nelements = read_array_len(writer, member_name, target_type, dest, scope) writer.assign("ptr_info[n_ptr].nelements", nelements) @@ -932,20 +929,13 @@ def write_ptr_info_check(writer): with writer.for_loop(index, "n_ptr") as scope: offset = "ptr_info[%s].offset" % index function = "ptr_info[%s].parse" % index - is_ptr = "ptr_info[%s].is_ptr" % index dest = "ptr_info[%s].dest" % index with writer.if_block("%s == 0" % offset, newline=False): - with writer.if_block(is_ptr, newline=False): - writer.assign("*(void **)(%s)" % dest, "NULL") - with writer.block(" else"): - writer.assign("*(SPICE_ADDRESS *)(%s)" % dest, "0") + writer.assign("*%s" % dest, "NULL") with writer.block(" else"): writer.comment("Align to 32 bit").newline() writer.assign("end", "(uint8_t *)SPICE_ALIGN((size_t)end, 4)") - with writer.if_block(is_ptr, newline=False): - writer.assign("*(void **)(%s)" % dest, "(void *)end") - with writer.block(" else"): - writer.assign("*(SPICE_ADDRESS *)(%s)" % dest, "(SPICE_ADDRESS)end") + writer.assign("*%s" % dest, "(void *)end") writer.assign("end", "%s(message_start, message_end, end, &ptr_info[%s], minor)" % (function, index)) writer.error_check("end == NULL") writer.newline() -- cgit