diff --git a/tools/widl/header.c b/tools/widl/header.c index c34f9a96df5..82637e5be57 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1004,3 +1004,11 @@ void write_coclass(class_t *cocl) write_coclass_guid(cocl); fprintf(header, "\n"); } + +void write_coclass_forward(class_t *cocl) +{ + fprintf(header, "#ifndef __%s_FWD_DEFINED__\n", cocl->name); + fprintf(header, "#define __%s_FWD_DEFINED__\n", cocl->name); + fprintf(header, "typedef struct %s %s;\n", cocl->name, cocl->name); + fprintf(header, "#endif /* defined __%s_FWD_DEFINED__\n\n", cocl->name ); +} diff --git a/tools/widl/header.h b/tools/widl/header.h index 642303328dd..b0aa82e8dc5 100644 --- a/tools/widl/header.h +++ b/tools/widl/header.h @@ -37,6 +37,7 @@ extern void write_forward(type_t *iface); extern void write_interface(type_t *iface); extern void write_dispinterface(type_t *iface); extern void write_coclass(class_t *iface); +extern void write_coclass_forward(class_t *iface); extern void write_typedef(type_t *type, const var_t *names); extern void write_expr(FILE *h, const expr_t *e, int brackets); extern void write_constdef(const var_t *v); diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 026b716fe2e..284d80269a2 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -239,6 +239,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 coclass ';' { $$ = $1; if (!parse_only && do_header) write_coclass_forward($2); } | gbl_statements coclassdef { $$ = $1; add_coclass($2); } | gbl_statements moduledef { $$ = $1; add_module($2); } | gbl_statements librarydef { $$ = $1; } @@ -248,6 +249,7 @@ gbl_statements: { $$ = NULL; } imp_statements: {} | imp_statements interfacedec { if (!parse_only) add_interface($2); } | imp_statements interfacedef { if (!parse_only) add_interface($2); } + | imp_statements coclass ';' {} | imp_statements coclassdef { if (!parse_only) add_coclass($2); } | imp_statements moduledef { if (!parse_only) add_module($2); } | imp_statements statement {}