}
int
-ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn)
-{
- int ok = 0;
- ExprResult leftRtrn, rightRtrn;
- ExprDef *left, *right;
-
- switch (expr->op) {
- case ExprValue:
- if (expr->type == TypeString) {
- const char *str;
- str = xkb_atom_text(ctx, expr->value.str);
- if ((str != NULL) && (strlen(str) == 1)) {
- val_rtrn->uval = str[0] * XkbGeomPtsPerMM;
- return true;
- }
- }
- if (expr->type != TypeInt) {
- log_err(ctx, "Found constant of type %s, expected a number\n",
- exprTypeText(expr->type));
- return false;
- }
- val_rtrn->ival = expr->value.ival;
- if (expr->type == TypeInt)
- val_rtrn->ival *= XkbGeomPtsPerMM;
- return true;
-
- case ExprIdent:
- log_err(ctx, "Numeric identifier \"%s\" unknown\n",
- xkb_atom_text(ctx, expr->value.str));
- return ok;
-
- case ExprFieldRef:
- log_err(ctx, "Numeric default \"%s.%s\" 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:
- left = expr->value.binary.left;
- right = expr->value.binary.right;
- if (ExprResolveFloat(ctx, left, &leftRtrn) &&
- ExprResolveFloat(ctx, right, &rightRtrn)) {
- switch (expr->op) {
- case OpAdd:
- val_rtrn->ival = leftRtrn.ival + rightRtrn.ival;
- break;
-
- case OpSubtract:
- val_rtrn->ival = leftRtrn.ival - rightRtrn.ival;
- break;
-
- case OpMultiply:
- val_rtrn->ival = leftRtrn.ival * rightRtrn.ival;
- break;
-
- case OpDivide:
- val_rtrn->ival = leftRtrn.ival / rightRtrn.ival;
- break;
- }
- return true;
- }
- return false;
-
- case OpAssign:
- log_wsgo(ctx, "Assignment operator not implemented yet\n");
- break;
-
- case OpNot:
- log_err(ctx, "The ! operator cannot be applied to a number\n");
- return false;
-
- case OpInvert:
- case OpNegate:
- left = expr->value.child;
- if (ExprResolveFloat(ctx, left, &leftRtrn)) {
- if (expr->op == OpNegate)
- val_rtrn->ival = -leftRtrn.ival;
- else
- val_rtrn->ival = ~leftRtrn.ival;
- return true;
- }
- return false;
-
- case OpUnaryPlus:
- left = expr->value.child;
- return ExprResolveFloat(ctx, left, val_rtrn);
-
- default:
- log_wsgo(ctx, "Unknown operator %d in ResolveFloat\n", expr->op);
- break;
- }
- return false;
-}
-
-int
ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn)
{