widl: Add support for the builtin constants "TRUE" and "FALSE".
This commit is contained in:
parent
5f453db5cf
commit
f627845624
|
@ -410,6 +410,12 @@ void write_expr(FILE *h, const expr_t *e, int brackets)
|
||||||
case EXPR_HEXNUM:
|
case EXPR_HEXNUM:
|
||||||
fprintf(h, "0x%lx", e->u.lval);
|
fprintf(h, "0x%lx", e->u.lval);
|
||||||
break;
|
break;
|
||||||
|
case EXPR_TRUEFALSE:
|
||||||
|
if (e->u.lval == 0)
|
||||||
|
fprintf(h, "FALSE");
|
||||||
|
else
|
||||||
|
fprintf(h, "TRUE");
|
||||||
|
break;
|
||||||
case EXPR_IDENTIFIER:
|
case EXPR_IDENTIFIER:
|
||||||
fprintf(h, "%s", e->u.sval);
|
fprintf(h, "%s", e->u.sval);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -172,6 +172,8 @@ static struct keyword {
|
||||||
int token;
|
int token;
|
||||||
int val;
|
int val;
|
||||||
} keywords[] = {
|
} keywords[] = {
|
||||||
|
{"FALSE", tFALSE},
|
||||||
|
{"TRUE", tTRUE},
|
||||||
{"__cdecl", tCDECL},
|
{"__cdecl", tCDECL},
|
||||||
{"__int64", tINT64},
|
{"__int64", tINT64},
|
||||||
{"__stdcall", tSTDCALL},
|
{"__stdcall", tSTDCALL},
|
||||||
|
@ -307,7 +309,7 @@ static struct keyword {
|
||||||
{"version", tVERSION},
|
{"version", tVERSION},
|
||||||
{"void", tVOID},
|
{"void", tVOID},
|
||||||
{"wchar_t", tWCHAR},
|
{"wchar_t", tWCHAR},
|
||||||
{"wire_marshal", tWIREMARSHAL}
|
{"wire_marshal", tWIREMARSHAL},
|
||||||
};
|
};
|
||||||
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
|
#define NKEYWORDS (sizeof(keywords)/sizeof(keywords[0]))
|
||||||
#define KWP(p) ((const struct keyword *)(p))
|
#define KWP(p) ((const struct keyword *)(p))
|
||||||
|
|
|
@ -141,6 +141,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
|
||||||
%token tENDPOINT
|
%token tENDPOINT
|
||||||
%token tENTRY tENUM tERRORSTATUST
|
%token tENTRY tENUM tERRORSTATUST
|
||||||
%token tEXPLICITHANDLE tEXTERN
|
%token tEXPLICITHANDLE tEXTERN
|
||||||
|
%token tFALSE
|
||||||
%token tFLOAT
|
%token tFLOAT
|
||||||
%token tHANDLE
|
%token tHANDLE
|
||||||
%token tHANDLET
|
%token tHANDLET
|
||||||
|
@ -188,6 +189,7 @@ static type_t std_uhyper = { "MIDL_uhyper" };
|
||||||
%token tSTRING tSTRUCT
|
%token tSTRING tSTRUCT
|
||||||
%token tSWITCH tSWITCHIS tSWITCHTYPE
|
%token tSWITCH tSWITCHIS tSWITCHTYPE
|
||||||
%token tTRANSMITAS
|
%token tTRANSMITAS
|
||||||
|
%token tTRUE
|
||||||
%token tTYPEDEF
|
%token tTYPEDEF
|
||||||
%token tUNION
|
%token tUNION
|
||||||
%token tUNIQUE
|
%token tUNIQUE
|
||||||
|
@ -496,6 +498,8 @@ m_expr: { $$ = make_expr(EXPR_VOID); }
|
||||||
|
|
||||||
expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
|
expr: aNUM { $$ = make_exprl(EXPR_NUM, $1); }
|
||||||
| aHEXNUM { $$ = make_exprl(EXPR_HEXNUM, $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); }
|
| aIDENTIFIER { $$ = make_exprs(EXPR_IDENTIFIER, $1); }
|
||||||
| expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); }
|
| expr '?' expr ':' expr { $$ = make_expr3(EXPR_COND, $1, $3, $5); }
|
||||||
| expr '|' expr { $$ = make_expr2(EXPR_OR , $1, $3); }
|
| expr '|' expr { $$ = make_expr2(EXPR_OR , $1, $3); }
|
||||||
|
@ -859,7 +863,9 @@ static expr_t *make_exprl(enum expr_type type, long val)
|
||||||
e->is_const = FALSE;
|
e->is_const = FALSE;
|
||||||
INIT_LINK(e);
|
INIT_LINK(e);
|
||||||
/* check for numeric constant */
|
/* 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->is_const = TRUE;
|
||||||
e->cval = val;
|
e->cval = val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ static int compare_expr(const expr_t *a, const expr_t *b)
|
||||||
{
|
{
|
||||||
case EXPR_NUM:
|
case EXPR_NUM:
|
||||||
case EXPR_HEXNUM:
|
case EXPR_HEXNUM:
|
||||||
|
case EXPR_TRUEFALSE:
|
||||||
return a->u.lval - b->u.lval;
|
return a->u.lval - b->u.lval;
|
||||||
case EXPR_IDENTIFIER:
|
case EXPR_IDENTIFIER:
|
||||||
return strcmp(a->u.sval, b->u.sval);
|
return strcmp(a->u.sval, b->u.sval);
|
||||||
|
@ -1957,6 +1958,12 @@ static void write_struct_expr(FILE *h, const expr_t *e, int brackets,
|
||||||
case EXPR_HEXNUM:
|
case EXPR_HEXNUM:
|
||||||
fprintf(h, "0x%lx", e->u.lval);
|
fprintf(h, "0x%lx", e->u.lval);
|
||||||
break;
|
break;
|
||||||
|
case EXPR_TRUEFALSE:
|
||||||
|
if (e->u.lval == 0)
|
||||||
|
fprintf(h, "FALSE");
|
||||||
|
else
|
||||||
|
fprintf(h, "TRUE");
|
||||||
|
break;
|
||||||
case EXPR_IDENTIFIER:
|
case EXPR_IDENTIFIER:
|
||||||
{
|
{
|
||||||
const var_t *field;
|
const var_t *field;
|
||||||
|
|
|
@ -156,6 +156,7 @@ enum expr_type
|
||||||
EXPR_AND,
|
EXPR_AND,
|
||||||
EXPR_OR,
|
EXPR_OR,
|
||||||
EXPR_COND,
|
EXPR_COND,
|
||||||
|
EXPR_TRUEFALSE,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum type_kind
|
enum type_kind
|
||||||
|
|
Loading…
Reference in New Issue