Rob Shearman : widl: Use type_get_type to determine the types of types during header writing.
Alexandre Julliard
julliard at winehq.org
Mon Feb 23 10:00:48 CST 2009
Module: wine
Branch: master
Commit: d854f322832c5c841db7ee44031bffbf5abb157f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d854f322832c5c841db7ee44031bffbf5abb157f
Author: Rob Shearman <robertshearman at gmail.com>
Date: Mon Feb 23 13:48:11 2009 +0000
widl: Use type_get_type to determine the types of types during header writing.
---
tools/widl/header.c | 80 +++++++++++++++++++++++++++++++-------------------
1 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 031e7dd..4a8929f 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -197,15 +197,8 @@ void write_type_left(FILE *h, type_t *t, int declonly)
if (type_is_alias(t)) fprintf(h, "%s", t->name);
else if (t->declarray) write_type_left(h, type_array_get_element(t), declonly);
else {
- if (t->sign > 0) fprintf(h, "signed ");
- else if (t->sign < 0) fprintf(h, "unsigned ");
-
- if (is_array(t) && !t->name) {
- write_type_left(h, type_array_get_element(t), declonly);
- fprintf(h, "%s*", needs_space_after(type_array_get_element(t)) ? " " : "");
- } else switch (t->type) {
- case RPC_FC_ENUM16:
- case RPC_FC_ENUM32:
+ switch (type_get_type_detect_alias(t)) {
+ case TYPE_ENUM:
if (!declonly && t->defined && !t->written) {
if (t->name) fprintf(h, "enum %s {\n", t->name);
else fprintf(h, "enum {\n");
@@ -217,19 +210,14 @@ void write_type_left(FILE *h, type_t *t, int declonly)
}
else fprintf(h, "enum %s", t->name ? t->name : "");
break;
- case RPC_FC_STRUCT:
- case RPC_FC_CVSTRUCT:
- case RPC_FC_CPSTRUCT:
- case RPC_FC_CSTRUCT:
- case RPC_FC_PSTRUCT:
- case RPC_FC_BOGUS_STRUCT:
- case RPC_FC_ENCAPSULATED_UNION:
+ case TYPE_STRUCT:
+ case TYPE_ENCAPSULATED_UNION:
if (!declonly && t->defined && !t->written) {
if (t->name) fprintf(h, "struct %s {\n", t->name);
else fprintf(h, "struct {\n");
t->written = TRUE;
indentation++;
- if (t->type == RPC_FC_ENCAPSULATED_UNION)
+ if (type_get_type(t) != TYPE_STRUCT)
write_fields(h, type_encapsulated_union_get_fields(t));
else
write_fields(h, type_struct_get_fields(t));
@@ -238,7 +226,7 @@ void write_type_left(FILE *h, type_t *t, int declonly)
}
else fprintf(h, "struct %s", t->name ? t->name : "");
break;
- case RPC_FC_NON_ENCAPSULATED_UNION:
+ case TYPE_UNION:
if (!declonly && t->defined && !t->written) {
if (t->name) fprintf(h, "union %s {\n", t->name);
else fprintf(h, "union {\n");
@@ -250,16 +238,35 @@ void write_type_left(FILE *h, type_t *t, int declonly)
}
else fprintf(h, "union %s", t->name ? t->name : "");
break;
- case RPC_FC_RP:
- case RPC_FC_UP:
- case RPC_FC_FP:
- case RPC_FC_OP:
+ case TYPE_POINTER:
write_type_left(h, type_pointer_get_ref(t), declonly);
fprintf(h, "%s*", needs_space_after(type_pointer_get_ref(t)) ? " " : "");
if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const ");
break;
- default:
+ case TYPE_ARRAY:
+ if (t->name)
+ fprintf(h, "%s", t->name);
+ else
+ {
+ write_type_left(h, type_array_get_element(t), declonly);
+ fprintf(h, "%s*", needs_space_after(type_array_get_element(t)) ? " " : "");
+ }
+ break;
+ case TYPE_BASIC:
+ if (t->sign > 0) fprintf(h, "signed ");
+ else if (t->sign < 0) fprintf(h, "unsigned ");
+ /* fall through */
+ case TYPE_INTERFACE:
+ case TYPE_MODULE:
+ case TYPE_COCLASS:
+ case TYPE_VOID:
fprintf(h, "%s", t->name);
+ break;
+ case TYPE_ALIAS:
+ case TYPE_FUNCTION:
+ /* handled elsewhere */
+ assert(0);
+ break;
}
}
}
@@ -288,7 +295,7 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c
for (pt = t; is_ptr(pt); pt = type_pointer_get_ref(pt), ptr_level++)
;
- if (pt->type == RPC_FC_FUNCTION) {
+ if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) {
int i;
const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV);
if (!callconv) callconv = "";
@@ -304,7 +311,7 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c
if (name) fprintf(h, "%s%s", needs_space_after(t) ? " " : "", name );
- if (pt->type == RPC_FC_FUNCTION) {
+ if (type_get_type_detect_alias(pt) == TYPE_FUNCTION) {
if (ptr_level) fputc(')', h);
fputc('(', h);
write_args(h, type_function_get_args(pt), NULL, 0, FALSE);
@@ -380,7 +387,9 @@ void check_for_additional_prototype_types(const var_list_t *list)
/* don't carry on parsing fields within this type */
break;
}
- if (type->type != RPC_FC_BIND_PRIMITIVE && is_attr(type->attrs, ATTR_HANDLE)) {
+ if ((type_get_type(type) != TYPE_BASIC ||
+ type_basic_get_fc(type) != RPC_FC_BIND_PRIMITIVE) &&
+ is_attr(type->attrs, ATTR_HANDLE)) {
if (!generic_handle_registered(name))
{
generic_handle_t *gh = xmalloc(sizeof(*gh));
@@ -403,13 +412,22 @@ void check_for_additional_prototype_types(const var_list_t *list)
}
else if (type_is_complete(type))
{
- var_list_t *vars = NULL;
- if (type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32)
+ var_list_t *vars;
+ switch (type_get_type_detect_alias(type))
+ {
+ case TYPE_ENUM:
vars = type_enum_get_values(type);
- else if (is_struct(type->type))
+ break;
+ case TYPE_STRUCT:
vars = type_struct_get_fields(type);
- else if (is_union(type->type))
+ break;
+ case TYPE_UNION:
vars = type_union_get_cases(type);
+ break;
+ default:
+ vars = NULL;
+ break;
+ }
check_for_additional_prototype_types(vars);
}
@@ -791,7 +809,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
fprintf(fp, " %s\n", comment);
if (rt->name && strcmp(rt->name, "HRESULT") == 0)
fprintf(fp, " return E_NOTIMPL;\n");
- else if (rt->type) {
+ else if (type_get_type(rt) != TYPE_VOID) {
fprintf(fp, " ");
write_type_decl(fp, rt, "rv");
fprintf(fp, ";\n");
More information about the wine-cvs
mailing list