Commit 0e53bb3f authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

Fix typelib only option.

Make -t and -h options inclusive.
parent 54c67dd1
......@@ -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");
......
......@@ -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 { $$ = make_class($2); }
coclasshdr: attributes coclass { $$ = $2;
$$->attrs = $1;
if (!parse_only) write_coclass($$);
if (!parse_only && do_header) write_coclass($$);
}
;
......@@ -609,7 +609,7 @@ dispinterfacehdr: attributes dispinterface { $$ = $2;
$$->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 { $$ = $2;
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 pident_list { typeref_t *tref = uniq_tref($3
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);
}
;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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();
if(do_header) {
fprintf(header, "#ifdef __cplusplus\n");
fprintf(header, "}\n");
fprintf(header, "#endif\n");
......
......@@ -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;
......
......@@ -14,21 +14,23 @@ 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"
Add a header search dir to path. Multiple search
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment