widl #29: fix -t option

Huw D M Davies h.davies1 at physics.ox.ac.uk
Tue Jan 25 16:12:09 CST 2005


        Huw Davies <huw at codeweavers.com>
        Fix typelib only option.
        Make -t and -h options inclusive.
Index: tools/widl/parser.l
===================================================================
RCS file: /home/wine/wine/tools/widl/parser.l,v
retrieving revision 1.23
diff -u -p -r1.23 parser.l
--- tools/widl/parser.l	10 Jan 2005 16:08:36 -0000	1.23
+++ tools/widl/parser.l	25 Jan 2005 22:09:07 -0000
@@ -391,7 +391,7 @@ int do_import(char *fname)
 	int ptr = import_stack_ptr;
 	int ret;
 
-	if (!parse_only) {
+	if (!parse_only && do_header) {
 		hname = dup_basename(fname, ".idl");
                 p = hname + strlen(hname) - 2;
                 if (p <= hname || strcmp( p, ".h" )) strcat(hname, ".h");
Index: tools/widl/parser.y
===================================================================
RCS file: /home/wine/wine/tools/widl/parser.y,v
retrieving revision 1.36
diff -u -p -r1.36 parser.y
--- tools/widl/parser.y	25 Jan 2005 20:02:09 -0000	1.36
+++ tools/widl/parser.y	25 Jan 2005 22:09:08 -0000
@@ -249,17 +249,17 @@ int_statements:					{ $$ = NULL; }
 	;
 
 statement: ';'					{}
-	| constdef ';'				{ if (!parse_only) { write_constdef($1); } }
+	| constdef ';'				{ if (!parse_only && do_header) { write_constdef($1); } }
 	| cppquote				{}
-	| enumdef ';'				{ if (!parse_only) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
-	| externdef ';'				{ if (!parse_only) { write_externdef($1); } }
+	| enumdef ';'				{ if (!parse_only && do_header) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
+	| externdef ';'				{ if (!parse_only && do_header) { write_externdef($1); } }
 	| import				{}
-	| structdef ';'				{ if (!parse_only) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
+	| structdef ';'				{ if (!parse_only && do_header) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
 	| typedef ';'				{}
-	| uniondef ';'				{ if (!parse_only) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
+	| uniondef ';'				{ if (!parse_only && do_header) { write_type(header, $1, NULL, NULL); fprintf(header, ";\n\n"); } }
 	;
 
-cppquote: tCPPQUOTE '(' aSTRING ')'		{ if (!parse_only) fprintf(header, "%s\n", $3); }
+cppquote: tCPPQUOTE '(' aSTRING ')'		{ if (!parse_only && do_header) fprintf(header, "%s\n", $3); }
 	;
 import_start: tIMPORT aSTRING ';'		{ assert(yychar == YYEMPTY);
 						  if (!do_import($2)) yychar = aEOF; }
@@ -580,7 +580,7 @@ coclass:  tCOCLASS aIDENTIFIER			{ $$ = 
 
 coclasshdr: attributes coclass			{ $$ = $2;
 						  $$->attrs = $1;
-                                                  if (!parse_only) write_coclass($$);
+                                                  if (!parse_only && do_header) write_coclass($$);
 						}
 	;
 
@@ -609,7 +609,7 @@ dispinterfacehdr: attributes dispinterfa
 						  $$->ref = find_type("IDispatch", 0);
 						  if (!$$->ref) yyerror("IDispatch is undefined\n");
 						  $$->defined = TRUE;
-						  if (!parse_only) write_forward($$);
+						  if (!parse_only && do_header) write_forward($$);
 						}
 	;
 
@@ -627,11 +627,11 @@ dispinterfacedef: dispinterfacehdr '{'
 	  '}'					{ $$ = $1;
 						  $$->fields = $3;
 						  $$->funcs = $4;
-						  if (!parse_only) write_dispinterface($$);
+						  if (!parse_only && do_header) write_dispinterface($$);
 						}
 /* FIXME: not sure how to handle this yet
 	| dispinterfacehdr '{' interface '}'	{ $$ = $1;
-						  if (!parse_only) write_interface($$);
+						  if (!parse_only && do_header) write_interface($$);
 						}
 */
 	;
@@ -648,7 +648,7 @@ interfacehdr: attributes interface		{ $$
 						  if ($$->defined) yyerror("multiple definition error\n");
 						  $$->attrs = $1;
 						  $$->defined = TRUE;
-						  if (!parse_only) write_forward($$);
+						  if (!parse_only && do_header) write_forward($$);
 						}
 	;
 
@@ -656,7 +656,7 @@ interfacedef: interfacehdr inherit
 	  '{' int_statements '}'		{ $$ = $1;
 						  $$->ref = $2;
 						  $$->funcs = $4;
-						  if (!parse_only) write_interface($$);
+						  if (!parse_only && do_header) write_interface($$);
 						}
 /* MIDL is able to import the definition of a base class from inside the
  * definition of a derived class, I'll try to support it with this rule */
@@ -665,14 +665,14 @@ interfacedef: interfacehdr inherit
 						  $$->ref = find_type2($3, 0);
 						  if (!$$->ref) yyerror("base class %s not found in import\n", $3);
 						  $$->funcs = $6;
-						  if (!parse_only) write_interface($$);
+						  if (!parse_only && do_header) write_interface($$);
 						}
 	| dispinterfacedef			{ $$ = $1; }
 	;
 
 interfacedec:
-	  interface ';'				{ $$ = $1; if (!parse_only) write_forward($$); }
-	| dispinterface ';'			{ $$ = $1; if (!parse_only) write_forward($$); }
+	  interface ';'				{ $$ = $1; if (!parse_only && do_header) write_forward($$); }
+	| dispinterface ';'			{ $$ = $1; if (!parse_only && do_header) write_forward($$); }
 	;
 
 module:   tMODULE aIDENTIFIER			{ $$ = make_type(0, NULL); $$->name = $2; }
@@ -686,7 +686,7 @@ modulehdr: attributes module			{ $$ = $2
 
 moduledef: modulehdr '{' int_statements '}'	{ $$ = $1;
 						  $$->funcs = $3;
-						  /* FIXME: if (!parse_only) write_module($$); */
+						  /* FIXME: if (!parse_only && do_header) write_module($$); */
 						}
 	;
 
@@ -736,7 +736,7 @@ typedef: tTYPEDEF m_attributes type pide
 						  tref->name = NULL;
 						  $$ = type_ref(tref);
 						  $$->attrs = $2;
-						  if (!parse_only) write_typedef($$, $4);
+						  if (!parse_only && do_header) write_typedef($$, $4);
 						  reg_types($$, $4, 0);
 						}
 	;
Index: tools/widl/proxy.c
===================================================================
RCS file: /home/wine/wine/tools/widl/proxy.c,v
retrieving revision 1.19
diff -u -p -r1.19 proxy.c
--- tools/widl/proxy.c	21 Jan 2005 10:20:04 -0000	1.19
+++ tools/widl/proxy.c	25 Jan 2005 22:09:09 -0000
@@ -952,7 +952,7 @@ void write_proxies(ifref_t *ifaces)
   char *file_id = proxy_token;
   int c;
 
-  if (!do_everything) return;
+  if (!do_proxies) return;
   if (!lcur) return;
   END_OF_LIST(lcur);
 
Index: tools/widl/typelib.c
===================================================================
RCS file: /home/wine/wine/tools/widl/typelib.c,v
retrieving revision 1.8
diff -u -p -r1.8 typelib.c
--- tools/widl/typelib.c	25 Jan 2005 20:02:09 -0000	1.8
+++ tools/widl/typelib.c	25 Jan 2005 22:09:10 -0000
@@ -170,7 +170,7 @@ unsigned short get_var_vt(var_t *v)
 void start_typelib(char *name, attr_t *attrs)
 {
     in_typelib++;
-    if (!do_everything && !typelib_only) return;
+    if (!do_typelib) return;
 
     typelib = xmalloc(sizeof(*typelib));
     typelib->name = xstrdup(name);
Index: tools/widl/widl.c
===================================================================
RCS file: /home/wine/wine/tools/widl/widl.c,v
retrieving revision 1.20
diff -u -p -r1.20 widl.c
--- tools/widl/widl.c	5 Jan 2005 17:30:37 -0000	1.20
+++ tools/widl/widl.c	25 Jan 2005 22:09:10 -0000
@@ -59,11 +59,11 @@ static char usage[] =
 "   -d n        Set debug level to 'n'\n"
 "   -D id[=val] Define preprocessor identifier id=val\n"
 "   -E          Preprocess only\n"
-"   -h          Generate headers only\n"
+"   -h          Generate headers\n"
 "   -H file     Name of header file (default is infile.h)\n"
 "   -I path     Set include search dir to path (multiple -I allowed)\n"
 "   -N          Do not preprocess input\n"
-"   -t          Generate typelib only\n"
+"   -t          Generate typelib\n"
 "   -T file     Name of typelib file (default is infile.tlb)\n"
 "   -V          Print version and exit\n"
 "   -W          Enable pedantic warnings\n"
@@ -83,10 +83,11 @@ int win32 = 1;
 int debuglevel = DEBUGLEVEL_NONE;
 
 int pedantic = 0;
-int do_everything = 1;
+static int do_everything = 1;
 int preprocess_only = 0;
-int header_only = 0;
-int typelib_only = 0;
+int do_header = 0;
+int do_typelib = 0;
+int do_proxies = 0;
 int no_preprocess = 0;
 
 char *input_name;
@@ -150,7 +151,7 @@ int main(int argc,char *argv[])
       break;
     case 'h':
       do_everything = 0;
-      header_only = 1;
+      do_header = 1;
       break;
     case 'H':
       header_name = strdup(optarg);
@@ -163,7 +164,7 @@ int main(int argc,char *argv[])
       break;
     case 't':
       do_everything = 0;
-      typelib_only = 1;
+      do_typelib = 1;
       break;
     case 'T':
       typelib_name = strdup(optarg);
@@ -180,6 +181,9 @@ int main(int argc,char *argv[])
     }
   }
 
+  if(do_everything) {
+      do_header = do_typelib = do_proxies = 1;
+  }
   if(optind < argc) {
     input_name = xstrdup(argv[optind]);
   }
@@ -201,17 +205,17 @@ int main(int argc,char *argv[])
                  (debuglevel & DEBUGLEVEL_PPTRACE) != 0,
                  (debuglevel & DEBUGLEVEL_PPMSG) != 0 );
 
-  if (!header_name && (do_everything || header_only)) {
+  if (!header_name && do_header) {
     header_name = dup_basename(input_name, ".idl");
     strcat(header_name, ".h");
   }
 
-  if (!typelib_name && (do_everything || typelib_only)) {
+  if (!typelib_name && do_typelib) {
     typelib_name = dup_basename(input_name, ".idl");
     strcat(typelib_name, ".tlb");
   }
 
-  if (!proxy_name && do_everything) {
+  if (!proxy_name && do_proxies) {
     proxy_name = dup_basename(input_name, ".idl");
     proxy_token = xstrdup(proxy_name);
     strcat(proxy_name, "_p.c");
@@ -247,7 +251,7 @@ int main(int argc,char *argv[])
     }
   }
 
-  if(do_everything || header_only) {
+  if(do_header) {
     header_token = make_token(header_name);
 
     if(!(header = fopen(header_name, "w"))) {
@@ -262,9 +266,11 @@ int main(int argc,char *argv[])
     fprintf(header, "#ifdef __cplusplus\n");
     fprintf(header, "extern \"C\" {\n");
     fprintf(header, "#endif\n");
+  }
 
-    ret = yyparse();
+  ret = yyparse();
 
+  if(do_header) {
     fprintf(header, "#ifdef __cplusplus\n");
     fprintf(header, "}\n");
     fprintf(header, "#endif\n");
Index: tools/widl/widl.h
===================================================================
RCS file: /home/wine/wine/tools/widl/widl.h,v
retrieving revision 1.7
diff -u -p -r1.7 widl.h
--- tools/widl/widl.h	5 Oct 2004 04:44:20 -0000	1.7
+++ tools/widl/widl.h	25 Jan 2005 22:09:10 -0000
@@ -38,9 +38,9 @@ extern int debuglevel;
 
 extern int win32;
 extern int pedantic;
-extern int do_everything;
-extern int header_only;
-extern int typelib_only;
+extern int do_header;
+extern int do_typelib;
+extern int do_proxies;
 
 extern char *input_name;
 extern char *header_name;
Index: tools/widl/widl.man
===================================================================
RCS file: /home/wine/wine/tools/widl/widl.man,v
retrieving revision 1.2
diff -u -p -r1.2 widl.man
--- tools/widl/widl.man	5 Oct 2004 04:44:20 -0000	1.2
+++ tools/widl/widl.man	25 Jan 2005 22:09:10 -0000
@@ -14,20 +14,22 @@ No options are used.
 The program prints the help info and then exits.
 .PP
 .B General options:
-.IP \fB-t\fR
-Only generate a type library.
-.IP "\fB-T \fIfile\fR"
-Define the name of the type library to be generated. 
-The default filename is infile.tlb.
 .IP \fB-V\fR
 Print version number and exits from the program.
 .PP
 .B Header options:
 .IP \fB-h\fR
-Only generate header files.
+Generate header files.
 .IP "\fB-H \fIfile\fR"
 Name of header file to generate. The default header
 filename is infile.h.
+.PP
+.B Type library options:
+.IP \fB-t\fR
+Generate a type library.
+.IP "\fB-T \fIfile\fR"
+Define the name of the type library to be generated. 
+The default filename is infile.tlb.
 .PP
 .B Preprocessor options:
 .IP "\fB-I \fIpath\fR"



More information about the wine-patches mailing list