Commit d854f322 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Use type_get_type to determine the types of types during header writing.

parent fb934347
...@@ -197,15 +197,8 @@ void write_type_left(FILE *h, type_t *t, int declonly) ...@@ -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); 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->declarray) write_type_left(h, type_array_get_element(t), declonly);
else { else {
if (t->sign > 0) fprintf(h, "signed "); switch (type_get_type_detect_alias(t)) {
else if (t->sign < 0) fprintf(h, "unsigned "); case TYPE_ENUM:
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:
if (!declonly && t->defined && !t->written) { if (!declonly && t->defined && !t->written) {
if (t->name) fprintf(h, "enum %s {\n", t->name); if (t->name) fprintf(h, "enum %s {\n", t->name);
else fprintf(h, "enum {\n"); else fprintf(h, "enum {\n");
...@@ -217,19 +210,14 @@ void write_type_left(FILE *h, type_t *t, int declonly) ...@@ -217,19 +210,14 @@ void write_type_left(FILE *h, type_t *t, int declonly)
} }
else fprintf(h, "enum %s", t->name ? t->name : ""); else fprintf(h, "enum %s", t->name ? t->name : "");
break; break;
case RPC_FC_STRUCT: case TYPE_STRUCT:
case RPC_FC_CVSTRUCT: case TYPE_ENCAPSULATED_UNION:
case RPC_FC_CPSTRUCT:
case RPC_FC_CSTRUCT:
case RPC_FC_PSTRUCT:
case RPC_FC_BOGUS_STRUCT:
case RPC_FC_ENCAPSULATED_UNION:
if (!declonly && t->defined && !t->written) { if (!declonly && t->defined && !t->written) {
if (t->name) fprintf(h, "struct %s {\n", t->name); if (t->name) fprintf(h, "struct %s {\n", t->name);
else fprintf(h, "struct {\n"); else fprintf(h, "struct {\n");
t->written = TRUE; t->written = TRUE;
indentation++; indentation++;
if (t->type == RPC_FC_ENCAPSULATED_UNION) if (type_get_type(t) != TYPE_STRUCT)
write_fields(h, type_encapsulated_union_get_fields(t)); write_fields(h, type_encapsulated_union_get_fields(t));
else else
write_fields(h, type_struct_get_fields(t)); write_fields(h, type_struct_get_fields(t));
...@@ -238,7 +226,7 @@ void write_type_left(FILE *h, type_t *t, int declonly) ...@@ -238,7 +226,7 @@ void write_type_left(FILE *h, type_t *t, int declonly)
} }
else fprintf(h, "struct %s", t->name ? t->name : ""); else fprintf(h, "struct %s", t->name ? t->name : "");
break; break;
case RPC_FC_NON_ENCAPSULATED_UNION: case TYPE_UNION:
if (!declonly && t->defined && !t->written) { if (!declonly && t->defined && !t->written) {
if (t->name) fprintf(h, "union %s {\n", t->name); if (t->name) fprintf(h, "union %s {\n", t->name);
else fprintf(h, "union {\n"); else fprintf(h, "union {\n");
...@@ -250,16 +238,35 @@ void write_type_left(FILE *h, type_t *t, int declonly) ...@@ -250,16 +238,35 @@ void write_type_left(FILE *h, type_t *t, int declonly)
} }
else fprintf(h, "union %s", t->name ? t->name : ""); else fprintf(h, "union %s", t->name ? t->name : "");
break; break;
case RPC_FC_RP: case TYPE_POINTER:
case RPC_FC_UP:
case RPC_FC_FP:
case RPC_FC_OP:
write_type_left(h, type_pointer_get_ref(t), declonly); write_type_left(h, type_pointer_get_ref(t), declonly);
fprintf(h, "%s*", needs_space_after(type_pointer_get_ref(t)) ? " " : ""); fprintf(h, "%s*", needs_space_after(type_pointer_get_ref(t)) ? " " : "");
if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const "); if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const ");
break; 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); 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 ...@@ -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++) 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; int i;
const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV); const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV);
if (!callconv) 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 ...@@ -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 (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); if (ptr_level) fputc(')', h);
fputc('(', h); fputc('(', h);
write_args(h, type_function_get_args(pt), NULL, 0, FALSE); 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) ...@@ -380,7 +387,9 @@ void check_for_additional_prototype_types(const var_list_t *list)
/* don't carry on parsing fields within this type */ /* don't carry on parsing fields within this type */
break; 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)) if (!generic_handle_registered(name))
{ {
generic_handle_t *gh = xmalloc(sizeof(*gh)); generic_handle_t *gh = xmalloc(sizeof(*gh));
...@@ -403,13 +412,22 @@ void check_for_additional_prototype_types(const var_list_t *list) ...@@ -403,13 +412,22 @@ void check_for_additional_prototype_types(const var_list_t *list)
} }
else if (type_is_complete(type)) else if (type_is_complete(type))
{ {
var_list_t *vars = NULL; var_list_t *vars;
if (type->type == RPC_FC_ENUM16 || type->type == RPC_FC_ENUM32) switch (type_get_type_detect_alias(type))
{
case TYPE_ENUM:
vars = type_enum_get_values(type); vars = type_enum_get_values(type);
else if (is_struct(type->type)) break;
case TYPE_STRUCT:
vars = type_struct_get_fields(type); vars = type_struct_get_fields(type);
else if (is_union(type->type)) break;
case TYPE_UNION:
vars = type_union_get_cases(type); vars = type_union_get_cases(type);
break;
default:
vars = NULL;
break;
}
check_for_additional_prototype_types(vars); check_for_additional_prototype_types(vars);
} }
...@@ -791,7 +809,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body) ...@@ -791,7 +809,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body)
fprintf(fp, " %s\n", comment); fprintf(fp, " %s\n", comment);
if (rt->name && strcmp(rt->name, "HRESULT") == 0) if (rt->name && strcmp(rt->name, "HRESULT") == 0)
fprintf(fp, " return E_NOTIMPL;\n"); fprintf(fp, " return E_NOTIMPL;\n");
else if (rt->type) { else if (type_get_type(rt) != TYPE_VOID) {
fprintf(fp, " "); fprintf(fp, " ");
write_type_decl(fp, rt, "rv"); write_type_decl(fp, rt, "rv");
fprintf(fp, ";\n"); fprintf(fp, ";\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment