mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 12:54:13 +00:00
widl: Use new functions need_proxy and need_stub to clean up code and avoid generating unnecessary files.
This commit is contained in:
parent
691dc735fd
commit
f173addbef
6 changed files with 74 additions and 39 deletions
|
@ -390,18 +390,18 @@ void write_client(ifref_list_t *ifaces)
|
||||||
|
|
||||||
if (!do_client)
|
if (!do_client)
|
||||||
return;
|
return;
|
||||||
if (do_everything && !ifaces)
|
if (do_everything && !need_stub_files(ifaces))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
init_client();
|
init_client();
|
||||||
if (!client)
|
if (!client)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
write_formatstringsdecl(client, indent, ifaces, 0);
|
write_formatstringsdecl(client, indent, ifaces, need_stub);
|
||||||
|
|
||||||
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
|
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
|
||||||
{
|
{
|
||||||
if (is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
|
if (!need_stub(iface->iface))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fprintf(client, "/*****************************************************************************\n");
|
fprintf(client, "/*****************************************************************************\n");
|
||||||
|
@ -435,8 +435,8 @@ void write_client(ifref_list_t *ifaces)
|
||||||
|
|
||||||
fprintf(client, "\n");
|
fprintf(client, "\n");
|
||||||
|
|
||||||
write_procformatstring(client, ifaces, 0);
|
write_procformatstring(client, ifaces, need_stub);
|
||||||
write_typeformatstring(client, ifaces, 0);
|
write_typeformatstring(client, ifaces, need_stub);
|
||||||
|
|
||||||
fclose(client);
|
fclose(client);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ extern void write_type_decl_left(FILE *f, type_t *t);
|
||||||
extern int needs_space_after(type_t *t);
|
extern int needs_space_after(type_t *t);
|
||||||
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 int need_stub(const type_t *iface);
|
||||||
|
extern int need_proxy(const type_t *iface);
|
||||||
|
extern int need_stub_files(const ifref_list_t *ifaces);
|
||||||
|
extern int need_proxy_file(const ifref_list_t *ifaces);
|
||||||
extern const var_t *is_callas(const attr_list_t *list);
|
extern const var_t *is_callas(const attr_list_t *list);
|
||||||
extern void write_args(FILE *h, const var_list_t *arg, const char *name, int obj, int do_indent);
|
extern void write_args(FILE *h, const var_list_t *arg, const char *name, int obj, int do_indent);
|
||||||
extern void write_array(FILE *h, array_dims_t *v, int field);
|
extern void write_array(FILE *h, array_dims_t *v, int field);
|
||||||
|
|
|
@ -110,7 +110,7 @@ static void init_proxy(ifref_list_t *ifaces)
|
||||||
print_proxy( "\n");
|
print_proxy( "\n");
|
||||||
print_proxy( "#include \"%s\"\n", header_name);
|
print_proxy( "#include \"%s\"\n", header_name);
|
||||||
print_proxy( "\n");
|
print_proxy( "\n");
|
||||||
write_formatstringsdecl(proxy, indent, ifaces, 1);
|
write_formatstringsdecl(proxy, indent, ifaces, need_proxy);
|
||||||
write_stubdescproto();
|
write_stubdescproto();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -563,6 +563,38 @@ static void write_proxy(type_t *iface, unsigned int *proc_offset)
|
||||||
print_proxy( "\n");
|
print_proxy( "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int does_any_iface(const ifref_list_t *ifaces, type_pred_t pred)
|
||||||
|
{
|
||||||
|
ifref_t *ir;
|
||||||
|
|
||||||
|
if (ifaces)
|
||||||
|
LIST_FOR_EACH_ENTRY(ir, ifaces, ifref_t, entry)
|
||||||
|
if (pred(ir->iface))
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
int need_proxy(const type_t *iface)
|
||||||
|
{
|
||||||
|
return is_object(iface->attrs) && !is_local(iface->attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
int need_stub(const type_t *iface)
|
||||||
|
{
|
||||||
|
return !is_object(iface->attrs) && !is_local(iface->attrs);
|
||||||
|
}
|
||||||
|
|
||||||
|
int need_proxy_file(const ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
return does_any_iface(ifaces, need_proxy);
|
||||||
|
}
|
||||||
|
|
||||||
|
int need_stub_files(const ifref_list_t *ifaces)
|
||||||
|
{
|
||||||
|
return does_any_iface(ifaces, need_stub);
|
||||||
|
}
|
||||||
|
|
||||||
void write_proxies(ifref_list_t *ifaces)
|
void write_proxies(ifref_list_t *ifaces)
|
||||||
{
|
{
|
||||||
ifref_t *cur;
|
ifref_t *cur;
|
||||||
|
@ -571,14 +603,14 @@ void write_proxies(ifref_list_t *ifaces)
|
||||||
unsigned int proc_offset = 0;
|
unsigned int proc_offset = 0;
|
||||||
|
|
||||||
if (!do_proxies) return;
|
if (!do_proxies) return;
|
||||||
if (do_everything && !ifaces) return;
|
if (do_everything && !need_proxy_file(ifaces)) return;
|
||||||
|
|
||||||
init_proxy(ifaces);
|
init_proxy(ifaces);
|
||||||
if(!proxy) return;
|
if(!proxy) return;
|
||||||
|
|
||||||
if (ifaces)
|
if (ifaces)
|
||||||
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
if (is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
|
if (need_proxy(cur->iface))
|
||||||
write_proxy(cur->iface, &proc_offset);
|
write_proxy(cur->iface, &proc_offset);
|
||||||
|
|
||||||
write_user_quad_list(proxy);
|
write_user_quad_list(proxy);
|
||||||
|
@ -588,15 +620,14 @@ void write_proxies(ifref_list_t *ifaces)
|
||||||
print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
|
print_proxy( "#error Currently only Wine and WIN32 are supported.\n");
|
||||||
print_proxy( "#endif\n");
|
print_proxy( "#endif\n");
|
||||||
print_proxy( "\n");
|
print_proxy( "\n");
|
||||||
write_procformatstring(proxy, ifaces, 1);
|
write_procformatstring(proxy, ifaces, need_proxy);
|
||||||
write_typeformatstring(proxy, ifaces, 1);
|
write_typeformatstring(proxy, ifaces, need_proxy);
|
||||||
|
|
||||||
fprintf(proxy, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id);
|
fprintf(proxy, "static const CInterfaceProxyVtbl* const _%s_ProxyVtblList[] =\n", file_id);
|
||||||
fprintf(proxy, "{\n");
|
fprintf(proxy, "{\n");
|
||||||
if (ifaces)
|
if (ifaces)
|
||||||
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
if(cur->iface->ref && cur->iface->funcs &&
|
if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
|
||||||
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
|
|
||||||
fprintf(proxy, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
|
fprintf(proxy, " (const CInterfaceProxyVtbl*)&_%sProxyVtbl,\n", cur->iface->name);
|
||||||
|
|
||||||
fprintf(proxy, " 0\n");
|
fprintf(proxy, " 0\n");
|
||||||
|
@ -607,8 +638,7 @@ void write_proxies(ifref_list_t *ifaces)
|
||||||
fprintf(proxy, "{\n");
|
fprintf(proxy, "{\n");
|
||||||
if (ifaces)
|
if (ifaces)
|
||||||
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
if(cur->iface->ref && cur->iface->funcs &&
|
if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
|
||||||
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
|
|
||||||
fprintf(proxy, " (const CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
|
fprintf(proxy, " (const CInterfaceStubVtbl*)&_%sStubVtbl,\n", cur->iface->name);
|
||||||
fprintf(proxy, " 0\n");
|
fprintf(proxy, " 0\n");
|
||||||
fprintf(proxy, "};\n");
|
fprintf(proxy, "};\n");
|
||||||
|
@ -618,8 +648,7 @@ void write_proxies(ifref_list_t *ifaces)
|
||||||
fprintf(proxy, "{\n");
|
fprintf(proxy, "{\n");
|
||||||
if (ifaces)
|
if (ifaces)
|
||||||
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
LIST_FOR_EACH_ENTRY( cur, ifaces, ifref_t, entry )
|
||||||
if(cur->iface->ref && cur->iface->funcs &&
|
if(cur->iface->ref && cur->iface->funcs && need_proxy(cur->iface))
|
||||||
is_object(cur->iface->attrs) && !is_local(cur->iface->attrs))
|
|
||||||
fprintf(proxy, " \"%s\",\n", cur->iface->name);
|
fprintf(proxy, " \"%s\",\n", cur->iface->name);
|
||||||
fprintf(proxy, " 0\n");
|
fprintf(proxy, " 0\n");
|
||||||
fprintf(proxy, "};\n");
|
fprintf(proxy, "};\n");
|
||||||
|
|
|
@ -403,18 +403,18 @@ void write_server(ifref_list_t *ifaces)
|
||||||
|
|
||||||
if (!do_server)
|
if (!do_server)
|
||||||
return;
|
return;
|
||||||
if (do_everything && !ifaces)
|
if (do_everything && !need_stub_files(ifaces))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
init_server();
|
init_server();
|
||||||
if (!server)
|
if (!server)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
write_formatstringsdecl(server, indent, ifaces, 0);
|
write_formatstringsdecl(server, indent, ifaces, need_stub);
|
||||||
|
|
||||||
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
|
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, ifref_t, entry )
|
||||||
{
|
{
|
||||||
if (is_object(iface->iface->attrs) || is_local(iface->iface->attrs))
|
if (!need_stub(iface->iface))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
fprintf(server, "/*****************************************************************************\n");
|
fprintf(server, "/*****************************************************************************\n");
|
||||||
|
@ -449,8 +449,8 @@ void write_server(ifref_list_t *ifaces)
|
||||||
|
|
||||||
fprintf(server, "\n");
|
fprintf(server, "\n");
|
||||||
|
|
||||||
write_procformatstring(server, ifaces, 0);
|
write_procformatstring(server, ifaces, need_stub);
|
||||||
write_typeformatstring(server, ifaces, 0);
|
write_typeformatstring(server, ifaces, need_stub);
|
||||||
|
|
||||||
fclose(server);
|
fclose(server);
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,13 +334,13 @@ static void write_formatdesc(FILE *f, int indent, const char *str)
|
||||||
print_file(f, indent, "\n");
|
print_file(f, indent, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_formatstringsdecl(FILE *f, int indent, ifref_list_t *ifaces, int for_objects)
|
void write_formatstringsdecl(FILE *f, int indent, ifref_list_t *ifaces, type_pred_t pred)
|
||||||
{
|
{
|
||||||
print_file(f, indent, "#define TYPE_FORMAT_STRING_SIZE %d\n",
|
print_file(f, indent, "#define TYPE_FORMAT_STRING_SIZE %d\n",
|
||||||
get_size_typeformatstring(ifaces, for_objects));
|
get_size_typeformatstring(ifaces, pred));
|
||||||
|
|
||||||
print_file(f, indent, "#define PROC_FORMAT_STRING_SIZE %d\n",
|
print_file(f, indent, "#define PROC_FORMAT_STRING_SIZE %d\n",
|
||||||
get_size_procformatstring(ifaces, for_objects));
|
get_size_procformatstring(ifaces, pred));
|
||||||
|
|
||||||
fprintf(f, "\n");
|
fprintf(f, "\n");
|
||||||
write_formatdesc(f, indent, "TYPE");
|
write_formatdesc(f, indent, "TYPE");
|
||||||
|
@ -439,7 +439,7 @@ static size_t write_procformatstring_var(FILE *file, int indent,
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void write_procformatstring(FILE *file, const ifref_list_t *ifaces, int for_objects)
|
void write_procformatstring(FILE *file, const ifref_list_t *ifaces, type_pred_t pred)
|
||||||
{
|
{
|
||||||
const ifref_t *iface;
|
const ifref_t *iface;
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
|
@ -454,7 +454,7 @@ void write_procformatstring(FILE *file, const ifref_list_t *ifaces, int for_obje
|
||||||
|
|
||||||
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
|
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))
|
if (!pred(iface->iface))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (iface->iface->funcs)
|
if (iface->iface->funcs)
|
||||||
|
@ -2162,7 +2162,7 @@ static int write_embedded_types(FILE *file, const attr_list_t *attrs, type_t *ty
|
||||||
return retmask;
|
return retmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t process_tfs(FILE *file, const ifref_list_t *ifaces, int for_objects)
|
static size_t process_tfs(FILE *file, const ifref_list_t *ifaces, type_pred_t pred)
|
||||||
{
|
{
|
||||||
const var_t *var;
|
const var_t *var;
|
||||||
const ifref_t *iface;
|
const ifref_t *iface;
|
||||||
|
@ -2170,7 +2170,7 @@ static size_t process_tfs(FILE *file, const ifref_list_t *ifaces, int for_object
|
||||||
|
|
||||||
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
|
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))
|
if (!pred(iface->iface))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (iface->iface->funcs)
|
if (iface->iface->funcs)
|
||||||
|
@ -2197,7 +2197,7 @@ static size_t process_tfs(FILE *file, const ifref_list_t *ifaces, int for_object
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, int for_objects)
|
void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, type_pred_t pred)
|
||||||
{
|
{
|
||||||
int indent = 0;
|
int indent = 0;
|
||||||
|
|
||||||
|
@ -2210,7 +2210,7 @@ void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, int for_obje
|
||||||
print_file(file, indent, "NdrFcShort(0x0),\n");
|
print_file(file, indent, "NdrFcShort(0x0),\n");
|
||||||
|
|
||||||
set_all_tfswrite(TRUE);
|
set_all_tfswrite(TRUE);
|
||||||
process_tfs(file, ifaces, for_objects);
|
process_tfs(file, ifaces, pred);
|
||||||
|
|
||||||
print_file(file, indent, "0x0\n");
|
print_file(file, indent, "0x0\n");
|
||||||
indent--;
|
indent--;
|
||||||
|
@ -2805,7 +2805,7 @@ size_t get_size_procformatstring_func(const func_t *func)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects)
|
size_t get_size_procformatstring(const ifref_list_t *ifaces, type_pred_t pred)
|
||||||
{
|
{
|
||||||
const ifref_t *iface;
|
const ifref_t *iface;
|
||||||
size_t size = 1;
|
size_t size = 1;
|
||||||
|
@ -2813,7 +2813,7 @@ size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects)
|
||||||
|
|
||||||
if (ifaces) LIST_FOR_EACH_ENTRY( iface, ifaces, const ifref_t, entry )
|
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))
|
if (!pred(iface->iface))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (iface->iface->funcs)
|
if (iface->iface->funcs)
|
||||||
|
@ -2824,10 +2824,10 @@ size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects)
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t get_size_typeformatstring(const ifref_list_t *ifaces, int for_objects)
|
size_t get_size_typeformatstring(const ifref_list_t *ifaces, type_pred_t pred)
|
||||||
{
|
{
|
||||||
set_all_tfswrite(FALSE);
|
set_all_tfswrite(FALSE);
|
||||||
return process_tfs(NULL, ifaces, for_objects);
|
return process_tfs(NULL, ifaces, pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
|
static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
|
||||||
|
|
|
@ -36,15 +36,17 @@ enum remoting_phase
|
||||||
PHASE_FREE
|
PHASE_FREE
|
||||||
};
|
};
|
||||||
|
|
||||||
void write_formatstringsdecl(FILE *f, int indent, ifref_list_t *ifaces, int for_objects);
|
typedef int (*type_pred_t)(const type_t *);
|
||||||
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);
|
void write_formatstringsdecl(FILE *f, int indent, ifref_list_t *ifaces, type_pred_t pred);
|
||||||
|
void write_procformatstring(FILE *file, const ifref_list_t *ifaces, type_pred_t pred);
|
||||||
|
void write_typeformatstring(FILE *file, const ifref_list_t *ifaces, type_pred_t pred);
|
||||||
void print_phase_basetype(FILE *file, int indent, enum remoting_phase phase, enum pass pass, const var_t *var, const char *varname);
|
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, enum pass pass, enum remoting_phase phase);
|
void write_remoting_arguments(FILE *file, int indent, const func_t *func, enum pass pass, enum remoting_phase phase);
|
||||||
size_t get_size_procformatstring_var(const var_t *var);
|
size_t get_size_procformatstring_var(const var_t *var);
|
||||||
size_t get_size_procformatstring_func(const func_t *func);
|
size_t get_size_procformatstring_func(const func_t *func);
|
||||||
size_t get_size_procformatstring(const ifref_list_t *ifaces, int for_objects);
|
size_t get_size_procformatstring(const ifref_list_t *ifaces, type_pred_t pred);
|
||||||
size_t get_size_typeformatstring(const ifref_list_t *ifaces, int for_objects);
|
size_t get_size_typeformatstring(const ifref_list_t *ifaces, type_pred_t pred);
|
||||||
void assign_stub_out_args( FILE *file, int indent, const func_t *func );
|
void assign_stub_out_args( FILE *file, int indent, const func_t *func );
|
||||||
void declare_stub_args( FILE *file, int indent, const func_t *func );
|
void declare_stub_args( FILE *file, int indent, const func_t *func );
|
||||||
int write_expr_eval_routines(FILE *file, const char *iface);
|
int write_expr_eval_routines(FILE *file, const char *iface);
|
||||||
|
|
Loading…
Reference in a new issue