Robert Shearman : widl: Support coclass forward declarations.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jun 7 07:48:50 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 996c4f1f938eb47e47b69d04b34ca9cefbb78ee7
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=996c4f1f938eb47e47b69d04b34ca9cefbb78ee7

Author: Robert Shearman <rob at codeweavers.com>
Date:   Tue Jun  6 20:05:39 2006 +0100

widl: Support coclass forward declarations.

---

 tools/widl/header.c |    8 ++++++++
 tools/widl/header.h |    1 +
 tools/widl/parser.y |    2 ++
 3 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index c34f9a9..82637e5 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 6423033..b0aa82e 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 026b716..284d802 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -239,6 +239,7 @@ input:   gbl_statements                 
 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		{}




More information about the wine-cvs mailing list