widl: Add support for #pragma directives.
This commit is contained in:
parent
1f3e3fa424
commit
cc02e15220
|
@ -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:
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -243,6 +243,7 @@ enum statement_type
|
|||
STMT_TYPEDEF,
|
||||
STMT_IMPORT,
|
||||
STMT_IMPORTLIB,
|
||||
STMT_PRAGMA,
|
||||
STMT_CPPQUOTE
|
||||
};
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue