From fd96c54641e500952233d0ac5a1a2730f82a60d7 Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Mon, 15 Mar 2010 19:31:10 +0000 Subject: [PATCH] widl: Simplify write_parameter_conf_or_var_exprs by making use of typegen_detect_type. Remove the difficult manual walking of the alias tree and make the code easier to read and less likely to break if a new type is added. --- tools/widl/typegen.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index e42d6571538..ca0faf1b737 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -3324,15 +3324,10 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char /* get fundamental type for the argument */ for (;;) { - if (is_attr(type->attrs, ATTR_WIREMARSHAL)) - break; - else if (is_attr(type->attrs, ATTR_CONTEXTHANDLE)) - break; - else if (type_is_alias(type)) - type = type_alias_get_aliasee(type); - else if (is_array(type)) + switch (typegen_detect_type(type, var->attrs, TDT_IGNORE_STRINGS|TDT_IGNORE_RANGES)) { - if (is_conformance_needed_for_phase(phase) && is_array(type)) + case TGT_ARRAY: + if (is_conformance_needed_for_phase(phase)) { if (type_array_has_conformance(type)) { @@ -3349,18 +3344,16 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char } } break; - } - else if (type_get_type(type) == TYPE_UNION) - { - if (is_conformance_needed_for_phase(phase)) + case TGT_UNION: + if (type_get_type(type) == TYPE_UNION && + is_conformance_needed_for_phase(phase)) { print_file(file, indent, "__frame->_StubMsg.MaxCount = (ULONG_PTR)"); write_expr(file, get_attrp(var->attrs, ATTR_SWITCHIS), 1, 1, NULL, NULL, local_var_prefix); fprintf(file, ";\n\n"); } break; - } - else if (type_get_type(type) == TYPE_INTERFACE || is_void(type)) + case TGT_IFACE_POINTER: { expr_t *iid; @@ -3372,10 +3365,21 @@ static void write_parameter_conf_or_var_exprs(FILE *file, int indent, const char } break; } - else if (is_ptr(type)) + case TGT_POINTER: type = type_pointer_get_ref(type); - else + continue; + case TGT_INVALID: + case TGT_USER_TYPE: + case TGT_CTXT_HANDLE: + case TGT_CTXT_HANDLE_POINTER: + case TGT_STRING: + case TGT_BASIC: + case TGT_ENUM: + case TGT_STRUCT: + case TGT_RANGE: break; + } + break; } }