For statement / expression types.
Signed-off-by: Ran Benita <ran234@gmail.com>
unsigned *flags_inout, xkb_mod_mask_t *mods_rtrn)
{
ExprResult rtrn;
-
- if (value->op == ExprIdent) {
+ if (value->op == EXPR_IDENT) {
const char *valStr;
valStr = xkb_atom_text(keymap->ctx, value->value.str);
if (valStr && (istreq(valStr, "usemodmapmods") ||
ExprDef *spec;
ExprResult rtrn;
- if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
+ if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
*flags_inout &= ~XkbSA_GroupAbsolute;
spec = value->value.child;
}
if (!ExprResolveGroup(keymap->ctx, spec, &rtrn))
return ReportMismatch(keymap, action, F_Group,
"integer (range 1..8)");
- if (value->op == OpNegate)
+ if (value->op == EXPR_NEGATE)
*grp_rtrn = -rtrn.ival;
- else if (value->op == OpUnaryPlus)
+ else if (value->op == EXPR_UNARY_PLUS)
*grp_rtrn = rtrn.ival;
else
*grp_rtrn = rtrn.ival - 1;
return ReportActionNotArray(keymap, action->type, field);
if ((field == F_X) || (field == F_Y)) {
- if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
+ if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS)
absolute = false;
else
absolute = true;
ExprDef *btn;
if (array_ndx != NULL)
return ReportActionNotArray(keymap, action->type, field);
- if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
+ if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
act->flags &= ~XkbSA_DfltBtnAbsolute;
btn = value->value.child;
}
"Illegal default button setting ignored\n");
return false;
}
- if (value->op == OpNegate)
- act->value = -rtrn.ival;
- else
- act->value = rtrn.ival;
+
+ act->value = (value->op == EXPR_NEGATE ? -rtrn.ival : rtrn.ival);
return true;
}
return ReportIllegal(keymap, action->type, field);
ExprDef *scrn;
if (array_ndx != NULL)
return ReportActionNotArray(keymap, action->type, field);
- if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
+ if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
act->flags &= ~XkbSA_SwitchAbsolute;
scrn = value->value.child;
}
"Illegal screen value %d ignored\n", rtrn.ival);
return false;
}
- if (value->op == OpNegate)
+ if (value->op == EXPR_NEGATE)
act->screen = -rtrn.ival;
else
act->screen = rtrn.ival;
if (!actionsInitialized)
ActionsInit(keymap->ctx);
- if (def->op != ExprActionDecl) {
+ if (def->op != EXPR_ACTION_DECL) {
log_err(keymap->ctx, "Expected an action definition, found %s\n",
exprOpText(def->op));
return false;
ExprResult elemRtrn, fieldRtrn;
unsigned fieldNdx;
- if (arg->op == OpAssign) {
+ if (arg->op == EXPR_ASSIGN) {
field = arg->value.binary.left;
value = arg->value.binary.right;
}
else {
- if ((arg->op == OpNot) || (arg->op == OpInvert)) {
+ if (arg->op == EXPR_NOT || arg->op == EXPR_INVERT) {
field = arg->value.child;
constFalse.value.str = xkb_atom_intern(keymap->ctx, "false");
value = &constFalse;
if (!actionsInitialized) {
memset(&constTrue, 0, sizeof(constTrue));
memset(&constFalse, 0, sizeof(constFalse));
- constTrue.common.stmtType = StmtExpr;
+ constTrue.common.type = STMT_EXPR;
constTrue.common.next = NULL;
- constTrue.op = ExprIdent;
- constTrue.type = TypeBoolean;
+ constTrue.op = EXPR_IDENT;
+ constTrue.value_type = EXPR_TYPE_BOOLEAN;
constTrue.value.str = xkb_atom_intern(ctx, "true");
- constFalse.common.stmtType = StmtExpr;
+ constFalse.common.type = STMT_EXPR;
constFalse.common.next = NULL;
- constFalse.op = ExprIdent;
- constFalse.type = TypeBoolean;
+ constFalse.op = EXPR_IDENT;
+ constFalse.value_type = EXPR_TYPE_BOOLEAN;
constFalse.value.str = xkb_atom_intern(ctx, "false");
actionsInitialized = 1;
}
}
*pred_rtrn = XkbSI_Exactly;
- if (expr->op == ExprActionDecl) {
+ if (expr->op == EXPR_ACTION_DECL) {
const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.action.name);
if (istreq(pred_txt, "noneof"))
}
expr = expr->value.action.args;
}
- else if (expr->op == ExprIdent) {
+ else if (expr->op == EXPR_IDENT) {
const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.str);
if (pred_txt && istreq(pred_txt, "any")) {
stmt->stmt = NULL;
}
- for (; stmt; stmt = stmt->next) {
+ for (; stmt; stmt = stmt->next_incl) {
if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_COMPAT,
&rtrn, &merge)) {
info->errorCount += 10;
ExprDef *arrayNdx;
for (; def != NULL; def = (VarDef *) def->common.next) {
- if ((def->name) && (def->name->op == ExprFieldRef)) {
+ if (def->name && def->name->op == EXPR_FIELD_REF) {
ok = HandleInterpVar(info, def);
continue;
}
stmt = file->defs;
while (stmt)
{
- switch (stmt->stmtType) {
- case StmtInclude:
+ switch (stmt->type) {
+ case STMT_INCLUDE:
if (!HandleIncludeCompatMap(info, (IncludeStmt *) stmt))
info->errorCount++;
break;
- case StmtInterpDef:
+ case STMT_INTERP:
if (!HandleInterpDef(info, (InterpDef *) stmt, merge))
info->errorCount++;
break;
- case StmtGroupCompatDef:
+ case STMT_GROUP_COMPAT:
if (!HandleGroupCompatDef(info, (GroupCompatDef *) stmt, merge))
info->errorCount++;
break;
- case StmtIndicatorMapDef:
+ case STMT_INDICATOR_MAP:
if (!HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge))
info->errorCount++;
break;
- case StmtVarDef:
+ case STMT_VAR:
if (!HandleInterpVar(info, (VarDef *) stmt))
info->errorCount++;
break;
- case StmtVModDef:
+ case STMT_VMOD:
if (!HandleVModDef((VModDef *) stmt, info->keymap, merge,
&info->vmods))
info->errorCount++;
break;
- case StmtKeycodeDef:
+ case STMT_KEYCODE:
log_err(info->keymap->ctx,
"Interpretation files may not include other types; "
"Ignoring definition of key name\n");
default:
log_wsgo(info->keymap->ctx,
"Unexpected statement type %d in HandleCompatMapFile\n",
- stmt->stmtType);
+ stmt->type);
break;
}
stmt = stmt->next;
#include "expr.h"
typedef bool (*IdentLookupFunc)(struct xkb_context *ctx, const void *priv,
- xkb_atom_t field, unsigned type,
+ xkb_atom_t field, enum expr_value_type type,
ExprResult *val_rtrn);
const char *
-exprOpText(unsigned type)
+exprOpText(enum expr_op_type op)
{
static char buf[32];
- switch (type) {
- case ExprValue:
+ switch (op) {
+ case EXPR_VALUE:
strcpy(buf, "literal");
break;
- case ExprIdent:
+ case EXPR_IDENT:
strcpy(buf, "identifier");
break;
- case ExprActionDecl:
+ case EXPR_ACTION_DECL:
strcpy(buf, "action declaration");
break;
- case ExprFieldRef:
+ case EXPR_FIELD_REF:
strcpy(buf, "field reference");
break;
- case ExprArrayRef:
+ case EXPR_ARRAY_REF:
strcpy(buf, "array reference");
break;
- case ExprKeysymList:
+ case EXPR_KEYSYM_LIST:
strcpy(buf, "list of keysyms");
break;
- case ExprActionList:
+ case EXPR_ACTION_LIST:
strcpy(buf, "list of actions");
break;
- case OpAdd:
+ case EXPR_ADD:
strcpy(buf, "addition");
break;
- case OpSubtract:
+ case EXPR_SUBTRACT:
strcpy(buf, "subtraction");
break;
- case OpMultiply:
+ case EXPR_MULTIPLY:
strcpy(buf, "multiplication");
break;
- case OpDivide:
+ case EXPR_DIVIDE:
strcpy(buf, "division");
break;
- case OpAssign:
+ case EXPR_ASSIGN:
strcpy(buf, "assignment");
break;
- case OpNot:
+ case EXPR_NOT:
strcpy(buf, "logical not");
break;
- case OpNegate:
+ case EXPR_NEGATE:
strcpy(buf, "arithmetic negation");
break;
- case OpInvert:
+ case EXPR_INVERT:
strcpy(buf, "bitwise inversion");
break;
- case OpUnaryPlus:
+ case EXPR_UNARY_PLUS:
strcpy(buf, "unary plus");
break;
default:
- snprintf(buf, sizeof(buf), "illegal(%d)", type);
+ snprintf(buf, sizeof(buf), "illegal(%d)", op);
break;
}
return buf;
}
static const char *
-exprTypeText(unsigned type)
+exprValueTypeText(enum expr_value_type type)
{
static char buf[20];
switch (type) {
- case TypeUnknown:
+ case EXPR_TYPE_UNKNOWN:
strcpy(buf, "unknown");
break;
- case TypeBoolean:
+ case EXPR_TYPE_BOOLEAN:
strcpy(buf, "boolean");
break;
- case TypeInt:
+ case EXPR_TYPE_INT:
strcpy(buf, "int");
break;
- case TypeString:
+ case EXPR_TYPE_STRING:
strcpy(buf, "string");
break;
- case TypeAction:
+ case EXPR_TYPE_ACTION:
strcpy(buf, "action");
break;
- case TypeKeyName:
+ case EXPR_TYPE_KEYNAME:
strcpy(buf, "keyname");
break;
default:
struct xkb_context *ctx = keymap->ctx;
switch (expr->op) {
- case ExprIdent:
+ case EXPR_IDENT:
elem_rtrn->str = NULL;
field_rtrn->str = xkb_atom_text(ctx, expr->value.str);
*index_rtrn = NULL;
return true;
- case ExprFieldRef:
+ case EXPR_FIELD_REF:
elem_rtrn->str = xkb_atom_text(ctx, expr->value.field.element);
field_rtrn->str = xkb_atom_text(ctx, expr->value.field.field);
*index_rtrn = NULL;
return true;
- case ExprArrayRef:
+ case EXPR_ARRAY_REF:
elem_rtrn->str = xkb_atom_text(ctx, expr->value.array.element);
field_rtrn->str = xkb_atom_text(ctx, expr->value.array.field);
*index_rtrn = expr->value.array.entry;
return true;
+ default:
+ break;
}
log_wsgo(keymap->ctx, "Unexpected operator %d in ResolveLhs\n", expr->op);
return false;
static bool
SimpleLookup(struct xkb_context *ctx, const void *priv,
- xkb_atom_t field, unsigned type, ExprResult *val_rtrn)
+ xkb_atom_t field, enum expr_value_type type,
+ ExprResult *val_rtrn)
{
const LookupEntry *entry;
const char *str;
- if ((priv == NULL) || (field == XKB_ATOM_NONE) || (type != TypeInt))
+ if (!priv || field == XKB_ATOM_NONE || type != EXPR_TYPE_INT)
return false;
str = xkb_atom_text(ctx, field);
- for (entry = priv; (entry != NULL) && (entry->name != NULL); entry++) {
+ for (entry = priv; entry && entry->name; entry++) {
if (istreq(str, entry->name)) {
val_rtrn->uval = entry->result;
return true;
bool
LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type, ExprResult *val_rtrn)
+ enum expr_value_type type, ExprResult *val_rtrn)
{
return SimpleLookup(ctx, modIndexNames, field, type, val_rtrn);
}
bool
LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type, ExprResult *val_rtrn)
+ enum expr_value_type type, ExprResult *val_rtrn)
{
const char *str;
bool ret = true;
- if (type != TypeInt)
+ if (type != EXPR_TYPE_INT)
return false;
str = xkb_atom_text(ctx, field);
if (str == NULL)
const char *ident;
switch (expr->op) {
- case ExprValue:
- if (expr->type != TypeBoolean) {
+ case EXPR_VALUE:
+ if (expr->value_type != EXPR_TYPE_BOOLEAN) {
log_err(ctx,
"Found constant of type %s where boolean was expected\n",
- exprTypeText(expr->type));
+ exprValueTypeText(expr->value_type));
return false;
}
val_rtrn->ival = expr->value.ival;
return true;
- case ExprIdent:
+ case EXPR_IDENT:
ident = xkb_atom_text(ctx, expr->value.str);
if (ident) {
if (istreq(ident, "true") ||
xkb_atom_text(ctx, expr->value.str));
return false;
- case ExprFieldRef:
+ case EXPR_FIELD_REF:
log_err(ctx, "Default \"%s.%s\" of type boolean is unknown\n",
xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field));
return false;
- case OpInvert:
- case OpNot:
+ case EXPR_INVERT:
+ case EXPR_NOT:
ok = ExprResolveBoolean(ctx, expr, val_rtrn);
if (ok)
val_rtrn->uval = !val_rtrn->uval;
return ok;
- case OpAdd:
- case OpSubtract:
- case OpMultiply:
- case OpDivide:
- case OpAssign:
- case OpNegate:
- case OpUnaryPlus:
+ case EXPR_ADD:
+ case EXPR_SUBTRACT:
+ case EXPR_MULTIPLY:
+ case EXPR_DIVIDE:
+ case EXPR_ASSIGN:
+ case EXPR_NEGATE:
+ case EXPR_UNARY_PLUS:
log_err(ctx, "%s of boolean values not permitted\n",
exprOpText(expr->op));
break;
ExprDef *left, *right;
switch (expr->op) {
- case ExprValue:
- if (expr->type != TypeInt) {
+ case EXPR_VALUE:
+ if (expr->value_type != EXPR_TYPE_INT) {
log_err(ctx,
"Found constant of type %s where an int was expected\n",
- exprTypeText(expr->type));
+ exprValueTypeText(expr->value_type));
return false;
}
val_rtrn->uval = expr->value.uval;
return true;
- case OpAdd:
- case OpSubtract:
- case OpMultiply:
- case OpDivide:
+ case EXPR_ADD:
+ case EXPR_SUBTRACT:
+ case EXPR_MULTIPLY:
+ case EXPR_DIVIDE:
left = expr->value.binary.left;
right = expr->value.binary.right;
- if (ExprResolveKeyCode(ctx, left, &leftRtrn) &&
- ExprResolveKeyCode(ctx, right, &rightRtrn)) {
- switch (expr->op) {
- case OpAdd:
- val_rtrn->uval = leftRtrn.uval + rightRtrn.uval;
- break;
- case OpSubtract:
- val_rtrn->uval = leftRtrn.uval - rightRtrn.uval;
- break;
- case OpMultiply:
- val_rtrn->uval = leftRtrn.uval * rightRtrn.uval;
- break;
- case OpDivide:
- if (rightRtrn.uval == 0) {
- log_err(ctx, "Cannot divide by zero: %d / %d\n",
- leftRtrn.uval, rightRtrn.uval);
- return false;
- }
- val_rtrn->uval = leftRtrn.uval / rightRtrn.uval;
- break;
+ if (!ExprResolveKeyCode(ctx, left, &leftRtrn) ||
+ !ExprResolveKeyCode(ctx, right, &rightRtrn))
+ return false;
+
+ switch (expr->op) {
+ case EXPR_ADD:
+ val_rtrn->uval = leftRtrn.uval + rightRtrn.uval;
+ break;
+ case EXPR_SUBTRACT:
+ val_rtrn->uval = leftRtrn.uval - rightRtrn.uval;
+ break;
+ case EXPR_MULTIPLY:
+ val_rtrn->uval = leftRtrn.uval * rightRtrn.uval;
+ break;
+ case EXPR_DIVIDE:
+ if (rightRtrn.uval == 0) {
+ log_err(ctx, "Cannot divide by zero: %d / %d\n",
+ leftRtrn.uval, rightRtrn.uval);
+ return false;
}
- return true;
+ val_rtrn->uval = leftRtrn.uval / rightRtrn.uval;
+ break;
+ default:
+ break;
}
- return false;
- case OpNegate:
+ return true;
+
+ case EXPR_NEGATE:
left = expr->value.child;
if (ExprResolveKeyCode(ctx, left, &leftRtrn)) {
val_rtrn->uval = ~leftRtrn.uval;
}
return false;
- case OpUnaryPlus:
+ case EXPR_UNARY_PLUS:
left = expr->value.child;
return ExprResolveKeyCode(ctx, left, val_rtrn);
ExprDef *left, *right;
switch (expr->op) {
- case ExprValue:
- if (expr->type == TypeString) {
+ case EXPR_VALUE:
+ if (expr->value_type == EXPR_TYPE_STRING) {
const char *str;
str = xkb_atom_text(ctx, expr->value.str);
if (str != NULL)
break;
}
}
- if (expr->type != TypeInt) {
+ if (expr->value_type != EXPR_TYPE_INT) {
log_err(ctx,
"Found constant of type %s where an int was expected\n",
- exprTypeText(expr->type));
+ exprValueTypeText(expr->value_type));
return false;
}
val_rtrn->ival = expr->value.ival;
return true;
- case ExprIdent:
+ case EXPR_IDENT:
if (lookup)
ok = lookup(ctx, lookupPriv, expr->value.str,
- TypeInt, val_rtrn);
+ EXPR_TYPE_INT, val_rtrn);
if (!ok)
log_err(ctx, "Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.str));
return ok;
- case ExprFieldRef:
+ case EXPR_FIELD_REF:
log_err(ctx, "Default \"%s.%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field));
return false;
- case OpAdd:
- case OpSubtract:
- case OpMultiply:
- case OpDivide:
+ case EXPR_ADD:
+ case EXPR_SUBTRACT:
+ case EXPR_MULTIPLY:
+ case EXPR_DIVIDE:
left = expr->value.binary.left;
right = expr->value.binary.right;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
ExprResolveIntegerLookup(ctx, right, &rightRtrn, lookup,
lookupPriv)) {
switch (expr->op) {
- case OpAdd:
+ case EXPR_ADD:
val_rtrn->ival = leftRtrn.ival + rightRtrn.ival;
break;
- case OpSubtract:
+ case EXPR_SUBTRACT:
val_rtrn->ival = leftRtrn.ival - rightRtrn.ival;
break;
- case OpMultiply:
+ case EXPR_MULTIPLY:
val_rtrn->ival = leftRtrn.ival * rightRtrn.ival;
break;
- case OpDivide:
+ case EXPR_DIVIDE:
if (rightRtrn.ival == 0) {
log_err(ctx, "Cannot divide by zero: %d / %d\n",
leftRtrn.ival, rightRtrn.ival);
}
val_rtrn->ival = leftRtrn.ival / rightRtrn.ival;
break;
+ default:
+ break;
}
return true;
}
return false;
- case OpAssign:
+ case EXPR_ASSIGN:
log_wsgo(ctx, "Assignment operator not implemented yet\n");
break;
- case OpNot:
+ case EXPR_NOT:
log_err(ctx, "The ! operator cannot be applied to an integer\n");
return false;
- case OpInvert:
- case OpNegate:
+ case EXPR_INVERT:
+ case EXPR_NEGATE:
left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) {
- if (expr->op == OpNegate)
+ if (expr->op == EXPR_NEGATE)
val_rtrn->ival = -leftRtrn.ival;
else
val_rtrn->ival = ~leftRtrn.ival;
}
return false;
- case OpUnaryPlus:
+ case EXPR_UNARY_PLUS:
left = expr->value.child;
return ExprResolveIntegerLookup(ctx, left, val_rtrn, lookup,
lookupPriv);
ExprResult *val_rtrn)
{
switch (expr->op) {
- case ExprValue:
- if (expr->type != TypeString) {
+ case EXPR_VALUE:
+ if (expr->value_type != EXPR_TYPE_STRING) {
log_err(ctx, "Found constant of type %s, expected a string\n",
- exprTypeText(expr->type));
+ exprValueTypeText(expr->value_type));
return false;
}
val_rtrn->str = xkb_atom_text(ctx, expr->value.str);
return true;
- case ExprIdent:
+ case EXPR_IDENT:
log_err(ctx, "Identifier \"%s\" of type string not found\n",
xkb_atom_text(ctx, expr->value.str));
return false;
- case ExprFieldRef:
+ case EXPR_FIELD_REF:
log_err(ctx, "Default \"%s.%s\" of type string not found\n",
xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field));
return false;
- case OpAdd:
- case OpSubtract:
- case OpMultiply:
- case OpDivide:
- case OpAssign:
- case OpNegate:
- case OpInvert:
- case OpNot:
- case OpUnaryPlus:
+ case EXPR_ADD:
+ case EXPR_SUBTRACT:
+ case EXPR_MULTIPLY:
+ case EXPR_DIVIDE:
+ case EXPR_ASSIGN:
+ case EXPR_NEGATE:
+ case EXPR_INVERT:
+ case EXPR_NOT:
+ case EXPR_UNARY_PLUS:
log_err(ctx, "%s of strings not permitted\n", exprOpText(expr->op));
return false;
ExprResult *val_rtrn)
{
switch (expr->op) {
- case ExprValue:
- if (expr->type != TypeKeyName) {
+ case EXPR_VALUE:
+ if (expr->value_type != EXPR_TYPE_KEYNAME) {
log_err(ctx, "Found constant of type %s, expected a key name\n",
- exprTypeText(expr->type));
+ exprValueTypeText(expr->value_type));
return false;
}
memcpy(val_rtrn->name, expr->value.keyName, XkbKeyNameLength);
return true;
- case ExprIdent:
+ case EXPR_IDENT:
log_err(ctx, "Identifier \"%s\" of type string not found\n",
xkb_atom_text(ctx, expr->value.str));
return false;
- case ExprFieldRef:
+ case EXPR_FIELD_REF:
log_err(ctx, "Default \"%s.%s\" of type key name not found\n",
xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field));
return false;
- case OpAdd:
- case OpSubtract:
- case OpMultiply:
- case OpDivide:
- case OpAssign:
- case OpNegate:
- case OpInvert:
- case OpNot:
- case OpUnaryPlus:
+ case EXPR_ADD:
+ case EXPR_SUBTRACT:
+ case EXPR_MULTIPLY:
+ case EXPR_DIVIDE:
+ case EXPR_ASSIGN:
+ case EXPR_NEGATE:
+ case EXPR_INVERT:
+ case EXPR_NOT:
+ case EXPR_UNARY_PLUS:
log_err(ctx, "%s of key name values not permitted\n",
exprOpText(expr->op));
return false;
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn, const LookupEntry *values)
{
- if (expr->op != ExprIdent) {
+ if (expr->op != EXPR_IDENT) {
log_err(ctx, "Found a %s where an enumerated value was expected\n",
exprOpText(expr->op));
return false;
}
- if (!SimpleLookup(ctx, values, expr->value.str, TypeInt, val_rtrn)) {
+ if (!SimpleLookup(ctx, values, expr->value.str, EXPR_TYPE_INT,
+ val_rtrn)) {
int nOut = 0;
log_err(ctx, "Illegal identifier %s (expected one of: ",
xkb_atom_text(ctx, expr->value.str));
const char *bogus = NULL;
switch (expr->op) {
- case ExprValue:
- if (expr->type != TypeInt) {
+ case EXPR_VALUE:
+ if (expr->value_type != EXPR_TYPE_INT) {
log_err(ctx,
"Found constant of type %s where a mask was expected\n",
- exprTypeText(expr->type));
+ exprValueTypeText(expr->value_type));
return false;
}
val_rtrn->ival = expr->value.ival;
return true;
- case ExprIdent:
- ok = lookup(ctx, lookupPriv, expr->value.str, TypeInt, val_rtrn);
+ case EXPR_IDENT:
+ ok = lookup(ctx, lookupPriv, expr->value.str, EXPR_TYPE_INT, val_rtrn);
if (!ok)
log_err(ctx, "Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.str));
return ok;
- case ExprFieldRef:
+ case EXPR_FIELD_REF:
log_err(ctx, "Default \"%s.%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field));
return false;
- case ExprArrayRef:
+ case EXPR_ARRAY_REF:
bogus = "array reference";
- case ExprActionDecl:
+ case EXPR_ACTION_DECL:
if (bogus == NULL)
bogus = "function use";
log_err(ctx,
bogus);
return false;
- case OpAdd:
- case OpSubtract:
- case OpMultiply:
- case OpDivide:
+ case EXPR_ADD:
+ case EXPR_SUBTRACT:
+ case EXPR_MULTIPLY:
+ case EXPR_DIVIDE:
left = expr->value.binary.left;
right = expr->value.binary.right;
if (ExprResolveMaskLookup(ctx, left, &leftRtrn, lookup,
ExprResolveMaskLookup(ctx, right, &rightRtrn, lookup,
lookupPriv)) {
switch (expr->op) {
- case OpAdd:
+ case EXPR_ADD:
val_rtrn->ival = leftRtrn.ival | rightRtrn.ival;
break;
- case OpSubtract:
+ case EXPR_SUBTRACT:
val_rtrn->ival = leftRtrn.ival & (~rightRtrn.ival);
break;
- case OpMultiply:
- case OpDivide:
+ case EXPR_MULTIPLY:
+ case EXPR_DIVIDE:
log_err(ctx, "Cannot %s masks; Illegal operation ignored\n",
- (expr->op == OpDivide ? "divide" : "multiply"));
+ (expr->op == EXPR_DIVIDE ? "divide" : "multiply"));
return false;
+ default:
+ break;
}
return true;
}
return false;
- case OpAssign:
+ case EXPR_ASSIGN:
log_wsgo(ctx, "Assignment operator not implemented yet\n");
break;
- case OpInvert:
+ case EXPR_INVERT:
left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) {
}
return false;
- case OpUnaryPlus:
- case OpNegate:
- case OpNot:
+ case EXPR_UNARY_PLUS:
+ case EXPR_NEGATE:
+ case EXPR_NOT:
left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) {
log_err(ctx, "The %s operator cannot be used with a mask\n",
- (expr->op == OpNegate ? "-" : "!"));
+ (expr->op == EXPR_NEGATE ? "-" : "!"));
}
return false;
int ok = 0;
xkb_keysym_t sym;
- if (expr->op == ExprIdent) {
+ if (expr->op == EXPR_IDENT) {
const char *str;
str = xkb_atom_text(ctx, expr->value.str);
if (str) {
} LookupEntry;
extern const char *
-exprOpText(unsigned type);
+exprOpText(enum expr_op_type op);
extern bool
LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type,
- ExprResult *val_rtrn);
+ enum expr_value_type type, ExprResult *val_rtrn);
extern bool
LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type,
- ExprResult *val_rtrn);
+ enum expr_value_type type, ExprResult *val_rtrn);
extern bool
LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type,
- ExprResult *val_rtrn);
+ enum expr_value_type type, ExprResult *val_rtrn);
extern int
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr,
stmt->stmt = NULL;
}
- for (; stmt; stmt = stmt->next) {
+ for (; stmt; stmt = stmt->next_incl) {
if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_KEYCODES,
&rtrn, &merge)) {
info->errorCount += 10;
stmt = file->defs;
while (stmt)
{
- switch (stmt->stmtType) {
- case StmtInclude: /* e.g. include "evdev+aliases(qwerty)" */
+ switch (stmt->type) {
+ case STMT_INCLUDE: /* e.g. include "evdev+aliases(qwerty)" */
if (!HandleIncludeKeycodes(info, (IncludeStmt *) stmt))
info->errorCount++;
break;
- case StmtKeycodeDef: /* e.g. <ESC> = 9; */
+ case STMT_KEYCODE: /* e.g. <ESC> = 9; */
if (!HandleKeycodeDef(info, (KeycodeDef *) stmt, merge))
info->errorCount++;
break;
- case StmtKeyAliasDef: /* e.g. alias <MENU> = <COMP>; */
+ case STMT_ALIAS: /* e.g. alias <MENU> = <COMP>; */
if (!HandleAliasDef(info, (KeyAliasDef *) stmt, merge,
info->file_id))
info->errorCount++;
break;
- case StmtVarDef: /* e.g. minimum, maximum */
+ case STMT_VAR: /* e.g. minimum, maximum */
if (!HandleKeyNameVar(info, (VarDef *) stmt))
info->errorCount++;
break;
- case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */
+ case STMT_INDICATOR_NAME: /* e.g. indicator 1 = "Caps Lock"; */
if (!HandleIndicatorNameDef(info, (IndicatorNameDef *) stmt,
merge))
info->errorCount++;
break;
- case StmtInterpDef:
- case StmtVModDef:
+ case STMT_INTERP:
+ case STMT_VMOD:
log_err(info->keymap->ctx,
"Keycode files may define key and indicator names only; "
"Ignoring definition of %s\n",
- (stmt->stmtType == StmtInterpDef ?
+ (stmt->type == STMT_INTERP ?
"a symbol interpretation" : "virtual modifiers"));
info->errorCount++;
break;
default:
log_wsgo(info->keymap->ctx,
"Unexpected statement type %d in HandleKeycodesFile\n",
- stmt->stmtType);
+ stmt->type);
break;
}
stmt = stmt->next;
stmt->stmt = NULL;
}
- for (; stmt; stmt = stmt->next) {
+ for (; stmt; stmt = stmt->next_incl) {
if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_TYPES,
&rtrn, &merge)) {
info->errorCount += 10;
ExprResult tmp, field;
ExprDef *arrayNdx;
- for (; def != NULL; def = (VarDef *) def->common.next) {
- if ((def->name) && (def->name->op == ExprFieldRef)) {
+ for (; def; def = (VarDef *) def->common.next) {
+ if (def->name && def->name->op == EXPR_FIELD_REF) {
ok = HandleKeyTypeVar(info, def);
continue;
}
stmt = file->defs;
while (stmt)
{
- switch (stmt->stmtType) {
- case StmtInclude:
+ switch (stmt->type) {
+ case STMT_INCLUDE:
if (!HandleIncludeKeyTypes(info, (IncludeStmt *) stmt))
info->errorCount++;
break;
- case StmtKeyTypeDef: /* e.g. type "ONE_LEVEL" */
+ case STMT_TYPE: /* e.g. type "ONE_LEVEL" */
if (!HandleKeyTypeDef(info, (KeyTypeDef *) stmt, merge))
info->errorCount++;
break;
- case StmtVarDef:
+ case STMT_VAR:
if (!HandleKeyTypeVar(info, (VarDef *) stmt))
info->errorCount++;
break;
- case StmtVModDef: /* virtual_modifiers NumLock, ... */
+ case STMT_VMOD: /* virtual_modifiers NumLock, ... */
if (!HandleVModDef((VModDef *) stmt, info->keymap, merge,
&info->vmods))
info->errorCount++;
break;
- case StmtKeyAliasDef:
+ case STMT_ALIAS:
log_err(info->keymap->ctx,
"Key type files may not include other declarations; "
"Ignoring definition of key alias\n");
info->errorCount++;
break;
- case StmtKeycodeDef:
+ case STMT_KEYCODE:
log_err(info->keymap->ctx,
"Key type files may not include other declarations; "
"Ignoring definition of key name\n");
info->errorCount++;
break;
- case StmtInterpDef:
+ case STMT_INTERP:
log_err(info->keymap->ctx,
"Key type files may not include other declarations; "
"Ignoring definition of symbol interpretation\n");
default:
log_wsgo(info->keymap->ctx,
"Unexpected statement type %d in HandleKeyTypesFile\n",
- stmt->stmtType);
+ stmt->type);
break;
}
stmt = stmt->next;
next = (XkbFile *) mapToUse->common.next;
mapToUse->common.next = NULL;
if (streq(mapToUse->name, stmt->map) &&
- mapToUse->type == file_type) {
+ mapToUse->file_type == file_type) {
FreeXKBFile(next);
break;
}
"Using first defined map, \"%s\"\n",
stmt->file, rtrn->name);
}
- if (mapToUse->type != file_type) {
+ if (mapToUse->file_type != file_type) {
log_err(ctx,
"Include file wrong type (expected %s, got %s); "
"Include file \"%s\" ignored\n",
- FileTypeText(file_type), FileTypeText(mapToUse->type),
+ FileTypeText(file_type), FileTypeText(mapToUse->file_type),
stmt->file);
return false;
}
ArrayInit : OBRACKET OptKeySymList CBRACKET
{ $$= $2; }
| OBRACKET ActionList CBRACKET
- { $$= ExprCreateUnary(ExprActionList,TypeAction,$2); }
+ { $$= ExprCreateUnary(EXPR_ACTION_LIST, EXPR_TYPE_ACTION, $2); }
;
GroupCompatDecl : GROUP Integer EQUALS Expr SEMI
;
Expr : Expr DIVIDE Expr
- { $$= ExprCreateBinary(OpDivide,$1,$3); }
+ { $$= ExprCreateBinary(EXPR_DIVIDE,$1,$3); }
| Expr PLUS Expr
- { $$= ExprCreateBinary(OpAdd,$1,$3); }
+ { $$= ExprCreateBinary(EXPR_ADD,$1,$3); }
| Expr MINUS Expr
- { $$= ExprCreateBinary(OpSubtract,$1,$3); }
+ { $$= ExprCreateBinary(EXPR_SUBTRACT,$1,$3); }
| Expr TIMES Expr
- { $$= ExprCreateBinary(OpMultiply,$1,$3); }
+ { $$= ExprCreateBinary(EXPR_MULTIPLY,$1,$3); }
| Lhs EQUALS Expr
- { $$= ExprCreateBinary(OpAssign,$1,$3); }
+ { $$= ExprCreateBinary(EXPR_ASSIGN,$1,$3); }
| Term
{ $$= $1; }
;
Term : MINUS Term
- { $$= ExprCreateUnary(OpNegate,$2->type,$2); }
+ { $$= ExprCreateUnary(EXPR_NEGATE,$2->value_type,$2); }
| PLUS Term
- { $$= ExprCreateUnary(OpUnaryPlus,$2->type,$2); }
+ { $$= ExprCreateUnary(EXPR_UNARY_PLUS,$2->value_type,$2); }
| EXCLAM Term
- { $$= ExprCreateUnary(OpNot,TypeBoolean,$2); }
+ { $$= ExprCreateUnary(EXPR_NOT,EXPR_TYPE_BOOLEAN,$2); }
| INVERT Term
- { $$= ExprCreateUnary(OpInvert,$2->type,$2); }
+ { $$= ExprCreateUnary(EXPR_INVERT,$2->value_type,$2); }
| Lhs
{ $$= $1; }
| FieldSpec OPAREN OptExprList CPAREN %prec OPAREN
Lhs : FieldSpec
{
ExprDef *expr;
- expr= ExprCreate(ExprIdent,TypeUnknown);
+ expr= ExprCreate(EXPR_IDENT, EXPR_TYPE_UNKNOWN);
expr->value.str= $1;
$$= expr;
}
| FieldSpec DOT FieldSpec
{
ExprDef *expr;
- expr= ExprCreate(ExprFieldRef,TypeUnknown);
+ expr= ExprCreate(EXPR_FIELD_REF,EXPR_TYPE_UNKNOWN);
expr->value.field.element= $1;
expr->value.field.field= $3;
$$= expr;
| FieldSpec OBRACKET Expr CBRACKET
{
ExprDef *expr;
- expr= ExprCreate(ExprArrayRef,TypeUnknown);
+ expr= ExprCreate(EXPR_ARRAY_REF,EXPR_TYPE_UNKNOWN);
expr->value.array.element= XKB_ATOM_NONE;
expr->value.array.field= $1;
expr->value.array.entry= $3;
| FieldSpec DOT FieldSpec OBRACKET Expr CBRACKET
{
ExprDef *expr;
- expr= ExprCreate(ExprArrayRef,TypeUnknown);
+ expr= ExprCreate(EXPR_ARRAY_REF,EXPR_TYPE_UNKNOWN);
expr->value.array.element= $1;
expr->value.array.field= $3;
expr->value.array.entry= $5;
Terminal : String
{
ExprDef *expr;
- expr= ExprCreate(ExprValue,TypeString);
+ expr= ExprCreate(EXPR_VALUE,EXPR_TYPE_STRING);
expr->value.str= $1;
$$= expr;
}
| Integer
{
ExprDef *expr;
- expr= ExprCreate(ExprValue,TypeInt);
+ expr= ExprCreate(EXPR_VALUE,EXPR_TYPE_INT);
expr->value.ival= $1;
$$= expr;
}
| KeyName
{
ExprDef *expr;
- expr= ExprCreate(ExprValue,TypeKeyName);
+ expr= ExprCreate(EXPR_VALUE,EXPR_TYPE_KEYNAME);
strncpy(expr->value.keyName,$1,4);
$$= expr;
}
}
ExprDef *
-ExprCreate(unsigned op, unsigned type)
+ExprCreate(enum expr_op_type op, enum expr_value_type type)
{
ExprDef *expr;
expr = malloc_or_die(sizeof(*expr));
- expr->common.stmtType = StmtExpr;
+ expr->common.type = STMT_EXPR;
expr->common.next = NULL;
expr->op = op;
- expr->type = type;
+ expr->value_type = type;
return expr;
}
ExprDef *
-ExprCreateUnary(unsigned op, unsigned type, ExprDef * child)
+ExprCreateUnary(enum expr_op_type op, enum expr_value_type type,
+ ExprDef *child)
{
ExprDef *expr;
expr = malloc_or_die(sizeof(*expr));
- expr->common.stmtType = StmtExpr;
+ expr->common.type = STMT_EXPR;
expr->common.next = NULL;
expr->op = op;
- expr->type = type;
+ expr->value_type = type;
expr->value.child = child;
return expr;
}
ExprDef *
-ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right)
+ExprCreateBinary(enum expr_op_type op, ExprDef *left, ExprDef *right)
{
ExprDef *expr;
expr = malloc_or_die(sizeof(*expr));
- expr->common.stmtType = StmtExpr;
+ expr->common.type = STMT_EXPR;
expr->common.next = NULL;
expr->op = op;
- if ((op == OpAssign) || (left->type == TypeUnknown))
- expr->type = right->type;
- else if ((left->type == right->type) || (right->type == TypeUnknown))
- expr->type = left->type;
+ if (op == EXPR_ASSIGN || left->value_type == EXPR_TYPE_UNKNOWN)
+ expr->value_type = right->value_type;
+ else if (left->value_type == right->value_type ||
+ right->value_type == EXPR_TYPE_UNKNOWN)
+ expr->value_type = left->value_type;
else
- expr->type = TypeUnknown;
+ expr->value_type = EXPR_TYPE_UNKNOWN;
expr->value.binary.left = left;
expr->value.binary.right = right;
return expr;
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtKeycodeDef;
+ def->common.type = STMT_KEYCODE;
def->common.next = NULL;
strncpy(def->name, keyName, XkbKeyNameLength);
def->name[XkbKeyNameLength] = '\0';
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtKeyAliasDef;
+ def->common.type = STMT_ALIAS;
def->common.next = NULL;
strncpy(def->alias, alias, XkbKeyNameLength);
def->alias[XkbKeyNameLength] = '\0';
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtVModDef;
+ def->common.type = STMT_VMOD;
def->common.next = NULL;
def->name = name;
def->value = value;
VarDef *def;
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtVarDef;
+ def->common.type = STMT_VAR;
def->common.next = NULL;
def->name = name;
def->value = value;
{
ExprDef *name, *value;
- name = ExprCreate(ExprIdent, TypeUnknown);
+ name = ExprCreate(EXPR_IDENT, EXPR_TYPE_UNKNOWN);
name->value.str = nameToken;
- value = ExprCreate(ExprValue, TypeBoolean);
+ value = ExprCreate(EXPR_VALUE, EXPR_TYPE_BOOLEAN);
value->value.uval = set;
return VarCreate(name, value);
}
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtInterpDef;
+ def->common.type = STMT_INTERP;
def->common.next = NULL;
def->sym = sym;
def->match = match;
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtKeyTypeDef;
+ def->common.type = STMT_TYPE;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->name = name;
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtSymbolsDef;
+ def->common.type = STMT_SYMBOLS;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
strncpy(def->keyName, keyName, XkbKeyNameLength);
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtGroupCompatDef;
+ def->common.type = STMT_GROUP_COMPAT;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->group = group;
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtModMapDef;
+ def->common.type = STMT_MODMAP;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->modifier = modifier;
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtIndicatorMapDef;
+ def->common.type = STMT_INDICATOR_MAP;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->name = name;
def = malloc_or_die(sizeof(*def));
- def->common.stmtType = StmtIndicatorNameDef;
+ def->common.type = STMT_INDICATOR_NAME;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->ndx = ndx;
act = malloc_or_die(sizeof(*act));
- act->common.stmtType = StmtExpr;
+ act->common.type = STMT_EXPR;
act->common.next = NULL;
- act->op = ExprActionDecl;
+ act->op = EXPR_ACTION_DECL;
act->value.action.name = name;
act->value.action.args = args;
return act;
{
ExprDef *def;
- def = ExprCreate(ExprKeysymList, TypeSymbols);
+ def = ExprCreate(EXPR_KEYSYM_LIST, EXPR_TYPE_SYMBOLS);
darray_init(def->value.list.syms);
darray_init(def->value.list.symsMapIndex);
if (first == NULL) {
first = incl = malloc(sizeof(*first));
} else {
- incl->next = malloc(sizeof(*first));
- incl = incl->next;
+ incl->next_incl = malloc(sizeof(*first));
+ incl = incl->next_incl;
}
if (!incl) {
break;
}
- incl->common.stmtType = StmtInclude;
+ incl->common.type = STMT_INCLUDE;
incl->common.next = NULL;
incl->merge = merge;
incl->stmt = NULL;
incl->map = map;
incl->modifier = extra_data;
incl->path = NULL;
- incl->next = NULL;
+ incl->next_incl = NULL;
if (nextop == '|')
merge = MERGE_AUGMENT;
return NULL;
EnsureSafeMapName(name);
- file->type = type;
+ file->file_type = type;
file->topName = strdup_safe(name);
file->name = name;
file->defs = defs;
return;
switch (expr->op) {
- case ExprActionList:
- case OpNegate:
- case OpUnaryPlus:
- case OpNot:
- case OpInvert:
+ case EXPR_ACTION_LIST:
+ case EXPR_NEGATE:
+ case EXPR_UNARY_PLUS:
+ case EXPR_NOT:
+ case EXPR_INVERT:
FreeStmt(&expr->value.child->common);
break;
- case OpDivide:
- case OpAdd:
- case OpSubtract:
- case OpMultiply:
- case OpAssign:
+ case EXPR_DIVIDE:
+ case EXPR_ADD:
+ case EXPR_SUBTRACT:
+ case EXPR_MULTIPLY:
+ case EXPR_ASSIGN:
FreeStmt(&expr->value.binary.left->common);
FreeStmt(&expr->value.binary.right->common);
break;
- case ExprActionDecl:
+ case EXPR_ACTION_DECL:
FreeStmt(&expr->value.action.args->common);
break;
- case ExprArrayRef:
+ case EXPR_ARRAY_REF:
FreeStmt(&expr->value.array.entry->common);
break;
- case ExprKeysymList:
+ case EXPR_KEYSYM_LIST:
darray_foreach(sym, expr->value.list.syms)
free(*sym);
darray_free(expr->value.list.syms);
while (incl)
{
- next = incl->next;
+ next = incl->next_incl;
free(incl->file);
free(incl->map);
next = stmt->next;
u.any = stmt;
- switch (stmt->stmtType) {
- case StmtInclude:
+ switch (stmt->type) {
+ case STMT_INCLUDE:
FreeInclude((IncludeStmt *) stmt);
/* stmt is already free'd here. */
stmt = NULL;
break;
- case StmtExpr:
+ case STMT_EXPR:
FreeExpr(u.expr);
break;
- case StmtVarDef:
+ case STMT_VAR:
FreeStmt(&u.var->name->common);
FreeStmt(&u.var->value->common);
break;
- case StmtKeyTypeDef:
+ case STMT_TYPE:
FreeStmt(&u.keyType->body->common);
break;
- case StmtInterpDef:
+ case STMT_INTERP:
free(u.interp->sym);
FreeStmt(&u.interp->match->common);
FreeStmt(&u.interp->def->common);
break;
- case StmtVModDef:
+ case STMT_VMOD:
FreeStmt(&u.vmod->value->common);
break;
- case StmtSymbolsDef:
+ case STMT_SYMBOLS:
FreeStmt(&u.syms->symbols->common);
break;
- case StmtModMapDef:
+ case STMT_MODMAP:
FreeStmt(&u.modMask->keys->common);
break;
- case StmtGroupCompatDef:
+ case STMT_GROUP_COMPAT:
FreeStmt(&u.groupCompat->def->common);
break;
- case StmtIndicatorMapDef:
+ case STMT_INDICATOR_MAP:
FreeStmt(&u.ledMap->body->common);
break;
- case StmtIndicatorNameDef:
+ case STMT_INDICATOR_NAME:
FreeStmt(&u.ledName->name->common);
break;
default:
{
next = (XkbFile *) file->common.next;
- switch (file->type) {
+ switch (file->file_type) {
case FILE_TYPE_KEYMAP:
FreeXKBFile((XkbFile *) file->defs);
break;
AppendStmt(ParseCommon *to, ParseCommon *append);
extern ExprDef *
-ExprCreate(unsigned op, unsigned type);
+ExprCreate(enum expr_op_type op, enum expr_value_type type);
extern ExprDef *
-ExprCreateUnary(unsigned op, unsigned type, ExprDef *child);
+ExprCreateUnary(enum expr_op_type op, enum expr_value_type type,
+ ExprDef *child);
extern ExprDef *
-ExprCreateBinary(unsigned op, ExprDef *left, ExprDef *right);
+ExprCreateBinary(enum expr_op_type op, ExprDef *left, ExprDef *right);
KeycodeDef *
KeycodeCreate(char keyName[XkbKeyNameLength], unsigned long value);
* pathRtrn is undefined.
*/
FILE *
-XkbFindFileInPath(struct xkb_context *ctx,
- const char *name, enum xkb_file_type type, char **pathRtrn)
+XkbFindFileInPath(struct xkb_context *ctx, const char *name,
+ enum xkb_file_type type, char **pathRtrn)
{
size_t i;
int ret;
char **extra_data);
const char *
-XkbDirectoryForInclude(unsigned type);
+XkbDirectoryForInclude(enum xkb_file_type type);
FILE *
-XkbFindFileInPath(struct xkb_context *ctx, const char *name, unsigned type,
- char **pathRtrn);
+XkbFindFileInPath(struct xkb_context *ctx, const char *name,
+ enum xkb_file_type type, char **pathRtrn);
#endif /* XKBCOMP_PATH_H */
stmt->stmt = NULL;
}
- for (; stmt; stmt = stmt->next) {
+ for (; stmt; stmt = stmt->next_incl) {
if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_SYMBOLS,
&rtrn, &merge)) {
info->errorCount += 10;
keyi->symsDefined |= (1 << ndx);
return true;
}
- if (value->op != ExprKeysymList) {
+ if (value->op != EXPR_KEYSYM_LIST) {
log_err(info->keymap->ctx,
"Expected a list of symbols, found %s; "
"Ignoring symbols for group %u of %s\n",
return true;
}
- if (value->op != ExprActionList) {
+ if (value->op != EXPR_ACTION_LIST) {
log_wsgo(info->keymap->ctx,
"Bad expression type (%d) for action list value; "
"Ignoring actions for group %u of %s\n",
ExprResult tmp, field;
ExprDef *arrayNdx;
- for (; def != NULL; def = (VarDef *) def->common.next) {
- if ((def->name) && (def->name->type == ExprFieldRef)) {
+ for (; def; def = (VarDef *) def->common.next) {
+ if (def->name && def->name->op == EXPR_FIELD_REF) {
ok = HandleSymbolsVar(info, def);
continue;
}
if (!def->name) {
- if (!def->value || (def->value->op == ExprKeysymList))
+ if (!def->value || def->value->op == EXPR_KEYSYM_LIST)
field.str = "symbols";
else
field.str = "actions";
bool ok;
struct xkb_context *ctx = info->keymap->ctx;
- if (!LookupModIndex(ctx, NULL, def->modifier, TypeInt, &rtrn)) {
+ if (!LookupModIndex(ctx, NULL, def->modifier, EXPR_TYPE_INT, &rtrn)) {
log_err(info->keymap->ctx,
"Illegal modifier map definition; "
"Ignoring map for non-modifier \"%s\"\n",
ok = true;
tmp.modifier = rtrn.uval;
for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) {
- if ((key->op == ExprValue) && (key->type == TypeKeyName)) {
+ if (key->op == EXPR_VALUE && key->value_type == EXPR_TYPE_KEYNAME) {
tmp.haveSymbol = false;
tmp.u.keyName = KeyNameToLong(key->value.keyName);
}
stmt = file->defs;
while (stmt)
{
- switch (stmt->stmtType) {
- case StmtInclude:
+ switch (stmt->type) {
+ case STMT_INCLUDE:
if (!HandleIncludeSymbols(info, (IncludeStmt *) stmt))
info->errorCount++;
break;
- case StmtSymbolsDef:
+ case STMT_SYMBOLS:
if (!HandleSymbolsDef(info, (SymbolsDef *) stmt))
info->errorCount++;
break;
- case StmtVarDef:
+ case STMT_VAR:
if (!HandleSymbolsVar(info, (VarDef *) stmt))
info->errorCount++;
break;
- case StmtVModDef:
+ case STMT_VMOD:
if (!HandleVModDef((VModDef *) stmt, info->keymap, merge,
&info->vmods))
info->errorCount++;
break;
- case StmtInterpDef:
+ case STMT_INTERP:
log_err(info->keymap->ctx,
"Interpretation files may not include other types; "
"Ignoring definition of symbol interpretation\n");
info->errorCount++;
break;
- case StmtKeycodeDef:
+ case STMT_KEYCODE:
log_err(info->keymap->ctx,
"Interpretation files may not include other types; "
"Ignoring definition of key name\n");
info->errorCount++;
break;
- case StmtModMapDef:
+ case STMT_MODMAP:
if (!HandleModMapDef(info, (ModMapDef *) stmt))
info->errorCount++;
break;
default:
log_wsgo(info->keymap->ctx,
"Unexpected statement type %d in HandleSymbolsFile\n",
- stmt->stmtType);
+ stmt->type);
break;
}
stmt = stmt->next;
*
* @param keymap Pointer to the xkb data structure.
* @param field The Atom of the modifier's name (e.g. Atom for LAlt)
- * @param type Must be TypeInt, otherwise return false.
+ * @param type Must be EXPR_TYPE_INT, otherwise return false.
* @param val_rtrn Set to the index of the modifier that matches.
*
* @return true on success, false otherwise. If false is returned, val_rtrn is
*/
static int
LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
- unsigned type, ExprResult * val_rtrn)
+ enum expr_value_type type, ExprResult * val_rtrn)
{
xkb_mod_index_t i;
const char *name = xkb_atom_text(keymap->ctx, field);
- if (type != TypeInt)
+ if (type != EXPR_TYPE_INT)
return false;
/* For each named modifier, get the name and compare it to the one passed
*/
bool
LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type, ExprResult *val_rtrn)
+ enum expr_value_type type, ExprResult *val_rtrn)
{
if (LookupModMask(ctx, NULL, field, type, val_rtrn)) {
return true;
ExprResult rtrn;
name = xkb_atom_intern(keymap->ctx, "NumLock");
- if ((keymap) && LookupVModIndex(keymap, name, TypeInt, &rtrn)) {
+ if ((keymap) && LookupVModIndex(keymap, name, EXPR_TYPE_INT, &rtrn)) {
return rtrn.ival;
}
return -1;
ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
ExprResult *val_rtrn, VModInfo *info)
{
- if (def->op == ExprIdent) {
+ if (def->op == EXPR_IDENT) {
xkb_mod_index_t i;
xkb_mod_mask_t bit;
const char *name = xkb_atom_text(keymap->ctx, def->value.str);
* Other aggregate file types are converted to FILE_TYPE_KEYMAP
* in the parser.
*/
- if (file->type != FILE_TYPE_KEYMAP) {
+ if (file->file_type != FILE_TYPE_KEYMAP) {
log_err(ctx, "Cannot compile a %s file alone into a keymap\n",
- FileTypeText(file->type));
+ FileTypeText(file->file_type));
goto err;
}
/* Check for duplicate entries in the input file */
for (file = (XkbFile *) file->defs; file;
file = (XkbFile *) file->common.next) {
- if (have & file->type) {
+ if (have & file->file_type) {
log_err(ctx,
"More than one %s section in a keymap file; "
"All sections after the first ignored\n",
- FileTypeText(file->type));
+ FileTypeText(file->file_type));
continue;
}
- switch (file->type) {
+ switch (file->file_type) {
case FILE_TYPE_KEYCODES:
keycodes = file;
break;
default:
log_err(ctx, "Cannot define %s in a keymap file\n",
- FileTypeText(file->type));
+ FileTypeText(file->file_type));
continue;
}
file->topName = strdup(main_name);
}
- have |= file->type;
+ have |= file->file_type;
}
if (REQUIRED_FILE_TYPES & (~have)) {
#include "xkb-priv.h"
-#define TypeUnknown 0
-#define TypeBoolean 1
-#define TypeInt 2
-#define TypeString 4
-#define TypeAction 5
-#define TypeKeyName 6
-#define TypeSymbols 7
-
-#define StmtUnknown 0
-#define StmtInclude 1
-#define StmtKeycodeDef 2
-#define StmtKeyAliasDef 3
-#define StmtExpr 4
-#define StmtVarDef 5
-#define StmtKeyTypeDef 6
-#define StmtInterpDef 7
-#define StmtVModDef 8
-#define StmtSymbolsDef 9
-#define StmtModMapDef 10
-#define StmtGroupCompatDef 11
-#define StmtIndicatorMapDef 12
-#define StmtIndicatorNameDef 13
+enum stmt_type {
+ STMT_UNKNOWN = 0,
+ STMT_INCLUDE,
+ STMT_KEYCODE,
+ STMT_ALIAS,
+ STMT_EXPR,
+ STMT_VAR,
+ STMT_TYPE,
+ STMT_INTERP,
+ STMT_VMOD,
+ STMT_SYMBOLS,
+ STMT_MODMAP,
+ STMT_GROUP_COMPAT,
+ STMT_INDICATOR_MAP,
+ STMT_INDICATOR_NAME,
+};
-typedef struct _ParseCommon {
- unsigned stmtType;
- struct _ParseCommon *next;
-} ParseCommon;
+enum expr_value_type {
+ EXPR_TYPE_UNKNOWN = 0,
+ EXPR_TYPE_BOOLEAN,
+ EXPR_TYPE_INT,
+ EXPR_TYPE_STRING,
+ EXPR_TYPE_ACTION,
+ EXPR_TYPE_KEYNAME,
+ EXPR_TYPE_SYMBOLS,
+};
-#define ExprValue 0
-#define ExprIdent 1
-#define ExprActionDecl 2
-#define ExprFieldRef 3
-#define ExprArrayRef 4
-#define ExprKeysymList 5
-#define ExprActionList 6
-
-#define OpAdd 20
-#define OpSubtract 21
-#define OpMultiply 22
-#define OpDivide 23
-#define OpAssign 24
-#define OpNot 25
-#define OpNegate 26
-#define OpInvert 27
-#define OpUnaryPlus 28
+enum expr_op_type {
+ EXPR_VALUE = 0,
+ EXPR_IDENT,
+ EXPR_ACTION_DECL,
+ EXPR_FIELD_REF,
+ EXPR_ARRAY_REF,
+ EXPR_KEYSYM_LIST,
+ EXPR_ACTION_LIST,
+ EXPR_ADD,
+ EXPR_SUBTRACT,
+ EXPR_MULTIPLY,
+ EXPR_DIVIDE,
+ EXPR_ASSIGN,
+ EXPR_NOT,
+ EXPR_NEGATE,
+ EXPR_INVERT,
+ EXPR_UNARY_PLUS,
+};
enum merge_mode {
MERGE_DEFAULT,
MERGE_REPLACE,
};
-#define AutoKeyNames (1L << 0)
-#define CreateKeyNames(x) ((x)->flags & AutoKeyNames)
+typedef struct _ParseCommon {
+ enum stmt_type type;
+ struct _ParseCommon *next;
+} ParseCommon;
typedef struct _IncludeStmt {
ParseCommon common;
char *map;
char *modifier;
char *path;
- struct _IncludeStmt *next;
+ struct _IncludeStmt *next_incl;
} IncludeStmt;
typedef struct _Expr {
ParseCommon common;
- unsigned op;
- unsigned type;
+ enum expr_op_type op;
+ enum expr_value_type value_type;
union {
struct {
struct _Expr *left;
typedef struct _IndicatorMapDef {
ParseCommon common;
enum merge_mode merge;
- unsigned type;
xkb_atom_t name;
VarDef *body;
} IndicatorMapDef;
typedef struct _XkbFile {
ParseCommon common;
- enum xkb_file_type type;
+ enum xkb_file_type file_type;
char *topName;
char *name;
ParseCommon *defs;
CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge);
+#define AutoKeyNames (1L << 0)
+#define CreateKeyNames(x) ((x)->flags & AutoKeyNames)
+
#endif /* XKBCOMP_H */