widl: Write the generated file containing IID, DIID, CLSID and LIBID data based on the parsed list of statements instead of using hooks in the parser code.
This commit is contained in:
parent
5223d04a7c
commit
7d7dd182c1
|
@ -139,11 +139,6 @@ static type_t *get_type(unsigned char type, char *name, int t);
|
||||||
|
|
||||||
static var_t *reg_const(var_t *var);
|
static var_t *reg_const(var_t *var);
|
||||||
|
|
||||||
static void write_libid(const typelib_t *typelib);
|
|
||||||
static void write_clsid(type_t *cls);
|
|
||||||
static void write_diid(type_t *iface);
|
|
||||||
static void write_iid(type_t *iface);
|
|
||||||
|
|
||||||
static char *gen_name(void);
|
static char *gen_name(void);
|
||||||
static statement_t *process_typedefs(var_list_t *names);
|
static statement_t *process_typedefs(var_list_t *names);
|
||||||
static void check_arg(var_t *arg);
|
static void check_arg(var_t *arg);
|
||||||
|
@ -354,6 +349,7 @@ static func_list_t *append_func_from_statement(func_list_t *list, statement_t *s
|
||||||
|
|
||||||
input: gbl_statements { fix_incomplete();
|
input: gbl_statements { fix_incomplete();
|
||||||
check_all_user_types($1);
|
check_all_user_types($1);
|
||||||
|
write_id_data($1);
|
||||||
write_proxies($1);
|
write_proxies($1);
|
||||||
write_client($1);
|
write_client($1);
|
||||||
write_server($1);
|
write_server($1);
|
||||||
|
@ -449,7 +445,6 @@ libraryhdr: tLIBRARY aIDENTIFIER { $$ = $2; }
|
||||||
library_start: attributes libraryhdr '{' { $$ = make_library($2, check_library_attrs($2, $1));
|
library_start: attributes libraryhdr '{' { $$ = make_library($2, check_library_attrs($2, $1));
|
||||||
if (!parse_only) start_typelib($$);
|
if (!parse_only) start_typelib($$);
|
||||||
if (!parse_only && do_header) write_library($$);
|
if (!parse_only && do_header) write_library($$);
|
||||||
if (!parse_only && do_idfile) write_libid($$);
|
|
||||||
is_inside_library = TRUE;
|
is_inside_library = TRUE;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -847,8 +842,6 @@ coclasshdr: attributes coclass { $$ = $2;
|
||||||
$$->attrs = check_coclass_attrs($2->name, $1);
|
$$->attrs = check_coclass_attrs($2->name, $1);
|
||||||
if (!parse_only && do_header)
|
if (!parse_only && do_header)
|
||||||
write_coclass($$);
|
write_coclass($$);
|
||||||
if (!parse_only && do_idfile)
|
|
||||||
write_clsid($$);
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -897,14 +890,12 @@ dispinterfacedef: dispinterfacehdr '{'
|
||||||
'}' { $$ = $1;
|
'}' { $$ = $1;
|
||||||
type_dispinterface_define($$, $3, $4);
|
type_dispinterface_define($$, $3, $4);
|
||||||
if (!parse_only && do_header) write_interface($$);
|
if (!parse_only && do_header) write_interface($$);
|
||||||
if (!parse_only && do_idfile) write_diid($$);
|
|
||||||
is_in_interface = FALSE;
|
is_in_interface = FALSE;
|
||||||
}
|
}
|
||||||
| dispinterfacehdr
|
| dispinterfacehdr
|
||||||
'{' interface ';' '}' { $$ = $1;
|
'{' interface ';' '}' { $$ = $1;
|
||||||
type_dispinterface_define_from_iface($$, $3);
|
type_dispinterface_define_from_iface($$, $3);
|
||||||
if (!parse_only && do_header) write_interface($$);
|
if (!parse_only && do_header) write_interface($$);
|
||||||
if (!parse_only && do_idfile) write_diid($$);
|
|
||||||
is_in_interface = FALSE;
|
is_in_interface = FALSE;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -935,7 +926,6 @@ interfacedef: interfacehdr inherit
|
||||||
type_interface_define($$, $2, $4);
|
type_interface_define($$, $2, $4);
|
||||||
if (!parse_only && do_header) write_interface($$);
|
if (!parse_only && do_header) write_interface($$);
|
||||||
if (!parse_only && local_stubs) write_locals(local_stubs, $$, TRUE);
|
if (!parse_only && local_stubs) write_locals(local_stubs, $$, TRUE);
|
||||||
if (!parse_only && do_idfile) write_iid($$);
|
|
||||||
pointer_default = $1.old_pointer_default;
|
pointer_default = $1.old_pointer_default;
|
||||||
is_in_interface = FALSE;
|
is_in_interface = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -947,7 +937,6 @@ interfacedef: interfacehdr inherit
|
||||||
type_interface_define($$, find_type_or_error2($3, 0), $6);
|
type_interface_define($$, find_type_or_error2($3, 0), $6);
|
||||||
if (!parse_only && do_header) write_interface($$);
|
if (!parse_only && do_header) write_interface($$);
|
||||||
if (!parse_only && local_stubs) write_locals(local_stubs, $$, TRUE);
|
if (!parse_only && local_stubs) write_locals(local_stubs, $$, TRUE);
|
||||||
if (!parse_only && do_idfile) write_iid($$);
|
|
||||||
pointer_default = $1.old_pointer_default;
|
pointer_default = $1.old_pointer_default;
|
||||||
is_in_interface = FALSE;
|
is_in_interface = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -2022,30 +2011,6 @@ var_t *find_const(const char *name, int f)
|
||||||
return cur->var;
|
return cur->var;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void write_libid(const typelib_t *typelib)
|
|
||||||
{
|
|
||||||
const UUID *uuid = get_attrp(typelib->attrs, ATTR_UUID);
|
|
||||||
write_guid(idfile, "LIBID", typelib->name, uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void write_clsid(type_t *cls)
|
|
||||||
{
|
|
||||||
const UUID *uuid = get_attrp(cls->attrs, ATTR_UUID);
|
|
||||||
write_guid(idfile, "CLSID", cls->name, uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void write_diid(type_t *iface)
|
|
||||||
{
|
|
||||||
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
|
|
||||||
write_guid(idfile, "DIID", iface->name, uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void write_iid(type_t *iface)
|
|
||||||
{
|
|
||||||
const UUID *uuid = get_attrp(iface->attrs, ATTR_UUID);
|
|
||||||
write_guid(idfile, "IID", iface->name, uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *gen_name(void)
|
static char *gen_name(void)
|
||||||
{
|
{
|
||||||
static const char format[] = "__WIDL_%s_generated_name_%08lX";
|
static const char format[] = "__WIDL_%s_generated_name_%08lX";
|
||||||
|
|
|
@ -343,6 +343,65 @@ void write_dlldata(const statement_list_t *stmts)
|
||||||
free_filename_nodes(&filenames);
|
free_filename_nodes(&filenames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void write_id_data_stmts(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)
|
||||||
|
{
|
||||||
|
const type_t *type = stmt->u.type;
|
||||||
|
if (type->type == RPC_FC_IP)
|
||||||
|
{
|
||||||
|
const UUID *uuid;
|
||||||
|
if (!is_object(type->attrs) && !is_attr(type->attrs, ATTR_DISPINTERFACE))
|
||||||
|
continue;
|
||||||
|
uuid = get_attrp(type->attrs, ATTR_UUID);
|
||||||
|
write_guid(idfile, is_attr(type->attrs, ATTR_DISPINTERFACE) ? "DIID" : "IID",
|
||||||
|
type->name, uuid);
|
||||||
|
}
|
||||||
|
else if (type->type == RPC_FC_COCLASS)
|
||||||
|
{
|
||||||
|
const UUID *uuid = get_attrp(type->attrs, ATTR_UUID);
|
||||||
|
write_guid(idfile, "CLSID", type->name, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (stmt->type == STMT_LIBRARY)
|
||||||
|
{
|
||||||
|
const UUID *uuid = get_attrp(stmt->u.lib->attrs, ATTR_UUID);
|
||||||
|
write_guid(idfile, "LIBID", stmt->u.lib->name, uuid);
|
||||||
|
write_id_data_stmts(stmt->u.lib->stmts);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void write_id_data(const statement_list_t *stmts)
|
||||||
|
{
|
||||||
|
if (!do_idfile) return;
|
||||||
|
|
||||||
|
idfile_token = make_token(idfile_name);
|
||||||
|
|
||||||
|
idfile = fopen(idfile_name, "w");
|
||||||
|
if (! idfile) {
|
||||||
|
error("Could not open %s for output\n", idfile_name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION);
|
||||||
|
fprintf(idfile, "from %s - Do not edit ***/\n\n", input_name);
|
||||||
|
fprintf(idfile, "#include <rpc.h>\n");
|
||||||
|
fprintf(idfile, "#include <rpcndr.h>\n\n");
|
||||||
|
fprintf(idfile, "#include <initguid.h>\n\n");
|
||||||
|
start_cplusplus_guard(idfile);
|
||||||
|
|
||||||
|
write_id_data_stmts(stmts);
|
||||||
|
|
||||||
|
fprintf(idfile, "\n");
|
||||||
|
end_cplusplus_guard(idfile);
|
||||||
|
|
||||||
|
fclose(idfile);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc,char *argv[])
|
int main(int argc,char *argv[])
|
||||||
{
|
{
|
||||||
extern char* optarg;
|
extern char* optarg;
|
||||||
|
@ -595,23 +654,6 @@ int main(int argc,char *argv[])
|
||||||
fprintf(local_stubs, "#include \"%s\"\n\n", header_name);
|
fprintf(local_stubs, "#include \"%s\"\n\n", header_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_idfile) {
|
|
||||||
idfile_token = make_token(idfile_name);
|
|
||||||
|
|
||||||
idfile = fopen(idfile_name, "w");
|
|
||||||
if (! idfile) {
|
|
||||||
fprintf(stderr, "Could not open %s for output\n", idfile_name);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
fprintf(idfile, "/*** Autogenerated by WIDL %s ", PACKAGE_VERSION);
|
|
||||||
fprintf(idfile, "from %s - Do not edit ***/\n\n", input_name);
|
|
||||||
fprintf(idfile, "#include <rpc.h>\n");
|
|
||||||
fprintf(idfile, "#include <rpcndr.h>\n\n");
|
|
||||||
fprintf(idfile, "#include <initguid.h>\n\n");
|
|
||||||
start_cplusplus_guard(idfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
init_types();
|
init_types();
|
||||||
ret = parser_parse();
|
ret = parser_parse();
|
||||||
|
|
||||||
|
@ -633,13 +675,6 @@ int main(int argc,char *argv[])
|
||||||
fclose(local_stubs);
|
fclose(local_stubs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_idfile) {
|
|
||||||
fprintf(idfile, "\n");
|
|
||||||
end_cplusplus_guard(idfile);
|
|
||||||
|
|
||||||
fclose(idfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(parser_in);
|
fclose(parser_in);
|
||||||
|
|
||||||
if(ret) {
|
if(ret) {
|
||||||
|
|
|
@ -71,6 +71,7 @@ extern FILE* header;
|
||||||
extern FILE* local_stubs;
|
extern FILE* local_stubs;
|
||||||
extern FILE* idfile;
|
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_proxies(const statement_list_t *stmts);
|
||||||
extern void write_client(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_server(const statement_list_t *stmts);
|
||||||
|
|
Loading…
Reference in New Issue