Remove VModInfo for now VModInfo currently is only used to track which virtual modifiers were declared in the file which owns the VModInfo. This, in turn, is only used in ResolveVirtualModifier, which in turn is only used to resolve the virtualModifier field in an interpret statement (compat.c). In other words, it is used to ensure that interprets can only use a vmod which was declared in the same map. We remove this now, because it doesn't do much and distracts from other changes; we will later re-add it properly. Specificly, we will make it so that virtual modifiers are not the exception in that they modify the keymap directly, instead of keeping the changes in some *Info struct and commiting them to the keymap at the end of the compilation. (This is bad because if a vmod is added to the keymap, and then the compilation of this specific file fails, the change sticks around nonetheless). 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 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index d883ab3..0c94346 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -195,7 +195,6 @@ typedef struct {
darray(SymInterpInfo) interps;
LEDInfo ledDflt;
darray(LEDInfo) leds;
- VModInfo vmods;
ActionsInfo *actions;
struct xkb_keymap *keymap;
} CompatInfo;
@@ -260,7 +259,6 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id,
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
@@ -584,7 +582,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
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;
@@ -898,7 +896,7 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
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,
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index cf6ff40..c8197d1 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -90,7 +90,7 @@ LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
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)
{
@@ -624,6 +624,44 @@ ExprResolveModMask(struct xkb_context *ctx, const ExprDef *expr,
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)
@@ -655,3 +693,33 @@ ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr,
*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;
+}
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index 21d9c5d..a5abce1 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -33,14 +33,6 @@ ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr,
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);
@@ -53,6 +45,10 @@ ExprResolveVModMask(struct xkb_keymap *keymap, const ExprDef *expr,
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);
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index bb6ccc6..06661ae 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -179,7 +179,6 @@ typedef struct {
xkb_layout_index_t explicit_group;
darray(KeyInfo) keys;
KeyInfo dflt;
- VModInfo vmods;
ActionsInfo *actions;
darray_xkb_atom_t group_names;
darray(ModMapEntry) modMaps;
@@ -196,7 +195,6 @@ InitSymbolsInfo(SymbolsInfo *info, struct xkb_keymap *keymap,
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;
}
@@ -1268,7 +1266,7 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
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);
diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c
index 73c1427..5eff5f4 100644
--- a/src/xkbcomp/types.c
+++ b/src/xkbcomp/types.c
@@ -160,7 +160,6 @@ typedef struct {
unsigned file_id;
darray(KeyTypeInfo) types;
- VModInfo vmods;
struct xkb_keymap *keymap;
} KeyTypesInfo;
@@ -219,7 +218,6 @@ InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
memset(info, 0, sizeof(*info));
info->keymap = keymap;
info->file_id = file_id;
- InitVModInfo(&info->vmods, keymap);
}
static void
@@ -761,7 +759,7 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge)
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,
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 51269be..5e8a6c5 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -29,18 +29,8 @@
#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;
@@ -61,12 +51,9 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, VModInfo *info)
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,
@@ -78,73 +65,5 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, VModInfo *info)
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;
-}
diff --git a/src/xkbcomp/vmod.h b/src/xkbcomp/vmod.h
index 6fdd891..9915507 100644
--- a/src/xkbcomp/vmod.h
+++ b/src/xkbcomp/vmod.h
@@ -27,19 +27,7 @@
#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