widl: Convert function lists to standard Wine lists.

This commit is contained in:
Alexandre Julliard 2007-01-22 14:23:08 +01:00
parent e262933bdf
commit 58827d026b
8 changed files with 103 additions and 127 deletions

View File

@ -107,14 +107,13 @@ static void check_pointers(const func_t *func)
static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsigned int *type_offset) static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsigned int *type_offset)
{ {
const func_t *func = iface->funcs; const func_t *func;
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE); const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE); int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
var_t *var; var_t *var;
int method_count = 0; int method_count = 0;
while (NEXT_LINK(func)) func = NEXT_LINK(func); if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
while (func)
{ {
const var_t *def = func->def; const var_t *def = func->def;
const var_t* explicit_handle_var; const var_t* explicit_handle_var;
@ -301,7 +300,6 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig
fprintf(client, "\n"); fprintf(client, "\n");
method_count++; method_count++;
func = PREV_LINK(func);
} }
} }

View File

@ -514,15 +514,15 @@ const var_t *is_callas(const attr_list_t *a)
static void write_method_macro(const type_t *iface, const char *name) static void write_method_macro(const type_t *iface, const char *name)
{ {
func_t *cur = iface->funcs; const func_t *cur;
if (iface->ref) write_method_macro(iface->ref, name); if (iface->ref) write_method_macro(iface->ref, name);
if (!cur) return; if (!iface->funcs) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
fprintf(header, "/*** %s methods ***/\n", iface->name); fprintf(header, "/*** %s methods ***/\n", iface->name);
while (cur) { LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
{
var_t *def = cur->def; var_t *def = cur->def;
if (!is_callas(def->attrs)) { if (!is_callas(def->attrs)) {
var_t *arg = cur->args; var_t *arg = cur->args;
@ -547,7 +547,6 @@ static void write_method_macro(const type_t *iface, const char *name)
fprintf(header, ",%c", c+'a'); fprintf(header, ",%c", c+'a');
fprintf(header, ")\n"); fprintf(header, ")\n");
} }
cur = PREV_LINK(cur);
} }
} }
@ -600,11 +599,12 @@ void write_args(FILE *h, var_t *arg, const char *name, int method, int do_indent
static void write_cpp_method_def(const type_t *iface) static void write_cpp_method_def(const type_t *iface)
{ {
func_t *cur = iface->funcs; const func_t *cur;
if (!cur) return; if (!iface->funcs) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
while (cur) { LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
{
var_t *def = cur->def; var_t *def = cur->def;
if (!is_callas(def->attrs)) { if (!is_callas(def->attrs)) {
indent(header, 0); indent(header, 0);
@ -617,21 +617,20 @@ static void write_cpp_method_def(const type_t *iface)
fprintf(header, ") = 0;\n"); fprintf(header, ") = 0;\n");
fprintf(header, "\n"); fprintf(header, "\n");
} }
cur = PREV_LINK(cur);
} }
} }
static void do_write_c_method_def(const type_t *iface, const char *name) static void do_write_c_method_def(const type_t *iface, const char *name)
{ {
const func_t *cur = iface->funcs; const func_t *cur;
if (iface->ref) do_write_c_method_def(iface->ref, name); if (iface->ref) do_write_c_method_def(iface->ref, name);
if (!cur) return; if (!iface->funcs) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur);
indent(header, 0); indent(header, 0);
fprintf(header, "/*** %s methods ***/\n", iface->name); fprintf(header, "/*** %s methods ***/\n", iface->name);
while (cur) { LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
{
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);
@ -643,7 +642,6 @@ static void do_write_c_method_def(const type_t *iface, const char *name)
fprintf(header, ");\n"); fprintf(header, ");\n");
fprintf(header, "\n"); fprintf(header, "\n");
} }
cur = PREV_LINK(cur);
} }
} }
@ -659,11 +657,11 @@ static void write_c_disp_method_def(const type_t *iface)
static void write_method_proto(const type_t *iface) static void write_method_proto(const type_t *iface)
{ {
const func_t *cur = iface->funcs; const func_t *cur;
if (!cur) return; if (!iface->funcs) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur); LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
while (cur) { {
const var_t *def = cur->def; const var_t *def = cur->def;
const var_t *cas = is_callas(def->attrs); const var_t *cas = is_callas(def->attrs);
const var_t *args; const var_t *args;
@ -692,10 +690,10 @@ static void write_method_proto(const type_t *iface)
check_for_user_types(args); check_for_user_types(args);
} }
if (cas) { if (cas) {
const func_t *m = iface->funcs; const func_t *m;
while (m && strcmp(get_name(m->def), cas->name)) LIST_FOR_EACH_ENTRY( m, iface->funcs, const func_t, entry )
m = NEXT_LINK(m); if (!strcmp(get_name(m->def), cas->name)) break;
if (m) { 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, mdef->tname);
@ -716,8 +714,6 @@ static void write_method_proto(const type_t *iface)
parser_warning("invalid call_as attribute (%s -> %s)\n", get_name(def), cas->name); parser_warning("invalid call_as attribute (%s -> %s)\n", get_name(def), cas->name);
} }
} }
cur = PREV_LINK(cur);
} }
} }
@ -726,10 +722,11 @@ static void write_function_proto(const type_t *iface)
const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE); const char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE); int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
const var_t* explicit_handle_var; const var_t* explicit_handle_var;
const func_t *cur;
func_t *cur = iface->funcs; if (!iface->funcs) return;
while (NEXT_LINK(cur)) cur = NEXT_LINK(cur); LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
while (cur) { {
var_t *def = cur->def; var_t *def = cur->def;
/* check for a defined binding handle */ /* check for a defined binding handle */
@ -756,8 +753,6 @@ static void write_function_proto(const type_t *iface)
else else
fprintf(header, " void"); fprintf(header, " void");
fprintf(header, ");\n"); fprintf(header, ");\n");
cur = PREV_LINK(cur);
} }
} }

