Robert Shearman : widl: Add support for the builtin constants "TRUE"
and " FALSE".
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jul 7 07:56:05 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: f6278456240f6095a501daedab9ec24c6af1ee18
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=f6278456240f6095a501daedab9ec24c6af1ee18
Author: Robert Shearman <rob at codeweavers.com>
Date: Thu Jul 6 12:56:36 2006 +0100
widl: Add support for the builtin constants "TRUE" and "FALSE".
---
tools/widl/header.c | 6 ++++++
tools/widl/parser.l | 4 +++-
tools/widl/parser.y | 8 +++++++-
tools/widl/typegen.c | 7 +++++++
tools/widl/widltypes.h | 1 +
5 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/tools/widl/header.c b/tools/widl/header.c
index 82637e5..546481a 100644
--- a/tools/widl/header.c
+++ b/tools/widl/header.c
@@ -410,6 +410,12 @@ void write_expr(FILE *h, const expr_t *e
case EXPR_HEXNUM:
fprintf(h, "0x%lx", e->u.lval);
break;
+ case EXPR_TRUEFALSE:
+ if (e->u.lval == 0)
+ fprintf(h, "FALSE");
+ else
+ fprintf(h, "TRUE");
+ break;
case EXPR_IDENTIFIER:
fprintf(h, "%s", e->u.sval);
break;
diff --git a/tools/widl/parser.l b/tools/widl/parser.l
index 01984f3..cefdca9 100644
--- a/tools/widl/parser.l
+++ b/tools/widl/parser.l
@@ -172,6 +172,8 @@ static struct keyword {
int token;
int val;
} keywords[] = {
+ {"FALSE", tFALSE},
+ {"TRUE", tTRUE},
{"__cdecl", tCDECL},
{"__int64", tINT64},
{"__stdcall", tSTDCALL},
@@ -307,7 +309,7 @@ static struct keyword {
{"version", tVERSION},
{"void", tVOID},
{"wchar_t", tWCHAR},
- {"wire_marshal", tWIREMARSHAL}
+ {"wire_marshal", tWIREMARSHAL},
};
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
#define KWP(p) ((const struct keyword *)(p))
diff --git a/tools/widl/parser.y b/tools/widl/parser.y
index 284d802..284f0fd 100644
--- a/tools/widl/parser.y
+++ b/tools/widl/parser.y
@@ -141,6 +141,7 @@ static type_t std_uhyper = { "MIDL_uhype
%token tENDPOINT
%token tENTRY tENUM tERRORSTATUST
%token tEXPLICITHANDLE tEXTERN
+%token tFALSE
%token tFLOAT
%token tHANDLE
%token tHANDLET
@@ -188,6 +189,7 @@ static type_t std_uhyper = { "MIDL_uhype
%token tSTRING tSTRUCT
%token tSWITCH tSWITCHIS tSWITCHTYPE
%token tTRANSMITAS
+%token tTRUE
%token tTYPEDEF
%token tUNION
%token tUNIQUE
@@ -496,6 +498,8 @@ m_expr: { $$ = make_expr(EXPR_VOID)
expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
| aHEXNUM { $$ = make_exprl(EXPR_HEXNUM, $1); }
+ | tFALSE { $$ = make_exprl(EXPR_TRUEFALSE, 0); }
+ | tTRUE { $$ = make_exprl(EXPR_TRUEFALSE, 1); }
| aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
| expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); }
| expr '|' expr { $$ = make_expr2(EXPR_OR , $1, $3); }
@@ -859,7 +863,9 @@ static expr_t *make_exprl(enum expr_type
e->is_const = FALSE;
INIT_LINK(e);
/* check for numeric constant */
- if (type == EXPR_NUM || type == EXPR_HEXNUM) {
+ if (type == EXPR_NUM || type == EXPR_HEXNUM || type == EXPR_TRUEFALSE) {
+ /* make sure true/false value is valid */
+ assert(type != EXPR_TRUEFALSE || val == 0 || val == 1);
e->is_const = TRUE;
e->cval = val;
}
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c
index 20db78c..190fae2 100644
--- a/tools/widl/typegen.c
+++ b/tools/widl/typegen.c
@@ -73,6 +73,7 @@ static int compare_expr(const expr_t *a,
{
case EXPR_NUM:
case EXPR_HEXNUM:
+ case EXPR_TRUEFALSE:
return a->u.lval - b->u.lval;
case EXPR_IDENTIFIER:
return strcmp(a->u.sval, b->u.sval);
@@ -1957,6 +1958,12 @@ static void write_struct_expr(FILE *h, c
case EXPR_HEXNUM:
fprintf(h, "0x%lx", e->u.lval);
break;
+ case EXPR_TRUEFALSE:
+ if (e->u.lval == 0)
+ fprintf(h, "FALSE");
+ else
+ fprintf(h, "TRUE");
+ break;
case EXPR_IDENTIFIER:
{
const var_t *field;
diff --git a/tools/widl/widltypes.h b/tools/widl/widltypes.h
index c86e8c0..508284e 100644
--- a/tools/widl/widltypes.h
+++ b/tools/widl/widltypes.h
@@ -156,6 +156,7 @@ enum expr_type
EXPR_AND,
EXPR_OR,
EXPR_COND,
+ EXPR_TRUEFALSE,
};
enum type_kind
More information about the wine-cvs
mailing list