widl: Write the local stubs file based on the parsed list of statements, rather than using hooks in the parser code.
This commit is contained in:
parent
7d7dd182c1
commit
bf5a9cb61e
|
@ -754,7 +754,7 @@ static void write_method_proto(FILE *header, const type_t *iface)
|
|||
}
|
||||
}
|
||||
|
||||
void write_locals(FILE *fp, const type_t *iface, int body)
|
||||
static void write_locals(FILE *fp, const type_t *iface, int body)
|
||||
{
|
||||
static const char comment[]
|
||||
= "/* WIDL-generated stub. You must provide an implementation for this. */";
|
||||
|
@ -814,6 +814,38 @@ void write_locals(FILE *fp, const type_t *iface, int body)
|
|||
}
|
||||
}
|
||||
|
||||
static void write_local_stubs_stmts(FILE *local_stubs, const statement_list_t *stmts)
|
||||
{
|
||||
const statement_t *stmt;
|
||||
if (stmts) LIST_FOR_EACH_ENTRY( stmt, stmts, const statement_t, entry )
|
||||
{
|
||||
if (stmt->type == STMT_TYPE && stmt->u.type->type == RPC_FC_IP)
|
||||
write_locals(local_stubs, stmt->u.type, TRUE);
|
||||
else if (stmt->type == STMT_LIBRARY)
|
||||
write_local_stubs_stmts(local_stubs, stmt->u.lib->stmts);
|
||||
}
|
||||
}
|
||||
|
||||
void write_local_stubs(const statement_list_t *stmts)
|
||||
{
|
||||
FILE *local_stubs;
|
||||
|
||||
if (!local_stubs_name) return;
|
||||
|
||||
local_stubs = fopen(local_stubs_name, "w");
|
||||
if (!local_stubs) {
|
||||
error("Could not open %s for output\n", local_stubs_name);
|
||||
return;
|
||||
}
|
||||
fprintf(local_stubs, "/* call_as/local stubs for %s */\n\n", input_name);
|
||||
fprintf(local_stubs, "#include <objbase.h>\n");
|
||||
fprintf(local_stubs, "#include \"%s\"\n\n", header_name);
|
||||
|
||||
write_local_stubs_stmts(local_stubs, stmts);
|
||||
|
||||
fclose(local_stubs);
|
||||
}
|
||||
|
||||
static void write_function_proto(FILE *header, const type_t *iface, const func_t *fun, const char *prefix)
|
||||
{
|
||||
var_t *def = fun->def;
|
||||
|
|
|
@ -50,7 +50,6 @@ extern void write_array(FILE *h, array_dims_t *v, int field);
|
|||
extern void write_import(const char *fname);
|
||||
extern void write_forward(type_t *iface);
|
||||
extern void write_interface(type_t *iface);
|
||||
extern void write_locals(FILE *fp, const type_t *iface, int body);
|
||||
extern void write_coclass(type_t *cocl);
|
||||
extern void write_coclass_forward(type_t *cocl);
|
||||
extern void write_typedef(type_t *type);
|
||||
|
|
|
@ -354,6 +354,7 @@ input: gbl_statements { fix_incomplete();
|
|||
write_client($1);
|
||||
write_server($1);
|
||||
write_dlldata($1);
|
||||
write_local_stubs($1);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -925,7 +926,6 @@ interfacedef: interfacehdr inherit
|
|||
'{' int_statements '}' semicolon_opt { $$ = $1.interface;
|
||||
type_interface_define($$, $2, $4);
|
||||
if (!parse_only && do_header) write_interface($$);
|
||||
if (!parse_only && local_stubs) write_locals(local_stubs, $$, TRUE);
|
||||
pointer_default = $1.old_pointer_default;
|
||||
is_in_interface = FALSE;
|
||||
}
|
||||
|
@ -936,7 +936,6 @@ interfacedef: interfacehdr inherit
|
|||
semicolon_opt { $$ = $1.interface;
|
||||
type_interface_define($$, find_type_or_error2($3, 0), $6);
|
||||
if (!parse_only && do_header) write_interface($$);
|
||||
if (!parse_only && local_stubs) write_locals(local_stubs, $$, TRUE);
|
||||
pointer_default = $1.old_pointer_default;
|
||||
is_in_interface = FALSE;
|
||||
}
|
||||
|
|
|
@ -132,8 +132,6 @@ const char *prefix_server = "";
|
|||
int line_number = 1;
|
||||
|
||||
FILE *header;
|
||||
FILE *local_stubs;
|
||||
FILE *proxy;
|
||||
FILE *idfile;
|
||||
|
||||
size_t pointer_size = 0;
|
||||
|
@ -643,17 +641,6 @@ int main(int argc,char *argv[])
|
|||
start_cplusplus_guard(header);
|
||||
}
|
||||
|
||||
if (local_stubs_name) {
|
||||
local_stubs = fopen(local_stubs_name, "w");
|
||||
if (!local_stubs) {
|
||||
fprintf(stderr, "Could not open %s for output\n", local_stubs_name);
|
||||
return 1;
|
||||
}
|
||||
fprintf(local_stubs, "/* call_as/local stubs for %s */\n\n", input_name);
|
||||
fprintf(local_stubs, "#include <objbase.h>\n");
|
||||
fprintf(local_stubs, "#include \"%s\"\n\n", header_name);
|
||||
}
|
||||
|
||||
init_types();
|
||||
ret = parser_parse();
|
||||
|
||||
|
@ -671,10 +658,6 @@ int main(int argc,char *argv[])
|
|||
fclose(header);
|
||||
}
|
||||
|
||||
if (local_stubs) {
|
||||
fclose(local_stubs);
|
||||
}
|
||||
|
||||
fclose(parser_in);
|
||||
|
||||
if(ret) {
|
||||
|
|
|
@ -68,13 +68,13 @@ extern int line_number;
|
|||
extern int char_number;
|
||||
|
||||
extern FILE* header;
|
||||
extern FILE* local_stubs;
|
||||
extern FILE* idfile;
|
||||
|
||||
extern void write_id_data(const statement_list_t *stmts);
|
||||
extern void write_proxies(const statement_list_t *stmts);
|
||||
extern void write_client(const statement_list_t *stmts);
|
||||
extern void write_server(const statement_list_t *stmts);
|
||||
extern void write_local_stubs(const statement_list_t *stmts);
|
||||
extern void write_dlldata(const statement_list_t *stmts);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue