Module: wine Branch: master Commit: cc02e15220cdf082b3fc19e585f7bab11e523198 URL: http://source.winehq.org/git/wine.git/?a=commit;h=cc02e15220cdf082b3fc19e585...
Author: Alexandre Julliard julliard@winehq.org Date: Mon Nov 4 14:13:06 2013 +0100
widl: Add support for #pragma directives.
---
tools/widl/header.c | 3 +++ tools/widl/parser.l | 4 ++++ tools/widl/parser.y | 11 ++++++++++- tools/widl/widltypes.h | 1 + tools/widl/write_msft.c | 1 + 5 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 2f275c7..bd9f21c 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -1342,6 +1342,7 @@ static void write_imports(FILE *header, const statement_list_t *stmts) case STMT_TYPEDEF: case STMT_MODULE: case STMT_CPPQUOTE: + case STMT_PRAGMA: case STMT_DECLARATION: /* not processed here */ break; @@ -1376,6 +1377,7 @@ static void write_forward_decls(FILE *header, const statement_list_t *stmts) case STMT_TYPEDEF: case STMT_MODULE: case STMT_CPPQUOTE: + case STMT_PRAGMA: case STMT_DECLARATION: /* not processed here */ break; @@ -1428,6 +1430,7 @@ static void write_header_stmts(FILE *header, const statement_list_t *stmts, cons break; case STMT_IMPORTLIB: case STMT_MODULE: + case STMT_PRAGMA: /* not included in header */ break; case STMT_IMPORT: diff --git a/tools/widl/parser.l b/tools/widl/parser.l index fb61e21..b911186 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -37,6 +37,7 @@ double [0-9]+.[0-9]+([eE][+-]?[0-9]+)* %x WSTRQUOTE %x ATTR %x PP_LINE +%x PP_PRAGMA %x SQUOTE
%{ @@ -125,6 +126,7 @@ UUID *parse_uuid(const char *u) ************************************************************************** */ %% +<INITIAL>^{ws}*#{ws}*pragma{ws}+ yy_push_state(PP_PRAGMA); <INITIAL,ATTR>^{ws}*#{ws}* yy_push_state(PP_LINE); <PP_LINE>[^\n]* { int lineno; @@ -144,6 +146,8 @@ UUID *parse_uuid(const char *u) line_number = lineno - 1; /* We didn't read the newline */ input_name = xstrdup(fname); } +<PP_PRAGMA>midl_echo[^\n]* yyless(9); yy_pop_state(); return tCPPQUOTE; +<PP_PRAGMA>[^\n]* parser_lval.str = xstrdup(yytext); yy_pop_state(); return aPRAGMA; <INITIAL,ATTR>" yy_push_state(QUOTE); cbufidx = 0; <QUOTE>" { yy_pop_state(); diff --git a/tools/widl/parser.y b/tools/widl/parser.y index 97c3896..946d165 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -114,6 +114,7 @@ static statement_t *make_statement_type_decl(type_t *type); static statement_t *make_statement_reference(type_t *type); static statement_t *make_statement_declaration(var_t *var); static statement_t *make_statement_library(typelib_t *typelib); +static statement_t *make_statement_pragma(const char *str); static statement_t *make_statement_cppquote(const char *str); static statement_t *make_statement_importlib(const char *str); static statement_t *make_statement_module(type_t *type); @@ -152,7 +153,7 @@ static attr_list_t *append_attribs(attr_list_t *, attr_list_t *); enum storage_class stgclass; }
-%token <str> aIDENTIFIER +%token <str> aIDENTIFIER aPRAGMA %token <str> aKNOWNTYPE %token <num> aNUM aHEXNUM %token <dbl> aDOUBLE @@ -363,6 +364,7 @@ statement: | declaration ';' { $$ = make_statement_declaration($1); } | import { $$ = make_statement_import($1); } | typedef ';' { $$ = $1; } + | aPRAGMA { $$ = make_statement_pragma($1); } ;
typedecl: @@ -2744,6 +2746,13 @@ static statement_t *make_statement_library(typelib_t *typelib) return stmt; }
+static statement_t *make_statement_pragma(const char *str) +{ + statement_t *stmt = make_statement(STMT_PRAGMA); + stmt->u.str = str; + return stmt; +} + static statement_t *make_statement_cppquote(const char *str) { statement_t *stmt = make_statement(STMT_CPPQUOTE); diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index efde0b0..30b6560 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -243,6 +243,7 @@ enum statement_type STMT_TYPEDEF, STMT_IMPORT, STMT_IMPORTLIB, + STMT_PRAGMA, STMT_CPPQUOTE };
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c index dd98486..6eb229a 100644 --- a/tools/widl/write_msft.c +++ b/tools/widl/write_msft.c @@ -2266,6 +2266,7 @@ static void add_entry(msft_typelib_t *typelib, const statement_t *stmt) switch(stmt->type) { case STMT_LIBRARY: case STMT_IMPORT: + case STMT_PRAGMA: case STMT_CPPQUOTE: case STMT_DECLARATION: /* not included in typelib */