Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xkbcomp/expr: remove unused ExprResolveKeyCode #654

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 0 additions & 83 deletions src/xkbcomp/expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,89 +186,6 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
return false;
}

bool
ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr,
xkb_keycode_t *kc)
{
xkb_keycode_t leftRtrn, rightRtrn;

switch (expr->common.type) {
case STMT_EXPR_INTEGER_LITERAL:
*kc = (xkb_keycode_t) expr->integer.ival;
return true;

case STMT_EXPR_STRING_LITERAL:
case STMT_EXPR_FLOAT_LITERAL:
case STMT_EXPR_BOOLEAN_LITERAL:
case STMT_EXPR_KEYNAME_LITERAL:
log_err(ctx, XKB_ERROR_WRONG_FIELD_TYPE,
"Found %s where an int was expected\n",
stmt_type_to_string(expr->common.type));
return false;

case STMT_EXPR_ADD:
case STMT_EXPR_SUBTRACT:
case STMT_EXPR_MULTIPLY:
case STMT_EXPR_DIVIDE:
if (!ExprResolveKeyCode(ctx, expr->binary.left, &leftRtrn) ||
!ExprResolveKeyCode(ctx, expr->binary.right, &rightRtrn))
return false;

switch (expr->common.type) {
case STMT_EXPR_ADD:
*kc = leftRtrn + rightRtrn;
break;
case STMT_EXPR_SUBTRACT:
*kc = leftRtrn - rightRtrn;
break;
case STMT_EXPR_MULTIPLY:
*kc = leftRtrn * rightRtrn;
break;
case STMT_EXPR_DIVIDE:
if (rightRtrn == 0) {
log_err(ctx, XKB_ERROR_INVALID_OPERATION,
"Cannot divide by zero: %d / %d\n",
leftRtrn, rightRtrn);
return false;
}

*kc = leftRtrn / rightRtrn;
break;
default:
break;
}

return true;

case STMT_EXPR_NEGATE:
if (!ExprResolveKeyCode(ctx, expr->unary.child, &leftRtrn))
return false;

*kc = ~leftRtrn;
return true;

case STMT_EXPR_UNARY_PLUS:
return ExprResolveKeyCode(ctx, expr->unary.child, kc);

default:
log_wsgo(ctx, XKB_ERROR_INVALID_SYNTAX,
"Unknown operator %d in ResolveKeyCode\n", expr->common.type);
break;
}

return false;
}

/**
* This function returns ... something. It's a bit of a guess, really.
*
* If an integer is given in value ctx, it will be returned in ival.
* If an ident or field reference is given, the lookup function (if given)
* will be called. At the moment, only SimpleLookup use this, and they both
* return the results in uval. And don't support field references.
*
* Cool.
*/
static bool
ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
int *val_rtrn, IdentLookupFunc lookup,
Expand Down
4 changes: 0 additions & 4 deletions src/xkbcomp/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ bool
ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
bool *set_rtrn);

bool
ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr,
xkb_keycode_t *kc);

bool
ExprResolveInteger(struct xkb_context *ctx, const ExprDef *expr,
int *val_rtrn);
Expand Down
Loading