expr: add 'ident' value to ExprDef union This distinguishes between an identifier expression and a string expression in the union. Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 88323f9..3522dc8 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -267,7 +267,7 @@ CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
{
if (value->op == EXPR_IDENT) {
const char *valStr;
- valStr = xkb_atom_text(keymap->ctx, value->value.str);
+ valStr = xkb_atom_text(keymap->ctx, value->value.ident);
if (valStr && (istreq(valStr, "usemodmapmods") ||
istreq(valStr, "modmapmods"))) {
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index 25172ee..29980aa 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -192,7 +192,7 @@ BoolVarCreate(xkb_atom_t nameToken, unsigned set)
VarDef *def;
name = ExprCreate(EXPR_IDENT, EXPR_TYPE_UNKNOWN);
- name->value.str = nameToken;
+ name->value.ident = nameToken;
value = ExprCreate(EXPR_VALUE, EXPR_TYPE_BOOLEAN);
value->value.uval = set;
def = VarCreate(name, value);
diff --git a/src/xkbcomp/ast.h b/src/xkbcomp/ast.h
index ed8831b..d94550f 100644
--- a/src/xkbcomp/ast.h
+++ b/src/xkbcomp/ast.h
@@ -186,6 +186,7 @@ typedef struct _Expr {
darray(unsigned int) symsNumEntries;
} list;
struct _Expr *child;
+ xkb_atom_t ident;
xkb_atom_t str;
unsigned uval;
int ival;
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 9e17cbb..0775a98 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -444,7 +444,7 @@ ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn,
}
else if (expr->op == EXPR_IDENT) {
const char *pred_txt = xkb_atom_text(info->keymap->ctx,
- expr->value.str);
+ expr->value.ident);
if (pred_txt && istreq(pred_txt, "any")) {
*pred_rtrn = MATCH_ANY;
*mods_rtrn = MOD_REAL_MASK_ALL;
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index dc64d78..4d61609 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -40,7 +40,7 @@ ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr,
switch (expr->op) {
case EXPR_IDENT:
*elem_rtrn = NULL;
- *field_rtrn = xkb_atom_text(ctx, expr->value.str);
+ *field_rtrn = xkb_atom_text(ctx, expr->value.ident);
*index_rtrn = NULL;
return true;
case EXPR_FIELD_REF:
@@ -139,7 +139,7 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
return true;
case EXPR_IDENT:
- ident = xkb_atom_text(ctx, expr->value.str);
+ ident = xkb_atom_text(ctx, expr->value.ident);
if (ident) {
if (istreq(ident, "true") ||
istreq(ident, "yes") ||
@@ -155,7 +155,7 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
}
}
log_err(ctx, "Identifier \"%s\" of type boolean is unknown\n",
- xkb_atom_text(ctx, expr->value.str));
+ xkb_atom_text(ctx, expr->value.ident));
return false;
case EXPR_FIELD_REF:
@@ -298,11 +298,11 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
case EXPR_IDENT:
if (lookup)
- ok = lookup(ctx, lookupPriv, expr->value.str, EXPR_TYPE_INT, &u);
+ ok = lookup(ctx, lookupPriv, expr->value.ident, EXPR_TYPE_INT, &u);
if (!ok)
log_err(ctx, "Identifier \"%s\" of type int is unknown\n",
- xkb_atom_text(ctx, expr->value.str));
+ xkb_atom_text(ctx, expr->value.ident));
else
*val_rtrn = (int) u;
@@ -458,7 +458,7 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr,
case EXPR_IDENT:
log_err(ctx, "Identifier \"%s\" of type string not found\n",
- xkb_atom_text(ctx, expr->value.str));
+ xkb_atom_text(ctx, expr->value.ident));
return false;
case EXPR_FIELD_REF:
@@ -497,10 +497,10 @@ ExprResolveEnum(struct xkb_context *ctx, const ExprDef *expr,
return false;
}
- if (!SimpleLookup(ctx, values, expr->value.str, EXPR_TYPE_INT,
+ if (!SimpleLookup(ctx, values, expr->value.ident, EXPR_TYPE_INT,
val_rtrn)) {
log_err(ctx, "Illegal identifier %s; expected one of:\n",
- xkb_atom_text(ctx, expr->value.str));
+ xkb_atom_text(ctx, expr->value.ident));
while (values && values->name)
{
log_err(ctx, "\t%s\n", values->name);
@@ -535,11 +535,11 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr,
return true;
case EXPR_IDENT:
- ok = lookup(ctx, lookupPriv, expr->value.str, EXPR_TYPE_INT,
+ ok = lookup(ctx, lookupPriv, expr->value.ident, EXPR_TYPE_INT,
val_rtrn);
if (!ok)
log_err(ctx, "Identifier \"%s\" of type int is unknown\n",
- xkb_atom_text(ctx, expr->value.str));
+ xkb_atom_text(ctx, expr->value.ident));
return ok;
case EXPR_FIELD_REF:
@@ -640,7 +640,7 @@ ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr,
if (expr->op == EXPR_IDENT) {
const char *str;
- str = xkb_atom_text(ctx, expr->value.str);
+ str = xkb_atom_text(ctx, expr->value.ident);
*sym_rtrn = xkb_keysym_from_name(str, 0);
if (*sym_rtrn != XKB_KEY_NoSymbol)
return true;
@@ -661,7 +661,7 @@ ExprResolveMod(struct xkb_keymap *keymap, const ExprDef *def,
enum mod_type mod_type, xkb_mod_index_t *ndx_rtrn)
{
xkb_mod_index_t ndx;
- xkb_atom_t name = def->value.str;
+ xkb_atom_t name = def->value.ident;
if (def->op != EXPR_IDENT) {
log_err(keymap->ctx,
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index 01421fc..b48966d 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -669,7 +669,7 @@ Lhs : FieldSpec
{
ExprDef *expr;
expr = ExprCreate(EXPR_IDENT, EXPR_TYPE_UNKNOWN);
- expr->value.str = $1;
+ expr->value.ident = $1;
$$ = expr;
}
| FieldSpec DOT FieldSpec