widl: Calculate method indices in parser instead of during header generation.

This commit is contained in:
Dan Hipschman 2006-08-15 14:23:18 -07:00 committed by Alexandre Julliard
parent e86828a072
commit 16d4e71230
2 changed files with 31 additions and 9 deletions

View File

@ -572,15 +572,13 @@ const var_t *is_callas(const attr_t *a)
return get_attrp(a, ATTR_CALLAS); return get_attrp(a, ATTR_CALLAS);
} }
static int write_method_macro(const type_t *iface, const char *name) static void write_method_macro(const type_t *iface, const char *name)
{ {
int idx;
func_t *cur = iface->funcs; func_t *cur = iface->funcs;
if (iface->ref) idx = write_method_macro(iface->ref, name); if (iface->ref) write_method_macro(iface->ref, name);
else idx = 0;
if (!cur) return idx; if (!cur) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur); while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
fprintf(header, "/*** %s methods ***/\n", iface->name); fprintf(header, "/*** %s methods ***/\n", iface->name);
@ -608,13 +606,9 @@ static int write_method_macro(const type_t *iface, const char *name)
for (c=0; c<argc; c++) for (c=0; c<argc; c++)
fprintf(header, ",%c", c+'a'); fprintf(header, ",%c", c+'a');
fprintf(header, ")\n"); fprintf(header, ")\n");
if (cur->idx == -1) cur->idx = idx;
else if (cur->idx != idx) yyerror("BUG: method index mismatch in write_method_macro");
idx++;
} }
cur = PREV_LINK(cur); cur = PREV_LINK(cur);
} }
return idx;
} }
void write_args(FILE *h, var_t *arg, const char *name, int method, int do_indent) void write_args(FILE *h, var_t *arg, const char *name, int method, int do_indent)

View File

@ -101,6 +101,8 @@ static void write_clsid(type_t *cls);
static void write_diid(type_t *iface); static void write_diid(type_t *iface);
static void write_iid(type_t *iface); static void write_iid(type_t *iface);
static int compute_method_indexes(type_t *iface);
#define tsENUM 1 #define tsENUM 1
#define tsSTRUCT 2 #define tsSTRUCT 2
#define tsUNION 3 #define tsUNION 3
@ -711,6 +713,7 @@ dispinterfacedef: dispinterfacehdr '{'
} }
/* FIXME: not sure how to handle this yet /* FIXME: not sure how to handle this yet
| dispinterfacehdr '{' interface '}' { $$ = $1; | dispinterfacehdr '{' interface '}' { $$ = $1;
compute_method_indexes($$);
if (!parse_only && do_header) write_interface($$); if (!parse_only && do_header) write_interface($$);
if (!parse_only && do_idfile) write_iid($$); if (!parse_only && do_idfile) write_iid($$);
} }
@ -737,6 +740,7 @@ interfacedef: interfacehdr inherit
'{' int_statements '}' { $$ = $1; '{' int_statements '}' { $$ = $1;
$$->ref = $2; $$->ref = $2;
$$->funcs = $4; $$->funcs = $4;
compute_method_indexes($$);
if (!parse_only && do_header) write_interface($$); if (!parse_only && do_header) write_interface($$);
if (!parse_only && do_idfile) write_iid($$); if (!parse_only && do_idfile) write_iid($$);
} }
@ -747,6 +751,7 @@ interfacedef: interfacehdr inherit
$$->ref = find_type2($3, 0); $$->ref = find_type2($3, 0);
if (!$$->ref) yyerror("base class '%s' not found in import", $3); if (!$$->ref) yyerror("base class '%s' not found in import", $3);
$$->funcs = $6; $$->funcs = $6;
compute_method_indexes($$);
if (!parse_only && do_header) write_interface($$); if (!parse_only && do_header) write_interface($$);
if (!parse_only && do_idfile) write_iid($$); if (!parse_only && do_idfile) write_iid($$);
} }
@ -1539,3 +1544,26 @@ static void write_iid(type_t *iface)
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID); const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
write_guid(idfile, "IID", iface->name, uuid); write_guid(idfile, "IID", iface->name, uuid);
} }
static int compute_method_indexes(type_t *iface)
{
int idx;
func_t *f = iface->funcs;
if (iface->ref)
idx = compute_method_indexes(iface->ref);
else
idx = 0;
if (! f)
return idx;
while (NEXT_LINK(f))
f = NEXT_LINK(f);
for ( ; f ; f = PREV_LINK(f))
if (! is_callas(f->def->attrs))
f->idx = idx++;
return idx;
}