Commit efe2880e855195b87d057123e555401bae89b994

Ran Benita 2014-02-15T22:28:41

action: don't pass a keymap where a ctx is sufficient 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
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index a4344c6..0aad747 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -186,10 +186,10 @@ fieldText(enum action_field field)
 /***====================================================================***/
 
 static inline bool
-ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action,
+ReportMismatch(struct xkb_context *ctx, enum xkb_action_type action,
                enum action_field field, const char *type)
 {
-    log_err(keymap->ctx,
+    log_err(ctx,
             "Value of %s field must be of type %s; "
             "Action %s definition ignored\n",
             fieldText(field), type, ActionTypeText(action));
@@ -197,10 +197,10 @@ ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action,
 }
 
 static inline bool
-ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action,
+ReportIllegal(struct xkb_context *ctx, enum xkb_action_type action,
               enum action_field field)
 {
-    log_err(keymap->ctx,
+    log_err(ctx,
             "Field %s is not defined for an action of type %s; "
             "Action definition ignored\n",
             fieldText(field), ActionTypeText(action));
@@ -208,10 +208,10 @@ ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action,
 }
 
 static inline bool
-ReportActionNotArray(struct xkb_keymap *keymap, enum xkb_action_type action,
+ReportActionNotArray(struct xkb_context *ctx, enum xkb_action_type action,
                      enum action_field field)
 {
-    log_err(keymap->ctx,
+    log_err(ctx,
             "The %s field in the %s action is not an array; "
             "Action definition ignored\n",
             fieldText(field), ActionTypeText(action));
@@ -228,7 +228,7 @@ HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action,
 }
 
 static bool
-CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
+CheckLatchLockFlags(struct xkb_context *ctx, enum xkb_action_type action,
                     enum action_field field, const ExprDef *array_ndx,
                     const ExprDef *value, enum xkb_action_flags *flags_inout)
 {
@@ -236,7 +236,7 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
     bool result;
 
     if (array_ndx)
-        return ReportActionNotArray(keymap, action, field);
+        return ReportActionNotArray(ctx, action, field);
 
     if (field == ACTION_FIELD_CLEAR_LOCKS)
         tmp = ACTION_LOCK_CLEAR;
@@ -245,8 +245,8 @@ CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action,
     else
         return false;           /* WSGO! */
 
-    if (!ExprResolveBoolean(keymap->ctx, value, &result))
-        return ReportMismatch(keymap, action, field, "boolean");
+    if (!ExprResolveBoolean(ctx, value, &result))
+        return ReportMismatch(ctx, action, field, "boolean");
 
     if (result)
         *flags_inout |= tmp;
@@ -262,7 +262,7 @@ CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
                    enum xkb_action_flags *flags_inout, xkb_mod_mask_t *mods_rtrn)
 {
     if (array_ndx)
-        return ReportActionNotArray(keymap, action, ACTION_FIELD_MODIFIERS);
+        return ReportActionNotArray(keymap->ctx, action, ACTION_FIELD_MODIFIERS);
 
     if (value->expr.op == EXPR_IDENT) {
         const char *valStr;
@@ -276,7 +276,7 @@ CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action,
     }
 
     if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn))
-        return ReportMismatch(keymap, action,
+        return ReportMismatch(keymap->ctx, action,
                               ACTION_FIELD_MODIFIERS, "modifier mask");
 
     *flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP;
@@ -292,13 +292,13 @@ HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action,
 
     if (field == ACTION_FIELD_CLEAR_LOCKS ||
         field == ACTION_FIELD_LATCH_TO_LOCK)
-        return CheckLatchLockFlags(keymap, action->type, field, array_ndx,
+        return CheckLatchLockFlags(keymap->ctx, action->type, field, array_ndx,
                                    value, &act->flags);
     else if (field == ACTION_FIELD_MODIFIERS)
         return CheckModifierField(keymap, action->type, array_ndx, value,
                                   &act->flags, &act->mods.mods);
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static const LookupEntry lockWhich[] = {
@@ -310,17 +310,17 @@ static const LookupEntry lockWhich[] = {
 };
 
 static bool
-CheckAffectField(struct xkb_keymap *keymap, enum xkb_action_type action,
+CheckAffectField(struct xkb_context *ctx, enum xkb_action_type action,
                  const ExprDef *array_ndx, const ExprDef *value,
                  enum xkb_action_flags *flags_inout)
 {
     enum xkb_action_flags flags;
 
     if (array_ndx)
-        return ReportActionNotArray(keymap, action, ACTION_FIELD_AFFECT);
+        return ReportActionNotArray(ctx, action, ACTION_FIELD_AFFECT);
 
-    if (!ExprResolveEnum(keymap->ctx, value, &flags, lockWhich))
-        return ReportMismatch(keymap, action, ACTION_FIELD_AFFECT,
+    if (!ExprResolveEnum(ctx, value, &flags, lockWhich))
+        return ReportMismatch(ctx, action, ACTION_FIELD_AFFECT,
                               "lock, unlock, both, neither");
 
     *flags_inout &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK);
@@ -339,14 +339,14 @@ HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action,
         return CheckModifierField(keymap, action->type, array_ndx, value,
                                   &act->flags, &act->mods.mods);
     else if (field == ACTION_FIELD_AFFECT)
-        return CheckAffectField(keymap, action->type, array_ndx, value,
+        return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
                                 &act->flags);
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static bool
-CheckGroupField(struct xkb_keymap *keymap, unsigned action,
+CheckGroupField(struct xkb_context *ctx, unsigned action,
                 const ExprDef *array_ndx, const ExprDef *value,
                 enum xkb_action_flags *flags_inout, int32_t *group_rtrn)
 {
@@ -355,7 +355,7 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
     enum xkb_action_flags flags = *flags_inout;
 
     if (array_ndx)
-        return ReportActionNotArray(keymap, action, ACTION_FIELD_GROUP);
+        return ReportActionNotArray(ctx, action, ACTION_FIELD_GROUP);
 
     if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) {
         flags &= ~ACTION_ABSOLUTE_SWITCH;
@@ -366,8 +366,8 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
         spec = value;
     }
 
-    if (!ExprResolveGroup(keymap->ctx, spec, &idx))
-        return ReportMismatch(keymap, action, ACTION_FIELD_GROUP,
+    if (!ExprResolveGroup(ctx, spec, &idx))
+        return ReportMismatch(ctx, action, ACTION_FIELD_GROUP,
                               "integer (range 1..8)");
 
     /* +n, -n are relative, n is absolute. */
@@ -392,13 +392,13 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action,
 
     if (field == ACTION_FIELD_CLEAR_LOCKS ||
         field == ACTION_FIELD_LATCH_TO_LOCK)
-        return CheckLatchLockFlags(keymap, action->type, field, array_ndx,
+        return CheckLatchLockFlags(keymap->ctx, action->type, field, array_ndx,
                                    value, &act->flags);
     else if (field == ACTION_FIELD_GROUP)
-        return CheckGroupField(keymap, action->type, array_ndx, value,
+        return CheckGroupField(keymap->ctx, action->type, array_ndx, value,
                                &act->flags, &act->group);
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static bool
@@ -409,10 +409,10 @@ HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action,
     struct xkb_group_action *act = &action->group;
 
     if (field == ACTION_FIELD_GROUP)
-        return CheckGroupField(keymap, action->type, array_ndx, value,
+        return CheckGroupField(keymap->ctx, action->type, array_ndx, value,
                                &act->flags, &act->group);
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static bool
@@ -428,10 +428,10 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
                                value->expr.op != EXPR_UNARY_PLUS);
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (!ExprResolveInteger(keymap->ctx, value, &val))
-            return ReportMismatch(keymap, action->type, field, "integer");
+            return ReportMismatch(keymap->ctx, action->type, field, "integer");
 
         if (val < INT16_MIN || val > INT16_MAX) {
             log_err(keymap->ctx,
@@ -459,10 +459,10 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
         bool set;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (!ExprResolveBoolean(keymap->ctx, value, &set))
-            return ReportMismatch(keymap, action->type, field, "boolean");
+            return ReportMismatch(keymap->ctx, action->type, field, "boolean");
 
         if (set)
             act->flags &= ~ACTION_NO_ACCEL;
@@ -470,7 +470,7 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
             act->flags |= ACTION_NO_ACCEL;
     }
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static bool
@@ -484,10 +484,10 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
         int btn;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (!ExprResolveButton(keymap->ctx, value, &btn))
-            return ReportMismatch(keymap, action->type, field,
+            return ReportMismatch(keymap->ctx, action->type, field,
                                   "integer (range 1..5)");
 
         if (btn < 0 || btn > 5) {
@@ -502,17 +502,17 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
     }
     else if (action->type == ACTION_TYPE_PTR_LOCK &&
              field == ACTION_FIELD_AFFECT) {
-        return CheckAffectField(keymap, action->type, array_ndx, value,
+        return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
                                 &act->flags);
     }
     else if (field == ACTION_FIELD_COUNT) {
         int val;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (!ExprResolveInteger(keymap->ctx, value, &val))
-            return ReportMismatch(keymap, action->type, field, "integer");
+            return ReportMismatch(keymap->ctx, action->type, field, "integer");
 
         if (val < 0 || val > 255) {
             log_err(keymap->ctx,
@@ -525,7 +525,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action,
         return true;
     }
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static const LookupEntry ptrDflts[] = {
@@ -546,10 +546,10 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
         unsigned int val;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
-            return ReportMismatch(keymap, action->type, field,
+            return ReportMismatch(keymap->ctx, action->type, field,
                                   "pointer component");
         return true;
     }
@@ -558,7 +558,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
         int btn;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (value->expr.op == EXPR_NEGATE ||
             value->expr.op == EXPR_UNARY_PLUS) {
@@ -571,7 +571,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
         }
 
         if (!ExprResolveButton(keymap->ctx, button, &btn))
-            return ReportMismatch(keymap, action->type, field,
+            return ReportMismatch(keymap->ctx, action->type, field,
                                   "integer (range 1..5)");
 
         if (btn < 0 || btn > 5) {
@@ -591,7 +591,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action,
         return true;
     }
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static bool
@@ -606,7 +606,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
         int val;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (value->expr.op == EXPR_NEGATE ||
             value->expr.op == EXPR_UNARY_PLUS) {
@@ -619,7 +619,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
         }
 
         if (!ExprResolveInteger(keymap->ctx, scrn, &val))
-            return ReportMismatch(keymap, action->type, field,
+            return ReportMismatch(keymap->ctx, action->type, field,
                                   "integer (0..255)");
 
         if (val < 0 || val > 255) {
@@ -636,10 +636,10 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
         bool set;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (!ExprResolveBoolean(keymap->ctx, value, &set))
-            return ReportMismatch(keymap, action->type, field, "boolean");
+            return ReportMismatch(keymap->ctx, action->type, field, "boolean");
 
         if (set)
             act->flags &= ~ACTION_SAME_SCREEN;
@@ -649,7 +649,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action,
         return true;
     }
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static bool
@@ -663,21 +663,21 @@ HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action,
         unsigned int mask;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames))
-            return ReportMismatch(keymap, action->type, field,
+            return ReportMismatch(keymap->ctx, action->type, field,
                                   "controls mask");
 
         act->ctrls = mask;
         return true;
     }
     else if (field == ACTION_FIELD_AFFECT) {
-        return CheckAffectField(keymap, action->type, array_ndx, value,
+        return CheckAffectField(keymap->ctx, action->type, array_ndx, value,
                                 &act->flags);
     }
 
-    return ReportIllegal(keymap, action->type, field);
+    return ReportIllegal(keymap->ctx, action->type, field);
 }
 
 static bool
@@ -691,10 +691,10 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
         int type;
 
         if (array_ndx)
-            return ReportActionNotArray(keymap, action->type, field);
+            return ReportActionNotArray(keymap->ctx, action->type, field);
 
         if (!ExprResolveInteger(keymap->ctx, value, &type))
-            return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer");
+            return ReportMismatch(keymap->ctx, ACTION_TYPE_PRIVATE, field, "integer");
 
         if (type < 0 || type > 255) {
             log_err(keymap->ctx,
@@ -732,7 +732,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
             size_t len;
 
             if (!ExprResolveString(keymap->ctx, value, &val))
-                return ReportMismatch(keymap, action->type, field, "string");
+                return ReportMismatch(keymap->ctx, action->type, field, "string");
 
             str = xkb_atom_text(keymap->ctx, val);
             len = strlen(str);
@@ -765,7 +765,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
             }
 
             if (!ExprResolveInteger(keymap->ctx, value, &datum))
-                return ReportMismatch(keymap, act->type, field, "integer");
+                return ReportMismatch(keymap->ctx, act->type, field, "integer");
 
             if (datum < 0 || datum > 255) {
                 log_err(keymap->ctx,
@@ -779,7 +779,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
         }
     }
 
-    return ReportIllegal(keymap, ACTION_TYPE_NONE, field);
+    return ReportIllegal(keymap->ctx, ACTION_TYPE_NONE, field);
 }
 
 typedef bool (*actionHandler)(struct xkb_keymap *keymap,