View File

@ -83,6 +83,7 @@ static void set_type(var_t *v, typeref_t *ref, expr_t *arr);
static ifref_list_t *append_ifref(ifref_list_t *list, ifref_t *iface); static ifref_list_t *append_ifref(ifref_list_t *list, ifref_t *iface);
static ifref_t *make_ifref(type_t *iface); static ifref_t *make_ifref(type_t *iface);
static var_t *make_var(char *name); static var_t *make_var(char *name);
static func_list_t *append_func(func_list_t *list, func_t *func);
static func_t *make_func(var_t *def, var_t *args); static func_t *make_func(var_t *def, var_t *args);
static type_t *make_class(char *name); static type_t *make_class(char *name);
static type_t *make_safearray(void); static type_t *make_safearray(void);
@ -123,6 +124,7 @@ static void check_arg(var_t *arg);
typeref_t *tref; typeref_t *tref;
var_t *var; var_t *var;
func_t *func; func_t *func;
func_list_t *func_list;
ifref_t *ifref; ifref_t *ifref;
ifref_list_t *ifref_list; ifref_list_t *ifref_list;
char *str; char *str;
@ -229,8 +231,8 @@ static void check_arg(var_t *arg);
%type <var> fields field s_field cases case enums enum_list enum constdef externdef %type <var> fields field s_field cases case enums enum_list enum constdef externdef
%type <var> m_ident t_ident ident p_ident pident pident_list %type <var> m_ident t_ident ident p_ident pident pident_list
%type <var> dispint_props %type <var> dispint_props
%type <func> funcdef int_statements %type <func> funcdef
%type <func> dispint_meths %type <func_list> int_statements dispint_meths
%type <type> coclass coclasshdr coclassdef %type <type> coclass coclasshdr coclassdef
%type <num> pointer_type version %type <num> pointer_type version
%type <str> libraryhdr %type <str> libraryhdr
@ -283,7 +285,7 @@ imp_statements: {}
; ;
int_statements: { $$ = NULL; } int_statements: { $$ = NULL; }
| int_statements funcdef ';' { $$ = $2; LINK($$, $1); } | int_statements funcdef ';' { $$ = append_func( $1, $2 ); }
| int_statements statement { $$ = $1; } | int_statements statement { $$ = $1; }
; ;
@ -704,7 +706,7 @@ dispint_props: tPROPERTIES ':' { $$ = NULL; }
; ;
dispint_meths: tMETHODS ':' { $$ = NULL; } dispint_meths: tMETHODS ':' { $$ = NULL; }
| dispint_meths funcdef ';' { LINK($2, $1); $$ = $2; } | dispint_meths funcdef ';' { $$ = append_func( $1, $2 ); }
; ;
dispinterfacedef: dispinterfacehdr '{' dispinterfacedef: dispinterfacehdr '{'
@ -1238,6 +1240,18 @@ static var_t *make_var(char *name)
return v; return v;
} }
static func_list_t *append_func(func_list_t *list, func_t *func)
{
if (!func) return list;
if (!list)
{
list = xmalloc( sizeof(*list) );
list_init( list );
}
list_add_tail( list, &func->entry );
return list;
}
static func_t *make_func(var_t *def, var_t *args) static func_t *make_func(var_t *def, var_t *args)
{ {
func_t *f = xmalloc(sizeof(func_t)); func_t *f = xmalloc(sizeof(func_t));
@ -1245,7 +1259,6 @@ static func_t *make_func(var_t *def, var_t *args)
f->args = args; f->args = args;
f->ignore = parse_only; f->ignore = parse_only;
f->idx = -1; f->idx = -1;
INIT_LINK(f);
return f; return f;
} }
@ -1634,20 +1647,17 @@ static void write_iid(type_t *iface)
static int compute_method_indexes(type_t *iface) static int compute_method_indexes(type_t *iface)
{ {
int idx; int idx;
func_t *f = iface->funcs; func_t *f;
if (iface->ref) if (iface->ref)
idx = compute_method_indexes(iface->ref); idx = compute_method_indexes(iface->ref);
else else
idx = 0; idx = 0;
if (! f) if (!iface->funcs)
return idx; return idx;
while (NEXT_LINK(f)) LIST_FOR_EACH_ENTRY( f, iface->funcs, func_t, entry )
f = NEXT_LINK(f);
for ( ; f ; f = PREV_LINK(f))
if (! is_callas(f->def->attrs)) if (! is_callas(f->def->attrs))
f->idx = idx++; f->idx = idx++;

View File

@ -576,7 +576,7 @@ static void proxy_free_variables( var_t *arg )
} }
} }
static void gen_proxy(type_t *iface, func_t *cur, int idx) static void gen_proxy(type_t *iface, const func_t *cur, int idx)
{ {
var_t *def = cur->def; var_t *def = cur->def;
int has_ret = !is_void(def->type, def); int has_ret = !is_void(def->type, def);
@ -762,7 +762,7 @@ static void stub_genmarshall( var_t *args )
stub_gen_marshall_copydata( args ); stub_gen_marshall_copydata( args );
} }
static void gen_stub(type_t *iface, func_t *cur, const char *cas) static void gen_stub(type_t *iface, const func_t *cur, const char *cas)
{ {
var_t *def = cur->def; var_t *def = cur->def;
var_t *arg; var_t *arg;
@ -865,13 +865,11 @@ static void gen_stub(type_t *iface, func_t *cur, const char *cas)
static int write_proxy_methods(type_t *iface) static int write_proxy_methods(type_t *iface)
{ {
func_t *cur = iface->funcs; const func_t *cur;
int i = 0; int i = 0;
END_OF_LIST(cur);
if (iface->ref) i = write_proxy_methods(iface->ref); if (iface->ref) i = write_proxy_methods(iface->ref);
while (cur) { if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
var_t *def = cur->def; var_t *def = cur->def;
if (!is_callas(def->attrs)) { if (!is_callas(def->attrs)) {
if (i) fprintf(proxy, ",\n"); if (i) fprintf(proxy, ",\n");
@ -880,21 +878,19 @@ static int write_proxy_methods(type_t *iface)
fprintf(proxy, "_Proxy"); fprintf(proxy, "_Proxy");
i++; i++;
} }
cur = PREV_LINK(cur);
} }
return i; return i;
} }
static int write_stub_methods(type_t *iface) static int write_stub_methods(type_t *iface)
{ {
func_t *cur = iface->funcs; const func_t *cur;
int i = 0; int i = 0;
END_OF_LIST(cur);
if (iface->ref) i = write_stub_methods(iface->ref); if (iface->ref) i = write_stub_methods(iface->ref);
else return i; /* skip IUnknown */ else return i; /* skip IUnknown */
while (cur) {
if (iface->funcs) LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry ) {
var_t *def = cur->def; var_t *def = cur->def;
if (!is_local(def->attrs)) { if (!is_local(def->attrs)) {
if (i) fprintf(proxy,",\n"); if (i) fprintf(proxy,",\n");
@ -903,7 +899,6 @@ static int write_stub_methods(type_t *iface)
fprintf(proxy, "_Stub"); fprintf(proxy, "_Stub");
i++; i++;
} }
cur = PREV_LINK(cur);
} }
return i; return i;
} }
@ -911,28 +906,30 @@ static int write_stub_methods(type_t *iface)
static void write_proxy(type_t *iface) static void write_proxy(type_t *iface)
{ {
int midx = -1, stubs; int midx = -1, stubs;
func_t *cur = iface->funcs; const func_t *cur;
if (!cur) return; if (!iface->funcs) return;
END_OF_LIST(cur);
/* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */ /* FIXME: check for [oleautomation], shouldn't generate proxies/stubs if specified */
fprintf(proxy, "/*****************************************************************************\n"); fprintf(proxy, "/*****************************************************************************\n");
fprintf(proxy, " * %s interface\n", iface->name); fprintf(proxy, " * %s interface\n", iface->name);
fprintf(proxy, " */\n"); fprintf(proxy, " */\n");
while (cur) { LIST_FOR_EACH_ENTRY( cur, iface->funcs, const func_t, entry )
{
const var_t *def = cur->def; const var_t *def = cur->def;
if (!is_local(def->attrs)) { if (!is_local(def->attrs)) {
const var_t *cas = is_callas(def->attrs); const var_t *cas = is_callas(def->attrs);
const char *cname = cas ? cas->name : NULL; const char *cname = cas ? cas->name : NULL;
int idx = cur->idx; int idx = cur->idx;
if (cname) { if (cname) {
const func_t *m = iface->funcs; const func_t *m;
while (m && strcmp(get_name(m->def), cname)) LIST_FOR_EACH_ENTRY( m, iface->funcs, const func_t, entry )
m = NEXT_LINK(m); if (!strcmp(get_name(m->def), cname))
idx = m->idx; {
idx = m->idx;
break;
}
} }
gen_proxy(iface, cur, idx); gen_proxy(iface, cur, idx);
gen_stub(iface, cur, cname); gen_stub(iface, cur, cname);
@ -940,7 +937,6 @@ static void write_proxy(type_t *iface)
else if (midx != idx) parser_error("method index mismatch in write_proxy"); else if (midx != idx) parser_error("method index mismatch in write_proxy");
midx++; midx++;
} }
cur = PREV_LINK(cur);
} }
/* proxy vtable */ /* proxy vtable */

View File

@ -186,12 +186,12 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig
{ {
char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE); char *implicit_handle = get_attrp(iface->attrs, ATTR_IMPLICIT_HANDLE);
int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE); int explicit_handle = is_attr(iface->attrs, ATTR_EXPLICIT_HANDLE);
const func_t *func = iface->funcs; const func_t *func;
const var_t *var; const var_t *var;
const var_t* explicit_handle_var; const var_t* explicit_handle_var;
while (NEXT_LINK(func)) func = NEXT_LINK(func); if (!iface->funcs) return;
while (func) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
{ {
const var_t *def = func->def; const var_t *def = func->def;
unsigned long buffer_size = 0; unsigned long buffer_size = 0;
@ -429,8 +429,6 @@ static void write_function_stubs(type_t *iface, unsigned int *proc_offset, unsig
*proc_offset += get_size_procformatstring_var(def); *proc_offset += get_size_procformatstring_var(def);
else else
*proc_offset += 2; /* FC_END and FC_PAD */ *proc_offset += 2; /* FC_END and FC_PAD */
func = PREV_LINK(func);
} }
} }
@ -439,13 +437,13 @@ static void write_dispatchtable(type_t *iface)
{ {
unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION); unsigned long ver = get_attrv(iface->attrs, ATTR_VERSION);
unsigned long method_count = 0; unsigned long method_count = 0;
func_t *func = iface->funcs; const func_t *func;
print_server("static RPC_DISPATCH_FUNCTION %s_table[] =\n", iface->name); print_server("static RPC_DISPATCH_FUNCTION %s_table[] =\n", iface->name);
print_server("{\n"); print_server("{\n");
indent++; indent++;
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func) if (iface->funcs) LIST_FOR_EACH_ENTRY( func, iface->funcs, const func_t, entry )
{ {
var_t *def = func->def; var_t *def = func->def;
@ -454,7 +452,6 @@ static void write_dispatchtable(type_t *iface)
fprintf(server, ",\n"); fprintf(server, ",\n");
method_count++; method_count++;
func = PREV_LINK(func);
} }
print_server("0\n"); print_server("0\n");
indent--; indent--;

View File

@ -280,9 +280,8 @@ void write_procformatstring(FILE *file, const ifref_list_t *ifaces, int for_obje
if (iface->iface->funcs) if (iface->iface->funcs)
{ {
func_t *func = iface->iface->funcs; const func_t *func;
while (NEXT_LINK(func)) func = NEXT_LINK(func); LIST_FOR_EACH_ENTRY( func, iface->iface->funcs, const func_t, entry )
for (; func; func = PREV_LINK(func))
{ {
/* emit argument data */ /* emit argument data */
if (func->args) if (func->args)
@ -1479,9 +1478,8 @@ void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, int for_obje
if (iface->iface->funcs) if (iface->iface->funcs)
{ {
func_t *func = iface->iface->funcs; const func_t *func;
while (NEXT_LINK(func)) func = NEXT_LINK(func); LIST_FOR_EACH_ENTRY( func, iface->iface->funcs, const func_t, entry )
for (; func; func = PREV_LINK(func))
{ {
current_func = func; current_func = func;
if (func->args) if (func->args)
@ -1967,7 +1965,7 @@ size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects)
{ {
const ifref_t *iface; const ifref_t *iface;
size_t size = 1; size_t size = 1;
func_t *func; const func_t *func;
var_t *var; var_t *var;
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry ) if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
@ -1977,9 +1975,7 @@ size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects)
if (iface->iface->funcs) if (iface->iface->funcs)
{ {
func = iface->iface->funcs; LIST_FOR_EACH_ENTRY( func, iface->iface->funcs, const func_t, entry )
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{ {
/* argument list size */ /* argument list size */
if (func->args) if (func->args)
@ -1999,8 +1995,6 @@ size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects)
size += 2; size += 2;
else else
size += get_size_procformatstring_var(var); size += get_size_procformatstring_var(var);
func = PREV_LINK(func);
} }
} }
} }
@ -2011,7 +2005,7 @@ size_t get_size_typeformatstring(const ifref_list_t *ifaces, int for_objects)
{ {
const ifref_t *iface; const ifref_t *iface;
size_t size = 3; size_t size = 3;
func_t *func; const func_t *func;
var_t *var; var_t *var;
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry ) if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
@ -2021,9 +2015,7 @@ size_t get_size_typeformatstring(const ifref_list_t *ifaces, int for_objects)
if (iface->iface->funcs) if (iface->iface->funcs)
{ {
func = iface->iface->funcs; LIST_FOR_EACH_ENTRY( func, iface->iface->funcs, const func_t, entry )
while (NEXT_LINK(func)) func = NEXT_LINK(func);
while (func)
{ {
/* argument list size */ /* argument list size */
if (func->args) if (func->args)
@ -2036,8 +2028,6 @@ size_t get_size_typeformatstring(const ifref_list_t *ifaces, int for_objects)
var = PREV_LINK(var); var = PREV_LINK(var);
} }
} }
func = PREV_LINK(func);
} }
} }
} }

View File

@ -47,6 +47,7 @@ typedef struct _importinfo_t importinfo_t;
typedef struct _typelib_t typelib_t; typedef struct _typelib_t typelib_t;
typedef struct list attr_list_t; typedef struct list attr_list_t;
typedef struct list func_list_t;
typedef struct list ifref_list_t; typedef struct list ifref_list_t;
#define DECL_LINK(type) \ #define DECL_LINK(type) \
@ -208,7 +209,7 @@ struct _type_t {
unsigned char type; unsigned char type;
struct _type_t *ref; struct _type_t *ref;
const attr_list_t *attrs; const attr_list_t *attrs;
func_t *funcs; /* interfaces and modules */ func_list_t *funcs; /* interfaces and modules */
var_t *fields; /* interfaces, structures and enumerations */ var_t *fields; /* interfaces, structures and enumerations */
ifref_list_t *ifaces; /* coclasses */ ifref_list_t *ifaces; /* coclasses */
type_t *orig; /* dup'd types */ type_t *orig; /* dup'd types */
@ -245,7 +246,7 @@ struct _func_t {
int ignore, idx; int ignore, idx;
/* parser-internal */ /* parser-internal */
DECL_LINK(func_t); struct list entry;
}; };
struct _ifref_t { struct _ifref_t {

View File

@ -1243,7 +1243,7 @@ static HRESULT set_custdata(msft_typelib_t *typelib, REFGUID guid,
return S_OK; return S_OK;
} }
static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, func_t *func, int index) static HRESULT add_func_desc(msft_typeinfo_t* typeinfo, const func_t *func, int index)
{ {
int offset, name_offset; int offset, name_offset;
int *typedata, typedata_size; int *typedata, typedata_size;
@ -1897,7 +1897,7 @@ static void add_dispatch(msft_typelib_t *typelib)
static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinterface) static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinterface)
{ {
int idx = 0; int idx = 0;
func_t *func; const func_t *func;
var_t *var; var_t *var;
msft_typeinfo_t *msft_typeinfo; msft_typeinfo_t *msft_typeinfo;
@ -1916,13 +1916,8 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte
msft_typeinfo->typeinfo->cImplTypes = 1; msft_typeinfo->typeinfo->cImplTypes = 1;
/* count the no of funcs, as the variable indices come after the funcs */ /* count the no of funcs, as the variable indices come after the funcs */
if((func = dispinterface->funcs)) { if (dispinterface->funcs)
idx++; LIST_FOR_EACH_ENTRY( func, dispinterface->funcs, const func_t, entry ) idx++;
while(NEXT_LINK(func)) {
func = NEXT_LINK(func);
idx++;
}
}
if((var = dispinterface->fields)) { if((var = dispinterface->fields)) {
while(NEXT_LINK(var)) var = NEXT_LINK(var); while(NEXT_LINK(var)) var = NEXT_LINK(var);
@ -1933,19 +1928,19 @@ static void add_dispinterface_typeinfo(msft_typelib_t *typelib, type_t *dispinte
} }
} }
idx = 0; if (dispinterface->funcs)
/* the func count above has already left us pointing at the first func */ {
while(func) { idx = 0;
if(add_func_desc(msft_typeinfo, func, idx) == S_OK) LIST_FOR_EACH_ENTRY( func, dispinterface->funcs, const func_t, entry )
idx++; if(add_func_desc(msft_typeinfo, func, idx) == S_OK)
func = PREV_LINK(func); idx++;
} }
} }
static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface) static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface)
{ {
int idx = 0; int idx = 0;
func_t *func; const func_t *func;
type_t *ref; type_t *ref;
msft_typeinfo_t *msft_typeinfo; msft_typeinfo_t *msft_typeinfo;
importinfo_t *ref_importinfo = NULL; importinfo_t *ref_importinfo = NULL;
@ -1987,20 +1982,17 @@ static void add_interface_typeinfo(msft_typelib_t *typelib, type_t *interface)
/* count the number of inherited interfaces and non-local functions */ /* count the number of inherited interfaces and non-local functions */
for(ref = interface->ref; ref; ref = ref->ref) { for(ref = interface->ref; ref; ref = ref->ref) {
num_parents++; num_parents++;
for(func = ref->funcs; func; func = NEXT_LINK(func)) if (ref->funcs)
if (!is_local(func->def->attrs)) num_funcs++; LIST_FOR_EACH_ENTRY( func, ref->funcs, const func_t, entry )
if (!is_local(func->def->attrs)) num_funcs++;
} }
msft_typeinfo->typeinfo->datatype2 = num_funcs << 16 | num_parents; msft_typeinfo->typeinfo->datatype2 = num_funcs << 16 | num_parents;
msft_typeinfo->typeinfo->cbSizeVft = num_funcs * 4; msft_typeinfo->typeinfo->cbSizeVft = num_funcs * 4;
if((func = interface->funcs)) { if (interface->funcs)
while(NEXT_LINK(func)) func = NEXT_LINK(func); LIST_FOR_EACH_ENTRY( func, interface->funcs, const func_t, entry )
while(func) {
if(add_func_desc(msft_typeinfo, func, idx) == S_OK) if(add_func_desc(msft_typeinfo, func, idx) == S_OK)
idx++; idx++;
func = PREV_LINK(func);
}
}
} }
static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure) static void add_structure_typeinfo(msft_typelib_t *typelib, type_t *structure)
@ -2139,7 +2131,7 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls)
static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module) static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module)
{ {
int idx = 0; int idx = 0;
func_t *func; const func_t *func;
msft_typeinfo_t *msft_typeinfo; msft_typeinfo_t *msft_typeinfo;
if (-1 < module->typelib_idx) if (-1 < module->typelib_idx)
@ -2149,14 +2141,11 @@ static void add_module_typeinfo(msft_typelib_t *typelib, type_t *module)
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_MODULE, module->name, module->attrs); msft_typeinfo = create_msft_typeinfo(typelib, TKIND_MODULE, module->name, module->attrs);
msft_typeinfo->typeinfo->typekind |= 0x0a00; msft_typeinfo->typeinfo->typekind |= 0x0a00;
if((func = module->funcs)) { if (module->funcs)
while(NEXT_LINK(func)) func = NEXT_LINK(func); LIST_FOR_EACH_ENTRY( func, module->funcs, const func_t, entry )
while(func) {
if(add_func_desc(msft_typeinfo, func, idx) == S_OK) if(add_func_desc(msft_typeinfo, func, idx) == S_OK)
idx++; idx++;
func = PREV_LINK(func);
}
}
msft_typeinfo->typeinfo->size = idx; msft_typeinfo->typeinfo->size = idx;
} }