Commit d676d3be authored by Dan Hipschman's avatar Dan Hipschman Committed by Alexandre Julliard

widl: Get rid of the tname field of var_t, simplify code.

parent 1ecbb016
...@@ -113,7 +113,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig ...@@ -113,7 +113,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig
} }
} }
write_type(client, def->type, def, def->tname); write_type(client, def->type, def);
fprintf(client, " "); fprintf(client, " ");
write_prefix_name(client, prefix_client, def); write_prefix_name(client, prefix_client, def);
fprintf(client, "(\n"); fprintf(client, "(\n");
...@@ -133,7 +133,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig ...@@ -133,7 +133,7 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig
if (!is_void(def->type, NULL)) if (!is_void(def->type, NULL))
{ {
print_client(""); print_client("");
write_type(client, def->type, def, def->tname); write_type(client, def->type, def);
fprintf(client, " _RetVal;\n"); fprintf(client, " _RetVal;\n");
} }
......
...@@ -159,7 +159,7 @@ static void write_field(FILE *h, var_t *v) ...@@ -159,7 +159,7 @@ static void write_field(FILE *h, var_t *v)
if (!v) return; if (!v) return;
if (v->type) { if (v->type) {
indent(h, 0); indent(h, 0);
write_type(h, v->type, NULL, v->tname); write_type(h, v->type, NULL);
if (get_name(v)) { if (get_name(v)) {
fprintf(h, " "); fprintf(h, " ");
write_pident(h, v); write_pident(h, v);
...@@ -220,14 +220,13 @@ static int needs_space_after(type_t *t) ...@@ -220,14 +220,13 @@ static int needs_space_after(type_t *t)
return t->kind == TKIND_ALIAS || ! is_ptr(t); return t->kind == TKIND_ALIAS || ! is_ptr(t);
} }
void write_type(FILE *h, type_t *t, const var_t *v, const char *n) void write_type(FILE *h, type_t *t, const var_t *v)
{ {
int c; int c;
if (t->is_const) fprintf(h, "const "); if (t->is_const) fprintf(h, "const ");
if (n) fprintf(h, "%s", n); if (t->kind == TKIND_ALIAS) fprintf(h, "%s", t->name);
else if (t->kind == TKIND_ALIAS) fprintf(h, "%s", t->name);
else { else {
if (t->sign > 0) fprintf(h, "signed "); if (t->sign > 0) fprintf(h, "signed ");
else if (t->sign < 0) fprintf(h, "unsigned "); else if (t->sign < 0) fprintf(h, "unsigned ");
...@@ -279,7 +278,7 @@ void write_type(FILE *h, type_t *t, const var_t *v, const char *n) ...@@ -279,7 +278,7 @@ void write_type(FILE *h, type_t *t, const var_t *v, const char *n)
case RPC_FC_UP: case RPC_FC_UP:
case RPC_FC_FP: case RPC_FC_FP:
case RPC_FC_OP: case RPC_FC_OP:
if (t->ref) write_type(h, t->ref, NULL, t->name); if (t->ref) write_type(h, t->ref, NULL);
fprintf(h, "%s*", needs_space_after(t->ref) ? " " : ""); fprintf(h, "%s*", needs_space_after(t->ref) ? " " : "");
break; break;
default: default:
...@@ -359,7 +358,7 @@ void write_user_types(void) ...@@ -359,7 +358,7 @@ void write_user_types(void)
void write_typedef(type_t *type) void write_typedef(type_t *type)
{ {
fprintf(header, "typedef "); fprintf(header, "typedef ");
write_type(header, type->orig, NULL, NULL); write_type(header, type->orig, NULL);
fprintf(header, "%s%s;\n", needs_space_after(type->orig) ? " " : "", type->name); fprintf(header, "%s%s;\n", needs_space_after(type->orig) ? " " : "", type->name);
} }
...@@ -397,13 +396,13 @@ void write_expr(FILE *h, const expr_t *e, int brackets) ...@@ -397,13 +396,13 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
break; break;
case EXPR_CAST: case EXPR_CAST:
fprintf(h, "("); fprintf(h, "(");
write_type(h, e->u.tref, NULL, e->u.tref->name); write_type(h, e->u.tref, NULL);
fprintf(h, ")"); fprintf(h, ")");
write_expr(h, e->ref, 1); write_expr(h, e->ref, 1);
break; break;
case EXPR_SIZEOF: case EXPR_SIZEOF:
fprintf(h, "sizeof("); fprintf(h, "sizeof(");
write_type(h, e->u.tref, NULL, e->u.tref->name); write_type(h, e->u.tref, NULL);
fprintf(h, ")"); fprintf(h, ")");
break; break;
case EXPR_SHL: case EXPR_SHL:
...@@ -452,7 +451,7 @@ void write_constdef(const var_t *v) ...@@ -452,7 +451,7 @@ void write_constdef(const var_t *v)
void write_externdef(const var_t *v) void write_externdef(const var_t *v)
{ {
fprintf(header, "extern const "); fprintf(header, "extern const ");
write_type(header, v->type, NULL, v->tname); write_type(header, v->type, NULL);
if (get_name(v)) { if (get_name(v)) {
fprintf(header, " "); fprintf(header, " ");
write_pident(header, v); write_pident(header, v);
...@@ -580,7 +579,7 @@ void write_args(FILE *h, const var_list_t *args, const char *name, int method, i ...@@ -580,7 +579,7 @@ void write_args(FILE *h, const var_list_t *args, const char *name, int method, i
} }
else fprintf(h, ","); else fprintf(h, ",");
} }
write_type(h, arg->type, arg, arg->tname); write_type(h, arg->type, arg);
if (arg->args) if (arg->args)
{ {
fprintf(h, " (STDMETHODCALLTYPE *"); fprintf(h, " (STDMETHODCALLTYPE *");
...@@ -613,7 +612,7 @@ static void write_cpp_method_def(const type_t *iface) ...@@ -613,7 +612,7 @@ static void write_cpp_method_def(const type_t *iface)
if (!is_callas(def->attrs)) { if (!is_callas(def->attrs)) {
indent(header, 0); indent(header, 0);
fprintf(header, "virtual "); fprintf(header, "virtual ");
write_type(header, def->type, def, def->tname); write_type(header, def->type, def);
fprintf(header, " STDMETHODCALLTYPE "); fprintf(header, " STDMETHODCALLTYPE ");
write_name(header, def); write_name(header, def);
fprintf(header, "(\n"); fprintf(header, "(\n");
...@@ -638,7 +637,7 @@ static void do_write_c_method_def(const type_t *iface, const char *name) ...@@ -638,7 +637,7 @@ static void do_write_c_method_def(const type_t *iface, const char *name)
const var_t *def = cur->def; const var_t *def = cur->def;
if (!is_callas(def->attrs)) { if (!is_callas(def->attrs)) {
indent(header, 0); indent(header, 0);
write_type(header, def->type, def, def->tname); write_type(header, def->type, def);
fprintf(header, " (STDMETHODCALLTYPE *"); fprintf(header, " (STDMETHODCALLTYPE *");
write_name(header, def); write_name(header, def);
fprintf(header, ")(\n"); fprintf(header, ")(\n");
...@@ -671,7 +670,7 @@ static void write_method_proto(const type_t *iface) ...@@ -671,7 +670,7 @@ static void write_method_proto(const type_t *iface)
if (!is_local(def->attrs)) { if (!is_local(def->attrs)) {
/* proxy prototype */ /* proxy prototype */
write_type(header, def->type, def, def->tname); write_type(header, def->type, def);
fprintf(header, " CALLBACK %s_", iface->name); fprintf(header, " CALLBACK %s_", iface->name);
write_name(header, def); write_name(header, def);
fprintf(header, "_Proxy(\n"); fprintf(header, "_Proxy(\n");
...@@ -694,14 +693,14 @@ static void write_method_proto(const type_t *iface) ...@@ -694,14 +693,14 @@ static void write_method_proto(const type_t *iface)
if (&m->entry != iface->funcs) { if (&m->entry != iface->funcs) {
const var_t *mdef = m->def; const var_t *mdef = m->def;
/* proxy prototype - use local prototype */ /* proxy prototype - use local prototype */
write_type(header, mdef->type, mdef, mdef->tname); write_type(header, mdef->type, mdef);
fprintf(header, " CALLBACK %s_", iface->name); fprintf(header, " CALLBACK %s_", iface->name);
write_name(header, mdef); write_name(header, mdef);
fprintf(header, "_Proxy(\n"); fprintf(header, "_Proxy(\n");
write_args(header, m->args, iface->name, 1, TRUE); write_args(header, m->args, iface->name, 1, TRUE);
fprintf(header, ");\n"); fprintf(header, ");\n");
/* stub prototype - use remotable prototype */ /* stub prototype - use remotable prototype */
write_type(header, def->type, def, def->tname); write_type(header, def->type, def);
fprintf(header, " __RPC_STUB %s_", iface->name); fprintf(header, " __RPC_STUB %s_", iface->name);
write_name(header, mdef); write_name(header, mdef);
fprintf(header, "_Stub(\n"); fprintf(header, "_Stub(\n");
...@@ -720,7 +719,7 @@ static void write_function_proto(const type_t *iface, const func_t *fun, const c ...@@ -720,7 +719,7 @@ static void write_function_proto(const type_t *iface, const func_t *fun, const c
var_t *def = fun->def; var_t *def = fun->def;
/* FIXME: do we need to handle call_as? */ /* FIXME: do we need to handle call_as? */
write_type(header, def->type, def, def->tname); write_type(header, def->type, def);
fprintf(header, " "); fprintf(header, " ");
write_prefix_name(header, prefix, def); write_prefix_name(header, prefix, def);
fprintf(header, "(\n"); fprintf(header, "(\n");
......
...@@ -30,7 +30,7 @@ extern int is_non_void(const expr_list_t *list); ...@@ -30,7 +30,7 @@ extern int is_non_void(const expr_list_t *list);
extern void write_name(FILE *h, const var_t *v); extern void write_name(FILE *h, const var_t *v);
extern void write_prefix_name(FILE *h, const char *prefix, const var_t *v); extern void write_prefix_name(FILE *h, const char *prefix, const var_t *v);
extern const char* get_name(const var_t *v); extern const char* get_name(const var_t *v);
extern void write_type(FILE *h, type_t *t, const var_t *v, const char *n); extern void write_type(FILE *h, type_t *t, const var_t *v);
extern int is_object(const attr_list_t *list); extern int is_object(const attr_list_t *list);
extern int is_local(const attr_list_t *list); extern int is_local(const attr_list_t *list);
extern const var_t *is_callas(const attr_list_t *list); extern const var_t *is_callas(const attr_list_t *list);
......
...@@ -297,12 +297,12 @@ int_statements: { $$ = NULL; } ...@@ -297,12 +297,12 @@ int_statements: { $$ = NULL; }
statement: ';' {} statement: ';' {}
| constdef ';' { if (!parse_only && do_header) { write_constdef($1); } } | constdef ';' { if (!parse_only && do_header) { write_constdef($1); } }
| cppquote {} | cppquote {}
| enumdef ';' { if (!parse_only && do_header) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } } | enumdef ';' { if (!parse_only && do_header) { write_type(header, $1, NULL); fprintf(header, ";\n\n"); } }
| externdef ';' { if (!parse_only && do_header) { write_externdef($1); } } | externdef ';' { if (!parse_only && do_header) { write_externdef($1); } }
| import {} | import {}
| structdef ';' { if (!parse_only && do_header) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } } | structdef ';' { if (!parse_only && do_header) { write_type(header, $1, NULL); fprintf(header, ";\n\n"); } }
| typedef ';' {} | typedef ';' {}
| uniondef ';' { if (!parse_only && do_header) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } } | uniondef ';' { if (!parse_only && do_header) { write_type(header, $1, NULL); fprintf(header, ";\n\n"); } }
; ;
cppquote: tCPPQUOTE '(' aSTRING ')' { if (!parse_only && do_header) fprintf(header, "%s\n", $3); } cppquote: tCPPQUOTE '(' aSTRING ')' { if (!parse_only && do_header) fprintf(header, "%s\n", $3); }
...@@ -1240,7 +1240,6 @@ static var_t *make_var(char *name) ...@@ -1240,7 +1240,6 @@ static var_t *make_var(char *name)
v->ptr_level = 0; v->ptr_level = 0;
v->type = NULL; v->type = NULL;
v->args = NULL; v->args = NULL;
v->tname = NULL;
v->attrs = NULL; v->attrs = NULL;
v->array = NULL; v->array = NULL;
v->eval = NULL; v->eval = NULL;
......
...@@ -264,7 +264,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, ...@@ -264,7 +264,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
unsigned int offset; unsigned int offset;
indent = 0; indent = 0;
write_type(proxy, def->type, def, def->tname); write_type(proxy, def->type, def);
print_proxy( " STDMETHODCALLTYPE %s_", iface->name); print_proxy( " STDMETHODCALLTYPE %s_", iface->name);
write_name(proxy, def); write_name(proxy, def);
print_proxy( "_Proxy(\n"); print_proxy( "_Proxy(\n");
...@@ -275,7 +275,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx, ...@@ -275,7 +275,7 @@ static void gen_proxy(type_t *iface, const func_t *cur, int idx,
/* local variables */ /* local variables */
if (has_ret) { if (has_ret) {
print_proxy( "" ); print_proxy( "" );
write_type(proxy, def->type, def, def->tname); write_type(proxy, def->type, def);
print_proxy( " _RetVal;\n"); print_proxy( " _RetVal;\n");
} }
print_proxy( "RPC_MESSAGE _RpcMessage;\n" ); print_proxy( "RPC_MESSAGE _RpcMessage;\n" );
......
...@@ -1842,7 +1842,7 @@ void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, ...@@ -1842,7 +1842,7 @@ void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase,
if (phase == PHASE_MARSHAL) if (phase == PHASE_MARSHAL)
{ {
print_file(file, indent, "*("); print_file(file, indent, "*(");
write_type(file, var->type, NULL, var->tname); write_type(file, var->type, NULL);
if (var->ptr_level) if (var->ptr_level)
fprintf(file, " *)_StubMsg.Buffer = *"); fprintf(file, " *)_StubMsg.Buffer = *");
else else
...@@ -1861,12 +1861,12 @@ void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, ...@@ -1861,12 +1861,12 @@ void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase,
fprintf(file, " = ("); fprintf(file, " = (");
else else
fprintf(file, " = *("); fprintf(file, " = *(");
write_type(file, var->type, NULL, var->tname); write_type(file, var->type, NULL);
fprintf(file, " *)_StubMsg.Buffer;\n"); fprintf(file, " *)_StubMsg.Buffer;\n");
} }
print_file(file, indent, "_StubMsg.Buffer += sizeof("); print_file(file, indent, "_StubMsg.Buffer += sizeof(");
write_type(file, var->type, NULL, var->tname); write_type(file, var->type, NULL);
fprintf(file, ");\n"); fprintf(file, ");\n");
} }
...@@ -2214,13 +2214,13 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets, ...@@ -2214,13 +2214,13 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
break; break;
case EXPR_CAST: case EXPR_CAST:
fprintf(h, "("); fprintf(h, "(");
write_type(h, e->u.tref, NULL, e->u.tref->name); write_type(h, e->u.tref, NULL);
fprintf(h, ")"); fprintf(h, ")");
write_struct_expr(h, e->ref, 1, fields, structvar); write_struct_expr(h, e->ref, 1, fields, structvar);
break; break;
case EXPR_SIZEOF: case EXPR_SIZEOF:
fprintf(h, "sizeof("); fprintf(h, "sizeof(");
write_type(h, e->u.tref, NULL, e->u.tref->name); write_type(h, e->u.tref, NULL);
fprintf(h, ")"); fprintf(h, ")");
break; break;
case EXPR_SHL: case EXPR_SHL:
...@@ -2271,7 +2271,7 @@ void declare_stub_args( FILE *file, int indent, const func_t *func ) ...@@ -2271,7 +2271,7 @@ void declare_stub_args( FILE *file, int indent, const func_t *func )
if (!is_void(def->type, NULL)) if (!is_void(def->type, NULL))
{ {
print_file(file, indent, ""); print_file(file, indent, "");
write_type(file, def->type, def, def->tname); write_type(file, def->type, def);
fprintf(file, " _RetVal;\n"); fprintf(file, " _RetVal;\n");
} }
...@@ -2293,14 +2293,14 @@ void declare_stub_args( FILE *file, int indent, const func_t *func ) ...@@ -2293,14 +2293,14 @@ void declare_stub_args( FILE *file, int indent, const func_t *func )
{ {
int indirection; int indirection;
print_file(file, indent, ""); print_file(file, indent, "");
write_type(file, var->type, NULL, var->tname); write_type(file, var->type, NULL);
for (indirection = 0; indirection < var->ptr_level - 1; indirection++) for (indirection = 0; indirection < var->ptr_level - 1; indirection++)
fprintf(file, "*"); fprintf(file, "*");
fprintf(file, " _W%u;\n", i++); fprintf(file, " _W%u;\n", i++);
} }
print_file(file, indent, ""); print_file(file, indent, "");
write_type(file, var->type, var, var->tname); write_type(file, var->type, var);
fprintf(file, " "); fprintf(file, " ");
if (var->array) { if (var->array) {
fprintf(file, "( *"); fprintf(file, "( *");
......
...@@ -215,10 +215,11 @@ unsigned short get_type_vt(type_t *t) ...@@ -215,10 +215,11 @@ unsigned short get_type_vt(type_t *t)
unsigned short get_var_vt(var_t *v) unsigned short get_var_vt(var_t *v)
{ {
unsigned short vt; unsigned short vt;
const char *tname = v->type->name;
chat("get_var_vt: %p tname %s\n", v, v->tname); chat("get_var_vt: var %p type->name %s\n", v, tname ? tname : "NULL");
if (v->tname) { if (tname) {
vt = builtin_vt(v->tname); vt = builtin_vt(tname);
if (vt) return vt; if (vt) return vt;
} }
......
...@@ -216,7 +216,6 @@ struct _var_t { ...@@ -216,7 +216,6 @@ struct _var_t {
array_dims_t *array; array_dims_t *array;
type_t *type; type_t *type;
var_list_t *args; /* for function pointers */ var_list_t *args; /* for function pointers */
const char *tname;
attr_list_t *attrs; attr_list_t *attrs;
expr_t *eval; expr_t *eval;
......
...@@ -1068,7 +1068,8 @@ static int encode_var( ...@@ -1068,7 +1068,8 @@ static int encode_var(
if (!decoded_size) decoded_size = &scratch; if (!decoded_size) decoded_size = &scratch;
*decoded_size = 0; *decoded_size = 0;
chat("encode_var: var %p var->tname %s var->type %p var->ptr_level %d var->type->ref %p\n", var, var->tname, var->type, var->ptr_level, var->type->ref); chat("encode_var: var %p var->type %p var->type->name %s var->ptr_level %d var->type->ref %p\n",
var, var->type, var->type->name ? var->type->name : "NULL", var->ptr_level, var->type->ref);
if(var->ptr_level) { if(var->ptr_level) {
int skip_ptr; int skip_ptr;
var->ptr_level--; var->ptr_level--;
......
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