The modifier-resolving functions only need the modifier information.
Signed-off-by: Ran Benita <ran234@gmail.com>
}
}
- 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");
}
}
- return ExprResolveModMask(info->keymap, expr, MOD_REAL, mods_rtrn);
+ return ExprResolveModMask(info->ctx, expr, MOD_REAL, &info->keymap->mods,
+ mods_rtrn);
}
/***====================================================================***/
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;
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;
/* 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;
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)
return true;
}
- ndx = XkbModNameToIndex(&keymap->mods, field, mod_type);
+ ndx = XkbModNameToIndex(mods, field, mod_type);
if (ndx == XKB_MOD_INVALID)
return false;
}
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
}
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));
}
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;
}
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,
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",
"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");
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)) {
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");
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",
* 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));