Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/expr.c | 12 ++++++------ tools/widl/widltypes.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tools/widl/expr.c b/tools/widl/expr.c index 85ba4639e1..3d40da571f 100644 --- a/tools/widl/expr.c +++ b/tools/widl/expr.c @@ -202,7 +202,7 @@ expr_t *make_exprt(enum expr_type type, var_t *var, expr_t *expr) e = xmalloc(sizeof(expr_t)); e->type = type; e->ref = expr; - e->u.tref = tref; + e->u.tref = var->declspec; e->is_const = FALSE; if (type == EXPR_SIZEOF) { @@ -591,7 +591,7 @@ static struct expression_type resolve_expression(const struct expr_loc *expr_loc break; case EXPR_CAST: result = resolve_expression(expr_loc, cont_type, e->ref); - result.type = e->u.tref; + result.type = e->u.tref.type; break; case EXPR_SIZEOF: result.is_temporary = FALSE; @@ -759,13 +759,13 @@ void write_expr(FILE *h, const expr_t *e, int brackets, break; case EXPR_CAST: fprintf(h, "("); - write_type_decl(h, e->u.tref, NULL); + write_type_decl(h, e->u.tref.type, NULL); fprintf(h, ")"); write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_SIZEOF: fprintf(h, "sizeof("); - write_type_decl(h, e->u.tref, NULL); + write_type_decl(h, e->u.tref.type, NULL); fprintf(h, ")"); break; case EXPR_SHL: @@ -917,7 +917,7 @@ int compare_expr(const expr_t *a, const expr_t *b) return ret; return compare_expr(a->u.ext, b->u.ext); case EXPR_CAST: - ret = compare_type(a->u.tref, b->u.tref); + ret = compare_type(a->u.tref.type, b->u.tref.type); if (ret != 0) return ret; /* Fall through. */ @@ -929,7 +929,7 @@ int compare_expr(const expr_t *a, const expr_t *b) case EXPR_POS: return compare_expr(a->ref, b->ref); case EXPR_SIZEOF: - return compare_type(a->u.tref, b->u.tref); + return compare_type(a->u.tref.type, b->u.tref.type); case EXPR_VOID: return 0; } diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index 43931c9813..3f2a719f2d 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -319,7 +319,7 @@ struct _expr_t { double dval; const char *sval; const expr_t *ext; - type_t *tref; + decl_spec_t tref; } u; const expr_t *ext2; int is_const;
From: Richard Pospesel richard@torproject.org
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This supersedes https://source.winehq.org/patches/data/167612.
tools/widl/client.c | 4 ++-- tools/widl/expr.c | 4 ++-- tools/widl/header.c | 26 +++++++++++++------------- tools/widl/header.h | 2 +- tools/widl/proxy.c | 2 +- tools/widl/server.c | 2 +- tools/widl/typegen.c | 36 +++++++++++++++++++----------------- tools/widl/typetree.h | 11 +++++++++++ 8 files changed, 50 insertions(+), 37 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c index 3c0a0711b9..6b1da134ec 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -136,7 +136,7 @@ static void write_function_stub( const type_t *iface, const var_t *func, if (has_ret) { print_client("%s", ""); - write_type_decl(client, retval->declspec.type, retval->name); + write_type_decl(client, &retval->declspec, retval->name); fprintf(client, ";\n"); } print_client("RPC_MESSAGE _RpcMessage;\n"); @@ -488,7 +488,7 @@ static void write_implicithandledecl(type_t *iface)
if (implicit_handle) { - write_type_decl( client, implicit_handle->declspec.type, implicit_handle->name ); + write_type_decl(client, &implicit_handle->declspec, implicit_handle->name); fprintf(client, ";\n\n"); } } diff --git a/tools/widl/expr.c b/tools/widl/expr.c index 3d40da571f..41afb4b40e 100644 --- a/tools/widl/expr.c +++ b/tools/widl/expr.c @@ -759,13 +759,13 @@ void write_expr(FILE *h, const expr_t *e, int brackets, break; case EXPR_CAST: fprintf(h, "("); - write_type_decl(h, e->u.tref.type, NULL); + write_type_decl(h, &e->u.tref, NULL); fprintf(h, ")"); write_expr(h, e->ref, 1, toplevel, toplevel_prefix, cont_type, local_var_prefix); break; case EXPR_SIZEOF: fprintf(h, "sizeof("); - write_type_decl(h, e->u.tref.type, NULL); + write_type_decl(h, &e->u.tref, NULL); fprintf(h, ")"); break; case EXPR_SHL: diff --git a/tools/widl/header.c b/tools/widl/header.c index 51c2be7eef..b5a88bc107 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -43,7 +43,7 @@ user_type_list_t user_type_list = LIST_INIT(user_type_list); context_handle_list_t context_handle_list = LIST_INIT(context_handle_list); generic_handle_list_t generic_handle_list = LIST_INIT(generic_handle_list);
-static void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name); +static void write_type_def_or_decl(FILE *f, const decl_spec_t *t, int field, const char *name);
static void indent(FILE *h, int delta) { @@ -252,7 +252,7 @@ static void write_fields(FILE *h, var_list_t *fields) default: ; } - write_type_def_or_decl(h, v->declspec.type, TRUE, name); + write_type_def_or_decl(h, &v->declspec, TRUE, name); fprintf(h, ";\n"); } } @@ -485,9 +485,9 @@ void write_type_right(FILE *h, type_t *t, int is_field) } }
-static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const char *name) +static void write_type_v(FILE *h, const decl_spec_t *ds, int is_field, int declonly, const char *name) { - type_t *pt = NULL; + type_t *t = ds->type, *pt = NULL; int ptr_level = 0;
if (!h) return; @@ -529,7 +529,7 @@ static void write_type_v(FILE *h, type_t *t, int is_field, int declonly, const c } }
-static void write_type_def_or_decl(FILE *f, type_t *t, int field, const char *name) +static void write_type_def_or_decl(FILE *f, const decl_spec_t *t, int field, const char *name) { write_type_v(f, t, field, FALSE, name); } @@ -558,7 +558,7 @@ static void write_type_definition(FILE *f, type_t *t) } }
-void write_type_decl(FILE *f, type_t *t, const char *name) +void write_type_decl(FILE *f, const decl_spec_t *t, const char *name) { write_type_v(f, t, FALSE, TRUE, name); } @@ -789,7 +789,7 @@ static void write_generic_handle_routines(FILE *header) static void write_typedef(FILE *header, type_t *type) { fprintf(header, "typedef "); - write_type_def_or_decl(header, type_alias_get_aliasee_type(type), FALSE, type->name); + write_type_def_or_decl(header, type_alias_get_aliasee(type), FALSE, type->name); fprintf(header, ";\n"); }
@@ -833,7 +833,7 @@ static void write_declaration(FILE *header, const var_t *v) fprintf(header, "extern "); break; } - write_type_def_or_decl(header, v->declspec.type, FALSE, v->name); + write_type_def_or_decl(header, &v->declspec, FALSE, v->name); fprintf(header, ";\n\n"); } } @@ -1073,7 +1073,7 @@ void write_args(FILE *h, const var_list_t *args, const char *name, int method, i } else fprintf(h, ","); } - write_type_decl(h, arg->declspec.type, arg->name); + write_type_decl(h, &arg->declspec, arg->name); if (method == 2) { const expr_t *expr = get_attrp(arg->attrs, ATTR_DEFAULTVALUE); if (expr) { @@ -1337,12 +1337,12 @@ static void write_locals(FILE *fp, const type_t *iface, int body) write_args(fp, type_function_get_args(m->declspec.type), iface->name, 1, TRUE); fprintf(fp, ")"); if (body) { - type_t *rt = type_function_get_rettype(m->declspec.type); + const decl_spec_t *rt = type_function_get_ret(m->declspec.type); fprintf(fp, "\n{\n"); fprintf(fp, " %s\n", comment); - if (rt->name && strcmp(rt->name, "HRESULT") == 0) + if (rt->type->name && strcmp(rt->type->name, "HRESULT") == 0) fprintf(fp, " return E_NOTIMPL;\n"); - else if (type_get_type(rt) != TYPE_VOID) { + else if (type_get_type(rt->type) != TYPE_VOID) { fprintf(fp, " "); write_type_decl(fp, rt, "rv"); fprintf(fp, ";\n"); @@ -1536,7 +1536,7 @@ static void write_rpc_interface_start(FILE *header, const type_t *iface) if (var) { fprintf(header, "extern "); - write_type_decl( header, var->declspec.type, var->name ); + write_type_decl( header, &var->declspec, var->name ); fprintf(header, ";\n"); } if (old_names) diff --git a/tools/widl/header.h b/tools/widl/header.h index 94b90a391f..8d728c5df5 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -31,7 +31,7 @@ extern unsigned int get_attrv(const attr_list_t *list, enum attr_type t); extern const char* get_name(const var_t *v); extern void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly); extern void write_type_right(FILE *h, type_t *t, int is_field); -extern void write_type_decl(FILE *f, type_t *t, const char *name); +extern void write_type_decl(FILE *f, const decl_spec_t *t, const char *name); extern void write_type_decl_left(FILE *f, type_t *t); extern unsigned int get_context_handle_offset( const type_t *type ); extern unsigned int get_generic_handle_offset( const type_t *type ); diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c index 22c045d788..1633e6c9b2 100644 --- a/tools/widl/proxy.c +++ b/tools/widl/proxy.c @@ -229,7 +229,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx, /* local variables */ if (has_ret) { print_proxy( "%s", "" ); - write_type_decl(proxy, retval->declspec.type, retval->name); + write_type_decl(proxy, &retval->declspec, retval->name); fprintf( proxy, ";\n" ); } print_proxy( "RPC_MESSAGE _RpcMessage;\n" ); diff --git a/tools/widl/server.c b/tools/widl/server.c index 1ab305950a..3004efc8d2 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -159,7 +159,7 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned { print_server("__frame->_RetVal = NDRSContextUnmarshall((char*)0, _pRpcMessage->DataRepresentation);\n"); print_server("*(("); - write_type_decl(server, ret_type, NULL); + write_type_decl(server, type_function_get_ret(func->declspec.type), NULL); fprintf(server, "*)NDRSContextValue(__frame->_RetVal)) = "); } else diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index e266764144..5d47a72112 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -2217,8 +2217,9 @@ static unsigned int write_simple_pointer(FILE *file, const attr_list_t *attrs,
static void print_start_tfs_comment(FILE *file, type_t *t, unsigned int tfsoff) { + const decl_spec_t ds = {.type = t}; print_file(file, 0, "/* %u (", tfsoff); - write_type_decl(file, t, NULL); + write_type_decl(file, &ds, NULL); print_file(file, 0, ") */\n"); }
@@ -4006,8 +4007,9 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, } else { - const type_t *ref = is_ptr(type) ? type_pointer_get_ref_type(type) : type; - switch (get_basic_fc(ref)) + const decl_spec_t *ref = is_ptr(type) ? type_pointer_get_ref(type) : &var->declspec; + + switch (get_basic_fc(ref->type)) { case FC_BYTE: case FC_CHAR: @@ -4044,7 +4046,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix,
default: error("print_phase_basetype: Unsupported type: %s (0x%02x, ptr_level: 0)\n", - var->name, get_basic_fc(ref)); + var->name, get_basic_fc(ref->type)); }
if (phase == PHASE_MARSHAL && alignment > 1) @@ -4055,7 +4057,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, if (phase == PHASE_MARSHAL) { print_file(file, indent, "*("); - write_type_decl(file, is_ptr(type) ? type_pointer_get_ref_type(type) : type, NULL); + write_type_decl(file, ref, NULL); if (is_ptr(type)) fprintf(file, " *)__frame->_StubMsg.Buffer = *"); else @@ -4066,7 +4068,7 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, else if (phase == PHASE_UNMARSHAL) { print_file(file, indent, "if (__frame->_StubMsg.Buffer + sizeof("); - write_type_decl(file, is_ptr(type) ? type_pointer_get_ref_type(type) : type, NULL); + write_type_decl(file, ref, NULL); fprintf(file, ") > __frame->_StubMsg.BufferEnd)\n"); print_file(file, indent, "{\n"); print_file(file, indent + 1, "RpcRaiseException(RPC_X_BAD_STUB_DATA);\n"); @@ -4078,12 +4080,12 @@ void print_phase_basetype(FILE *file, int indent, const char *local_var_prefix, fprintf(file, " = ("); else fprintf(file, " = *("); - write_type_decl(file, is_ptr(type) ? type_pointer_get_ref_type(type) : type, NULL); + write_type_decl(file, ref, NULL); fprintf(file, " *)__frame->_StubMsg.Buffer;\n"); }
print_file(file, indent, "__frame->_StubMsg.Buffer += sizeof("); - write_type_decl(file, is_ptr(type) ? type_pointer_get_ref_type(type) : type, NULL); + write_type_decl(file, ref, NULL); fprintf(file, ");\n"); } } @@ -4388,9 +4390,9 @@ static void write_remoting_arg(FILE *file, int indent, const var_t *func, const range_max = LIST_ENTRY(list_next(range_list, list_head(range_list)), const expr_t, entry);
print_file(file, indent, "if ((%s%s < (", local_var_prefix, var->name); - write_type_decl(file, var->declspec.type, NULL); + write_type_decl(file, &var->declspec, NULL); fprintf(file, ")0x%x) || (%s%s > (", range_min->cval, local_var_prefix, var->name); - write_type_decl(file, var->declspec.type, NULL); + write_type_decl(file, &var->declspec, NULL); fprintf(file, ")0x%x))\n", range_max->cval); print_file(file, indent, "{\n"); print_file(file, indent+1, "RpcRaiseException(RPC_S_INVALID_BOUND);\n"); @@ -4605,7 +4607,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) { int in_attr, out_attr; int i = 0; - const var_t *var = type_function_get_retval(func->declspec.type); + var_t *var = type_function_get_retval(func->declspec.type);
/* declare return value */ if (!is_void(var->declspec.type)) @@ -4615,7 +4617,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) else { print_file(file, indent, "%s", ""); - write_type_decl(file, var->declspec.type, var->name); + write_type_decl(file, &var->declspec, var->name); fprintf(file, ";\n"); } } @@ -4623,7 +4625,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) if (!type_function_get_args(func->declspec.type)) return;
- LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), const var_t, entry ) + LIST_FOR_EACH_ENTRY( var, type_function_get_args(func->declspec.type), var_t, entry ) { in_attr = is_attr(var->attrs, ATTR_IN); out_attr = is_attr(var->attrs, ATTR_OUT); @@ -4636,14 +4638,14 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) { if (!in_attr && !is_conformant_array(var->declspec.type)) { - type_t *type_to_print; + const decl_spec_t *type_to_print; char name[16]; print_file(file, indent, "%s", ""); if (type_get_type(var->declspec.type) == TYPE_ARRAY && !type_array_is_decl_as_ptr(var->declspec.type)) - type_to_print = var->declspec.type; + type_to_print = &var->declspec; else - type_to_print = type_pointer_get_ref_type(var->declspec.type); + type_to_print = type_pointer_get_ref(var->declspec.type); sprintf(name, "_W%u", i++); write_type_decl(file, type_to_print, name); fprintf(file, ";\n"); @@ -4820,7 +4822,7 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun if (add_retval && !is_void( retval->declspec.type )) { print_file(file, 2, "%s", ""); - write_type_decl( file, retval->declspec.type, retval->name ); + write_type_decl( file, &retval->declspec, retval->name ); if (is_array( retval->declspec.type ) || is_ptr( retval->declspec.type ) || type_memsize( retval->declspec.type ) == pointer_size) fprintf( file, ";\n" ); diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index 58b388c825..d5f28fe590 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -105,6 +105,11 @@ static inline var_t *type_function_get_retval(const type_t *type) return type->details.function->retval; }
+static inline const decl_spec_t *type_function_get_ret(const type_t *type) +{ + return &type_function_get_retval(type)->declspec; +} + static inline type_t *type_function_get_rettype(const type_t *type) { return type_function_get_retval(type)->declspec.type; @@ -302,6 +307,12 @@ static inline int type_is_alias(const type_t *type) return type->type_type == TYPE_ALIAS; }
+static inline const decl_spec_t *type_alias_get_aliasee(const type_t *type) +{ + assert(type_is_alias(type)); + return &type->details.alias.aliasee; +} + static inline type_t *type_alias_get_aliasee_type(const type_t *type) { assert(type_is_alias(type));
From: Richard Pospesel richard@torproject.org
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This supersedes https://source.winehq.org/patches/data/167612.
tools/widl/client.c | 2 +- tools/widl/header.c | 52 ++++++++++++++++++++++++-------------------- tools/widl/header.h | 4 ++-- tools/widl/proxy.c | 4 ++-- tools/widl/server.c | 2 +- tools/widl/typegen.c | 13 ++++++----- 6 files changed, 42 insertions(+), 35 deletions(-)
diff --git a/tools/widl/client.c b/tools/widl/client.c index 6b1da134ec..6ef1cee2f7 100644 --- a/tools/widl/client.c +++ b/tools/widl/client.c @@ -54,7 +54,7 @@ static void write_client_func_decl( const type_t *iface, const var_t *func ) { const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV); const var_list_t *args = type_function_get_args(func->declspec.type); - type_t *rettype = type_function_get_rettype(func->declspec.type); + const decl_spec_t *rettype = type_function_get_ret(func->declspec.type);
if (!callconv) callconv = "__cdecl"; write_type_decl_left(client, rettype); diff --git a/tools/widl/header.c b/tools/widl/header.c index b5a88bc107..5bf5d09ef1 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -294,8 +294,9 @@ static void write_pointer_left(FILE *h, type_t *ref) fprintf(h, "*"); }
-void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly) +void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, int declonly) { + type_t *t = ds->type; const char *name;
if (!h) return; @@ -351,7 +352,7 @@ void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly) break; case TYPE_POINTER: { - write_type_left(h, type_pointer_get_ref_type(t), name_type, declonly); + write_type_left(h, type_pointer_get_ref(t), name_type, declonly); write_pointer_left(h, type_pointer_get_ref_type(t)); if (is_attr(t->attrs, ATTR_CONST)) fprintf(h, "const "); break; @@ -361,7 +362,7 @@ void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly) fprintf(h, "%s", t->name); else { - write_type_left(h, type_array_get_element_type(t), name_type, declonly); + write_type_left(h, type_array_get_element(t), name_type, declonly); if (type_array_is_decl_as_ptr(t)) write_pointer_left(h, type_array_get_element_type(t)); } @@ -423,8 +424,11 @@ void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly) fprintf(h, "void"); break; case TYPE_BITFIELD: - write_type_left(h, type_bitfield_get_field(t), name_type, declonly); + { + const decl_spec_t ds = {.type = type_bitfield_get_field(t)}; + write_type_left(h, &ds, name_type, declonly); break; + } case TYPE_ALIAS: case TYPE_FUNCTION: /* handled elsewhere */ @@ -501,14 +505,14 @@ static void write_type_v(FILE *h, const decl_spec_t *ds, int is_field, int declo const char *callconv = get_attrp(pt->attrs, ATTR_CALLCONV); if (!callconv && is_object_interface) callconv = "STDMETHODCALLTYPE"; if (is_attr(pt->attrs, ATTR_INLINE)) fprintf(h, "inline "); - write_type_left(h, type_function_get_rettype(pt), NAME_DEFAULT, declonly); + write_type_left(h, type_function_get_ret(pt), NAME_DEFAULT, declonly); fputc(' ', h); if (ptr_level) fputc('(', h); if (callconv) fprintf(h, "%s ", callconv); for (i = 0; i < ptr_level; i++) fputc('*', h); } else - write_type_left(h, t, NAME_DEFAULT, declonly); + write_type_left(h, ds, NAME_DEFAULT, declonly); }
if (name) fprintf(h, "%s%s", !t || needs_space_after(t) ? " " : "", name ); @@ -538,6 +542,7 @@ static void write_type_definition(FILE *f, type_t *t) { int in_namespace = t->namespace && !is_global_namespace(t->namespace); int save_written = t->written; + decl_spec_t ds = {.type = t};
if(in_namespace) { fprintf(f, "#ifdef __cplusplus\n"); @@ -545,14 +550,14 @@ static void write_type_definition(FILE *f, type_t *t) write_namespace_start(f, t->namespace); } indent(f, 0); - write_type_left(f, t, NAME_DEFAULT, FALSE); + write_type_left(f, &ds, NAME_DEFAULT, FALSE); fprintf(f, ";\n"); if(in_namespace) { t->written = save_written; write_namespace_end(f, t->namespace); fprintf(f, "extern "C" {\n"); fprintf(f, "#else\n"); - write_type_left(f, t, NAME_C, FALSE); + write_type_left(f, &ds, NAME_C, FALSE); fprintf(f, ";\n"); fprintf(f, "#endif\n\n"); } @@ -563,9 +568,9 @@ void write_type_decl(FILE *f, const decl_spec_t *t, const char *name) write_type_v(f, t, FALSE, TRUE, name); }
-void write_type_decl_left(FILE *f, type_t *t) +void write_type_decl_left(FILE *f, const decl_spec_t *ds) { - write_type_left(f, t, NAME_DEFAULT, TRUE); + write_type_left(f, ds, NAME_DEFAULT, TRUE); }
static int user_type_registered(const char *name) @@ -1114,6 +1119,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface) { const var_t *func = stmt->u.var; if (!is_callas(func->attrs)) { + const decl_spec_t *ret = type_function_get_ret(func->declspec.type); const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV); const var_list_t *args = type_function_get_args(func->declspec.type); const var_t *arg; @@ -1125,11 +1131,11 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
indent(header, 0); fprintf(header, "virtual "); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, ret); fprintf(header, "* %s %s(\n", callconv, get_name(func)); ++indentation; indent(header, 0); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, ret); fprintf(header, " *__ret"); --indentation; if (args) { @@ -1139,7 +1145,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface) fprintf(header, ") = 0;\n");
indent(header, 0); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, ret); fprintf(header, " %s %s(\n", callconv, get_name(func)); write_args(header, args, iface->name, 2, TRUE); fprintf(header, ")\n"); @@ -1147,7 +1153,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface) fprintf(header, "{\n"); ++indentation; indent(header, 0); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, ret); fprintf(header, " __ret;\n"); indent(header, 0); fprintf(header, "return *%s(&__ret", get_name(func)); @@ -1164,7 +1170,7 @@ static void write_cpp_method_def(FILE *header, const type_t *iface)
indent(header, 0); fprintf(header, "virtual "); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, ret); fprintf(header, " %s %s(\n", callconv, get_name(func)); write_args(header, args, iface->name, 2, TRUE); fprintf(header, ") = 0;\n"); @@ -1201,7 +1207,7 @@ static void write_inline_wrappers(FILE *header, const type_t *iface, const type_ const var_t *arg;
fprintf(header, "static FORCEINLINE "); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, type_function_get_ret(func->declspec.type)); fprintf(header, " %s_%s(", name, get_name(func)); write_args(header, type_function_get_args(func->declspec.type), name, 1, FALSE); fprintf(header, ") {\n"); @@ -1213,7 +1219,7 @@ static void write_inline_wrappers(FILE *header, const type_t *iface, const type_ get_vtbl_entry_name(iface, func)); } else { indent(header, 0); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, type_function_get_ret(func->declspec.type)); fprintf(header, " __ret;\n"); indent(header, 0); fprintf(header, "return *This->lpVtbl->%s(This,&__ret", get_vtbl_entry_name(iface, func)); @@ -1248,7 +1254,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV); if (!callconv) callconv = "STDMETHODCALLTYPE"; indent(header, 0); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, type_function_get_ret(func->declspec.type)); if (is_aggregate_return(func)) fprintf(header, " *"); if (is_inherited_method(iface, func)) @@ -1261,7 +1267,7 @@ static void do_write_c_method_def(FILE *header, const type_t *iface, const char if (is_aggregate_return(func)) { fprintf(header, ",\n"); indent(header, 0); - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, type_function_get_ret(func->declspec.type)); fprintf(header, " *__ret"); } --indentation; @@ -1297,7 +1303,7 @@ static void write_method_proto(FILE *header, const type_t *iface) const char *callconv = get_attrp(func->declspec.type->attrs, ATTR_CALLCONV); if (!callconv) callconv = "STDMETHODCALLTYPE"; /* proxy prototype */ - write_type_decl_left(header, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(header, type_function_get_ret(func->declspec.type)); fprintf(header, " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); write_args(header, type_function_get_args(func->declspec.type), iface->name, 1, TRUE); fprintf(header, ");\n"); @@ -1332,7 +1338,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body) if (&stmt2->entry != type_iface_get_stmts(iface)) { const var_t *m = stmt2->u.var; /* proxy prototype - use local prototype */ - write_type_decl_left(fp, type_function_get_rettype(m->declspec.type)); + write_type_decl_left(fp, type_function_get_ret(m->declspec.type)); fprintf(fp, " CALLBACK %s_%s_Proxy(\n", iface->name, get_name(m)); write_args(fp, type_function_get_args(m->declspec.type), iface->name, 1, TRUE); fprintf(fp, ")"); @@ -1354,7 +1360,7 @@ static void write_locals(FILE *fp, const type_t *iface, int body) else fprintf(fp, ";\n"); /* stub prototype - use remotable prototype */ - write_type_decl_left(fp, type_function_get_rettype(func->declspec.type)); + write_type_decl_left(fp, type_function_get_ret(func->declspec.type)); fprintf(fp, " __RPC_STUB %s_%s_Stub(\n", iface->name, get_name(m)); write_args(fp, type_function_get_args(func->declspec.type), iface->name, 1, TRUE); fprintf(fp, ")"); @@ -1406,7 +1412,7 @@ static void write_function_proto(FILE *header, const type_t *iface, const var_t
if (!callconv) callconv = "__cdecl"; /* FIXME: do we need to handle call_as? */ - write_type_decl_left(header, type_function_get_rettype(fun->declspec.type)); + write_type_decl_left(header, type_function_get_ret(fun->declspec.type)); fprintf(header, " %s ", callconv); fprintf(header, "%s%s(\n", prefix, get_name(fun)); if (type_function_get_args(fun->declspec.type)) diff --git a/tools/widl/header.h b/tools/widl/header.h index 8d728c5df5..e047e4e2e4 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -29,10 +29,10 @@ extern int is_attr(const attr_list_t *list, enum attr_type t); extern void *get_attrp(const attr_list_t *list, enum attr_type t); extern unsigned int get_attrv(const attr_list_t *list, enum attr_type t); extern const char* get_name(const var_t *v); -extern void write_type_left(FILE *h, type_t *t, enum name_type name_type, int declonly); +extern void write_type_left(FILE *h, const decl_spec_t *ds, enum name_type name_type, int declonly); extern void write_type_right(FILE *h, type_t *t, int 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, type_t *t); +extern void write_type_decl_left(FILE *f, const decl_spec_t *ds); extern unsigned int get_context_handle_offset( const type_t *type ); extern unsigned int get_generic_handle_offset( const type_t *type ); extern int needs_space_after(type_t *t); diff --git a/tools/widl/proxy.c b/tools/widl/proxy.c index 1633e6c9b2..d7788e1d57 100644 --- a/tools/widl/proxy.c +++ b/tools/widl/proxy.c @@ -202,7 +202,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx, if (is_interpreted_func( iface, func )) { if (get_stub_mode() == MODE_Oif && !is_callas( func->attrs )) return; - write_type_decl_left(proxy, retval->declspec.type); + write_type_decl_left(proxy, &retval->declspec); print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); write_args(proxy, args, iface->name, 1, TRUE); print_proxy( ")\n"); @@ -219,7 +219,7 @@ static void gen_proxy(type_t *iface, const var_t *func, int idx, print_proxy( "}\n"); print_proxy( "\n");
- write_type_decl_left(proxy, retval->declspec.type); + write_type_decl_left(proxy, &retval->declspec); print_proxy( " %s %s_%s_Proxy(\n", callconv, iface->name, get_name(func)); write_args(proxy, args, iface->name, 1, TRUE); print_proxy( ")\n"); diff --git a/tools/widl/server.c b/tools/widl/server.c index 3004efc8d2..79dc079fd2 100644 --- a/tools/widl/server.c +++ b/tools/widl/server.c @@ -185,7 +185,7 @@ static void write_function_stub(const type_t *iface, const var_t *func, unsigned * be direct, otherwise it is a pointer */ const char *ch_ptr = is_aliaschain_attr(var->declspec.type, ATTR_CONTEXTHANDLE) ? "*" : ""; print_server("("); - write_type_decl_left(server, var->declspec.type); + write_type_decl_left(server, &var->declspec); fprintf(server, ")%sNDRSContextValue(__frame->%s)", ch_ptr, var->name); } else diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 5d47a72112..55abd0a40c 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -4652,7 +4652,7 @@ void declare_stub_args( FILE *file, int indent, const var_t *func ) }
print_file(file, indent, "%s", ""); - write_type_decl_left(file, var->declspec.type); + write_type_decl_left(file, &var->declspec); fprintf(file, " "); if (type_get_type(var->declspec.type) == TYPE_ARRAY && !type_array_is_decl_as_ptr(var->declspec.type)) { @@ -4805,7 +4805,7 @@ void write_func_param_struct( FILE *file, const type_t *iface, const type_t *fun if (args) LIST_FOR_EACH_ENTRY( arg, args, const var_t, entry ) { print_file(file, 2, "%s", ""); - write_type_left( file, (type_t *)arg->declspec.type, NAME_DEFAULT, TRUE ); + write_type_left( file, &arg->declspec, NAME_DEFAULT, TRUE ); if (needs_space_after( arg->declspec.type )) fputc( ' ', file ); if (is_array( arg->declspec.type ) && !type_array_is_decl_as_ptr( arg->declspec.type )) fputc( '*', file );
@@ -4869,10 +4869,11 @@ int write_expr_eval_routines(FILE *file, const char *iface) } else { + decl_spec_t ds = {.type = (type_t *)eval->cont_type}; print_file(file, 1, "%s", ""); - write_type_left(file, (type_t *)eval->cont_type, NAME_DEFAULT, TRUE); + write_type_left(file, &ds, NAME_DEFAULT, TRUE); fprintf(file, " *%s = (", var_name); - write_type_left(file, (type_t *)eval->cont_type, NAME_DEFAULT, TRUE); + write_type_left(file, &ds, NAME_DEFAULT, TRUE); fprintf(file, " *)(pStubMsg->StackTop - %u);\n", eval->baseoff); } print_file(file, 1, "pStubMsg->Offset = 0;\n"); /* FIXME */ @@ -4966,8 +4967,8 @@ error: void write_client_call_routine( FILE *file, const type_t *iface, const var_t *func, const char *prefix, unsigned int proc_offset ) { - type_t *rettype = type_function_get_rettype( func->declspec.type ); - int has_ret = !is_void( rettype ); + const decl_spec_t *rettype = type_function_get_ret( func->declspec.type ); + int has_ret = !is_void( rettype->type ); const var_list_t *args = type_function_get_args( func->declspec.type ); const var_t *arg; int len, needs_params = 0;
From: Richard Pospesel richard@torproject.org
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This supersedes https://source.winehq.org/patches/data/167617.
tools/widl/parser.y | 10 +++++----- tools/widl/typetree.c | 5 +++-- tools/widl/typetree.h | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index c8b2cff76e..b75be01077 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1622,11 +1622,11 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl error_loc("%s: cannot specify size_is for an already sized array\n", v->name); else *ptype = type_new_array((*ptype)->name, - type_array_get_element_type(*ptype), FALSE, + type_array_get_element(*ptype), FALSE, 0, dim, NULL, FC_RP); } else if (is_ptr(*ptype)) - *ptype = type_new_array((*ptype)->name, type_pointer_get_ref_type(*ptype), TRUE, + *ptype = type_new_array((*ptype)->name, type_pointer_get_ref(*ptype), TRUE, 0, dim, NULL, pointer_default); else error_loc("%s: size_is attribute applied to illegal type\n", v->name); @@ -1648,7 +1648,7 @@ static var_t *declare_var(attr_list_t *attrs, decl_spec_t *decl_spec, const decl if (is_array(*ptype)) { *ptype = type_new_array((*ptype)->name, - type_array_get_element_type(*ptype), + type_array_get_element(*ptype), type_array_is_decl_as_ptr(*ptype), type_array_get_dim(*ptype), type_array_get_conformance(*ptype), @@ -1802,8 +1802,8 @@ static declarator_t *make_declarator(var_t *var)
static type_t *make_safearray(type_t *type) { - return type_new_array(NULL, type_new_alias(type, "SAFEARRAY"), TRUE, 0, - NULL, NULL, FC_RP); + const decl_spec_t ds = {.type = type_new_alias(type, "SAFEARRAY")}; + return type_new_array(NULL, &ds, TRUE, 0, NULL, NULL, FC_RP); }
static typelib_t *make_library(const char *name, const attr_list_t *attrs) diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index ae3f375450..3e9ac89ad9 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -217,7 +217,7 @@ type_t *type_new_coclass(char *name) }
-type_t *type_new_array(const char *name, type_t *element, int declptr, +type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr, unsigned int dim, expr_t *size_is, expr_t *length_is, unsigned char ptr_default_fc) { @@ -229,7 +229,8 @@ type_t *type_new_array(const char *name, type_t *element, int declptr, t->details.array.size_is = size_is; else t->details.array.dim = dim; - t->details.array.elem.type = element; + if (element) + t->details.array.elem = *element; t->details.array.ptr_def_fc = ptr_default_fc; return t; } diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index d5f28fe590..9453e9d161 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -33,7 +33,7 @@ type_t *type_new_function(var_list_t *args); type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs); type_t *type_new_alias(type_t *t, const char *name); type_t *type_new_module(char *name); -type_t *type_new_array(const char *name, type_t *element, int declptr, +type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr, unsigned int dim, expr_t *size_is, expr_t *length_is, unsigned char ptr_default_fc); type_t *type_new_basic(enum type_basic_type basic_type);
From: Richard Pospesel richard@torproject.org
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- This supersedes https://source.winehq.org/patches/data/167615.
tools/widl/parser.y | 8 +++++--- tools/widl/typetree.c | 4 ++-- tools/widl/typetree.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/tools/widl/parser.y b/tools/widl/parser.y index b75be01077..4421b6ef71 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -1188,7 +1188,8 @@ static void decl_builtin_basic(const char *name, enum type_basic_type type)
static void decl_builtin_alias(const char *name, type_t *t) { - reg_type(type_new_alias(t, name), name, NULL, 0); + const decl_spec_t ds = {.type = t}; + reg_type(type_new_alias(&ds, name), name, NULL, 0); }
void init_types(void) @@ -1802,7 +1803,8 @@ static declarator_t *make_declarator(var_t *var)
static type_t *make_safearray(type_t *type) { - const decl_spec_t ds = {.type = type_new_alias(type, "SAFEARRAY")}; + decl_spec_t ds = {.type = type}; + ds.type = type_new_alias(&ds, "SAFEARRAY"); return type_new_array(NULL, &ds, TRUE, 0, NULL, NULL, FC_RP); }
@@ -1976,7 +1978,7 @@ static type_t *reg_typedefs(decl_spec_t *decl_spec, declarator_list_t *decls, at cur->loc_info.line_number);
name = declare_var(attrs, decl_spec, decl, 0); - cur = type_new_alias(name->declspec.type, name->name); + cur = type_new_alias(&name->declspec, name->name); cur->attrs = attrs;
if (is_incomplete(cur)) diff --git a/tools/widl/typetree.c b/tools/widl/typetree.c index 3e9ac89ad9..ef9a6699b2 100644 --- a/tools/widl/typetree.c +++ b/tools/widl/typetree.c @@ -184,13 +184,13 @@ type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t return t; }
-type_t *type_new_alias(type_t *t, const char *name) +type_t *type_new_alias(const decl_spec_t *t, const char *name) { type_t *a = make_type(TYPE_ALIAS);
a->name = xstrdup(name); a->attrs = NULL; - a->details.alias.aliasee.type = t; + a->details.alias.aliasee = *t; init_loc_info(&a->loc_info);
return a; diff --git a/tools/widl/typetree.h b/tools/widl/typetree.h index 9453e9d161..6377614999 100644 --- a/tools/widl/typetree.h +++ b/tools/widl/typetree.h @@ -31,7 +31,7 @@ enum name_type {
type_t *type_new_function(var_list_t *args); type_t *type_new_pointer(unsigned char pointer_default, type_t *ref, attr_list_t *attrs); -type_t *type_new_alias(type_t *t, const char *name); +type_t *type_new_alias(const decl_spec_t *t, const char *name); type_t *type_new_module(char *name); type_t *type_new_array(const char *name, const decl_spec_t *element, int declptr, unsigned int dim, expr_t *size_is, expr_t *length_is,