expr: take xkb_mod_set instead of the entire keymap The modifier-resolving functions only need the modifier information. 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
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index d2baa5f..5389a03 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -270,7 +270,8 @@ CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
}
}
- if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn))
+ if (!ExprResolveModMask(keymap->ctx, value, MOD_BOTH, &keymap->mods,
+ mods_rtrn))
return ReportMismatch(keymap->ctx, action,
ACTION_FIELD_MODIFIERS, "modifier mask");
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 5ee5424..e94c231 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -280,7 +280,8 @@ ResolveStateAndPredicate(ExprDef *expr, enum xkb_match_operation *pred_rtrn,
}
}
- return ExprResolveModMask(info->keymap, expr, MOD_REAL, mods_rtrn);
+ return ExprResolveModMask(info->ctx, expr, MOD_REAL, &info->keymap->mods,
+ mods_rtrn);
}
/***====================================================================***/
@@ -471,7 +472,8 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
if (arrayNdx)
return ReportSINotArray(info, si, field);
- if (!ExprResolveMod(info->keymap, value, MOD_VIRT, &ndx))
+ if (!ExprResolveMod(info->ctx, value, MOD_VIRT, &info->keymap->mods,
+ &ndx))
return ReportSIBadType(info, si, field, "virtual modifier");
si->interp.virtual_mod = ndx;
@@ -526,8 +528,8 @@ SetLedMapField(CompatInfo *info, LedInfo *ledi, const char *field,
if (arrayNdx)
return ReportLedNotArray(info, ledi, field);
- if (!ExprResolveModMask(info->keymap, value, MOD_BOTH,
- &ledi->led.mods.mods))
+ if (!ExprResolveModMask(info->ctx, value, MOD_BOTH,
+ &info->keymap->mods, &ledi->led.mods.mods))
return ReportLedBadType(info, ledi, field, "modifier mask");
ledi->defined |= LED_FIELD_MODS;
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 6d5087d..a85f460 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -83,7 +83,7 @@ SimpleLookup(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
/* Data passed in the *priv argument for LookupModMask. */
typedef struct {
- const struct xkb_keymap *keymap;
+ const struct xkb_mod_set *mods;
enum mod_type mod_type;
} LookupModMaskPriv;
@@ -94,7 +94,7 @@ LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
const char *str;
xkb_mod_index_t ndx;
const LookupModMaskPriv *arg = priv;
- const struct xkb_keymap *keymap = arg->keymap;
+ const struct xkb_mod_set *mods = arg->mods;
enum mod_type mod_type = arg->mod_type;
if (type != EXPR_TYPE_INT)
@@ -112,7 +112,7 @@ LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
return true;
}
- ndx = XkbModNameToIndex(&keymap->mods, field, mod_type);
+ ndx = XkbModNameToIndex(mods, field, mod_type);
if (ndx == XKB_MOD_INVALID)
return false;
@@ -618,12 +618,12 @@ ExprResolveMask(struct xkb_context *ctx, const ExprDef *expr,
}
bool
-ExprResolveModMask(struct xkb_keymap *keymap, const ExprDef *expr,
- enum mod_type mod_type, xkb_mod_mask_t *mask_rtrn)
+ExprResolveModMask(struct xkb_context *ctx, const ExprDef *expr,
+ enum mod_type mod_type, const struct xkb_mod_set *mods,
+ xkb_mod_mask_t *mask_rtrn)
{
- LookupModMaskPriv priv = { .keymap = keymap, .mod_type = mod_type };
- return ExprResolveMaskLookup(keymap->ctx, expr, mask_rtrn, LookupModMask,
- &priv);
+ LookupModMaskPriv priv = { .mods = mods, .mod_type = mod_type };
+ return ExprResolveMaskLookup(ctx, expr, mask_rtrn, LookupModMask, &priv);
}
bool
@@ -650,14 +650,15 @@ ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr,
}
bool
-ExprResolveMod(struct xkb_keymap *keymap, const ExprDef *def,
- enum mod_type mod_type, xkb_mod_index_t *ndx_rtrn)
+ExprResolveMod(struct xkb_context *ctx, const ExprDef *def,
+ enum mod_type mod_type, const struct xkb_mod_set *mods,
+ xkb_mod_index_t *ndx_rtrn)
{
xkb_mod_index_t ndx;
xkb_atom_t name;
if (def->expr.op != EXPR_IDENT) {
- log_err(keymap->ctx,
+ log_err(ctx,
"Cannot resolve virtual modifier: "
"found %s where a virtual modifier name was expected\n",
expr_op_type_to_string(def->expr.op));
@@ -665,12 +666,12 @@ ExprResolveMod(struct xkb_keymap *keymap, const ExprDef *def,
}
name = def->ident.ident;
- ndx = XkbModNameToIndex(&keymap->mods, name, mod_type);
+ ndx = XkbModNameToIndex(mods, name, mod_type);
if (ndx == XKB_MOD_INVALID) {
- log_err(keymap->ctx,
+ log_err(ctx,
"Cannot resolve virtual modifier: "
"\"%s\" was not previously declared\n",
- xkb_atom_text(keymap->ctx, name));
+ xkb_atom_text(ctx, name));
return false;
}
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index 5434ad1..9882b8c 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -33,12 +33,14 @@ ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr,
ExprDef **index_rtrn);
bool
-ExprResolveModMask(struct xkb_keymap *keymap, const ExprDef *expr,
- enum mod_type mod_type, xkb_mod_mask_t *mask_rtrn);
+ExprResolveModMask(struct xkb_context *ctx, const ExprDef *expr,
+ enum mod_type mod_type, const struct xkb_mod_set *mods,
+ xkb_mod_mask_t *mask_rtrn);
bool
-ExprResolveMod(struct xkb_keymap *keymap, const ExprDef *def,
- enum mod_type mod_type, xkb_mod_index_t *ndx_rtrn);
+ExprResolveMod(struct xkb_context *ctx, const ExprDef *def,
+ enum mod_type mod_type, const struct xkb_mod_set *mods,
+ xkb_mod_index_t *ndx_rtrn);
bool
ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 21abfe7..3803ea5 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -822,7 +822,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
istreq(field, "virtualmodifiers")) {
xkb_mod_mask_t mask;
- if (!ExprResolveModMask(info->keymap, value, MOD_VIRT, &mask)) {
+ if (!ExprResolveModMask(info->ctx, value, MOD_VIRT,
+ &info->keymap->mods, &mask)) {
log_err(info->ctx,
"Expected a virtual modifier mask, found %s; "
"Ignoring virtual modifiers definition for key %s\n",
diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c
index 4ef9397..d022999 100644
--- a/src/xkbcomp/types.c
+++ b/src/xkbcomp/types.c
@@ -249,7 +249,8 @@ SetModifiers(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
"The modifiers field of a key type is not an array; "
"Illegal array subscript ignored\n");
- if (!ExprResolveModMask(info->keymap, value, MOD_BOTH, &mods)) {
+ if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->keymap->mods,
+ &mods)) {
log_err(info->ctx,
"Key type mask field must be a modifier mask; "
"Key type definition ignored\n");
@@ -333,7 +334,8 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(info, type, "map entry");
- if (!ExprResolveModMask(info->keymap, arrayNdx, MOD_BOTH, &entry.mods.mods))
+ if (!ExprResolveModMask(info->ctx, arrayNdx, MOD_BOTH,
+ &info->keymap->mods, &entry.mods.mods))
return ReportTypeBadType(info, type, "map entry", "modifier mask");
if (entry.mods.mods & (~type->mods)) {
@@ -422,7 +424,8 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(info, type, "preserve entry");
- if (!ExprResolveModMask(info->keymap, arrayNdx, MOD_BOTH, &mods))
+ if (!ExprResolveModMask(info->ctx, arrayNdx, MOD_BOTH, &info->keymap->mods,
+ &mods))
return ReportTypeBadType(info, type, "preserve entry",
"modifier mask");
@@ -439,7 +442,8 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
TypeTxt(info, type), before, after);
}
- if (!ExprResolveModMask(info->keymap, value, MOD_BOTH, &preserve_mods)) {
+ if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->keymap->mods,
+ &preserve_mods)) {
log_err(info->ctx,
"Preserve value in a key type is not a modifier mask; "
"Ignoring preserve[%s] in type %s\n",
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index d523913..363752e 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -46,7 +46,8 @@ HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt,
* it sets the vmod-to-real-mod[s] mapping directly instead of going
* through modifier_map or some such.
*/
- if (!ExprResolveModMask(keymap, stmt->value, MOD_REAL, &mapping)) {
+ if (!ExprResolveModMask(keymap->ctx, stmt->value, MOD_REAL,
+ &keymap->mods, &mapping)) {
log_err(keymap->ctx,
"Declaration of %s ignored\n",
xkb_atom_text(keymap->ctx, stmt->name));