widl [4/5]: Register types for coclasses

Dan Hipschman dsh at linux.ucla.edu
Fri Jul 28 15:44:59 CDT 2006


This fixes the parser so it recognizes coclasses as types, and gives them
an actual type representation (previously NULL).  It allows some files to
compile which didn't before (when coclasses were used where a type was
expected).  WIDL can output headers for these files with this patch,
although it still can't generate typelibs (that's the next patch).  Still,
without this patch WIDL would crash when you try to generate a typelib.
With this patch it gives a more helpful message that it doesn't know how
to encode a certain type and exits more gracefully.

ChangeLog:
* Register a real type for coclasses (instead of NULL)
---
 tools/widl/parser.y |   20 +++++++++++++++-----
 1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 2755597..a4efb66 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -242,8 +242,14 @@ 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 coclass ';'		{ $$ = $1;
+						  reg_type($2, $2->name, 0);
+						  if (!parse_only && do_header) write_coclass_forward($2);
+						}
+	| gbl_statements coclassdef		{ $$ = $1;
+						  add_coclass($2);
+						  reg_type($2, $2->name, 0);
+						}
 	| gbl_statements moduledef		{ $$ = $1; add_module($2); }
 	| gbl_statements librarydef		{ $$ = $1; }
 	| gbl_statements statement		{ $$ = $1; }
@@ -252,8 +258,10 @@ 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 ';'	{ reg_type(NULL, $2->name, 0); if (!parse_only && do_header) write_coclass_forward($2); }
-	| imp_statements coclassdef		{ if (!parse_only) add_coclass($2); }
+	| imp_statements coclass ';'		{ reg_type($2, $2->name, 0); if (!parse_only && do_header) write_coclass_forward($2); }
+	| imp_statements coclassdef		{ if (!parse_only) add_coclass($2);
+						  reg_type($2, $2->name, 0);
+						}
 	| imp_statements moduledef		{ if (!parse_only) add_module($2); }
 	| imp_statements statement		{}
 	| imp_statements importlib		{}
@@ -628,7 +636,9 @@ int_std:  tINT					{ $$ = make_type(RPC_
 	;
 
 coclass:  tCOCLASS aIDENTIFIER			{ $$ = make_class($2); }
-	| tCOCLASS aKNOWNTYPE			{ $$ = make_class($2); }
+	| tCOCLASS aKNOWNTYPE			{ $$ = find_type($2, 0);
+						  if ($$->defined) yyerror("multiple definition error");
+						}
 	;
 
 coclasshdr: attributes coclass			{ $$ = $2;



More information about the wine-patches mailing list