Commit 6b955b51 authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

widl: Generate header files from the parse tree instead of using hooks in the parser.

parent bf5a9cb6
......@@ -47,17 +47,6 @@ extern int need_proxy_file(const statement_list_t *stmts);
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_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_coclass(type_t *cocl);
extern void write_coclass_forward(type_t *cocl);
extern void write_typedef(type_t *type);
extern void write_declaration(const var_t *v, int is_in_interface);
extern void write_library(const typelib_t *typelib);
extern void write_user_types(void);
extern void write_context_handle_rundowns(void);
extern void write_generic_handle_routines(void);
extern const var_t* get_explicit_handle_var(const func_t* func);
extern const type_t* get_explicit_generic_handle_type(const var_t* var);
extern const var_t* get_explicit_generic_handle_var(const func_t* func);
......
......@@ -46,5 +46,6 @@ void pop_import(void);
int is_type(const char *name);
void check_functions(const type_t *iface);
func_list_t *gen_function_list(const statement_list_t *stmts);
#endif
......@@ -64,13 +64,14 @@ static int compute_method_indexes(type_t *iface)
return idx;
}
void type_interface_define(type_t *iface, type_t *inherit, func_list_t *funcs)
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts)
{
iface->ref = inherit;
iface->details.iface = xmalloc(sizeof(*iface->details.iface));
iface->funcs = funcs;
iface->funcs = gen_function_list(stmts);
iface->details.iface->disp_props = NULL;
iface->details.iface->disp_methods = NULL;
iface->stmts = stmts;
iface->defined = TRUE;
check_functions(iface);
compute_method_indexes(iface);
......@@ -84,7 +85,7 @@ void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *me
iface->funcs = NULL;
iface->details.iface->disp_props = props;
iface->details.iface->disp_methods = methods;
iface->funcs = methods;
iface->stmts = NULL;
iface->defined = TRUE;
check_functions(iface);
compute_method_indexes(iface);
......
......@@ -26,7 +26,7 @@
type_t *type_new_function(var_list_t *args);
type_t *type_new_pointer(type_t *ref, attr_list_t *attrs);
void type_interface_define(type_t *iface, type_t *inherit, func_list_t *funcs);
void type_interface_define(type_t *iface, type_t *inherit, statement_list_t *stmts);
void type_dispinterface_define(type_t *iface, var_list_t *props, func_list_t *methods);
void type_dispinterface_define_from_iface(type_t *dispiface, type_t *iface);
......
......@@ -213,14 +213,14 @@ static void set_everything(int x)
do_dlldata = x;
}
static void start_cplusplus_guard(FILE *fp)
void start_cplusplus_guard(FILE *fp)
{
fprintf(fp, "#ifdef __cplusplus\n");
fprintf(fp, "extern \"C\" {\n");
fprintf(fp, "#endif\n\n");
}
static void end_cplusplus_guard(FILE *fp)
void end_cplusplus_guard(FILE *fp)
{
fprintf(fp, "#ifdef __cplusplus\n");
fprintf(fp, "}\n");
......@@ -626,38 +626,11 @@ int main(int argc,char *argv[])
}
}
if(do_header) {
header_token = make_token(header_name);
if(!(header = fopen(header_name, "w"))) {
fprintf(stderr, "Could not open %s for output\n", header_name);
return 1;
}
fprintf(header, "/*** Autogenerated by WIDL %s from %s - Do not edit ***/\n", PACKAGE_VERSION, input_name);
fprintf(header, "#include <rpc.h>\n" );
fprintf(header, "#include <rpcndr.h>\n\n" );
fprintf(header, "#ifndef __WIDL_%s\n", header_token);
fprintf(header, "#define __WIDL_%s\n", header_token);
start_cplusplus_guard(header);
}
header_token = make_token(header_name);
init_types();
ret = parser_parse();
if(do_header) {
fprintf(header, "/* Begin additional prototypes for all interfaces */\n");
fprintf(header, "\n");
write_user_types();
write_generic_handle_routines();
write_context_handle_rundowns();
fprintf(header, "\n");
fprintf(header, "/* End additional prototypes */\n");
fprintf(header, "\n");
end_cplusplus_guard(header);
fprintf(header, "#endif /* __WIDL_%s */\n", header_token);
fclose(header);
}
fclose(parser_in);
if(ret) {
......
......@@ -50,6 +50,7 @@ extern int do_win64;
extern char *input_name;
extern char *header_name;
extern char *header_token;
extern char *local_stubs_name;
extern char *typelib_name;
extern char *dlldata_name;
......@@ -67,9 +68,7 @@ extern time_t now;
extern int line_number;
extern int char_number;
extern FILE* header;
extern FILE* idfile;
extern void write_header(const statement_list_t *stmts);
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);
......@@ -77,4 +76,7 @@ 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);
extern void start_cplusplus_guard(FILE *fp);
extern void end_cplusplus_guard(FILE *fp);
#endif
......@@ -295,6 +295,7 @@ struct _type_t {
struct iface_details *iface;
} details;
func_list_t *funcs; /* interfaces and modules */
statement_list_t *stmts; /* interfaces and modules */
ifref_list_t *ifaces; /* coclasses */
unsigned long dim; /* array dimension */
expr_t *size_is, *length_is;
......@@ -339,7 +340,7 @@ struct _declarator_t {
struct _func_t {
var_t *def;
var_list_t *args;
int ignore, idx;
int idx;
/* parser-internal */
struct list entry;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment