expr: drop ExprResult from ResolveEnum 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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index cc86387..bdfbbb1 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -508,13 +508,17 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
return true;
}
else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
- if (array_ndx != NULL)
+ unsigned int val;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
+
+ if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
return ReportMismatch(keymap, action->type, field,
"lock or unlock");
+
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
- act->flags |= rtrn.ival;
+ act->flags |= val;
return true;
}
else if (field == F_Count) {
@@ -556,12 +560,15 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
act = (struct xkb_pointer_default_action *) action;
if (field == F_Affect) {
- if (array_ndx != NULL)
+ unsigned int val;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveEnum(keymap->ctx, value, &rtrn, ptrDflts))
+
+ if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
return ReportMismatch(keymap, action->type, field,
"pointer component");
- act->affect = rtrn.uval;
+ act->affect = val;
return true;
}
else if ((field == F_Button) || (field == F_Value)) {
@@ -955,14 +962,18 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->button = val;
return true;
}
- else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect)) {
- if (array_ndx != NULL)
+ else if (action->type == XkbSA_LockDeviceBtn && field == F_Affect) {
+ unsigned int val;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
+
+ if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
return ReportMismatch(keymap, action->type, field,
"lock or unlock");
+
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
- act->flags |= rtrn.ival;
+ act->flags |= val;
return true;
}
else if (field == F_Count) {
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index e898d58..f299f39 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -634,29 +634,28 @@ static int
SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
ExprDef *arrayNdx, ExprDef *value)
{
- int ok = 1;
- ExprResult tmp;
struct xkb_keymap *keymap = info->keymap;
+ ExprResult tmp;
if (istreq(field, "action")) {
- if (arrayNdx != NULL)
+ if (arrayNdx)
return ReportSINotArray(info, si, field);
- ok = HandleActionDef(value, keymap, &si->interp.act.any,
- info->act);
- if (ok)
- si->defined |= _SI_Action;
+
+ if (!HandleActionDef(value, keymap, &si->interp.act.any, info->act))
+ return false;
+
+ si->defined |= _SI_Action;
}
else if (istreq(field, "virtualmodifier") ||
istreq(field, "virtualmod")) {
- if (arrayNdx != NULL)
+ if (arrayNdx)
return ReportSINotArray(info, si, field);
- ok = ResolveVirtualModifier(value, keymap, &tmp, &info->vmods);
- if (ok) {
- si->interp.virtual_mod = tmp.uval;
- si->defined |= _SI_VirtualMod;
- }
- else
+
+ if (!ResolveVirtualModifier(value, keymap, &tmp, &info->vmods))
return ReportSIBadType(info, si, field, "virtual modifier");
+
+ si->interp.virtual_mod = tmp.uval;
+ si->defined |= _SI_VirtualMod;
}
else if (istreq(field, "repeat")) {
bool set;
@@ -692,24 +691,27 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
}
else if (istreq(field, "usemodmap") ||
istreq(field, "usemodmapmods")) {
- if (arrayNdx != NULL)
+ unsigned int val;
+
+ if (arrayNdx)
return ReportSINotArray(info, si, field);
- ok = ExprResolveEnum(keymap->ctx, value, &tmp, useModMapValues);
- if (ok) {
- if (tmp.uval)
- si->interp.match |= XkbSI_LevelOneOnly;
- else
- si->interp.match &= ~XkbSI_LevelOneOnly;
- si->defined |= _SI_LevelOneOnly;
- }
- else
+
+ if (!ExprResolveEnum(keymap->ctx, value, &val, useModMapValues))
return ReportSIBadType(info, si, field, "level specification");
+
+ if (val)
+ si->interp.match |= XkbSI_LevelOneOnly;
+ else
+ si->interp.match &= ~XkbSI_LevelOneOnly;
+
+ si->defined |= _SI_LevelOneOnly;
}
else {
- ok = ReportBadField(keymap, "symbol interpretation", field,
- siText(si, info));
+ return ReportBadField(keymap, "symbol interpretation", field,
+ siText(si, info));
}
- return ok;
+
+ return true;
}
static const LookupEntry modComponentNames[] = {
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 7e10e45..11f803a 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -677,19 +677,19 @@ ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
return false;
}
-/***====================================================================***/
-
-int
+bool
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn, const LookupEntry *values)
+ unsigned int *val_rtrn, const LookupEntry *values)
{
+ ExprResult result;
+
if (expr->op != EXPR_IDENT) {
log_err(ctx, "Found a %s where an enumerated value was expected\n",
exprOpText(expr->op));
return false;
}
- if (!SimpleLookup(ctx, values, expr->value.str, EXPR_TYPE_INT,
- val_rtrn)) {
+
+ if (!SimpleLookup(ctx, values, expr->value.str, EXPR_TYPE_INT, &result)) {
int nOut = 0;
log_err(ctx, "Illegal identifier %s (expected one of: ",
xkb_atom_text(ctx, expr->value.str));
@@ -705,6 +705,8 @@ ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
log_info(ctx, ")\n");
return false;
}
+
+ *val_rtrn = result.uval;
return true;
}
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index 5b0c732..194b668 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -94,9 +94,9 @@ bool
ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
char name[XkbKeyNameLength]);
-extern int
-ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
- const LookupEntry *values);
+bool
+ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
+ unsigned int *val_rtrn, const LookupEntry *values);
bool
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr,
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 6dc9a0d..fcb679f 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1025,7 +1025,6 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
ExprDef *arrayNdx, ExprDef *value)
{
bool ok = true;
- ExprResult tmp;
struct xkb_context *ctx = info->keymap->ctx;
if (istreq(field, "type")) {
@@ -1078,9 +1077,11 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
else if (istreq(field, "locking") ||
istreq(field, "lock") ||
istreq(field, "locks")) {
- ok = ExprResolveEnum(ctx, value, &tmp, lockingEntries);
+ unsigned int val;
+
+ ok = ExprResolveEnum(ctx, value, &val, lockingEntries);
if (ok)
- keyi->behavior.type = tmp.uval;
+ keyi->behavior.type = val;
keyi->defined |= _Key_Behavior;
}
else if (istreq(field, "radiogroup") ||
@@ -1102,7 +1103,9 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
else if (istreq(field, "repeating") ||
istreq(field, "repeats") ||
istreq(field, "repeat")) {
- ok = ExprResolveEnum(ctx, value, &tmp, repeatEntries);
+ unsigned int val;
+
+ ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
if (!ok) {
log_err(info->keymap->ctx,
"Illegal repeat setting for %s; "
@@ -1110,7 +1113,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
longText(keyi->name));
return false;
}
- keyi->repeat = tmp.uval;
+ keyi->repeat = val;
keyi->defined |= _Key_Repeat;
}
else if (istreq(field, "groupswrap") ||