widl: Add support for "->" and "." operators in expressions.
authorRob Shearman <rob@codeweavers.com>
Sun, 20 Apr 2008 21:15:43 +0000 (22:15 +0100)
committerAlexandre Julliard <julliard@winehq.org>
Mon, 21 Apr 2008 11:36:19 +0000 (13:36 +0200)
tools/widl/header.c
tools/widl/parser.l
tools/widl/parser.y
tools/widl/typegen.c
tools/widl/widltypes.h

index 3c89d61..d2f7ca7 100644 (file)
@@ -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);
index 5b24b26..3439ea6 100644 (file)
@@ -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)
index c7fbe42..61a1252 100644 (file)
@@ -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; }
index 32e557f..b298403 100644 (file)
@@ -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);
index dfae4dd..256a3ad 100644 (file)
@@ -161,6 +161,8 @@ enum expr_type
     EXPR_COND,
     EXPR_TRUEFALSE,
     EXPR_ADDRESSOF,
+    EXPR_MEMBERPTR,
+    EXPR_MEMBER,
 };
 
 enum type_kind