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.
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 @@
constdef: tCONST type ident '=' expr_const { $$ = reg_const($3);
set_type($$, $2, NULL);
$$->eval = $5;
- $$->lval = $5->cval;
}
;
@@ -445,20 +444,20 @@
| 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 @@
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 @@
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 @@
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 @@
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;