From: Rémi Bernon rbernon@codeweavers.com
--- tools/widl/header.c | 120 +++++++++++++++++++++---------------------- tools/widl/header.h | 2 +- tools/widl/typegen.c | 2 +- 3 files changed, 61 insertions(+), 63 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index b1489989cb5..6472a44f2a4 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -384,73 +384,71 @@ void write_type_left( FILE *h, const decl_spec_t *ds, enum name_type name_type ) fwrite( str.buf, 1, str.pos, h ); }
-void write_type_right(FILE *h, type_t *t, int is_field) +void write_type_right( FILE *h, type_t *type, bool is_field ) { - if (!h) return; - if (type_is_alias(t)) return; + if (!h) return; + if (type_is_alias( type )) return;
- switch (type_get_type(t)) - { - case TYPE_ARRAY: - { - type_t *elem = type_array_get_element_type(t); - if (type_array_is_decl_as_ptr(t)) + switch (type_get_type( type )) { - if (decl_needs_parens(elem)) - fprintf(h, ")"); + case TYPE_ARRAY: + { + type_t *elem = type_array_get_element_type( type ); + if (type_array_is_decl_as_ptr( type )) + { + if (decl_needs_parens( elem )) fprintf( h, ")" ); + } + else + { + if (is_conformant_array( type )) fprintf( h, "[%s]", is_field ? "1" : "" ); + else fprintf( h, "[%u]", type_array_get_dim( type ) ); + } + write_type_right( h, elem, false ); + break; } - else + + case TYPE_FUNCTION: { - if (is_conformant_array(t)) - fprintf(h, "[%s]", is_field ? "1" : ""); - else - fprintf(h, "[%u]", type_array_get_dim(t)); + const var_list_t *args = type_function_get_args( type ); + fputc( '(', h ); + if (args) write_args( h, args, NULL, 0, false, NAME_DEFAULT ); + else fprintf( h, "void" ); + fputc( ')', h ); + write_type_right( h, type_function_get_rettype( type ), false ); + break; + } + + case TYPE_POINTER: + { + type_t *ref = type_pointer_get_ref_type( type ); + if (decl_needs_parens( ref )) fprintf( h, ")" ); + write_type_right( h, ref, false ); + break; + } + + case TYPE_BITFIELD: + fprintf( h, " : %u", type_bitfield_get_bits( type )->cval ); + break; + + case TYPE_VOID: + case TYPE_BASIC: + case TYPE_ENUM: + case TYPE_STRUCT: + case TYPE_ENCAPSULATED_UNION: + case TYPE_UNION: + case TYPE_ALIAS: + case TYPE_MODULE: + case TYPE_COCLASS: + case TYPE_INTERFACE: + case TYPE_RUNTIMECLASS: + case TYPE_DELEGATE: + case TYPE_PARAMETERIZED_TYPE: + case TYPE_PARAMETER: break; + case TYPE_APICONTRACT: + /* not supposed to be here */ + assert( 0 ); + break; } - write_type_right(h, elem, FALSE); - break; - } - case TYPE_FUNCTION: - { - const var_list_t *args = type_function_get_args(t); - fputc('(', h); - if (args) write_args(h, args, NULL, 0, FALSE, NAME_DEFAULT); - else - fprintf(h, "void"); - fputc(')', h); - write_type_right(h, type_function_get_rettype(t), FALSE); - break; - } - case TYPE_POINTER: - { - type_t *ref = type_pointer_get_ref_type(t); - if (decl_needs_parens(ref)) - fprintf(h, ")"); - write_type_right(h, ref, FALSE); - break; - } - case TYPE_BITFIELD: - fprintf(h, " : %u", type_bitfield_get_bits(t)->cval); - break; - case TYPE_VOID: - case TYPE_BASIC: - case TYPE_ENUM: - case TYPE_STRUCT: - case TYPE_ENCAPSULATED_UNION: - case TYPE_UNION: - case TYPE_ALIAS: - case TYPE_MODULE: - case TYPE_COCLASS: - case TYPE_INTERFACE: - case TYPE_RUNTIMECLASS: - case TYPE_DELEGATE: - case TYPE_PARAMETERIZED_TYPE: - case TYPE_PARAMETER: - break; - case TYPE_APICONTRACT: - /* not supposed to be here */ - assert(0); - break; - } }
static void write_type( FILE *f, type_t *t, bool define ) diff --git a/tools/widl/header.h b/tools/widl/header.h index b1bcbfee6b8..ddae3a40cc4 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -25,7 +25,7 @@
extern const char* get_name(const var_t *v); extern void write_type_left( FILE *h, const decl_spec_t *ds, enum name_type name_type ); -extern void write_type_right(FILE *h, type_t *t, int is_field); +extern void write_type_right( FILE *h, type_t *t, bool is_field ); extern void write_type_decl(FILE *f, const decl_spec_t *t, const char *name); extern void write_type_decl_left(FILE *f, const decl_spec_t *ds); extern unsigned int get_context_handle_offset( const type_t *type ); diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index ddde229bee8..76d7a2bde21 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -4909,7 +4909,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) fprintf(file, "(*%s)", var->name); } else fprintf(file, "%s", var->name); - write_type_right(file, var->declspec.type, FALSE); + write_type_right( file, var->declspec.type, false ); fprintf(file, ";\n");
if (decl_indirect(var->declspec.type))