From 67605d2c90f93c0332c7a465e44e9dd57cb83bae Mon Sep 17 00:00:00 2001 From: Daniel Stone Date: Mon, 20 Feb 2012 13:32:09 +0000 Subject: [PATCH] Introduce ExprResolveVModMask Which is just a slightly more typesafe wrapper around the chained ExprResolveModMask everyone was using earlier. Signed-off-by: Daniel Stone --- src/xkbcomp/action.c | 2 +- src/xkbcomp/compat.c | 2 +- src/xkbcomp/expr.c | 14 ++++++++++++++ src/xkbcomp/expr.h | 5 +++++ src/xkbcomp/indicators.c | 2 +- src/xkbcomp/keytypes.c | 8 ++++---- src/xkbcomp/symbols.c | 2 +- 7 files changed, 27 insertions(+), 8 deletions(-) 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 @@ -276,6 +277,19 @@ ExprResolveModMask(ExprDef * expr, return ExprResolveMask(expr, val_rtrn, LookupModMask, (char *) & priv); } +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, 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);