Robert Shearman : widl: The lval member of var_t is essentially a duplicate of eval->cval.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Mar 31 13:04:53 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 4cd506b8fd14ecc7ddc031001348149b31048100
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=4cd506b8fd14ecc7ddc031001348149b31048100

Author: Robert Shearman <rob at codeweavers.com>
Date:   Fri Mar 31 12:45:43 2006 +0100

widl: The lval member of var_t is essentially a duplicate of eval->cval.

- Generate eval's for enums that don't explicitly have one. This means
that enums written in header files won't match exactly what has been put
into the IDL file, but the numeric constat is the same and MIDL does a
similar thing.
- Replace constant lookups with eval->cval instead of lval.

---

 tools/widl/parser.y     |   14 ++++++--------
 tools/widl/widltypes.h  |    1 -
 tools/widl/write_msft.c |    2 +-
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index eb00304..7ab2edf 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -436,7 +436,6 @@ case:	  tCASE expr ':' field			{ attr_t 
 constdef: tCONST type ident '=' expr_const	{ $$ = reg_const($3);
 						  set_type($$, $2, NULL);
 						  $$->eval = $5;
-						  $$->lval = $5->cval;
 						}
 	;
 
@@ -445,20 +444,20 @@ enums:						{ $$ = NULL; }
 	| enum_list
 	;
 
-enum_list: enum
+enum_list: enum					{ if (!$$->eval)
+						    $$->eval = make_exprl(EXPR_NUM, 0 /* default for first enum entry */);
+						}
 	| enum_list ',' enum			{ LINK($3, $1); $$ = $3;
-						  if ($1 && !$3->eval)
-						    $3->lval = $1->lval + 1;
+						  if (!$$->eval)
+						    $$->eval = make_exprl(EXPR_NUM, $1->eval->cval + 1);
 						}
 	;
 
 enum:	  ident '=' expr_const			{ $$ = reg_const($1);
 						  $$->eval = $3;
-						  $$->lval = $3->cval;
                                                   $$->type = make_type(RPC_FC_LONG, &std_int);
 						}
 	| ident					{ $$ = reg_const($1);
-						  $$->lval = 0; /* default for first enum entry */
                                                   $$->type = make_type(RPC_FC_LONG, &std_int);
 						}
 	;
@@ -875,7 +874,7 @@ static expr_t *make_exprs(enum expr_type
       e->u.sval = c->name;
       free(val);
       e->is_const = TRUE;
-      e->cval = c->lval;
+      e->cval = c->eval->cval;
     }
   }
   return e;
@@ -1101,7 +1100,6 @@ static var_t *make_var(char *name)
   v->attrs = NULL;
   v->array = NULL;
   v->eval = NULL;
-  v->lval = 0;
   INIT_LINK(v);
   return v;
 }
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index 30620d0..a2d917b 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -216,7 +216,6 @@ struct _var_t {
   const char *tname;
   attr_t *attrs;
   expr_t *eval;
-  long lval;
 
   /* parser-internal */
   DECL_LINK(var_t)
diff --git a/tools/widl/write_msft.c b/tools/widl/write_msft.c
index ffbe9f8..2af7d66 100644
--- a/tools/widl/write_msft.c
+++ b/tools/widl/write_msft.c
@@ -1559,7 +1559,7 @@ static HRESULT add_var_desc(msft_typeinf
 
     switch(typeinfo->typeinfo->typekind & 0xf) {
     case TKIND_ENUM:
-        write_value(typeinfo->typelib, &typedata[4], VT_I4, &var->lval);
+        write_value(typeinfo->typelib, &typedata[4], VT_I4, &var->eval->cval);
         var_kind = 2; /* VAR_CONST */
         var_type_size += 16; /* sizeof(VARIANT) */
         typeinfo->datawidth = var_datawidth;




More information about the wine-cvs mailing list