Commit 79a2cc09cc67dd0781efc2c2ffff8661ddc046fb

Ran Benita 2012-08-11T11:54:05

action: convert action field type to enum We can also hide the ActionInfo definition inside action.c. 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
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 9aa3c95..1693308 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -30,6 +30,8 @@
 #include "action.h"
 #include "keycodes.h"
 
+#define PrivateAction (XkbSA_LastAction + 1)
+
 static const ExprDef constTrue = {
     .common = { .type = STMT_EXPR, .next = NULL },
     .op = EXPR_VALUE,
@@ -44,7 +46,50 @@ static const ExprDef constFalse = {
     .value = { .ival = 0 },
 };
 
-/***====================================================================***/
+enum action_field {
+    ACTION_FIELD_CLEAR_LOCKS,
+    ACTION_FIELD_LATCH_TO_LOCK,
+    ACTION_FIELD_GEN_KEY_EVENT,
+    ACTION_FIELD_REPORT,
+    ACTION_FIELD_DEFAULT,
+    ACTION_FIELD_AFFECT,
+    ACTION_FIELD_INCREMENT,
+    ACTION_FIELD_MODIFIERS,
+    ACTION_FIELD_GROUP,
+    ACTION_FIELD_X,
+    ACTION_FIELD_Y,
+    ACTION_FIELD_ACCEL,
+    ACTION_FIELD_BUTTON,
+    ACTION_FIELD_VALUE,
+    ACTION_FIELD_CONTROLS,
+    ACTION_FIELD_TYPE,
+    ACTION_FIELD_COUNT,
+    ACTION_FIELD_SCREEN,
+    ACTION_FIELD_SAME,
+    ACTION_FIELD_DATA,
+    ACTION_FIELD_DEVICE,
+    ACTION_FIELD_KEYCODE,
+    ACTION_FIELD_MODS_TO_CLEAR,
+};
+
+struct _ActionInfo {
+    unsigned action;
+    enum action_field field;
+    ExprDef *array_ndx;
+    ExprDef *value;
+    struct _ActionInfo *next;
+};
+
+void
+FreeActionInfo(ActionInfo *info)
+{
+    ActionInfo *next;
+    while (info) {
+        next = info->next;
+        free(info);
+        info = next;
+    }
+}
 
 static const LookupEntry actionStrings[] = {
     { "noaction",          XkbSA_NoAction       },
@@ -92,40 +137,40 @@ static const LookupEntry actionStrings[] = {
 };
 
 static const LookupEntry fieldStrings[] = {
-    { "clearLocks",       F_ClearLocks  },
-    { "latchToLock",      F_LatchToLock },
-    { "genKeyEvent",      F_GenKeyEvent },
-    { "generateKeyEvent", F_GenKeyEvent },
-    { "report",           F_Report      },
-    { "default",          F_Default     },
-    { "affect",           F_Affect      },
-    { "increment",        F_Increment   },
-    { "modifiers",        F_Modifiers   },
-    { "mods",             F_Modifiers   },
-    { "group",            F_Group       },
-    { "x",                F_X           },
-    { "y",                F_Y           },
-    { "accel",            F_Accel       },
-    { "accelerate",       F_Accel       },
-    { "repeat",           F_Accel       },
-    { "button",           F_Button      },
-    { "value",            F_Value       },
-    { "controls",         F_Controls    },
-    { "ctrls",            F_Controls    },
-    { "type",             F_Type        },
-    { "count",            F_Count       },
-    { "screen",           F_Screen      },
-    { "same",             F_Same        },
-    { "sameServer",       F_Same        },
-    { "data",             F_Data        },
-    { "device",           F_Device      },
-    { "dev",              F_Device      },
-    { "key",              F_Keycode     },
-    { "keycode",          F_Keycode     },
-    { "kc",               F_Keycode     },
-    { "clearmods",        F_ModsToClear },
-    { "clearmodifiers",   F_ModsToClear },
-    { NULL,               0             }
+    { "clearLocks",       ACTION_FIELD_CLEAR_LOCKS   },
+    { "latchToLock",      ACTION_FIELD_LATCH_TO_LOCK },
+    { "genKeyEvent",      ACTION_FIELD_GEN_KEY_EVENT },
+    { "generateKeyEvent", ACTION_FIELD_GEN_KEY_EVENT },
+    { "report",           ACTION_FIELD_REPORT        },
+    { "default",          ACTION_FIELD_DEFAULT       },
+    { "affect",           ACTION_FIELD_AFFECT        },
+    { "increment",        ACTION_FIELD_INCREMENT     },
+    { "modifiers",        ACTION_FIELD_MODIFIERS     },
+    { "mods",             ACTION_FIELD_MODIFIERS     },
+    { "group",            ACTION_FIELD_GROUP         },
+    { "x",                ACTION_FIELD_X             },
+    { "y",                ACTION_FIELD_Y             },
+    { "accel",            ACTION_FIELD_ACCEL         },
+    { "accelerate",       ACTION_FIELD_ACCEL         },
+    { "repeat",           ACTION_FIELD_ACCEL         },
+    { "button",           ACTION_FIELD_BUTTON        },
+    { "value",            ACTION_FIELD_VALUE         },
+    { "controls",         ACTION_FIELD_CONTROLS      },
+    { "ctrls",            ACTION_FIELD_CONTROLS      },
+    { "type",             ACTION_FIELD_TYPE          },
+    { "count",            ACTION_FIELD_COUNT         },
+    { "screen",           ACTION_FIELD_SCREEN        },
+    { "same",             ACTION_FIELD_SAME          },
+    { "sameServer",       ACTION_FIELD_SAME          },
+    { "data",             ACTION_FIELD_DATA          },
+    { "device",           ACTION_FIELD_DEVICE        },
+    { "dev",              ACTION_FIELD_DEVICE        },
+    { "key",              ACTION_FIELD_KEYCODE       },
+    { "keycode",          ACTION_FIELD_KEYCODE       },
+    { "kc",               ACTION_FIELD_KEYCODE       },
+    { "clearmods",        ACTION_FIELD_MODS_TO_CLEAR },
+    { "clearmodifiers",   ACTION_FIELD_MODS_TO_CLEAR },
+    { NULL,               0                          }
 };
 
 static bool
@@ -166,13 +211,13 @@ stringToAction(const char *str, unsigned *type_rtrn)
 }
 
 static bool
-stringToField(const char *str, unsigned *field_rtrn)
+stringToField(const char *str, enum action_field *field_rtrn)
 {
     return stringToValue(fieldStrings, str, field_rtrn);
 }
 
 static const char *
-fieldText(unsigned field)
+fieldText(enum action_field field)
 {
     return valueToString(fieldStrings, field);
 }
@@ -180,8 +225,8 @@ fieldText(unsigned field)
 /***====================================================================***/
 
 static inline bool
-ReportMismatch(struct xkb_keymap *keymap, unsigned action, unsigned field,
-               const char *type)
+ReportMismatch(struct xkb_keymap *keymap, unsigned action,
+               enum action_field field, const char *type)
 {
     log_err(keymap->ctx,
             "Value of %s field must be of type %s; "
@@ -191,7 +236,8 @@ ReportMismatch(struct xkb_keymap *keymap, unsigned action, unsigned field,
 }
 
 static inline bool
-ReportIllegal(struct xkb_keymap *keymap, unsigned action, unsigned field)
+ReportIllegal(struct xkb_keymap *keymap, unsigned action,
+              enum action_field field)
 {
     log_err(keymap->ctx,
             "Field %s is not defined for an action of type %s; "
@@ -202,7 +248,7 @@ ReportIllegal(struct xkb_keymap *keymap, unsigned action, unsigned field)
 
 static inline bool
 ReportActionNotArray(struct xkb_keymap *keymap, unsigned action,
-                     unsigned field)
+                     enum action_field field)
 {
     log_err(keymap->ctx,
             "The %s field in the %s action is not an array; "
@@ -212,8 +258,8 @@ ReportActionNotArray(struct xkb_keymap *keymap, unsigned action,
 }
 
 static inline bool
-ReportNotFound(struct xkb_keymap *keymap, unsigned action, unsigned field,
-               const char *what, const char *bad)
+ReportNotFound(struct xkb_keymap *keymap, unsigned action,
+               enum action_field field, const char *what, const char *bad)
 {
     log_err(keymap->ctx,
             "%s named %s not found; "
@@ -224,7 +270,8 @@ ReportNotFound(struct xkb_keymap *keymap, unsigned action, unsigned field,
 
 static bool
 HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
-               unsigned field, const ExprDef *array_ndx, const ExprDef *value)
+               enum action_field field, const ExprDef *array_ndx,
+               const ExprDef *value)
 
 {
     return ReportIllegal(keymap, action->type, field);
@@ -232,15 +279,15 @@ HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
 
 static bool
 CheckLatchLockFlags(struct xkb_keymap *keymap, unsigned action,
-                    unsigned field, const ExprDef * value,
+                    enum action_field field, const ExprDef * value,
                     unsigned *flags_inout)
 {
     unsigned tmp;
     bool result;
 
-    if (field == F_ClearLocks)
+    if (field == ACTION_FIELD_CLEAR_LOCKS)
         tmp = XkbSA_ClearLocks;
-    else if (field == F_LatchToLock)
+    else if (field == ACTION_FIELD_LATCH_TO_LOCK)
         tmp = XkbSA_LatchToLock;
     else
         return false;           /* WSGO! */
@@ -274,7 +321,8 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action,
     }
 
     if (!ExprResolveVModMask(keymap, value, mods_rtrn))
-        return ReportMismatch(keymap, action, F_Modifiers, "modifier mask");
+        return ReportMismatch(keymap, action,
+                              ACTION_FIELD_MODIFIERS, "modifier mask");
 
     *flags_inout &= ~XkbSA_UseModMapMods;
     return true;
@@ -282,7 +330,7 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action,
 
 static bool
 HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
-                   unsigned field, const ExprDef *array_ndx,
+                   enum action_field field, const ExprDef *array_ndx,
                    const ExprDef *value)
 {
     struct xkb_mod_action *act = &action->mods;
@@ -292,15 +340,18 @@ HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
 
     if (array_ndx != NULL) {
         switch (field) {
-        case F_ClearLocks:
-        case F_LatchToLock:
-        case F_Modifiers:
+        case ACTION_FIELD_CLEAR_LOCKS:
+        case ACTION_FIELD_LATCH_TO_LOCK:
+        case ACTION_FIELD_MODIFIERS:
             return ReportActionNotArray(keymap, action->type, field);
+        default:
+            break;
         }
     }
+
     switch (field) {
-    case F_ClearLocks:
-    case F_LatchToLock:
+    case ACTION_FIELD_CLEAR_LOCKS:
+    case ACTION_FIELD_LATCH_TO_LOCK:
         rtrn = act->flags;
         if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
             act->flags = rtrn;
@@ -308,7 +359,7 @@ HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
         }
         return false;
 
-    case F_Modifiers:
+    case ACTION_FIELD_MODIFIERS:
         t1 = act->flags;
         if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
             act->flags = t1;
@@ -316,22 +367,28 @@ HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
             return true;
         }
         return false;
+
+    default:
+        break;
     }
+
     return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
 HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
-               unsigned field, const ExprDef *array_ndx, const ExprDef *value)
+               enum action_field field, const ExprDef *array_ndx,
+               const ExprDef *value)
 {
     struct xkb_mod_action *act = &action->mods;
     unsigned t1;
     xkb_mod_mask_t t2;
 
-    if ((array_ndx != NULL) && (field == F_Modifiers))
+    if (array_ndx && field == ACTION_FIELD_MODIFIERS)
         return ReportActionNotArray(keymap, action->type, field);
+
     switch (field) {
-    case F_Modifiers:
+    case ACTION_FIELD_MODIFIERS:
         t1 = act->flags;
         if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
             act->flags = t1;
@@ -339,7 +396,11 @@ HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
             return true;
         }
         return false;
+
+    default:
+        break;
     }
+
     return ReportIllegal(keymap, action->type, field);
 }
 
@@ -360,7 +421,7 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
     }
 
     if (!ExprResolveGroup(keymap->ctx, spec, grp_rtrn))
-        return ReportMismatch(keymap, action, F_Group,
+        return ReportMismatch(keymap, action, ACTION_FIELD_GROUP,
                               "integer (range 1..8)");
 
     if (value->op == EXPR_NEGATE)
@@ -373,7 +434,7 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
 
 static bool
 HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
-                    unsigned field, const ExprDef *array_ndx,
+                    enum action_field field, const ExprDef *array_ndx,
                     const ExprDef *value)
 {
     struct xkb_group_action *act = &action->group;
@@ -383,15 +444,19 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
 
     if (array_ndx != NULL) {
         switch (field) {
-        case F_ClearLocks:
-        case F_LatchToLock:
-        case F_Group:
+        case ACTION_FIELD_CLEAR_LOCKS:
+        case ACTION_FIELD_LATCH_TO_LOCK:
+        case ACTION_FIELD_GROUP:
             return ReportActionNotArray(keymap, action->type, field);
+
+        default:
+            break;
         }
     }
+
     switch (field) {
-    case F_ClearLocks:
-    case F_LatchToLock:
+    case ACTION_FIELD_CLEAR_LOCKS:
+    case ACTION_FIELD_LATCH_TO_LOCK:
         rtrn = act->flags;
         if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
             act->flags = rtrn;
@@ -399,7 +464,7 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
         }
         return false;
 
-    case F_Group:
+    case ACTION_FIELD_GROUP:
         t1 = act->flags;
         if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
             act->flags = t1;
@@ -407,22 +472,26 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
             return true;
         }
         return false;
+
+    default:
+        break;
     }
+
     return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
 HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
-                unsigned field, const ExprDef *array_ndx,
+                enum action_field field, const ExprDef *array_ndx,
                 const ExprDef *value)
 {
     struct xkb_group_action *act = &action->group;
     unsigned t1;
     xkb_group_index_t t2;
 
-    if ((array_ndx != NULL) && (field == F_Group))
+    if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP))
         return ReportActionNotArray(keymap, action->type, field);
