expr: drop ExprResult from ResolveMask Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 35fd6e5..cc86387 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -245,7 +245,6 @@ static bool
CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
unsigned *flags_inout, xkb_mod_mask_t *mods_rtrn)
{
- ExprResult rtrn;
if (value->op == EXPR_IDENT) {
const char *valStr;
valStr = xkb_atom_text(keymap->ctx, value->value.str);
@@ -258,10 +257,9 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
}
}
- if (!ExprResolveVModMask(keymap, value, &rtrn))
+ if (!ExprResolveVModMask(keymap, value, mods_rtrn))
return ReportMismatch(keymap, action, F_Modifiers, "modifier mask");
- *mods_rtrn = (xkb_mod_mask_t) rtrn.ival;
*flags_inout &= ~XkbSA_UseModMapMods;
return true;
}
@@ -624,46 +622,53 @@ static bool
HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
- ExprResult rtrn;
struct xkb_iso_action *act;
- unsigned flags;
- xkb_mod_mask_t mods;
- xkb_group_index_t group;
act = (struct xkb_iso_action *) action;
- switch (field) {
- case F_Modifiers:
- if (array_ndx != NULL)
+ if (field == F_Modifiers) {
+ unsigned flags;
+ xkb_mod_mask_t mods;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
+
flags = act->flags;
- if (CheckModifierField(keymap, action->type, value, &flags, &mods)) {
- act->flags = flags & (~XkbSA_ISODfltIsGroup);
- act->real_mods = mods & 0xff;
- act->vmods = (mods >> 8) & 0xff;
- return true;
- }
- return false;
+ if (!CheckModifierField(keymap, action->type, value, &flags, &mods))
+ return false;
- case F_Group:
- if (array_ndx != NULL)
+ act->flags = flags & (~XkbSA_ISODfltIsGroup);
+ act->real_mods = mods & 0xff;
+ act->vmods = (mods >> 8) & 0xff;
+ return true;
+ }
+ else if (field == F_Group) {
+ xkb_group_index_t group;
+ unsigned flags;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
+
flags = act->flags;
- if (CheckGroupField(keymap, action->type, value, &flags, &group)) {
- act->flags = flags | XkbSA_ISODfltIsGroup;
- act->group = group;
- return true;
- }
- return false;
+ if (!CheckGroupField(keymap, action->type, value, &flags, &group))
+ return false;
- case F_Affect:
- if (array_ndx != NULL)
+ act->flags = flags | XkbSA_ISODfltIsGroup;
+ act->group = group;
+ return true;
+ } else if (F_Affect) {
+ xkb_mod_mask_t mask;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, isoNames))
+
+ if (!ExprResolveMask(keymap->ctx, value, &mask, isoNames))
return ReportMismatch(keymap, action->type, field,
"keyboard component");
- act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask;
+
+ act->affect = (~mask) & XkbSA_ISOAffectMask;
return true;
}
+
return ReportIllegal(keymap, action->type, field);
}
@@ -752,19 +757,23 @@ HandleSetLockControls(struct xkb_keymap *keymap,
unsigned field, ExprDef *array_ndx,
ExprDef *value)
{
- ExprResult rtrn;
struct xkb_controls_action *act;
act = (struct xkb_controls_action *) action;
if (field == F_Controls) {
- if (array_ndx != NULL)
+ unsigned int mask;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
+
+ if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlNames))
return ReportMismatch(keymap, action->type, field,
"controls mask");
- act->ctrls = rtrn.uval;
+
+ act->ctrls = mask;
return true;
}
+
return ReportIllegal(keymap, action->type, field);
}
@@ -782,25 +791,27 @@ static bool
HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx, ExprDef *value)
{
- ExprResult rtrn;
- const char *str;
- bool set;
struct xkb_message_action *act;
act = (struct xkb_message_action *) action;
- switch (field) {
- case F_Report:
- if (array_ndx != NULL)
+ if (field == F_Report) {
+ unsigned int mask;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, evNames))
+
+ if (!ExprResolveMask(keymap->ctx, value, &mask, evNames))
return ReportMismatch(keymap, action->type, field,
"key event mask");
+
+ /* FIXME: Something seems wrong here... */
act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
- act->flags =
- rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
+ act->flags = mask & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
return true;
+ }
+ else if (field == F_GenKeyEvent) {
+ bool set;
- case F_GenKeyEvent:
if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
@@ -813,54 +824,52 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->flags &= ~XkbSA_MessageGenKeyEvent;
return true;
-
- case F_Data:
- if (array_ndx == NULL) {
- int len;
-
- if (!ExprResolveString(keymap->ctx, value, &str))
- return ReportMismatch(keymap, action->type, field, "string");
-
- len = strlen(str);
- if (len < 1 || len > 6) {
- log_warn(keymap->ctx,
- "An action message can hold only 6 bytes; "
- "Extra %d bytes ignored\n", len - 6);
- }
-
- strncpy((char *) act->message, str, 6);
- return true;
+ }
+ else if (field == F_Data && !array_ndx) {
+ const char *str;
+ int len;
+
+ if (!ExprResolveString(keymap->ctx, value, &str))
+ return ReportMismatch(keymap, action->type, field, "string");
+
+ len = strlen(str);
+ if (len < 1 || len > 6) {
+ log_warn(keymap->ctx,
+ "An action message can hold only 6 bytes; "
+ "Extra %d bytes ignored\n", len - 6);
}
- else {
- int ndx, datum;
- if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
- log_err(keymap->ctx,
- "Array subscript must be integer; "
- "Illegal subscript ignored\n");
- return false;
- }
+ strncpy((char *) act->message, str, 6);
+ return true;
+ }
+ else if (field == F_Data && array_ndx) {
+ int ndx, datum;
- if (ndx < 0 || ndx > 5) {
- log_err(keymap->ctx,
- "An action message is at most 6 bytes long; "
- "Attempt to use data[%d] ignored\n", ndx);
- return false;
- }
+ if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
+ log_err(keymap->ctx,
+ "Array subscript must be integer; "
+ "Illegal subscript ignored\n");
+ return false;
+ }
- if (!ExprResolveInteger(keymap->ctx, value, &datum))
- return ReportMismatch(keymap, action->type, field, "integer");
+ if (ndx < 0 || ndx > 5) {
+ log_err(keymap->ctx,
+ "An action message is at most 6 bytes long; "
+ "Attempt to use data[%d] ignored\n", ndx);
+ return false;
+ }
- if (datum < 0 || datum > 255) {
- log_err(keymap->ctx,
- "Message data must be in the range 0..255; "
- "Illegal datum %d ignored\n", datum);
- return false;
- }
+ if (!ExprResolveInteger(keymap->ctx, value, &datum))
+ return ReportMismatch(keymap, action->type, field, "integer");
- act->message[ndx] = (uint8_t) datum;
+ if (datum < 0 || datum > 255) {
+ log_err(keymap->ctx,
+ "Message data must be in the range 0..255; "
+ "Illegal datum %d ignored\n", datum);
+ return false;
}
+ act->message[ndx] = (uint8_t) datum;
return true;
}
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index c7b07f9..e898d58 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -366,10 +366,8 @@ AddGroupCompat(CompatInfo *info, xkb_group_index_t group, GroupCompatInfo *new)
static bool
ResolveStateAndPredicate(ExprDef * expr,
unsigned *pred_rtrn,
- unsigned *mods_rtrn, CompatInfo * info)
+ xkb_mod_mask_t *mods_rtrn, CompatInfo * info)
{
- ExprResult result;
-
if (expr == NULL) {
*pred_rtrn = XkbSI_AnyOfOrNone;
*mods_rtrn = ~0;
@@ -407,11 +405,7 @@ ResolveStateAndPredicate(ExprDef * expr,
}
}
- if (ExprResolveModMask(info->keymap->ctx, expr, &result)) {
- *mods_rtrn = result.uval;
- return true;
- }
- return false;
+ return ExprResolveModMask(info->keymap->ctx, expr, mods_rtrn);
}
/***====================================================================***/
@@ -761,35 +755,41 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
struct xkb_keymap *keymap = info->keymap;
if (istreq(field, "modifiers") || istreq(field, "mods")) {
- if (arrayNdx != NULL)
+ xkb_mod_mask_t mask;
+
+ if (arrayNdx)
return ReportIndicatorNotArray(info, led, field);
- if (!ExprResolveVModMask(keymap, value, &rtrn))
+ if (!ExprResolveVModMask(keymap, value, &mask))
return ReportIndicatorBadType(info, led, field, "modifier mask");
- led->real_mods = rtrn.uval & 0xff;
- led->vmods = (rtrn.uval >> 8) & 0xff;
+ led->real_mods = mask & 0xff;
+ led->vmods = (mask >> 8) & 0xff;
led->defined |= _LED_Mods;
}
else if (istreq(field, "groups")) {
- if (arrayNdx != NULL)
+ unsigned int mask;
+
+ if (arrayNdx)
return ReportIndicatorNotArray(info, led, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupNames))
+ if (!ExprResolveMask(keymap->ctx, value, &mask, groupNames))
return ReportIndicatorBadType(info, led, field, "group mask");
- led->groups = rtrn.uval;
+ led->groups = mask;
led->defined |= _LED_Groups;
}
else if (istreq(field, "controls") || istreq(field, "ctrls")) {
- if (arrayNdx != NULL)
+ unsigned int mask;
+
+ if (arrayNdx)
return ReportIndicatorNotArray(info, led, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
+ if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlNames))
return ReportIndicatorBadType(info, led, field,
"controls mask");
- led->ctrls = rtrn.uval;
+ led->ctrls = mask;
led->defined |= _LED_Ctrls;
}
else if (istreq(field, "allowexplicit")) {
@@ -810,24 +810,28 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
}
else if (istreq(field, "whichmodstate") ||
istreq(field, "whichmodifierstate")) {
- if (arrayNdx != NULL)
+ unsigned int mask;
+
+ if (arrayNdx)
return ReportIndicatorNotArray(info, led, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, modComponentNames))
+ if (!ExprResolveMask(keymap->ctx, value, &mask, modComponentNames))
return ReportIndicatorBadType(info, led, field,
"mask of modifier state components");
- led->which_mods = rtrn.uval;
+ led->which_mods = mask;
}
else if (istreq(field, "whichgroupstate")) {
- if (arrayNdx != NULL)
+ unsigned mask;
+
+ if (arrayNdx)
return ReportIndicatorNotArray(info, led, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupComponentNames))
+ if (!ExprResolveMask(keymap->ctx, value, &mask, groupComponentNames))
return ReportIndicatorBadType(info, led, field,
"mask of group state components");
- led->which_groups = rtrn.uval;
+ led->which_groups = mask;
}
else if (istreq(field, "driveskbd") ||
istreq(field, "driveskeyboard") ||
@@ -966,11 +970,11 @@ static int
HandleGroupCompatDef(CompatInfo *info, GroupCompatDef *def,
enum merge_mode merge)
{
- ExprResult val;
+ xkb_mod_mask_t mask;
GroupCompatInfo tmp;
- if (def->merge != MERGE_DEFAULT)
- merge = def->merge;
+ merge = (def->merge == MERGE_DEFAULT ? merge : def->merge);
+
if (def->group < 1 || def->group > XkbNumKbdGroups) {
log_err(info->keymap->ctx,
"Keyboard group must be in the range 1..%u; "
@@ -978,17 +982,20 @@ HandleGroupCompatDef(CompatInfo *info, GroupCompatDef *def,
XkbNumKbdGroups, def->group);
return false;
}
+
tmp.file_id = info->file_id;
tmp.merge = merge;
- if (!ExprResolveVModMask(info->keymap, def->def, &val)) {
+
+ if (!ExprResolveVModMask(info->keymap, def->def, &mask)) {
log_err(info->keymap->ctx,
"Expected a modifier mask in group compatibility definition; "
"Ignoring illegal compatibility map for group %u\n",
def->group);
return false;
}
- tmp.real_mods = val.uval & 0xff;
- tmp.vmods = (val.uval >> 8) & 0xffff;
+
+ tmp.real_mods = mask & 0xff;
+ tmp.vmods = (mask >> 8) & 0xffff;
tmp.defined = true;
return AddGroupCompat(info, def->group - 1, &tmp);
}
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index c73d5c7..7e10e45 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -813,26 +813,44 @@ ExprResolveMaskLookup(struct xkb_context *ctx, ExprDef *expr,
return false;
}
-int
+bool
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn, const LookupEntry *values)
+ unsigned int *mask_rtrn, const LookupEntry *values)
{
- return ExprResolveMaskLookup(ctx, expr, val_rtrn, SimpleLookup, values);
+ ExprResult result;
+ bool ok;
+
+ ok = ExprResolveMaskLookup(ctx, expr, &result, SimpleLookup, values);
+ if (ok)
+ *mask_rtrn = (unsigned int) result.ival;
+ return ok;
}
-int
+bool
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn)
+ xkb_mod_mask_t *mask_rtrn)
{
- return ExprResolveMaskLookup(ctx, expr, val_rtrn, LookupModMask, NULL);
+ ExprResult result;
+ bool ok;
+
+ ok = ExprResolveMaskLookup(ctx, expr, &result, LookupModMask, NULL);
+ if (ok)
+ *mask_rtrn = (xkb_mod_mask_t) result.ival;
+ return ok;
}
-int
+bool
ExprResolveVModMask(struct xkb_keymap *keymap, ExprDef *expr,
- ExprResult *val_rtrn)
+ xkb_mod_mask_t *mask_rtrn)
{
- return ExprResolveMaskLookup(keymap->ctx, expr, val_rtrn, LookupVModMask,
- keymap);
+ ExprResult result;
+ bool ok;
+
+ ok = ExprResolveMaskLookup(keymap->ctx, expr, &result, LookupVModMask,
+ keymap);
+ if (ok)
+ *mask_rtrn = (xkb_mod_mask_t) result.ival;
+ return ok;
}
bool
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index abdd514..5b0c732 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -58,13 +58,13 @@ extern bool
LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
enum expr_value_type type, ExprResult *val_rtrn);
-extern int
+bool
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn);
+ xkb_mod_mask_t *mask_rtrn);
-extern int
+bool
ExprResolveVModMask(struct xkb_keymap *keymap, ExprDef *expr,
- ExprResult *val_rtrn);
+ xkb_mod_mask_t *mask_rtrn);
bool
ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr, bool *set_rtrn);
@@ -98,9 +98,9 @@ extern int
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
const LookupEntry *values);
-extern int
-ExprResolveMask(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
- const LookupEntry *values);
+bool
+ExprResolveMask(struct xkb_context *ctx, ExprDef *expr,
+ unsigned int *mask_rtrn, const LookupEntry *values);
bool
ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr,
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index b8df802..2661816 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -531,21 +531,21 @@ static bool
SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
ExprDef *value)
{
- ExprResult rtrn;
unsigned int level;
struct xkb_kt_map_entry entry;
+ xkb_mod_mask_t mask;
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(info, type, "map entry");
- if (!ExprResolveVModMask(info->keymap, arrayNdx, &rtrn))
+ if (!ExprResolveVModMask(info->keymap, arrayNdx, &mask))
return ReportTypeBadType(info, type, "map entry", "modifier mask");
- entry.mods.real_mods = rtrn.uval & 0xff; /* modifiers < 512 */
- entry.mods.vmods = (rtrn.uval >> 8) & 0xffff; /* modifiers > 512 */
+ entry.mods.real_mods = mask & 0xff; /* modifiers < 512 */
+ entry.mods.vmods = (mask >> 8) & 0xffff; /* modifiers > 512 */
if ((entry.mods.real_mods & (~type->mask)) ||
- ((entry.mods.vmods & (~type->vmask)) != 0)) {
+ (entry.mods.vmods & (~type->vmask))) {
log_lvl(info->keymap->ctx, 1,
"Map entry for unused modifiers in %s; "
"Using %s instead of %s\n",
@@ -574,18 +574,18 @@ static bool
SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
ExprDef *value)
{
- ExprResult rtrn;
+ xkb_mod_mask_t mask;
PreserveInfo new;
if (arrayNdx == NULL)
return ReportTypeShouldBeArray(info, type, "preserve entry");
- if (!ExprResolveVModMask(info->keymap, arrayNdx, &rtrn))
+ if (!ExprResolveVModMask(info->keymap, arrayNdx, &mask))
return ReportTypeBadType(info, type, "preserve entry",
"modifier mask");
- new.indexMods = rtrn.uval & 0xff;
- new.indexVMods = (rtrn.uval >> 8) & 0xffff;
+ new.indexMods = mask & 0xff;
+ new.indexVMods = (mask >> 8) & 0xffff;
if ((new.indexMods & (~type->mask)) ||
(new.indexVMods & (~type->vmask))) {
@@ -601,7 +601,7 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
PreserveIndexTxt(info, &new));
}
- if (!ExprResolveVModMask(info->keymap, value, &rtrn)) {
+ if (!ExprResolveVModMask(info->keymap, value, &mask)) {
log_err(info->keymap->ctx,
"Preserve value in a key type is not a modifier mask; "
"Ignoring preserve[%s] in type %s\n",
@@ -609,8 +609,8 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
return false;
}
- new.preMods = rtrn.uval & 0xff;
- new.preVMods = (rtrn.uval >> 16) & 0xffff;
+ new.preMods = mask & 0xff;
+ new.preVMods = (mask >> 16) & 0xffff;
if ((new.preMods & (~new.indexMods)) ||
(new.preVMods & (~new.indexVMods))) {
@@ -705,23 +705,24 @@ static bool
SetKeyTypeField(KeyTypesInfo *info, KeyTypeInfo *type,
const char *field, ExprDef *arrayNdx, ExprDef *value)
{
- ExprResult tmp;
-
if (istreq(field, "modifiers")) {
- unsigned mods, vmods;
- if (arrayNdx != NULL)
+ xkb_mod_mask_t mask, mods, vmods;
+
+ if (arrayNdx)
log_warn(info->keymap->ctx,
"The modifiers field of a key type is not an array; "
"Illegal array subscript ignored\n");
+
/* get modifier mask for current type */
- if (!ExprResolveVModMask(info->keymap, value, &tmp)) {
+ if (!ExprResolveVModMask(info->keymap, value, &mask)) {
log_err(info->keymap->ctx,
"Key type mask field must be a modifier mask; "
"Key type definition ignored\n");
return false;
}
- mods = tmp.uval & 0xff; /* core mods */
- vmods = (tmp.uval >> 8) & 0xffff; /* xkb virtual mods */
+
+ mods = mask & 0xff; /* core mods */
+ vmods = (mask >> 8) & 0xffff; /* xkb virtual mods */
if (type->defined & _KT_Mask) {
log_warn(info->keymap->ctx,
"Multiple modifier mask definitions for key type %s; "
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index ccc7568..6dc9a0d 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1061,9 +1061,11 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
else if (istreq(field, "vmods") ||
istreq(field, "virtualmods") ||
istreq(field, "virtualmodifiers")) {
- ok = ExprResolveVModMask(info->keymap, value, &tmp);
+ xkb_mod_mask_t mask;
+
+ ok = ExprResolveVModMask(info->keymap, value, &mask);
if (ok) {
- keyi->vmodmap = (tmp.uval >> 8);
+ keyi->vmodmap = (mask >> 8);
keyi->defined |= _Key_VModMap;
}
else {
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index d6cac95..5ce1f94 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -66,7 +66,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
xkb_mod_index_t i;
int nextFree;
xkb_mod_mask_t bit;
- ExprResult mod;
+ xkb_mod_mask_t mask;
nextFree = -1;
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
@@ -92,19 +92,19 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
if (!stmt->value)
return true;
- if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
+ if (!ExprResolveModMask(keymap->ctx, stmt->value, &mask)) {
log_err(keymap->ctx, "Declaration of %s ignored\n",
xkb_atom_text(keymap->ctx, stmt->name));
return false;
}
- if (mod.uval == keymap->vmods[i])
+ if (mask == keymap->vmods[i])
return true;
str1 = ModMaskText(keymap->vmods[i], true);
if (mergeMode == MERGE_OVERRIDE) {
str2 = str1;
- str1 = ModMaskText(mod.uval, true);
+ str1 = ModMaskText(mask, true);
}
log_warn(keymap->ctx,
@@ -113,7 +113,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
xkb_atom_text(keymap->ctx, stmt->name), str1, str2);
if (mergeMode == MERGE_OVERRIDE)
- keymap->vmods[i] = mod.uval;
+ keymap->vmods[i] = mask;
return true;
}
@@ -134,13 +134,13 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
if (!stmt->value)
return true;
- if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
+ if (!ExprResolveModMask(keymap->ctx, stmt->value, &mask)) {
log_err(keymap->ctx, "Declaration of %s ignored\n",
xkb_atom_text(keymap->ctx, stmt->name));
return false;
}
- keymap->vmods[nextFree] = mod.uval;
+ keymap->vmods[nextFree] = mask;
return true;
}