#include "text.h"
#include "expr.h"
#include "action.h"
-#include "keycodes.h"
-static const ExprDef constTrue = {
- .common = { .type = STMT_EXPR, .next = NULL },
- .op = EXPR_VALUE,
- .value_type = EXPR_TYPE_BOOLEAN,
- .value = { .ival = 1 },
+static const ExprBoolean constTrue = {
+ .expr = {
+ .common = { .type = STMT_EXPR, .next = NULL },
+ .op = EXPR_VALUE,
+ .value_type = EXPR_TYPE_BOOLEAN,
+ },
+ .set = true,
};
-static const ExprDef constFalse = {
- .common = { .type = STMT_EXPR, .next = NULL },
- .op = EXPR_VALUE,
- .value_type = EXPR_TYPE_BOOLEAN,
- .value = { .ival = 0 },
+static const ExprBoolean constFalse = {
+ .expr = {
+ .common = { .type = STMT_EXPR, .next = NULL },
+ .op = EXPR_VALUE,
+ .value_type = EXPR_TYPE_BOOLEAN,
+ },
+ .set = false,
};
enum action_field {
/* Increment default button. */
info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.flags = 0;
info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.value = 1;
+ info->actions[ACTION_TYPE_PTR_MOVE].ptr.flags = ACTION_ACCEL;
+ info->actions[ACTION_TYPE_SWITCH_VT].screen.flags = ACTION_SAME_SCREEN;
return info;
}
/***====================================================================***/
static inline bool
-ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action,
+ReportMismatch(struct xkb_context *ctx, enum xkb_action_type action,
enum action_field field, const char *type)
{
- log_err(keymap->ctx,
+ log_err(ctx,
"Value of %s field must be of type %s; "
"Action %s definition ignored\n",
fieldText(field), type, ActionTypeText(action));
}
static inline bool
-ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action,
+ReportIllegal(struct xkb_context *ctx, enum xkb_action_type action,
enum action_field field)
{
- log_err(keymap->ctx,
+ log_err(ctx,
"Field %s is not defined for an action of type %s; "
"Action definition ignored\n",
fieldText(field), ActionTypeText(action));
}
static inline bool
-ReportActionNotArray(struct xkb_keymap *keymap, enum xkb_action_type action,
+ReportActionNotArray(struct xkb_context *ctx, enum xkb_action_type action,
enum action_field field)
{
- log_err(keymap->ctx,
+ log_err(ctx,
"The %s field in the %s action is not an array; "
"Action definition ignored\n",
fieldText(field), ActionTypeText(action));
return false;
}
-static inline bool
-ReportNotFound(struct xkb_keymap *keymap, enum xkb_action_type action,
- enum action_field field, const char *what, const char *bad)
-{
- log_err(keymap->ctx,
- "%s named %s not found; "
- "Ignoring the %s field of an %s action\n",
- what, bad, fieldText(field), ActionTypeText(action));
- return false;
-}
-
static bool
HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
enum action_field field, const ExprDef *array_ndx,
}
static bool
-CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
- enum action_field field, const ExprDef * value,
- enum xkb_action_flags *flags_inout)
+CheckBooleanFlag(struct xkb_context *ctx, enum xkb_action_type action,
+ enum action_field field, enum xkb_action_flags flag,
+ const ExprDef *array_ndx, const ExprDef *value,
+ enum xkb_action_flags *flags_inout)
{
- enum xkb_action_flags tmp;
- bool result;
+ bool set;
- if (field == ACTION_FIELD_CLEAR_LOCKS)
- tmp = ACTION_LOCK_CLEAR;
- else if (field == ACTION_FIELD_LATCH_TO_LOCK)
- tmp = ACTION_LATCH_TO_LOCK;
- else
- return false; /* WSGO! */
+ if (array_ndx)
+ return ReportActionNotArray(ctx, action, field);
- if (!ExprResolveBoolean(keymap->ctx, value, &result))
- return ReportMismatch(keymap, action, field, "boolean");
+ if (!ExprResolveBoolean(ctx, value, &set))
+ return ReportMismatch(ctx, action, field, "boolean");
- if (result)
- *flags_inout |= tmp;
+ if (set)
+ *flags_inout |= flag;
else
- *flags_inout &= ~tmp;
+ *flags_inout &= ~flag;
return true;
}
static bool
CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
- const ExprDef *value, enum xkb_action_flags *flags_inout,
- xkb_mod_mask_t *mods_rtrn)
+ const ExprDef *array_ndx, const ExprDef *value,
+ enum xkb_action_flags *flags_inout, xkb_mod_mask_t *mods_rtrn)
{
- if (value->op == EXPR_IDENT) {
+ if (array_ndx)
+ return ReportActionNotArray(keymap->ctx, action, ACTION_FIELD_MODIFIERS);
+
+ if (value->expr.op == EXPR_IDENT) {
const char *valStr;
- valStr = xkb_atom_text(keymap->ctx, value->value.str);
+ valStr = xkb_atom_text(keymap->ctx, value->ident.ident);
if (valStr && (istreq(valStr, "usemodmapmods") ||
istreq(valStr, "modmapmods"))) {
-
*mods_rtrn = 0;
*flags_inout |= ACTION_MODS_LOOKUP_MODMAP;
return true;
}
}
- if (!ExprResolveVModMask(keymap, value, mods_rtrn))
- return ReportMismatch(keymap, action,
+ if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn))
+ return ReportMismatch(keymap->ctx, action,
ACTION_FIELD_MODIFIERS, "modifier mask");
*flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
const ExprDef *value)
{
struct xkb_mod_action *act = &action->mods;
- enum xkb_action_flags rtrn, t1;
- xkb_mod_mask_t t2;
-
- if (array_ndx != NULL) {
- switch (field) {
- case ACTION_FIELD_CLEAR_LOCKS:
- case ACTION_FIELD_LATCH_TO_LOCK:
- case ACTION_FIELD_MODIFIERS:
- return ReportActionNotArray(keymap, action->type, field);
- default:
- break;
- }
- }
- switch (field) {
- case ACTION_FIELD_CLEAR_LOCKS:
- case ACTION_FIELD_LATCH_TO_LOCK:
- rtrn = act->flags;
- if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
- act->flags = rtrn;
- return true;
- }
- return false;
+ if (field == ACTION_FIELD_CLEAR_LOCKS)
+ return CheckBooleanFlag(keymap->ctx, action->type, field,
+ ACTION_LOCK_CLEAR, array_ndx, value,
+ &act->flags);
+ if (field == ACTION_FIELD_LATCH_TO_LOCK)
+ return CheckBooleanFlag(keymap->ctx, action->type, field,
+ ACTION_LATCH_TO_LOCK, array_ndx, value,
+ &act->flags);
+ if (field == ACTION_FIELD_MODIFIERS)
+ return CheckModifierField(keymap, action->type, array_ndx, value,
+ &act->flags, &act->mods.mods);
+
+ return ReportIllegal(keymap->ctx, action->type, field);
+}
- case ACTION_FIELD_MODIFIERS:
- t1 = act->flags;
- if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
- act->flags = t1;
- act->mods.mods = t2;
- return true;
- }
- return false;
+static const LookupEntry lockWhich[] = {
+ { "both", 0 },
+ { "lock", ACTION_LOCK_NO_UNLOCK },
+ { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) },
+ { "unlock", ACTION_LOCK_NO_LOCK },
+ { NULL, 0 }
+};
- default:
- break;
- }
+static bool
+CheckAffectField(struct xkb_context *ctx, enum xkb_action_type action,
+ const ExprDef *array_ndx, const ExprDef *value,
+ enum xkb_action_flags *flags_inout)
+{
+ enum xkb_action_flags flags;
+
+ if (array_ndx)
+ return ReportActionNotArray(ctx, action, ACTION_FIELD_AFFECT);
- return ReportIllegal(keymap, action->type, field);
+ if (!ExprResolveEnum(ctx, value, &flags, lockWhich))
+ return ReportMismatch(ctx, action, ACTION_FIELD_AFFECT,
+ "lock, unlock, both, neither");
+
+ *flags_inout &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
+ *flags_inout |= flags;
+ return true;
}
static bool
const ExprDef *value)
{
struct xkb_mod_action *act = &action->mods;
- enum xkb_action_flags t1;
- xkb_mod_mask_t t2;
-
- if (array_ndx && field == ACTION_FIELD_MODIFIERS)
- return ReportActionNotArray(keymap, action->type, field);
-
- switch (field) {
- case ACTION_FIELD_MODIFIERS:
- t1 = act->flags;
- if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
- act->flags = t1;
- act->mods.mods = t2;
- return true;
- }
- return false;
- default:
- break;
- }
+ if (field == ACTION_FIELD_MODIFIERS)
+ return CheckModifierField(keymap, action->type, array_ndx, value,
+ &act->flags, &act->mods.mods);
+ else if (field == ACTION_FIELD_AFFECT)
+ return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
+ &act->flags);
- return ReportIllegal(keymap, action->type, field);
+ return ReportIllegal(keymap->ctx, action->type, field);
}
static bool
-CheckGroupField(struct xkb_keymap *keymap, unsigned action,
- const ExprDef *value, enum xkb_action_flags *flags_inout,
- xkb_layout_index_t *grp_rtrn)
+CheckGroupField(struct xkb_context *ctx, unsigned action,
+ const ExprDef *array_ndx, const ExprDef *value,
+ enum xkb_action_flags *flags_inout, int32_t *group_rtrn)
{
const ExprDef *spec;
+ xkb_layout_index_t idx;
+ enum xkb_action_flags flags = *flags_inout;
- if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
- *flags_inout &= ~ACTION_ABSOLUTE_SWITCH;
- spec = value->value.child;
+ if (array_ndx)
+ return ReportActionNotArray(ctx, action, ACTION_FIELD_GROUP);
+
+ if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) {
+ flags &= ~ACTION_ABSOLUTE_SWITCH;
+ spec = value->unary.child;
}
else {
- *flags_inout |= ACTION_ABSOLUTE_SWITCH;
+ flags |= ACTION_ABSOLUTE_SWITCH;
spec = value;
}
- if (!ExprResolveGroup(keymap->ctx, spec, grp_rtrn))
- return ReportMismatch(keymap, action, ACTION_FIELD_GROUP,
+ if (!ExprResolveGroup(ctx, spec, &idx))
+ return ReportMismatch(ctx, action, ACTION_FIELD_GROUP,
"integer (range 1..8)");
- if (value->op == EXPR_NEGATE)
- *grp_rtrn = -*grp_rtrn;
- else if (value->op != EXPR_UNARY_PLUS)
- (*grp_rtrn)--;
-
+ /* +n, -n are relative, n is absolute. */
+ if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) {
+ *group_rtrn = (int32_t) idx;
+ if (value->expr.op == EXPR_NEGATE)
+ *group_rtrn = -*group_rtrn;
+ }
+ else {
+ *group_rtrn = (int32_t) (idx - 1);
+ }
+ *flags_inout = flags;
return true;
}
const ExprDef *value)
{
struct xkb_group_action *act = &action->group;
- enum xkb_action_flags rtrn, t1;
- xkb_layout_index_t t2;
-
- if (array_ndx != NULL) {
- switch (field) {
- case ACTION_FIELD_CLEAR_LOCKS:
- case ACTION_FIELD_LATCH_TO_LOCK:
- case ACTION_FIELD_GROUP:
- return ReportActionNotArray(keymap, action->type, field);
-
- default:
- break;
- }
- }
-
- switch (field) {
- case ACTION_FIELD_CLEAR_LOCKS:
- case ACTION_FIELD_LATCH_TO_LOCK:
- rtrn = act->flags;
- if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
- act->flags = rtrn;
- return true;
- }
- return false;
-
- case ACTION_FIELD_GROUP:
- t1 = act->flags;
- if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
- act->flags = t1;
- act->group = t2;
- return true;
- }
- return false;
- default:
- break;
- }
-
- return ReportIllegal(keymap, action->type, field);
+ if (field == ACTION_FIELD_CLEAR_LOCKS)
+ return CheckBooleanFlag(keymap->ctx, action->type, field,
+ ACTION_LOCK_CLEAR, array_ndx, value,
+ &act->flags);
+ if (field == ACTION_FIELD_LATCH_TO_LOCK)
+ return CheckBooleanFlag(keymap->ctx, action->type, field,
+ ACTION_LATCH_TO_LOCK, array_ndx, value,
+ &act->flags);
+ if (field == ACTION_FIELD_GROUP)
+ return CheckGroupField(keymap->ctx, action->type, array_ndx, value,
+ &act->flags, &act->group);
+
+ return ReportIllegal(keymap->ctx, action->type, field);
}
static bool
const ExprDef *value)
{
struct xkb_group_action *act = &action->group;
- enum xkb_action_flags t1;
- xkb_layout_index_t t2;
-
- if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP))
- return ReportActionNotArray(keymap, action->type, field);
- if (field == ACTION_FIELD_GROUP) {
- t1 = act->flags;
- if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
- act->flags = t1;
- act->group = t2;
- return true;
- }
- return false;
- }
- return ReportIllegal(keymap, action->type, field);
+
+ if (field == ACTION_FIELD_GROUP)
+ return CheckGroupField(keymap->ctx, action->type, array_ndx, value,
+ &act->flags, &act->group);
+
+ return ReportIllegal(keymap->ctx, action->type, field);
}
static bool
const ExprDef *value)
{
struct xkb_pointer_action *act = &action->ptr;
- bool absolute;
-
- if (array_ndx && (field == ACTION_FIELD_X || field == ACTION_FIELD_Y))
- return ReportActionNotArray(keymap, action->type, field);
if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) {
int val;
+ const bool absolute = (value->expr.op != EXPR_NEGATE &&
+ value->expr.op != EXPR_UNARY_PLUS);
- if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS)
- absolute = false;
- else
- absolute = true;
+ if (array_ndx)
+ return ReportActionNotArray(keymap->ctx, action->type, field);
if (!ExprResolveInteger(keymap->ctx, value, &val))
- return ReportMismatch(keymap, action->type, field, "integer");
+ return ReportMismatch(keymap->ctx, action->type, field, "integer");
+
+ if (val < INT16_MIN || val > INT16_MAX) {
+ log_err(keymap->ctx,
+ "The %s field in the %s action must be in range %d..%d; "
+ "Action definition ignored\n",
+ fieldText(field), ActionTypeText(action->type),
+ INT16_MIN, INT16_MAX);
+ return false;
+ }
if (field == ACTION_FIELD_X) {
if (absolute)
act->flags |= ACTION_ABSOLUTE_X;
- act->x = val;
+ act->x = (int16_t) val;
}
else {
if (absolute)
act->flags |= ACTION_ABSOLUTE_Y;
- act->y = val;
+ act->y = (int16_t) val;
}
return true;
}
else if (field == ACTION_FIELD_ACCEL) {
- bool set;
-
- if (!ExprResolveBoolean(keymap->ctx, value, &set))
- return ReportMismatch(keymap, action->type, field, "boolean");
-
- if (set)
- act->flags &= ~ACTION_NO_ACCEL;
- else
- act->flags |= ACTION_NO_ACCEL;
+ return CheckBooleanFlag(keymap->ctx, action->type, field,
+ ACTION_ACCEL, array_ndx, value, &act->flags);
}
- return ReportIllegal(keymap, action->type, field);
+ return ReportIllegal(keymap->ctx, action->type, field);
}
-static const LookupEntry lockWhich[] = {
- { "both", 0 },
- { "lock", ACTION_LOCK_NO_UNLOCK },
- { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) },
- { "unlock", ACTION_LOCK_NO_LOCK },
- { NULL, 0 }
-};
-
static bool
HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
enum action_field field, const ExprDef *array_ndx,
int btn;
if (array_ndx)
- return ReportActionNotArray(keymap, action->type, field);
+ return ReportActionNotArray(keymap->ctx, action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &btn))
- return ReportMismatch(keymap, action->type, field,
+ return ReportMismatch(keymap->ctx, action->type, field,
"integer (range 1..5)");
if (btn < 0 || btn > 5) {
}
else if (action->type == ACTION_TYPE_PTR_LOCK &&
field == ACTION_FIELD_AFFECT) {
- enum xkb_action_flags val;
-
- if (array_ndx)
- return ReportActionNotArray(keymap, action->type, field);
-
- if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
- return ReportMismatch(keymap, action->type, field,
- "lock or unlock");
-
- act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
- act->flags |= val;
- return true;
+ return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
+ &act->flags);
}
else if (field == ACTION_FIELD_COUNT) {
- int btn;
+ int val;
if (array_ndx)
- return ReportActionNotArray(keymap, action->type, field);
+ return ReportActionNotArray(keymap->ctx, action->type, field);
- /* XXX: Should this actually be ResolveButton? */
- if (!ExprResolveButton(keymap->ctx, value, &btn))
- return ReportMismatch(keymap, action->type, field, "integer");
+ if (!ExprResolveInteger(keymap->ctx, value, &val))
+ return ReportMismatch(keymap->ctx, action->type, field, "integer");
- if (btn < 0 || btn > 255) {
+ if (val < 0 || val > 255) {
log_err(keymap->ctx,
"The count field must have a value in the range 0..255; "
- "Illegal count %d ignored\n", btn);
+ "Illegal count %d ignored\n", val);
return false;
}
- act->count = btn;
+ act->count = (uint8_t) val;
return true;
}
- return ReportIllegal(keymap, action->type, field);
+
+ return ReportIllegal(keymap->ctx, action->type, field);
}
static const LookupEntry ptrDflts[] = {
unsigned int val;
if (array_ndx)
- return ReportActionNotArray(keymap, action->type, field);
+ return ReportActionNotArray(keymap->ctx, action->type, field);
if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
- return ReportMismatch(keymap, action->type, field,
+ return ReportMismatch(keymap->ctx, action->type, field,
"pointer component");
return true;
}
int btn;
if (array_ndx)
- return ReportActionNotArray(keymap, action->type, field);
+ return ReportActionNotArray(keymap->ctx, action->type, field);
- if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
+ if (value->expr.op == EXPR_NEGATE ||
+ value->expr.op == EXPR_UNARY_PLUS) {
act->flags &= ~ACTION_ABSOLUTE_SWITCH;
- button = value->value.child;
+ button = value->unary.child;
}
else {
act->flags |= ACTION_ABSOLUTE_SWITCH;
}
if (!ExprResolveButton(keymap->ctx, button, &btn))
- return ReportMismatch(keymap, action->type, field,
+ return ReportMismatch(keymap->ctx, action->type, field,
"integer (range 1..5)");
if (btn < 0 || btn > 5) {
return false;
}
- act->value = (value->op == EXPR_NEGATE ? -btn: btn);
+ act->value = (value->expr.op == EXPR_NEGATE ? -btn: btn);
return true;
}
- return ReportIllegal(keymap, action->type, field);
+ return ReportIllegal(keymap->ctx, action->type, field);
}
static bool
int val;
if (array_ndx)
- return ReportActionNotArray(keymap, action->type, field);
+ return ReportActionNotArray(keymap->ctx, action->type, field);
- if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
+ if (value->expr.op == EXPR_NEGATE ||
+ value->expr.op == EXPR_UNARY_PLUS) {
act->flags &= ~ACTION_ABSOLUTE_SWITCH;
- scrn = value->value.child;
+ scrn = value->unary.child;
}
else {
act->flags |= ACTION_ABSOLUTE_SWITCH;
}
if (!ExprResolveInteger(keymap->ctx, scrn, &val))
- return ReportMismatch(keymap, action->type, field,
+ return ReportMismatch(keymap->ctx, action->type, field,
"integer (0..255)");
if (val < 0 || val > 255) {
return false;
}
- act->screen = (value->op == EXPR_NEGATE ? -val : val);
+ act->screen = (value->expr.op == EXPR_NEGATE ? -val : val);
return true;
}
else if (field == ACTION_FIELD_SAME) {
- bool set;
-
- if (array_ndx)
- return ReportActionNotArray(keymap, action->type, field);
-
- if (!ExprResolveBoolean(keymap->ctx, value, &set))
- return ReportMismatch(keymap, action->type, field, "boolean");
-
- if (set)
- act->flags &= ~ACTION_SAME_SCREEN;
- else
- act->flags |= ACTION_SAME_SCREEN;
-
- return true;
+ return CheckBooleanFlag(keymap->ctx, action->type, field,
+ ACTION_SAME_SCREEN, array_ndx, value,
+ &act->flags);
}
- return ReportIllegal(keymap, action->type, field);
+ return ReportIllegal(keymap->ctx, action->type, field);
}
static bool
unsigned int mask;
if (array_ndx)
- return ReportActionNotArray(keymap, action->type, field);
+ return ReportActionNotArray(keymap->ctx, action->type, field);
if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
- return ReportMismatch(keymap, action->type, field,
+ return ReportMismatch(keymap->ctx, action->type, field,
"controls mask");
act->ctrls = mask;
return true;
}
+ else if (field == ACTION_FIELD_AFFECT) {
+ return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
+ &act->flags);
+ }
- return ReportIllegal(keymap, action->type, field);
+ return ReportIllegal(keymap->ctx, action->type, field);
}
static bool
if (field == ACTION_FIELD_TYPE) {
int type;
+ if (array_ndx)
+ return ReportActionNotArray(keymap->ctx, action->type, field);
+
if (!ExprResolveInteger(keymap->ctx, value, &type))
- return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer");
+ return ReportMismatch(keymap->ctx, ACTION_TYPE_PRIVATE, field, "integer");
if (type < 0 || type > 255) {
log_err(keymap->ctx,
return false;
}
- act->type = (uint8_t) type;
+ /*
+ * It's possible for someone to write something like this:
+ * actions = [ Private(type=3,data[0]=1,data[1]=3,data[2]=3) ]
+ * where the type refers to some existing action type, e.g. LockMods.
+ * This assumes that this action's struct is laid out in memory
+ * exactly as described in the XKB specification and libraries.
+ * We, however, have changed these structs in various ways, so this
+ * assumption is no longer true. Since this is a lousy "feature", we
+ * make actions like these no-ops for now.
+ */
+ if (type < ACTION_TYPE_PRIVATE) {
+ log_info(keymap->ctx,
+ "Private actions of type %s are not supported; Ignored\n",
+ ActionTypeText(type));
+ act->type = ACTION_TYPE_NONE;
+ }
+ else {
+ act->type = (enum xkb_action_type) type;
+ }
+
return true;
}
else if (field == ACTION_FIELD_DATA) {
if (array_ndx == NULL) {
xkb_atom_t val;
const char *str;
- int len;
+ size_t len;
if (!ExprResolveString(keymap->ctx, value, &val))
- return ReportMismatch(keymap, action->type, field, "string");
+ return ReportMismatch(keymap->ctx, action->type, field, "string");
str = xkb_atom_text(keymap->ctx, val);
len = strlen(str);
if (len < 1 || len > 7) {
log_warn(keymap->ctx,
"A private action has 7 data bytes; "
- "Extra %d bytes ignored\n", len - 6);
+ "Illegal data ignored\n");
return false;
}
return false;
}
- if (ndx < 0 || ndx >= sizeof(act->data)) {
+ if (ndx < 0 || (size_t) ndx >= sizeof(act->data)) {
log_err(keymap->ctx,
"The data for a private action is %lu bytes long; "
"Attempt to use data[%d] ignored\n",
}
if (!ExprResolveInteger(keymap->ctx, value, &datum))
- return ReportMismatch(keymap, act->type, field, "integer");
+ return ReportMismatch(keymap->ctx, act->type, field, "integer");
if (datum < 0 || datum > 255) {
log_err(keymap->ctx,
}
}
- return ReportIllegal(keymap, ACTION_TYPE_NONE, field);
+ return ReportIllegal(keymap->ctx, ACTION_TYPE_NONE, field);
}
typedef bool (*actionHandler)(struct xkb_keymap *keymap,
{
ExprDef *arg;
const char *str;
- unsigned hndlrType;
+ unsigned handler_type;
- if (def->op != EXPR_ACTION_DECL) {
+ if (def->expr.op != EXPR_ACTION_DECL) {
log_err(keymap->ctx, "Expected an action definition, found %s\n",
- expr_op_type_to_string(def->op));
+ expr_op_type_to_string(def->expr.op));
return false;
}
- str = xkb_atom_text(keymap->ctx, def->value.action.name);
- if (!stringToAction(str, &hndlrType)) {
+ str = xkb_atom_text(keymap->ctx, def->action.name);
+ if (!stringToAction(str, &handler_type)) {
log_err(keymap->ctx, "Unknown action %s\n", str);
return false;
}
* statements such as:
* latchMods.clearLocks = True;
*/
- *action = info->actions[hndlrType];
+ *action = info->actions[handler_type];
/*
* Now change the action properties as specified for this
* particular instance, e.g. "modifiers" and "clearLocks" in:
* SetMods(modifiers=Alt,clearLocks);
*/
- for (arg = def->value.action.args; arg != NULL;
+ for (arg = def->action.args; arg != NULL;
arg = (ExprDef *) arg->common.next) {
const ExprDef *value;
ExprDef *field, *arrayRtrn;
const char *elemRtrn, *fieldRtrn;
enum action_field fieldNdx;
- if (arg->op == EXPR_ASSIGN) {
- field = arg->value.binary.left;
- value = arg->value.binary.right;
+ if (arg->expr.op == EXPR_ASSIGN) {
+ field = arg->binary.left;
+ value = arg->binary.right;
}
- else if (arg->op == EXPR_NOT || arg->op == EXPR_INVERT) {
- field = arg->value.child;
- value = &constFalse;
+ else if (arg->expr.op == EXPR_NOT || arg->expr.op == EXPR_INVERT) {
+ field = arg->unary.child;
+ value = (const ExprDef *) &constFalse;
}
else {
field = arg;
- value = &constTrue;
+ value = (const ExprDef *) &constTrue;
}
if (!ExprResolveLhs(keymap->ctx, field, &elemRtrn, &fieldRtrn,
return false;
}
- if (!handleAction[hndlrType](keymap, action, fieldNdx, arrayRtrn,
- value))
+ if (!handleAction[handler_type](keymap, action, fieldNdx, arrayRtrn,
+ value))
return false;
}
return true;
}
-
bool
SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
ExprDef *array_ndx, ExprDef *value, ActionsInfo *info)