widl: Convert interface lists to standard Wine lists.

This commit is contained in:
Alexandre Julliard 2007-01-22 14:21:56 +01:00
parent e998590557
commit e262933bdf
9 changed files with 88 additions and 97 deletions

View File

@ -424,17 +424,16 @@ static void init_client(void)
}
void write_client(ifref_t *ifaces)
void write_client(ifref_list_t *ifaces)
{
unsigned int proc_offset = 0;
unsigned int type_offset = 2;
ifref_t *iface = ifaces;
ifref_t *iface;
if (!do_client)
return;
if (do_everything && !ifaces)
return;
END_OF_LIST(iface);
init_client();
if (!client)
@ -442,7 +441,7 @@ void write_client(ifref_t *ifaces)
write_formatstringsdecl(client, indent, ifaces, 0);
for (; iface; iface = PREV_LINK(iface))
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
{
if (is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
continue;

View File

@ -80,6 +80,7 @@ static typeref_t *make_tref(char *name, type_t *ref);
static typeref_t *uniq_tref(typeref_t *ref);
static type_t *type_ref(typeref_t *ref);
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_t *make_ifref(type_t *iface);
static var_t *make_var(char *name);
static func_t *make_func(var_t *def, var_t *args);
@ -123,6 +124,7 @@ static void check_arg(var_t *arg);
var_t *var;
func_t *func;
ifref_t *ifref;
ifref_list_t *ifref_list;
char *str;
UUID *uuid;
unsigned int num;
@ -220,7 +222,8 @@ static void check_arg(var_t *arg);
%type <type> module modulehdr moduledef
%type <type> base_type int_std
%type <type> enumdef structdef uniondef
%type <ifref> gbl_statements coclass_ints coclass_int
%type <ifref> coclass_int
%type <ifref_list> gbl_statements coclass_ints
%type <tref> type
%type <var> m_args no_args args arg
%type <var> fields field s_field cases case enums enum_list enum constdef externdef
@ -251,7 +254,7 @@ input: gbl_statements { write_proxies($1); write_client
gbl_statements: { $$ = NULL; }
| gbl_statements interfacedec { $$ = $1; }
| gbl_statements interfacedef { $$ = make_ifref($2); LINK($$, $1); }
| gbl_statements interfacedef { $$ = append_ifref( $1, make_ifref($2) ); }
| gbl_statements coclass ';' { $$ = $1;
reg_type($2, $2->name, 0);
if (!parse_only && do_header) write_coclass_forward($2);
@ -673,7 +676,7 @@ coclassdef: coclasshdr '{' coclass_ints '}' { $$ = $1;
;
coclass_ints: { $$ = NULL; }
| coclass_ints coclass_int { LINK($2, $1); $$ = $2; }
| coclass_ints coclass_int { $$ = append_ifref( $1, $2 ); }
;
coclass_int:
@ -1200,12 +1203,23 @@ static void set_type(var_t *v, typeref_t *ref, expr_t *arr)
v->array = arr;
}
static ifref_list_t *append_ifref(ifref_list_t *list, ifref_t *iface)
{
if (!iface) return list;
if (!list)
{
list = xmalloc( sizeof(*list) );
list_init( list );
}
list_add_tail( list, &iface->entry );
return list;
}
static ifref_t *make_ifref(type_t *iface)
{
ifref_t *l = xmalloc(sizeof(ifref_t));
l->iface = iface;
l->attrs = NULL;
INIT_LINK(l);
return l;
}

View File

@ -83,7 +83,7 @@ static void write_stubdesc(void)
print_proxy( "\n");
}
static void init_proxy(ifref_t *ifaces)
static void init_proxy(ifref_list_t *ifaces)
{
if (proxy) return;
if(!(proxy = fopen(proxy_name, "w")))
@ -992,9 +992,8 @@ static void write_proxy(type_t *iface)
print_proxy( "\n");
}
void write_proxies(ifref_t *ifaces)
void write_proxies(ifref_list_t *ifaces)
{
ifref_t *lcur = ifaces;
ifref_t *cur;
char *file_id = proxy_token;
int c;
@ -1005,13 +1004,10 @@ void write_proxies(ifref_t *ifaces)
init_proxy(ifaces);
if(!proxy) return;
END_OF_LIST(lcur);
cur = lcur;
while (cur) {
if (is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
write_proxy(cur->iface);
cur = PREV_LINK(cur);
}
if (ifaces)
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
if (is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
write_proxy(cur->iface);
write_stubdesc();
@ -1024,39 +1020,34 @@ void write_proxies(ifref_t *ifaces)
fprintf(proxy, "const CInterfaceProxyVtbl* _%s_ProxyVtblList[] =\n", file_id);
fprintf(proxy, "{\n");
cur = lcur;
while (cur) {
if(cur->iface->ref && cur->iface->funcs &&
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
fprintf(proxy, " (CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
cur = PREV_LINK(cur);
}
if (ifaces)
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
if(cur->iface->ref && cur->iface->funcs &&
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
fprintf(proxy, " (CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
fprintf(proxy, " 0\n");
fprintf(proxy, "};\n");
fprintf(proxy, "\n");
fprintf(proxy, "const CInterfaceStubVtbl* _%s_StubVtblList[] =\n", file_id);
fprintf(proxy, "{\n");
cur = lcur;
while (cur) {
if(cur->iface->ref && cur->iface->funcs &&
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
fprintf(proxy, " (CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
cur = PREV_LINK(cur);
}
if (ifaces)
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
if(cur->iface->ref && cur->iface->funcs &&
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
fprintf(proxy, " (CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
fprintf(proxy, " 0\n");
fprintf(proxy, "};\n");
fprintf(proxy, "\n");
fprintf(proxy, "PCInterfaceName const _%s_InterfaceNamesList[] =\n", file_id);
fprintf(proxy, "{\n");
cur = lcur;
while (cur) {
if(cur->iface->ref && cur->iface->funcs &&
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
fprintf(proxy, " \"%s\",\n", cur->iface->name);
cur = PREV_LINK(cur);
}
if (ifaces)
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
if(cur->iface->ref && cur->iface->funcs &&
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
fprintf(proxy, " \"%s\",\n", cur->iface->name);
fprintf(proxy, " 0\n");
fprintf(proxy, "};\n");
fprintf(proxy, "\n");
@ -1065,20 +1056,18 @@ void write_proxies(ifref_t *ifaces)
fprintf(proxy, "\n");
fprintf(proxy, "int __stdcall _%s_IID_Lookup(const IID* pIID, int* pIndex)\n", file_id);
fprintf(proxy, "{\n");
cur = lcur;
c = 0;
while (cur) {
if(cur->iface->ref)
{
fprintf(proxy, " if (!_%s_CHECK_IID(%d))\n", file_id, c);
fprintf(proxy, " {\n");
fprintf(proxy, " *pIndex = %d;\n", c);
fprintf(proxy, " return 1;\n");
fprintf(proxy, " }\n");
c++;
}
cur = PREV_LINK(cur);
}
if (ifaces)
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
if(cur->iface->ref)
{
fprintf(proxy, " if (!_%s_CHECK_IID(%d))\n", file_id, c);
fprintf(proxy, " {\n");
fprintf(proxy, " *pIndex = %d;\n", c);
fprintf(proxy, " return 1;\n");
fprintf(proxy, " }\n");
c++;
}
fprintf(proxy, " return 0;\n");
fprintf(proxy, "}\n");
fprintf(proxy, "\n");

View File

@ -564,17 +564,16 @@ static void init_server(void)
}
void write_server(ifref_t *ifaces)
void write_server(ifref_list_t *ifaces)
{
unsigned int proc_offset = 0;
unsigned int type_offset = 2;
ifref_t *iface = ifaces;
ifref_t *iface;
if (!do_server)
return;
if (do_everything && !ifaces)
return;
END_OF_LIST(iface);
init_server();
if (!server)
@ -582,7 +581,7 @@ void write_server(ifref_t *ifaces)
write_formatstringsdecl(server, indent, ifaces, 0);
for (; iface; iface = PREV_LINK(iface))
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
{
if (is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
continue;

View File

@ -142,7 +142,7 @@ static void write_formatdesc(FILE *f, int indent, const char *str)
print_file(f, indent, "\n");
}
void write_formatstringsdecl(FILE *f, int indent, ifref_t *ifaces, int for_objects)
void write_formatstringsdecl(FILE *f, int indent, ifref_list_t *ifaces, int for_objects)
{
print_file(f, indent, "#define TYPE_FORMAT_STRING_SIZE %d\n",
get_size_typeformatstring(ifaces, for_objects));
@ -259,9 +259,9 @@ static size_t write_procformatstring_var(FILE *file, int indent,
return size;
}
void write_procformatstring(FILE *file, const ifref_t *ifaces, int for_objects)
void write_procformatstring(FILE *file, const ifref_list_t *ifaces, int for_objects)
{
const ifref_t *iface = ifaces;
const ifref_t *iface;
int indent = 0;
var_t *var;
unsigned int type_offset = 2;
@ -273,9 +273,7 @@ void write_procformatstring(FILE *file, const ifref_t *ifaces, int for_objects)
print_file(file, indent, "{\n");
indent++;
END_OF_LIST(iface);
for (; iface; iface = PREV_LINK(iface))
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
{
if (for_objects != is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
continue;
@ -1458,12 +1456,12 @@ static size_t write_typeformatstring_var(FILE *file, int indent,
}
void write_typeformatstring(FILE *file, const ifref_t *ifaces, int for_objects)
void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, int for_objects)
{
int indent = 0;
var_t *var;
unsigned int typeformat_offset;
const ifref_t *iface = ifaces;
const ifref_t *iface;
print_file(file, indent, "static const MIDL_TYPE_FORMAT_STRING __MIDL_TypeFormatString =\n");
print_file(file, indent, "{\n");
@ -1474,9 +1472,7 @@ void write_typeformatstring(FILE *file, const ifref_t *ifaces, int for_objects)
print_file(file, indent, "NdrFcShort(0x0),\n");
typeformat_offset = 2;
END_OF_LIST(iface);
for (; iface; iface = PREV_LINK(iface))
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
{
if (for_objects != is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
continue;
@ -1967,16 +1963,14 @@ size_t get_size_typeformatstring_var(const var_t *var)
return type_offset;
}
size_t get_size_procformatstring(const ifref_t *ifaces, int for_objects)
size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects)
{
const ifref_t *iface = ifaces;
const ifref_t *iface;
size_t size = 1;
func_t *func;
var_t *var;
END_OF_LIST(iface);
for (; iface; iface = PREV_LINK(iface))
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
{
if (for_objects != is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
continue;
@ -2013,16 +2007,14 @@ size_t get_size_procformatstring(const ifref_t *ifaces, int for_objects)
return size;
}
size_t get_size_typeformatstring(const ifref_t *ifaces, int for_objects)
size_t get_size_typeformatstring(const ifref_list_t *ifaces, int for_objects)
{
const ifref_t *iface = ifaces;
const ifref_t *iface;
size_t size = 3;
func_t *func;
var_t *var;
END_OF_LIST(iface);
for (; iface; iface = PREV_LINK(iface))
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
{
if (for_objects != is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
continue;

View File

@ -35,16 +35,16 @@ enum remoting_phase
PHASE_FREE
};
void write_formatstringsdecl(FILE *f, int indent, ifref_t *ifaces, int for_objects);
void write_procformatstring(FILE *file, const ifref_t *ifaces, int for_objects);
void write_typeformatstring(FILE *file, const ifref_t *ifaces, int for_objects);
void write_formatstringsdecl(FILE *f, int indent, ifref_list_t *ifaces, int for_objects);
void write_procformatstring(FILE *file, const ifref_list_t *ifaces, int for_objects);
void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, int for_objects);
size_t get_type_memsize(const type_t *type);
unsigned int get_required_buffer_size(const var_t *var, unsigned int *alignment, enum pass pass);
void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname);
void write_remoting_arguments(FILE *file, int indent, const func_t *func, unsigned int *type_offset, enum pass pass, enum remoting_phase phase);
size_t get_size_procformatstring_var(const var_t *var);
size_t get_size_typeformatstring_var(const var_t *var);
size_t get_size_procformatstring(const ifref_t *ifaces, int for_objects);
size_t get_size_typeformatstring(const ifref_t *ifaces, int for_objects);
size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects);
size_t get_size_typeformatstring(const ifref_list_t *ifaces, int for_objects);
int write_expr_eval_routines(FILE *file, const char *iface);
void write_expr_eval_routine_list(FILE *file, const char *iface);

View File

@ -62,8 +62,8 @@ extern int char_number;
extern FILE* header;
extern FILE* idfile;
extern void write_proxies(ifref_t *ifaces);
extern void write_client(ifref_t *ifaces);
extern void write_server(ifref_t *ifaces);
extern void write_proxies(ifref_list_t *ifaces);
extern void write_client(ifref_list_t *ifaces);
extern void write_server(ifref_list_t *ifaces);
#endif

View File

@ -46,6 +46,9 @@ typedef struct _importlib_t importlib_t;
typedef struct _importinfo_t importinfo_t;
typedef struct _typelib_t typelib_t;
typedef struct list attr_list_t;
typedef struct list ifref_list_t;
#define DECL_LINK(type) \
type *l_next; \
type *l_prev
@ -182,7 +185,6 @@ struct _attr_t {
/* parser-internal */
struct list entry;
};
typedef struct list attr_list_t;
struct _expr_t {
enum expr_type type;
@ -208,7 +210,7 @@ struct _type_t {
const attr_list_t *attrs;
func_t *funcs; /* interfaces and modules */
var_t *fields; /* interfaces, structures and enumerations */
ifref_t *ifaces; /* coclasses */
ifref_list_t *ifaces; /* coclasses */
type_t *orig; /* dup'd types */
int ignore, is_const, sign;
int defined, written, user_types_registered;
@ -251,7 +253,7 @@ struct _ifref_t {
attr_list_t *attrs;
/* parser-internal */
DECL_LINK(ifref_t);
struct list entry;
};
struct _typelib_entry_t {

View File

@ -2072,17 +2072,13 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls)
cls->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_COCLASS, cls->name, cls->attrs);
if((iref = cls->ifaces)) {
num_ifaces++;
while(NEXT_LINK(iref)) {
iref = NEXT_LINK(iref);
num_ifaces++;
}
}
if (cls->ifaces) LIST_FOR_EACH_ENTRY( iref, cls->ifaces, ifref_t, entry ) num_ifaces++;
offset = msft_typeinfo->typeinfo->datatype1 = ctl2_alloc_segment(typelib, MSFT_SEG_REFERENCES,
num_ifaces * sizeof(*ref), 0);
for(i = 0; i < num_ifaces; i++) {
i = 0;
if (cls->ifaces) LIST_FOR_EACH_ENTRY( iref, cls->ifaces, ifref_t, entry ) {
if(iref->iface->typelib_idx == -1)
add_interface_typeinfo(typelib, iref->iface);
ref = (MSFT_RefRecord*) (typelib->typelib_segment_data[MSFT_SEG_REFERENCES] + offset + i * sizeof(*ref));
@ -2125,7 +2121,7 @@ static void add_coclass_typeinfo(msft_typelib_t *typelib, type_t *cls)
else if(!first)
first = ref;
}
iref = PREV_LINK(iref);
i++;
}
/* If we haven't had a default interface, then set the default flags on the