Commit d6b76df3 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

widl: Preprocess and attempt to parse provided ACF file.

parent 1db0ad97
......@@ -76,6 +76,8 @@ static int cbufalloc = 0;
static int kw_token(const char *kw);
static int attr_token(const char *kw);
static void switch_to_acf(void);
static warning_list_t *disabled_warnings = NULL;
#define MAX_IMPORT_DEPTH 20
......@@ -225,9 +227,14 @@ SAFEARRAY{ws}*/\( return tSAFEARRAY;
<INITIAL,ATTR>\.\.\. return ELLIPSIS;
<INITIAL,ATTR>. return yytext[0];
<<EOF>> {
if (import_stack_ptr)
return aEOF;
else yyterminate();
if (import_stack_ptr)
return aEOF;
if (acf_name)
{
switch_to_acf();
return aACF;
}
yyterminate();
}
%%
......@@ -563,6 +570,38 @@ void abort_import(void)
unlink(import_stack[ptr].temp_name);
}
static void switch_to_acf(void)
{
int ptr = import_stack_ptr;
int ret, fd;
char *name;
FILE *f;
assert(import_stack_ptr == 0);
input_name = acf_name;
acf_name = NULL;
line_number = 1;
name = xstrdup( "widl.XXXXXX" );
if((fd = mkstemps( name, 0 )) == -1)
error("Could not generate a temp name from %s\n", name);
temp_name = name;
if (!(f = fdopen(fd, "wt")))
error("Could not open fd %s for writing\n", name);
ret = wpp_parse(input_name, f);
fclose(f);
if (ret) exit(1);
if((f = fopen(temp_name, "r")) == NULL)
error_loc("Unable to open %s\n", temp_name);
import_stack[ptr].state = YY_CURRENT_BUFFER;
yy_switch_to_buffer(yy_create_buffer(f, YY_BUF_SIZE));
}
static void warning_disable(int warning)
{
warning_t *warning_entry;
......
......@@ -173,7 +173,7 @@ static typelib_t *current_typelib;
%token <dbl> aDOUBLE
%token <str> aSTRING aWSTRING aSQSTRING
%token <uuid> aUUID
%token aEOF
%token aEOF aACF
%token SHL SHR
%token MEMBERPTR
%token EQUALITY INEQUALITY
......@@ -321,7 +321,7 @@ static typelib_t *current_typelib;
%%
input: gbl_statements { fix_incomplete();
input: gbl_statements m_acf { fix_incomplete();
check_statements($1, FALSE);
check_all_user_types($1);
write_header($1);
......@@ -336,6 +336,8 @@ input: gbl_statements { fix_incomplete();
}
;
m_acf: /* empty */ | aACF acf_statements
gbl_statements: { $$ = NULL; }
| gbl_statements namespacedef '{' { push_namespace($2); } gbl_statements '}'
{ pop_namespace($2); $$ = append_statements($1, $5); }
......@@ -1150,6 +1152,9 @@ version:
| aHEXNUM { $$ = $1; }
;
acf_statements
: /* empty */
%%
static void decl_builtin_basic(const char *name, enum type_basic_type type)
......
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