Rob Shearman : widl: Add support for arrays in expressions.

Alexandre Julliard julliard at winehq.org
Mon Apr 21 07:46:18 CDT 2008


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

Author: Rob Shearman <rob at codeweavers.com>
Date:   Sun Apr 20 22:16:00 2008 +0100

widl: Add support for arrays in expressions.

---

 tools/widl/header.c    |    8 ++++++++
 tools/widl/parser.y    |    3 ++-
 tools/widl/typegen.c   |    9 +++++++++
 tools/widl/widltypes.h |    1 +
 4 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/tools/widl/header.c b/tools/widl/header.c
index d2f7ca7..6989149 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -559,6 +559,14 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
     fprintf(h, "&");
     write_expr(h, e->ref, 1);
     break;
+  case EXPR_ARRAY:
+    if (brackets) fprintf(h, "(");
+    write_expr(h, e->ref, 1);
+    fprintf(h, "[");
+    write_expr(h, e->u.ext, 1);
+    fprintf(h, "]");
+    if (brackets) fprintf(h, ")");
+    break;
   }
 }
 
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 61a1252..32752bf 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -295,7 +295,7 @@ static void add_explicit_handle_if_necessary(func_t *func);
 %left '-' '+'
 %left '*' '/'
 %left SHL SHR
-%left '.' MEMBERPTR
+%left '.' MEMBERPTR '[' ']'
 %right '~'
 %right CAST
 %right PPTR
@@ -644,6 +644,7 @@ expr:	  aNUM					{ $$ = make_exprl(EXPR_NUM, $1); }
 	| 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 '[' expr ']'			{ $$ = make_expr2(EXPR_ARRAY, $1, $3); }
 	| '(' expr ')'				{ $$ = $2; }
 	;
 
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index b298403..da5c95a 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -358,6 +358,7 @@ static int compare_expr(const expr_t *a, const expr_t *b)
         case EXPR_SHR:
         case EXPR_MEMBERPTR:
         case EXPR_MEMBER:
+        case EXPR_ARRAY:
             ret = compare_expr(a->ref, b->ref);
             if (ret != 0)
                 return ret;
@@ -3186,6 +3187,14 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
             fprintf(h, "&");
             write_struct_expr(h, e->ref, 1, fields, structvar);
             break;
+        case EXPR_ARRAY:
+            if (brackets) fprintf(h, "(");
+            write_struct_expr(h, e->ref, 1, fields, structvar);
+            fprintf(h, "[");
+            write_struct_expr(h, e->u.ext, 1, fields, structvar);
+            fprintf(h, "]");
+            if (brackets) fprintf(h, ")");
+            break;
     }
 }
 
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 256a3ad..31c7599 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -163,6 +163,7 @@ enum expr_type
     EXPR_ADDRESSOF,
     EXPR_MEMBERPTR,
     EXPR_MEMBER,
+    EXPR_ARRAY,
 };
 
 enum type_kind




More information about the wine-cvs mailing list