Jacek Caban : widl: Preprocess and attempt to parse provided ACF file.

Alexandre Julliard julliard at winehq.org
Fri Nov 9 14:12:16 CST 2018


Module: wine
Branch: master
Commit: d6b76df314b8d7b265276a68ebeb1266933306ef
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=d6b76df314b8d7b265276a68ebeb1266933306ef

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Nov  9 13:51:00 2018 +0100

widl: Preprocess and attempt to parse provided ACF file.

Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 tools/widl/parser.l | 45 ++++++++++++++++++++++++++++++++++++++++++---
 tools/widl/parser.y |  9 +++++++--
 2 files changed, 49 insertions(+), 5 deletions(-)

diff --git a/tools/widl/parser.l b/tools/widl/parser.l
index 342109e..3cbf4ff 100644
--- a/tools/widl/parser.l
+++ b/tools/widl/parser.l
@@ -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;
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 757d796..542ee43 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -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)




More information about the wine-cvs mailing list