Module: wine Branch: master Commit: 03d5017416adfd47fe86d8ecf97af8a028ca7748 URL: http://source.winehq.org/git/wine.git/?a=commit;h=03d5017416adfd47fe86d8ecf9...
Author: Rob Shearman rob@codeweavers.com Date: Sun Apr 20 22:15:43 2008 +0100
widl: Add support for "->" and "." operators in expressions.
---
tools/widl/header.c | 4 ++++ tools/widl/parser.l | 1 + tools/widl/parser.y | 6 +++++- tools/widl/typegen.c | 6 ++++++ tools/widl/widltypes.h | 2 ++ 5 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c index 3c89d61..d2f7ca7 100644 --- a/tools/widl/header.c +++ b/tools/widl/header.c @@ -526,6 +526,8 @@ void write_expr(FILE *h, const expr_t *e, int brackets) case EXPR_SUB: case EXPR_AND: case EXPR_OR: + case EXPR_MEMBERPTR: + case EXPR_MEMBER: if (brackets) fprintf(h, "("); write_expr(h, e->ref, 1); switch (e->type) { @@ -537,6 +539,8 @@ void write_expr(FILE *h, const expr_t *e, int brackets) case EXPR_SUB: fprintf(h, " - "); break; case EXPR_AND: fprintf(h, " & "); break; case EXPR_OR: fprintf(h, " | "); break; + case EXPR_MEMBERPTR: fprintf(h, "->"); break; + case EXPR_MEMBER: fprintf(h, "."); break; default: break; } write_expr(h, e->u.ext, 1); diff --git a/tools/widl/parser.l b/tools/widl/parser.l index 5b24b26..3439ea6 100644 --- a/tools/widl/parser.l +++ b/tools/widl/parser.l @@ -162,6 +162,7 @@ SAFEARRAY{ws}*/( return tSAFEARRAY; <INITIAL,ATTR>{ws} <INITIAL,ATTR><< return SHL; <INITIAL,ATTR>>> return SHR; +<INITIAL,ATTR>-> return MEMBERPTR; <INITIAL,ATTR>. return yytext[0]; <<EOF>> { if (import_stack_ptr) diff --git a/tools/widl/parser.y b/tools/widl/parser.y index c7fbe42..61a1252 100644 --- a/tools/widl/parser.y +++ b/tools/widl/parser.y @@ -180,6 +180,7 @@ static void add_explicit_handle_if_necessary(func_t *func); %token <uuid> aUUID %token aEOF %token SHL SHR +%token MEMBERPTR %token tAGGREGATABLE tALLOCATE tAPPOBJECT tASYNC tASYNCUUID %token tAUTOHANDLE tBINDABLE tBOOLEAN tBROADCAST tBYTE tBYTECOUNT %token tCALLAS tCALLBACK tCASE tCDECL tCHAR tCOCLASS tCODE tCOMMSTATUS @@ -294,6 +295,7 @@ static void add_explicit_handle_if_necessary(func_t *func); %left '-' '+' %left '*' '/' %left SHL SHR +%left '.' MEMBERPTR %right '~' %right CAST %right PPTR @@ -636,8 +638,10 @@ expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); } | expr SHR expr { $$ = make_expr2(EXPR_SHR, $1, $3); } | '~' expr { $$ = make_expr1(EXPR_NOT, $2); } | '-' expr %prec NEG { $$ = make_expr1(EXPR_NEG, $2); } - | '&' expr %prec ADDRESSOF { $$ = make_expr1(EXPR_ADDRESSOF, $2); } + | '&' expr %prec ADDRESSOF { $$ = make_expr1(EXPR_ADDRESSOF, $2); } | '*' expr %prec PPTR { $$ = make_expr1(EXPR_PPTR, $2); } + | expr MEMBERPTR expr { $$ = make_expr2(EXPR_MEMBERPTR, $1, $3); } + | expr '.' expr { $$ = make_expr2(EXPR_MEMBER, $1, $3); } | '(' type ')' expr %prec CAST { $$ = make_exprt(EXPR_CAST, $2, $4); } | tSIZEOF '(' type ')' { $$ = make_exprt(EXPR_SIZEOF, $3, NULL); } | '(' expr ')' { $$ = $2; } diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 32e557f..b298403 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -356,6 +356,8 @@ static int compare_expr(const expr_t *a, const expr_t *b) case EXPR_DIV: case EXPR_SHL: case EXPR_SHR: + case EXPR_MEMBERPTR: + case EXPR_MEMBER: ret = compare_expr(a->ref, b->ref); if (ret != 0) return ret; @@ -3151,6 +3153,8 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets, case EXPR_SUB: case EXPR_AND: case EXPR_OR: + case EXPR_MEMBERPTR: + case EXPR_MEMBER: if (brackets) fprintf(h, "("); write_struct_expr(h, e->ref, 1, fields, structvar); switch (e->type) { @@ -3162,6 +3166,8 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets, case EXPR_SUB: fprintf(h, " - "); break; case EXPR_AND: fprintf(h, " & "); break; case EXPR_OR: fprintf(h, " | "); break; + case EXPR_MEMBERPTR: fprintf(h, "->"); break; + case EXPR_MEMBER: fprintf(h, "."); break; default: break; } write_struct_expr(h, e->u.ext, 1, fields, structvar); diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h index dfae4dd..256a3ad 100644 --- a/tools/widl/widltypes.h +++ b/tools/widl/widltypes.h @@ -161,6 +161,8 @@ enum expr_type EXPR_COND, EXPR_TRUEFALSE, EXPR_ADDRESSOF, + EXPR_MEMBERPTR, + EXPR_MEMBER, };
enum type_kind