expr: constify function arguments

We need this for later.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-08-03 00:33:40 +03:00
parent f2ecd6650a
commit 6f08a2cfa0
3 changed files with 79 additions and 58 deletions

View File

@ -210,7 +210,7 @@ ReportNotFound(struct xkb_keymap *keymap, unsigned action, unsigned field,
static bool static bool
HandleNoAction(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleNoAction(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx, const ExprDef *value)
{ {
return ReportIllegal(keymap, action->type, field); return ReportIllegal(keymap, action->type, field);
@ -218,7 +218,8 @@ HandleNoAction(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action, CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
unsigned field, ExprDef * value, unsigned *flags_inout) unsigned field, const ExprDef * value,
unsigned *flags_inout)
{ {
unsigned tmp; unsigned tmp;
bool result; bool result;
@ -242,8 +243,9 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
} }
static bool static bool
CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value, CheckModifierField(struct xkb_keymap *keymap, unsigned action,
unsigned *flags_inout, xkb_mod_mask_t *mods_rtrn) const ExprDef *value, unsigned *flags_inout,
xkb_mod_mask_t *mods_rtrn)
{ {
if (value->op == EXPR_IDENT) { if (value->op == EXPR_IDENT) {
const char *valStr; const char *valStr;
@ -266,7 +268,8 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
static bool static bool
HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
struct xkb_mod_action *act; struct xkb_mod_action *act;
unsigned rtrn; unsigned rtrn;
@ -307,7 +310,7 @@ HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx, const ExprDef *value)
{ {
struct xkb_mod_action *act; struct xkb_mod_action *act;
unsigned t1; unsigned t1;
@ -332,10 +335,10 @@ HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
CheckGroupField(struct xkb_keymap *keymap, unsigned action, CheckGroupField(struct xkb_keymap *keymap, unsigned action,
ExprDef * value, unsigned *flags_inout, const ExprDef *value, unsigned *flags_inout,
xkb_group_index_t *grp_rtrn) xkb_group_index_t *grp_rtrn)
{ {
ExprDef *spec; const ExprDef *spec;
if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) { if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
*flags_inout &= ~XkbSA_GroupAbsolute; *flags_inout &= ~XkbSA_GroupAbsolute;
@ -360,7 +363,8 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
static bool static bool
HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
struct xkb_group_action *act; struct xkb_group_action *act;
unsigned rtrn; unsigned rtrn;
@ -400,7 +404,8 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
struct xkb_group_action *act; struct xkb_group_action *act;
unsigned t1; unsigned t1;
@ -423,7 +428,7 @@ HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx, const ExprDef *value)
{ {
struct xkb_pointer_action *act; struct xkb_pointer_action *act;
bool absolute; bool absolute;
@ -481,7 +486,7 @@ static const LookupEntry lockWhich[] = {
static bool static bool
HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action, HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx, const ExprDef *value)
{ {
struct xkb_pointer_button_action *act; struct xkb_pointer_button_action *act;
@ -552,7 +557,8 @@ static const LookupEntry ptrDflts[] = {
static bool static bool
HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
struct xkb_pointer_default_action *act; struct xkb_pointer_default_action *act;
@ -570,7 +576,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
return true; return true;
} }
else if ((field == F_Button) || (field == F_Value)) { else if ((field == F_Button) || (field == F_Value)) {
ExprDef *button; const ExprDef *button;
int btn; int btn;
if (array_ndx) if (array_ndx)
@ -625,7 +631,7 @@ static const LookupEntry isoNames[] = {
static bool static bool
HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx, const ExprDef *value)
{ {
struct xkb_iso_action *act; struct xkb_iso_action *act;
@ -679,13 +685,14 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
struct xkb_switch_screen_action *act; struct xkb_switch_screen_action *act;
act = (struct xkb_switch_screen_action *) action; act = (struct xkb_switch_screen_action *) action;
if (field == F_Screen) { if (field == F_Screen) {
ExprDef *scrn; const ExprDef *scrn;
int val; int val;
if (array_ndx) if (array_ndx)
@ -758,8 +765,8 @@ const LookupEntry ctrlNames[] = {
static bool static bool
HandleSetLockControls(struct xkb_keymap *keymap, HandleSetLockControls(struct xkb_keymap *keymap,
struct xkb_any_action *action, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, unsigned field, const ExprDef *array_ndx,
ExprDef *value) const ExprDef *value)
{ {
struct xkb_controls_action *act; struct xkb_controls_action *act;
@ -793,7 +800,8 @@ static const LookupEntry evNames[] = {
static bool static bool
HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
struct xkb_message_action *act; struct xkb_message_action *act;
@ -882,7 +890,8 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
struct xkb_key *key; struct xkb_key *key;
struct xkb_redirect_key_action *act; struct xkb_redirect_key_action *act;
@ -933,7 +942,8 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
struct xkb_device_button_action *act; struct xkb_device_button_action *act;
@ -1018,7 +1028,8 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
HandleDeviceValuator(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleDeviceValuator(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx,
const ExprDef *value)
{ {
#if 0 #if 0
ExprResult rtrn; ExprResult rtrn;
@ -1032,7 +1043,7 @@ HandleDeviceValuator(struct xkb_keymap *keymap, struct xkb_any_action *action,
static bool static bool
HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action, HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value) unsigned field, const ExprDef *array_ndx, const ExprDef *value)
{ {
if (field == F_Type) { if (field == F_Type) {
int type; int type;
@ -1107,7 +1118,7 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
typedef bool (*actionHandler)(struct xkb_keymap *keymap, typedef bool (*actionHandler)(struct xkb_keymap *keymap,
struct xkb_any_action *action, unsigned field, struct xkb_any_action *action, unsigned field,
ExprDef *array_ndx, ExprDef *value); const ExprDef *array_ndx, const ExprDef *value);
static const actionHandler handleAction[XkbSA_NumActions + 1] = { static const actionHandler handleAction[XkbSA_NumActions + 1] = {
[XkbSA_NoAction] = HandleNoAction, [XkbSA_NoAction] = HandleNoAction,
@ -1197,7 +1208,8 @@ HandleActionDef(ExprDef * def,
} }
for (arg = def->value.action.args; arg != NULL; for (arg = def->value.action.args; arg != NULL;
arg = (ExprDef *) arg->common.next) { arg = (ExprDef *) arg->common.next) {
ExprDef *field, *value, *arrayRtrn; const ExprDef *value;
ExprDef *field, *arrayRtrn;
const char *elemRtrn, *fieldRtrn; const char *elemRtrn, *fieldRtrn;
unsigned fieldNdx; unsigned fieldNdx;

View File

@ -123,8 +123,9 @@ exprValueTypeText(enum expr_value_type type)
} }
bool bool
ExprResolveLhs(struct xkb_context *ctx, ExprDef *expr, const char **elem_rtrn, ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr,
const char **field_rtrn, ExprDef **index_rtrn) const char **elem_rtrn, const char **field_rtrn,
ExprDef **index_rtrn)
{ {
switch (expr->op) { switch (expr->op) {
case EXPR_IDENT: case EXPR_IDENT:
@ -210,7 +211,8 @@ LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
} }
bool bool
ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr, bool *set_rtrn) ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
bool *set_rtrn)
{ {
bool ok = false; bool ok = false;
const char *ident; const char *ident;
@ -278,7 +280,8 @@ ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr, bool *set_rtrn)
} }
bool bool
ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr, xkb_keycode_t *kc) ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr,
xkb_keycode_t *kc)
{ {
xkb_keycode_t leftRtrn, rightRtrn; xkb_keycode_t leftRtrn, rightRtrn;
ExprDef *left, *right; ExprDef *left, *right;
@ -362,7 +365,7 @@ ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr, xkb_keycode_t *kc)
* Cool. * Cool.
*/ */
static bool static bool
ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr, ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
int *val_rtrn, IdentLookupFunc lookup, int *val_rtrn, IdentLookupFunc lookup,
const void *lookupPriv) const void *lookupPriv)
{ {
@ -465,13 +468,14 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
} }
bool bool
ExprResolveInteger(struct xkb_context *ctx, ExprDef *expr, int *val_rtrn) ExprResolveInteger(struct xkb_context *ctx, const ExprDef *expr,
int *val_rtrn)
{ {
return ExprResolveIntegerLookup(ctx, expr, val_rtrn, NULL, NULL); return ExprResolveIntegerLookup(ctx, expr, val_rtrn, NULL, NULL);
} }
bool bool
ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr, ExprResolveGroup(struct xkb_context *ctx, const ExprDef *expr,
xkb_group_index_t *group_rtrn) xkb_group_index_t *group_rtrn)
{ {
bool ok; bool ok;
@ -504,7 +508,7 @@ ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr,
} }
bool bool
ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr,
unsigned int *level_rtrn) unsigned int *level_rtrn)
{ {
bool ok; bool ok;
@ -537,7 +541,7 @@ ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr,
} }
bool bool
ExprResolveButton(struct xkb_context *ctx, ExprDef *expr, int *btn_rtrn) ExprResolveButton(struct xkb_context *ctx, const ExprDef *expr, int *btn_rtrn)
{ {
int result; int result;
static const LookupEntry button_names[] = { static const LookupEntry button_names[] = {
@ -559,7 +563,7 @@ ExprResolveButton(struct xkb_context *ctx, ExprDef *expr, int *btn_rtrn)
} }
bool bool
ExprResolveString(struct xkb_context *ctx, ExprDef *expr, ExprResolveString(struct xkb_context *ctx, const ExprDef *expr,
const char **val_rtrn) const char **val_rtrn)
{ {
switch (expr->op) { switch (expr->op) {
@ -604,7 +608,7 @@ ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
} }
bool bool
ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr, ExprResolveKeyName(struct xkb_context *ctx, const ExprDef *expr,
char name[XkbKeyNameLength]) char name[XkbKeyNameLength])
{ {
switch (expr->op) { switch (expr->op) {
@ -649,7 +653,7 @@ ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
} }
bool bool
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResolveEnum(struct xkb_context *ctx, const ExprDef *expr,
unsigned int *val_rtrn, const LookupEntry *values) unsigned int *val_rtrn, const LookupEntry *values)
{ {
if (expr->op != EXPR_IDENT) { if (expr->op != EXPR_IDENT) {
@ -674,7 +678,7 @@ ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
} }
static bool static bool
ExprResolveMaskLookup(struct xkb_context *ctx, ExprDef *expr, ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr,
unsigned int *val_rtrn, IdentLookupFunc lookup, unsigned int *val_rtrn, IdentLookupFunc lookup,
const void *lookupPriv) const void *lookupPriv)
{ {
@ -778,21 +782,21 @@ ExprResolveMaskLookup(struct xkb_context *ctx, ExprDef *expr,
} }
bool bool
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr, ExprResolveMask(struct xkb_context *ctx, const ExprDef *expr,
unsigned int *mask_rtrn, const LookupEntry *values) unsigned int *mask_rtrn, const LookupEntry *values)
{ {
return ExprResolveMaskLookup(ctx, expr, mask_rtrn, SimpleLookup, values); return ExprResolveMaskLookup(ctx, expr, mask_rtrn, SimpleLookup, values);
} }
bool bool
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr, ExprResolveModMask(struct xkb_context *ctx, const ExprDef *expr,
xkb_mod_mask_t *mask_rtrn) xkb_mod_mask_t *mask_rtrn)
{ {
return ExprResolveMaskLookup(ctx, expr, mask_rtrn, LookupModMask, NULL); return ExprResolveMaskLookup(ctx, expr, mask_rtrn, LookupModMask, NULL);
} }
bool bool
ExprResolveVModMask(struct xkb_keymap *keymap, ExprDef *expr, ExprResolveVModMask(struct xkb_keymap *keymap, const ExprDef *expr,
xkb_mod_mask_t *mask_rtrn) xkb_mod_mask_t *mask_rtrn)
{ {
return ExprResolveMaskLookup(keymap->ctx, expr, mask_rtrn, LookupVModMask, return ExprResolveMaskLookup(keymap->ctx, expr, mask_rtrn, LookupVModMask,
@ -800,7 +804,7 @@ ExprResolveVModMask(struct xkb_keymap *keymap, ExprDef *expr,
} }
bool bool
ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr, ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr,
xkb_keysym_t *sym_rtrn) xkb_keysym_t *sym_rtrn)
{ {
int val; int val;

View File

@ -38,8 +38,9 @@ extern const char *
exprOpText(enum expr_op_type op); exprOpText(enum expr_op_type op);
bool bool
ExprResolveLhs(struct xkb_context *ctx, ExprDef *expr, const char **elem_rtrn, ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr,
const char **field_rtrn, ExprDef **index_rtrn); const char **elem_rtrn, const char **field_rtrn,
ExprDef **index_rtrn);
bool bool
LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field, LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
@ -54,51 +55,55 @@ LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
enum expr_value_type type, xkb_mod_index_t *val_rtrn); enum expr_value_type type, xkb_mod_index_t *val_rtrn);
bool bool
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr, ExprResolveModMask(struct xkb_context *ctx, const ExprDef *expr,
xkb_mod_mask_t *mask_rtrn); xkb_mod_mask_t *mask_rtrn);
bool bool
ExprResolveVModMask(struct xkb_keymap *keymap, ExprDef *expr, ExprResolveVModMask(struct xkb_keymap *keymap, const ExprDef *expr,
xkb_mod_mask_t *mask_rtrn); xkb_mod_mask_t *mask_rtrn);
bool bool
ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr, bool *set_rtrn); ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
bool *set_rtrn);
bool bool
ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr, xkb_keycode_t *kc); ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr,
xkb_keycode_t *kc);
bool bool
ExprResolveInteger(struct xkb_context *ctx, ExprDef *expr, int *val_rtrn); ExprResolveInteger(struct xkb_context *ctx, const ExprDef *expr,
int *val_rtrn);
bool bool
ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr,
unsigned int *level_rtrn); unsigned int *level_rtrn);
bool bool
ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr, ExprResolveGroup(struct xkb_context *ctx, const ExprDef *expr,
xkb_group_index_t *group_rtrn); xkb_group_index_t *group_rtrn);
bool bool
ExprResolveButton(struct xkb_context *ctx, ExprDef *expr, int *btn_rtrn); ExprResolveButton(struct xkb_context *ctx, const ExprDef *expr,
int *btn_rtrn);
bool bool
ExprResolveString(struct xkb_context *ctx, ExprDef *expr, ExprResolveString(struct xkb_context *ctx, const ExprDef *expr,
const char **val_rtrn); const char **val_rtrn);
bool bool
ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr, ExprResolveKeyName(struct xkb_context *ctx, const ExprDef *expr,
char name[XkbKeyNameLength]); char name[XkbKeyNameLength]);
bool bool
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResolveEnum(struct xkb_context *ctx, const ExprDef *expr,
unsigned int *val_rtrn, const LookupEntry *values); unsigned int *val_rtrn, const LookupEntry *values);
bool bool
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr, ExprResolveMask(struct xkb_context *ctx, const ExprDef *expr,
unsigned int *mask_rtrn, const LookupEntry *values); unsigned int *mask_rtrn, const LookupEntry *values);
bool bool
ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr, ExprResolveKeySym(struct xkb_context *ctx, const ExprDef *expr,
xkb_keysym_t *sym_rtrn); xkb_keysym_t *sym_rtrn);
#endif /* EXPR_H */ #endif /* EXPR_H */