Introduce ExprResolveVModMask Which is just a slightly more typesafe wrapper around the chained ExprResolveModMask everyone was using earlier. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
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
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 0dbad1b..2688647 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -383,7 +383,7 @@ CheckModifierField(struct xkb_desc * xkb,
return True;
}
}
- if (!ExprResolveModMask(value, &rtrn, LookupVModMask, (char *) xkb))
+ if (!ExprResolveVModMask(value, &rtrn, xkb))
return ReportMismatch(action, F_Modifiers, "modifier mask");
*mods_rtrn = rtrn.uval;
*flags_inout &= ~XkbSA_UseModMapMods;
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index bae43c4..26117a1 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -711,7 +711,7 @@ HandleGroupCompatDef(GroupCompatDef * def,
}
tmp.fileID = info->fileID;
tmp.merge = merge;
- if (!ExprResolveModMask(def->def, &val, LookupVModMask, (char *) xkb))
+ if (!ExprResolveVModMask(def->def, &val, xkb))
{
ERROR("Expected a modifier mask in group compatibility definition\n");
ACTION("Ignoring illegal compatibility map for group %d\n",
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index f49d1d7..2416bd2 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -28,6 +28,7 @@
#include "xkbmisc.h"
#include "tokens.h"
#include "expr.h"
+#include "vmod.h"
#include <ctype.h>
@@ -277,6 +278,19 @@ ExprResolveModMask(ExprDef * expr,
}
int
+ExprResolveVModMask(ExprDef * expr,
+ ExprResult * val_rtrn,
+ struct xkb_desc *xkb)
+{
+ LookupPriv priv;
+
+ priv.priv = NULL;
+ priv.chain = LookupVModMask;
+ priv.chainPriv = (char *) xkb;
+ return ExprResolveMask(expr, val_rtrn, LookupModMask, (char *) & priv);
+}
+
+int
ExprResolveBoolean(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, char * lookupPriv)
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index 22509a7..538770c 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -99,6 +99,11 @@ extern int ExprResolveModMask(ExprDef * /* expr */ ,
char * /* priv */
);
+extern int ExprResolveVModMask(ExprDef * /* expr */ ,
+ ExprResult * /* val_rtrn */ ,
+ struct xkb_desc * /* xkb */
+ );
+
extern int ExprResolveBoolean(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c
index 2b6c169..eeb2692 100644
--- a/src/xkbcomp/indicators.c
+++ b/src/xkbcomp/indicators.c
@@ -211,7 +211,7 @@ SetIndicatorMapField(LEDInfo * led,
{
if (arrayNdx != NULL)
return ReportIndicatorNotArray(led, field);
- if (!ExprResolveModMask(value, &rtrn, LookupVModMask, (char *) xkb))
+ if (!ExprResolveVModMask(value, &rtrn, xkb))
return ReportIndicatorBadType(led, field, "modifier mask");
led->real_mods = rtrn.uval & 0xff;
led->vmods = (rtrn.uval >> 8) & 0xff;
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index aa18be7..9ea3a7b 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -666,7 +666,7 @@ SetMapEntry(KeyTypeInfo * type,
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(type, "map entry");
- if (!ExprResolveModMask(arrayNdx, &rtrn, LookupVModMask, (char *) xkb))
+ if (!ExprResolveVModMask(arrayNdx, &rtrn, xkb))
return ReportTypeBadType(type, "map entry", "modifier mask");
entry.mods.real_mods = rtrn.uval & 0xff; /* modifiers < 512 */
entry.mods.vmods = (rtrn.uval >> 8) & 0xffff; /* modifiers > 512 */
@@ -712,7 +712,7 @@ SetPreserve(KeyTypeInfo * type,
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(type, "preserve entry");
- if (!ExprResolveModMask(arrayNdx, &rtrn, LookupVModMask, (char *) xkb))
+ if (!ExprResolveVModMask(arrayNdx, &rtrn, xkb))
return ReportTypeBadType(type, "preserve entry", "modifier mask");
new.defs = type->defs;
new.defs.next = NULL;
@@ -731,7 +731,7 @@ SetPreserve(KeyTypeInfo * type,
if (warningLevel > 0)
INFO("%s\n", PreserveIndexTxt(xkb, &new));
}
- if (!ExprResolveModMask(value, &rtrn, LookupVModMask, (char *) xkb))
+ if (!ExprResolveVModMask(value, &rtrn, xkb))
{
ERROR("Preserve value in a key type is not a modifier mask\n");
ACTION("Ignoring preserve[%s] in type %s\n",
@@ -869,7 +869,7 @@ SetKeyTypeField(KeyTypeInfo * type,
ACTION("Illegal array subscript ignored\n");
}
/* get modifier mask for current type */
- if (!ExprResolveModMask(value, &tmp, LookupVModMask, (char *) xkb))
+ if (!ExprResolveVModMask(value, &tmp, xkb))
{
ERROR("Key type mask field must be a modifier mask\n");
ACTION("Key type definition ignored\n");
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 49cef4b..df787d3 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1175,7 +1175,7 @@ SetSymbolsField(KeyInfo * key,
(uStrCaseCmp(field, "virtualmods") == 0) ||
(uStrCaseCmp(field, "virtualmodifiers") == 0))
{
- ok = ExprResolveModMask(value, &tmp, LookupVModMask, (char *) xkb);
+ ok = ExprResolveVModMask(value, &tmp, xkb);
if (ok)
{
key->vmodmap = (tmp.uval >> 8);