darray(SymInterpInfo) interps;
LEDInfo ledDflt;
darray(LEDInfo) leds;
- VModInfo vmods;
ActionsInfo *actions;
struct xkb_keymap *keymap;
} CompatInfo;
info->dflt.interp.virtual_mod = XKB_MOD_INVALID;
info->ledDflt.file_id = file_id;
info->ledDflt.merge = MERGE_OVERRIDE;
- InitVModInfo(&info->vmods, keymap);
}
static void
if (arrayNdx)
return ReportSINotArray(info, si, field);
- if (!ResolveVirtualModifier(value, keymap, &ndx, &info->vmods))
+ if (!ExprResolveVMod(keymap, value, &ndx))
return ReportSIBadType(info, si, field, "virtual modifier");
si->interp.virtual_mod = ndx;
ok = HandleGlobalVar(info, (VarDef *) stmt);
break;
case STMT_VMOD:
- ok = HandleVModDef((VModDef *) stmt, info->keymap, &info->vmods);
+ ok = HandleVModDef(info->keymap, (VModDef *) stmt);
break;
default:
log_err(info->keymap->ctx,
return (*val_rtrn != XKB_MOD_INVALID);
}
-bool
+static bool
LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
enum expr_value_type type, xkb_mod_mask_t *val_rtrn)
{
return ExprResolveMaskLookup(ctx, expr, mask_rtrn, LookupModMask, NULL);
}
+static bool
+LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
+ enum expr_value_type type, xkb_mod_index_t *val_rtrn)
+{
+ const struct xkb_vmod *vmod;
+ xkb_mod_index_t i;
+
+ if (type != EXPR_TYPE_INT)
+ return false;
+
+ darray_enumerate(i, vmod, keymap->vmods) {
+ if (vmod->name == field) {
+ *val_rtrn = i;
+ return true;
+ }
+ }
+
+ return false;
+}
+
+static bool
+LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
+ enum expr_value_type type, xkb_mod_mask_t *val_rtrn)
+{
+ xkb_mod_index_t ndx;
+
+ if (LookupModMask(ctx, NULL, field, type, val_rtrn)) {
+ return true;
+ }
+ else if (LookupVModIndex(priv, field, type, &ndx)) {
+ *val_rtrn = (1 << (XKB_NUM_CORE_MODS + ndx));
+ return true;
+ }
+
+ return false;
+}
+
+
bool
ExprResolveVModMask(struct xkb_keymap *keymap, const ExprDef *expr,
xkb_mod_mask_t *mask_rtrn)
*sym_rtrn = ((xkb_keysym_t) val) + '0';
return true;
}
+
+bool
+ExprResolveVMod(struct xkb_keymap *keymap, const ExprDef *def,
+ xkb_mod_index_t *ndx_rtrn)
+{
+ const struct xkb_vmod *vmod;
+ xkb_mod_index_t i;
+ xkb_atom_t name = def->value.str;
+
+ if (def->op != EXPR_IDENT) {
+ log_err(keymap->ctx,
+ "Cannot resolve virtual modifier: "
+ "found %s where a virtual modifier name was expected\n",
+ expr_op_type_to_string(def->op));
+ return false;
+ }
+
+ darray_enumerate(i, vmod, keymap->vmods) {
+ if (vmod->name == name) {
+ *ndx_rtrn = i;
+ return true;
+ }
+ }
+
+ log_err(keymap->ctx,
+ "Cannot resolve virtual modifier: "
+ "\"%s\" was not previously declared\n",
+ xkb_atom_text(keymap->ctx, name));
+ return false;
+}
ExprDef **index_rtrn);
bool
-LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- enum expr_value_type type, xkb_mod_mask_t *val_rtrn);
-
-bool
-LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- enum expr_value_type type, xkb_mod_mask_t *val_rtrn);
-
-bool
LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
enum expr_value_type type, xkb_mod_index_t *val_rtrn);
xkb_mod_mask_t *mask_rtrn);
bool
+ExprResolveVMod(struct xkb_keymap *keymap, const ExprDef *def,
+ xkb_mod_index_t *ndx_rtrn);
+
+bool
ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
bool *set_rtrn);
xkb_layout_index_t explicit_group;
darray(KeyInfo) keys;
KeyInfo dflt;
- VModInfo vmods;
ActionsInfo *actions;
darray_xkb_atom_t group_names;
darray(ModMapEntry) modMaps;
info->file_id = file_id;
info->merge = MERGE_OVERRIDE;
InitKeyInfo(keymap->ctx, &info->dflt, file_id);
- InitVModInfo(&info->vmods, keymap);
info->actions = actions;
info->explicit_group = XKB_LAYOUT_INVALID;
}
ok = HandleGlobalVar(info, (VarDef *) stmt);
break;
case STMT_VMOD:
- ok = HandleVModDef((VModDef *) stmt, info->keymap, &info->vmods);
+ ok = HandleVModDef(info->keymap, (VModDef *) stmt);
break;
case STMT_MODMAP:
ok = HandleModMapDef(info, (ModMapDef *) stmt);
unsigned file_id;
darray(KeyTypeInfo) types;
- VModInfo vmods;
struct xkb_keymap *keymap;
} KeyTypesInfo;
memset(info, 0, sizeof(*info));
info->keymap = keymap;
info->file_id = file_id;
- InitVModInfo(&info->vmods, keymap);
}
static void
ok = true;
break;
case STMT_VMOD: /* virtual_modifiers NumLock, ... */
- ok = HandleVModDef((VModDef *) stmt, info->keymap, &info->vmods);
+ ok = HandleVModDef(info->keymap, (VModDef *) stmt);
break;
default:
log_err(info->keymap->ctx,
#include "expr.h"
#include "vmod.h"
-void
-InitVModInfo(VModInfo *info, struct xkb_keymap *keymap)
-{
- xkb_mod_index_t i;
-
- memset(info, 0, sizeof(*info));
- for (i = 0; i < darray_size(keymap->vmods); i++)
- info->defined |= (1 << i);
-}
-
bool
-HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, VModInfo *info)
+HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt)
{
xkb_mod_index_t i;
const char *name;
return false;
}
- darray_enumerate(i, vmod, keymap->vmods) {
- if (vmod->name == stmt->name) {
- info->available |= 1 << i;
+ darray_enumerate(i, vmod, keymap->vmods)
+ if (vmod->name == stmt->name)
return true;
- }
- }
if (darray_size(keymap->vmods) >= XKB_MAX_VIRTUAL_MODS) {
log_err(keymap->ctx,
new.name = stmt->name;
new.mapping = 0;
darray_append(keymap->vmods, new);
- info->available |= (1 << (darray_size(keymap->vmods) - 1));
return true;
}
-
-static bool
-LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
- enum expr_value_type type, xkb_mod_index_t *val_rtrn)
-{
- const struct xkb_vmod *vmod;
- xkb_mod_index_t i;
-
- if (type != EXPR_TYPE_INT)
- return false;
-
- darray_enumerate(i, vmod, keymap->vmods) {
- if (vmod->name == field) {
- *val_rtrn = i;
- return true;
- }
- }
-
- return false;
-}
-
-bool
-LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- enum expr_value_type type, xkb_mod_mask_t *val_rtrn)
-{
- xkb_mod_index_t ndx;
-
- if (LookupModMask(ctx, NULL, field, type, val_rtrn)) {
- return true;
- }
- else if (LookupVModIndex(priv, field, type, &ndx)) {
- *val_rtrn = (1 << (XKB_NUM_CORE_MODS + ndx));
- return true;
- }
-
- return false;
-}
-
-bool
-ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
- xkb_mod_index_t *ndx_rtrn, VModInfo *info)
-{
- const struct xkb_vmod *vmod;
- xkb_mod_index_t i;
- xkb_atom_t name = def->value.str;
-
- if (def->op != EXPR_IDENT) {
- log_err(keymap->ctx,
- "Cannot resolve virtual modifier: "
- "found %s where a virtual modifier name was expected\n",
- expr_op_type_to_string(def->op));
- return false;
- }
-
- darray_enumerate(i, vmod, keymap->vmods) {
- if ((info->available & (1 << i)) && vmod->name == name) {
- *ndx_rtrn = i;
- return true;
- }
- }
-
- log_err(keymap->ctx,
- "Cannot resolve virtual modifier: "
- "\"%s\" was not previously declared\n",
- xkb_atom_text(keymap->ctx, name));
- return false;
-}
#ifndef XKBCOMP_VMOD_H
#define XKBCOMP_VMOD_H
-typedef struct {
- xkb_mod_mask_t defined;
- xkb_mod_mask_t available;
-} VModInfo;
-
-void
-InitVModInfo(VModInfo *info, struct xkb_keymap *keymap);
-
-bool
-HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, VModInfo *info);
-
bool
-ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
- xkb_mod_index_t *ndx_rtrn, VModInfo *info);
+HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt);
#endif