-    if (field == F_Group) {
+    if (field == ACTION_FIELD_GROUP) {
         t1 = act->flags;
         if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
             act->flags = t1;
@@ -436,15 +505,16 @@ HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
 
 static bool
 HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
-              unsigned field, const ExprDef *array_ndx, const ExprDef *value)
+              enum action_field field, const ExprDef *array_ndx,
+              const ExprDef *value)
 {
     struct xkb_pointer_action *act = &action->ptr;
     bool absolute;
 
-    if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
+    if (array_ndx && (field == ACTION_FIELD_X || field == ACTION_FIELD_Y))
         return ReportActionNotArray(keymap, action->type, field);
 
-    if (field == F_X || field == F_Y) {
+    if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) {
         int val;
 
         if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS)
@@ -455,7 +525,7 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
         if (!ExprResolveInteger(keymap->ctx, value, &val))
             return ReportMismatch(keymap, action->type, field, "integer");
 
-        if (field == F_X) {
+        if (field == ACTION_FIELD_X) {
             if (absolute)
                 act->flags |= XkbSA_MoveAbsoluteX;
             act->x = val;
@@ -468,7 +538,7 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
 
         return true;
     }
-    else if (field == F_Accel) {
+    else if (field == ACTION_FIELD_ACCEL) {
         bool set;
 
         if (!ExprResolveBoolean(keymap->ctx, value, &set))
@@ -493,11 +563,12 @@ static const LookupEntry lockWhich[] = {
 
 static bool
 HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
-             unsigned field, const ExprDef *array_ndx, const ExprDef *value)
+             enum action_field field, const ExprDef *array_ndx,
+             const ExprDef *value)
 {
     struct xkb_pointer_button_action *act = &action->btn;
 
-    if (field == F_Button) {
+    if (field == ACTION_FIELD_BUTTON) {
         int btn;
 
         if (array_ndx)
@@ -517,7 +588,8 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
         act->button = btn;
         return true;
     }
-    else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
+    else if (action->type == XkbSA_LockPtrBtn &&
+             field == ACTION_FIELD_AFFECT) {
         unsigned int val;
 
         if (array_ndx)
@@ -531,7 +603,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
         act->flags |= val;
         return true;
     }
-    else if (field == F_Count) {
+    else if (field == ACTION_FIELD_COUNT) {
         int btn;
 
         if (array_ndx)
@@ -563,12 +635,12 @@ static const LookupEntry ptrDflts[] = {
 
 static bool
 HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
-                 unsigned field, const ExprDef *array_ndx,
+                 enum action_field field, const ExprDef *array_ndx,
                  const ExprDef *value)
 {
     struct xkb_pointer_default_action *act = &action->dflt;
 
-    if (field == F_Affect) {
+    if (field == ACTION_FIELD_AFFECT) {
         unsigned int val;
 
         if (array_ndx)
@@ -580,7 +652,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
         act->affect = val;
         return true;
     }
-    else if ((field == F_Button) || (field == F_Value)) {
+    else if (field == ACTION_FIELD_BUTTON || field == ACTION_FIELD_VALUE) {
         const ExprDef *button;
         int btn;
 
@@ -636,11 +708,12 @@ static const LookupEntry isoNames[] = {
 
 static bool
 HandleISOLock(struct xkb_keymap *keymap, union xkb_action *action,
-              unsigned field, const ExprDef *array_ndx, const ExprDef *value)
+              enum action_field field, const ExprDef *array_ndx,
+              const ExprDef *value)
 {
     struct xkb_iso_action *act = &action->iso;
 
-    if (field == F_Modifiers) {
+    if (field == ACTION_FIELD_MODIFIERS) {
         unsigned flags;
         xkb_mod_mask_t mods;
 
@@ -655,7 +728,7 @@ HandleISOLock(struct xkb_keymap *keymap, union xkb_action *action,
         act->mods.mods = mods;
         return true;
     }
-    else if (field == F_Group) {
+    else if (field == ACTION_FIELD_GROUP) {
         xkb_group_index_t group;
         unsigned flags;
 
@@ -669,7 +742,7 @@ HandleISOLock(struct xkb_keymap *keymap, union xkb_action *action,
         act->flags = flags | XkbSA_ISODfltIsGroup;
         act->group = group;
         return true;
-    } else if (F_Affect) {
+    } else if (ACTION_FIELD_AFFECT) {
         xkb_mod_mask_t mask;
 
         if (array_ndx)
@@ -688,12 +761,12 @@ HandleISOLock(struct xkb_keymap *keymap, union xkb_action *action,
 
 static bool
 HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
-                   unsigned field, const ExprDef *array_ndx,
+                   enum action_field field, const ExprDef *array_ndx,
                    const ExprDef *value)
 {
     struct xkb_switch_screen_action *act = &action->screen;
 
-    if (field == F_Screen) {
+    if (field == ACTION_FIELD_SCREEN) {
         const ExprDef *scrn;
         int val;
 
@@ -723,7 +796,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
         act->screen = (value->op == EXPR_NEGATE ? -val : val);
         return true;
     }
-    else if (field == F_Same) {
+    else if (field == ACTION_FIELD_SAME) {
         bool set;
 
         if (array_ndx)
@@ -765,14 +838,13 @@ const LookupEntry ctrlNames[] = {
 };
 
 static bool
-HandleSetLockControls(struct xkb_keymap *keymap,
-                      union xkb_action *action,
-                      unsigned field, const ExprDef *array_ndx,
+HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
+                      enum action_field field, const ExprDef *array_ndx,
                       const ExprDef *value)
 {
     struct xkb_controls_action *act = &action->ctrls;
 
-    if (field == F_Controls) {
+    if (field == ACTION_FIELD_CONTROLS) {
         unsigned int mask;
 
         if (array_ndx)
@@ -801,12 +873,12 @@ static const LookupEntry evNames[] = {
 
 static bool
 HandleActionMessage(struct xkb_keymap *keymap, union xkb_action *action,
-                    unsigned field, const ExprDef *array_ndx,
+                    enum action_field field, const ExprDef *array_ndx,
                     const ExprDef *value)
 {
     struct xkb_message_action *act = &action->msg;
 
-    if (field == F_Report) {
+    if (field == ACTION_FIELD_REPORT) {
         unsigned int mask;
 
         if (array_ndx)
@@ -821,7 +893,7 @@ HandleActionMessage(struct xkb_keymap *keymap, union xkb_action *action,
         act->flags = mask & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
         return true;
     }
-    else if (field == F_GenKeyEvent) {
+    else if (field == ACTION_FIELD_GEN_KEY_EVENT) {
         bool set;
 
         if (array_ndx)
@@ -837,7 +909,7 @@ HandleActionMessage(struct xkb_keymap *keymap, union xkb_action *action,
 
         return true;
     }
-    else if (field == F_Data && !array_ndx) {
+    else if (field == ACTION_FIELD_DATA && !array_ndx) {
         const char *str;
         int len;
 
@@ -854,7 +926,7 @@ HandleActionMessage(struct xkb_keymap *keymap, union xkb_action *action,
         strncpy((char *) act->message, str, 6);
         return true;
     }
-    else if (field == F_Data && array_ndx) {
+    else if (field == ACTION_FIELD_DATA && array_ndx) {
         int ndx, datum;
 
         if (!ExprResolveInteger(keymap->ctx, array_ndx, &ndx)) {
@@ -890,7 +962,7 @@ HandleActionMessage(struct xkb_keymap *keymap, union xkb_action *action,
 
 static bool
 HandleRedirectKey(struct xkb_keymap *keymap, union xkb_action *action,
-                  unsigned field, const ExprDef *array_ndx,
+                  enum action_field field, const ExprDef *array_ndx,
                   const ExprDef *value)
 {
     struct xkb_key *key;
@@ -904,7 +976,7 @@ HandleRedirectKey(struct xkb_keymap *keymap, union xkb_action *action,
         return ReportActionNotArray(keymap, action->type, field);
 
     switch (field) {
-    case F_Keycode:
+    case ACTION_FIELD_KEYCODE:
         if (!ExprResolveKeyName(keymap->ctx, value, key_name))
             return ReportMismatch(keymap, action->type, field, "key name");
 
@@ -916,37 +988,41 @@ HandleRedirectKey(struct xkb_keymap *keymap, union xkb_action *action,
         act->new_kc = XkbKeyGetKeycode(keymap, key);
         return true;
 
-    case F_ModsToClear:
-    case F_Modifiers:
+    case ACTION_FIELD_MODS_TO_CLEAR:
+    case ACTION_FIELD_MODIFIERS:
         t1 = 0;
         if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
             act->mods_mask |= (t2 & 0xff);
-            if (field == F_Modifiers)
+            if (field == ACTION_FIELD_MODIFIERS)
                 act->mods |= (t2 & 0xff);
             else
                 act->mods &= ~(t2 & 0xff);
 
             t2 = (t2 >> XkbNumModifiers) & 0xffff;
             act->vmods_mask |= t2;
-            if (field == F_Modifiers)
+            if (field == ACTION_FIELD_MODIFIERS)
                 act->vmods |= t2;
             else
                 act->vmods &= ~t2;
             return true;
         }
         return true;
+
+    default:
+        break;
     }
+
     return ReportIllegal(keymap, action->type, field);
 }
 
 static bool
 HandleDeviceBtn(struct xkb_keymap *keymap, union xkb_action *action,
-                unsigned field, const ExprDef *array_ndx,
+                enum action_field field, const ExprDef *array_ndx,
                 const ExprDef *value)
 {
     struct xkb_device_button_action *act = &action->devbtn;
 
-    if (field == F_Button) {
+    if (field == ACTION_FIELD_BUTTON) {
         int val;
 
         if (array_ndx)
@@ -966,7 +1042,8 @@ HandleDeviceBtn(struct xkb_keymap *keymap, union xkb_action *action,
         act->button = val;
         return true;
     }
-    else if (action->type == XkbSA_LockDeviceBtn && field == F_Affect) {
+    else if (action->type == XkbSA_LockDeviceBtn &&
+             field == ACTION_FIELD_AFFECT) {
         unsigned int val;
 
         if (array_ndx)
@@ -980,7 +1057,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, union xkb_action *action,
         act->flags |= val;
         return true;
     }
-    else if (field == F_Count) {
+    else if (field == ACTION_FIELD_COUNT) {
         int btn;
 
         if (array_ndx)
@@ -1000,7 +1077,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, union xkb_action *action,
         act->count = btn;
         return true;
     }
-    else if (field == F_Device) {
+    else if (field == ACTION_FIELD_DEVICE) {
         int val;
 
         if (array_ndx)
@@ -1026,7 +1103,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, union xkb_action *action,
 
 static bool
 HandleDeviceValuator(struct xkb_keymap *keymap, union xkb_action *action,
-                     unsigned field, const ExprDef *array_ndx,
+                     enum action_field field, const ExprDef *array_ndx,
                      const ExprDef *value)
 {
     struct xkb_device_valuator_action *act = &action->devval;
@@ -1038,11 +1115,12 @@ HandleDeviceValuator(struct xkb_keymap *keymap, union xkb_action *action,
 
 static bool
 HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
-              unsigned field, const ExprDef *array_ndx, const ExprDef *value)
+              enum action_field field, const ExprDef *array_ndx,
+              const ExprDef *value)
 {
     struct xkb_private_action *act = &action->priv;
 
-    if (field == F_Type) {
+    if (field == ACTION_FIELD_TYPE) {
         int type;
 
         if (!ExprResolveInteger(keymap->ctx, value, &type))
@@ -1058,7 +1136,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
         act->type = (uint8_t) type;
         return true;
     }
-    else if (field == F_Data) {
+    else if (field == ACTION_FIELD_DATA) {
         if (array_ndx == NULL) {
             const char *str;
             int len;
@@ -1114,8 +1192,10 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
 }
 
 typedef bool (*actionHandler)(struct xkb_keymap *keymap,
-                              union xkb_action *action, unsigned field,
-                              const ExprDef *array_ndx, const ExprDef *value);
+                              union xkb_action *action,
+                              enum action_field field,
+                              const ExprDef *array_ndx,
+                              const ExprDef *value);
 
 static const actionHandler handleAction[XkbSA_NumActions + 1] = {
     [XkbSA_NoAction] = HandleNoAction,
@@ -1202,7 +1282,7 @@ HandleActionDef(ExprDef * def,
         const ExprDef *value;
         ExprDef *field, *arrayRtrn;
         const char *elemRtrn, *fieldRtrn;
-        unsigned fieldNdx;
+        enum action_field fieldNdx;
 
         if (arg->op == EXPR_ASSIGN) {
             field = arg->value.binary.left;
diff --git a/src/xkbcomp/action.h b/src/xkbcomp/action.h
index f5c9443..2460eb3 100644
--- a/src/xkbcomp/action.h
+++ b/src/xkbcomp/action.h
@@ -27,41 +27,10 @@
 #ifndef XKBCOMP_ACTION_H
 #define XKBCOMP_ACTION_H
 
-#define F_ClearLocks  0
-#define F_LatchToLock 1
-#define F_GenKeyEvent 2
-#define F_Report      3
-#define F_Default     4
-#define F_Affect      5
-#define F_Increment   6
-#define F_Modifiers   7
-#define F_Group       8
-#define F_X           9
-#define F_Y           10
-#define F_Accel       11
-#define F_Button      12
-#define F_Value       13
-#define F_Controls    14
-#define F_Type        15
-#define F_Count       16
-#define F_Screen      17
-#define F_Same        18
-#define F_Data        19
-#define F_Device      20
-#define F_Keycode     21
-#define F_ModsToClear 22
-#define F_LastField   F_ModsToClear
-#define F_NumFields   (F_LastField + 1)
+typedef struct _ActionInfo ActionInfo;
 
-#define PrivateAction (XkbSA_LastAction + 1)
-
-typedef struct _ActionInfo {
-    unsigned action;
-    unsigned field;
-    ExprDef *array_ndx;
-    ExprDef *value;
-    struct _ActionInfo *next;
-} ActionInfo;
+void
+FreeActionInfo(ActionInfo *info);
 
 int
 HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index e8f394b..d1754e9 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -187,7 +187,6 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap, unsigned file_id)
 static void
 ClearCompatInfo(CompatInfo *info)
 {
-    ActionInfo *next_act;
     SymInterpInfo *si, *next_si;
     LEDInfo *led, *next_led;
     struct xkb_keymap *keymap = info->keymap;
@@ -208,11 +207,8 @@ ClearCompatInfo(CompatInfo *info)
            XkbNumKbdGroups * sizeof(GroupCompatInfo));
     list_foreach_safe(led, next_led, &info->leds, entry)
         free(led);
-    while (info->act) {
-        next_act = info->act->next;
-        free(info->act);
-        info->act = next_act;
-    }
+    FreeActionInfo(info->act);
+    info->act = NULL;
     info->keymap = NULL;
     ClearVModInfo(&info->vmods, keymap);
 }