Commit 90d86c360ae35ef24c21a8fa7ec8fda545535307

Daniel Stone 2012-02-20T16:54:54

Remove field reference lookup support None of the lookup functions anyone ever used supported field references, so don't pretend we do in the API. Signed-off-by: Daniel Stone <daniel@fooishbar.org>

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
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 0297907..95afcde 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -795,7 +795,7 @@ HandleISOLock(struct xkb_desc * xkb,
     case F_Affect:
         if (array_ndx != NULL)
             return ReportActionNotArray(action->type, field);
-        if (!ExprResolveMask(value, &rtrn, SimpleLookup, (char *) isoNames))
+        if (!ExprResolveMask(value, &rtrn, isoNames))
             return ReportMismatch(action->type, field, "keyboard component");
         act->affect = (~rtrn.uval) & XkbSA_ISOAffectMask;
         return True;
@@ -908,8 +908,7 @@ HandleSetLockControls(struct xkb_desc * xkb,
     {
         if (array_ndx != NULL)
             return ReportActionNotArray(action->type, field);
-        if (!ExprResolveMask
-            (value, &rtrn, SimpleLookup, (char *) ctrlNames))
+        if (!ExprResolveMask(value, &rtrn, ctrlNames))
             return ReportMismatch(action->type, field, "controls mask");
         act->ctrls = rtrn.uval;
         return True;
@@ -941,7 +940,7 @@ HandleActionMessage(struct xkb_desc * xkb,
     case F_Report:
         if (array_ndx != NULL)
             return ReportActionNotArray(action->type, field);
-        if (!ExprResolveMask(value, &rtrn, SimpleLookup, (char *) evNames))
+        if (!ExprResolveMask(value, &rtrn, evNames))
             return ReportMismatch(action->type, field, "key event mask");
         act->flags &= ~(XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
         act->flags =
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 5b33ff8..3915988 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -156,14 +156,13 @@ ExprResolveLhs(ExprDef * expr,
 }
 
 Bool
-SimpleLookup(char * priv,
-             uint32_t elem, uint32_t field, unsigned type, ExprResult * val_rtrn)
+SimpleLookup(char * priv, uint32_t field, unsigned type,
+             ExprResult * val_rtrn)
 {
     LookupEntry *entry;
     const char *str;
 
-    if ((priv == NULL) ||
-        (field == None) || (elem != None) ||
+    if ((priv == NULL) || (field == None) ||
         ((type != TypeInt) && (type != TypeFloat)))
     {
         return False;
@@ -184,13 +183,12 @@ SimpleLookup(char * priv,
 }
 
 Bool
-RadioLookup(char * priv,
-            uint32_t elem, uint32_t field, unsigned type, ExprResult * val_rtrn)
+RadioLookup(char * priv, uint32_t field, unsigned type, ExprResult * val_rtrn)
 {
     const char *str;
     int rg;
 
-    if ((field == None) || (elem != None) || (type != TypeInt))
+    if ((field == None) || (type != TypeInt))
         return False;
     str = XkbcAtomText(field);
     if (str)
@@ -225,21 +223,20 @@ static LookupEntry modIndexNames[] = {
 };
 
 int
-LookupModIndex(char * priv,
-               uint32_t elem, uint32_t field, unsigned type, ExprResult * val_rtrn)
+LookupModIndex(char * priv, uint32_t field, unsigned type,
+               ExprResult * val_rtrn)
 {
-    return SimpleLookup((char *) modIndexNames, elem, field, type,
-                        val_rtrn);
+    return SimpleLookup((char *) modIndexNames, field, type, val_rtrn);
 }
 
 static int
-LookupModMask(char * priv,
-              uint32_t elem, uint32_t field, unsigned type, ExprResult * val_rtrn)
+LookupModMask(char * priv, uint32_t field, unsigned type,
+              ExprResult * val_rtrn)
 {
     char *str;
     Bool ret = True;
 
-    if ((elem != None) || (type != TypeInt))
+    if (type != TypeInt)
         return False;
     str = XkbcAtomGetString(field);
     if (str == NULL)
@@ -248,14 +245,13 @@ LookupModMask(char * priv,
         val_rtrn->uval = 0xff;
     else if (uStrCaseCmp(str, "none") == 0)
         val_rtrn->uval = 0;
-    else if (LookupModIndex(priv, elem, field, type, val_rtrn))
+    else if (LookupModIndex(priv, field, type, val_rtrn))
         val_rtrn->uval = (1 << val_rtrn->uval);
     else if (priv != NULL)
     {
         LookupPriv *lpriv = (LookupPriv *) priv;
         if ((lpriv->chain == NULL) ||
-            (!(*lpriv->chain) (lpriv->chainPriv, elem, field, type,
-                               val_rtrn)))
+            (!(*lpriv->chain) (lpriv->chainPriv, field, type, val_rtrn)))
             ret = False;
     }
     else
@@ -265,31 +261,6 @@ LookupModMask(char * priv,
 }
 
 int
-ExprResolveModMask(ExprDef * expr,
-                   ExprResult * val_rtrn)
-{
-    LookupPriv priv;
-
-    priv.priv = NULL;
-    priv.chain = NULL;
-    priv.chainPriv = NULL;
-    return ExprResolveMask(expr, val_rtrn, LookupModMask, (char *) & priv);
-}
-
-int
-ExprResolveVModMask(ExprDef * expr,
-                    ExprResult * val_rtrn,
-                    struct xkb_desc *xkb)
-{
-    LookupPriv priv;
-
-    priv.priv = NULL;
-    priv.chain = LookupVModMask;
-    priv.chainPriv = (char *) xkb;
-    return ExprResolveMask(expr, val_rtrn, LookupModMask, (char *) & priv);
-}
-
-int
 ExprResolveBoolean(ExprDef * expr,
                    ExprResult * val_rtrn)
 {
@@ -410,7 +381,7 @@ ExprResolveFloat(ExprDef * expr,
         ERROR("Numeric default \"%s.%s\" unknown\n",
               XkbcAtomText(expr->value.field.element),
               XkbcAtomText(expr->value.field.field));
-        return ok;
+        return False;
     case OpAdd:
     case OpSubtract:
     case OpMultiply:
@@ -588,25 +559,17 @@ ExprResolveIntegerLookup(ExprDef * expr,
     case ExprIdent:
         if (lookup)
         {
-            ok = (*lookup) (lookupPriv,
-                            None, expr->value.str, TypeInt, val_rtrn);
+            ok = (*lookup) (lookupPriv, expr->value.str, TypeInt, val_rtrn);
         }
         if (!ok)
             ERROR("Identifier \"%s\" of type int is unknown\n",
                    XkbcAtomText(expr->value.str));
         return ok;
     case ExprFieldRef:
-        if (lookup)
-        {
-            ok = (*lookup) (lookupPriv,
-                            expr->value.field.element,
-                            expr->value.field.field, TypeInt, val_rtrn);
-        }
-        if (!ok)
-            ERROR("Default \"%s.%s\" of type int is unknown\n",
-                   XkbcAtomText(expr->value.field.element),
-                   XkbcAtomText(expr->value.field.field));
-        return ok;
+        ERROR("Default \"%s.%s\" of type int is unknown\n",
+              XkbcAtomText(expr->value.field.element),
+              XkbcAtomText(expr->value.field.field));
+        return False;
     case OpAdd:
     case OpSubtract:
     case OpMultiply:
@@ -892,8 +855,7 @@ ExprResolveEnum(ExprDef * expr, ExprResult * val_rtrn, LookupEntry * values)
                exprOpText(expr->op));
         return False;
     }
-    if (!SimpleLookup((char *) values, (uint32_t) None, expr->value.str,
-                      (unsigned) TypeInt, val_rtrn))
+    if (!SimpleLookup((char *) values, expr->value.str, TypeInt, val_rtrn))
     {
         int nOut = 0;
         ERROR("Illegal identifier %s (expected one of: ",
@@ -913,10 +875,11 @@ ExprResolveEnum(ExprDef * expr, ExprResult * val_rtrn, LookupEntry * values)
     return True;
 }
 
-int
-ExprResolveMask(ExprDef * expr,
-                ExprResult * val_rtrn,
-                IdentLookupFunc lookup, char * lookupPriv)
+static int
+ExprResolveMaskLookup(ExprDef * expr,
+                      ExprResult * val_rtrn,
+                      IdentLookupFunc lookup,
+                      char * lookupPriv)
 {
     int ok = 0;
     ExprResult leftRtrn, rightRtrn;
@@ -936,27 +899,16 @@ ExprResolveMask(ExprDef * expr,
         val_rtrn->ival = expr->value.ival;
         return True;
     case ExprIdent:
-        if (lookup)
-        {
-            ok = (*lookup) (lookupPriv,
-                            None, expr->value.str, TypeInt, val_rtrn);
-        }
+        ok = (*lookup) (lookupPriv, expr->value.str, TypeInt, val_rtrn);
         if (!ok)
             ERROR("Identifier \"%s\" of type int is unknown\n",
                    XkbcAtomText(expr->value.str));
         return ok;
     case ExprFieldRef:
-        if (lookup)
-        {
-            ok = (*lookup) (lookupPriv,
-                            expr->value.field.element,
-                            expr->value.field.field, TypeInt, val_rtrn);
-        }
-        if (!ok)
-            ERROR("Default \"%s.%s\" of type int is unknown\n",
-                   XkbcAtomText(expr->value.field.element),
-                   XkbcAtomText(expr->value.field.field));
-        return ok;
+        ERROR("Default \"%s.%s\" of type int is unknown\n",
+              XkbcAtomText(expr->value.field.element),
+              XkbcAtomText(expr->value.field.field));
+        return False;
     case ExprArrayRef:
         bogus = "array reference";
     case ExprActionDecl:
@@ -971,8 +923,8 @@ ExprResolveMask(ExprDef * expr,
     case OpDivide:
         left = expr->value.binary.left;
         right = expr->value.binary.right;
-        if (ExprResolveMask(left, &leftRtrn, lookup, lookupPriv) &&
-            ExprResolveMask(right, &rightRtrn, lookup, lookupPriv))
+        if (ExprResolveMaskLookup(left, &leftRtrn, lookup, lookupPriv) &&
+            ExprResolveMaskLookup(right, &rightRtrn, lookup, lookupPriv))
         {
             switch (expr->op)
             {
@@ -1021,6 +973,42 @@ ExprResolveMask(ExprDef * expr,
 }
 
 int
+ExprResolveMask(ExprDef * expr,
+                ExprResult * val_rtrn,
+                LookupEntry * values)
+{
+    return ExprResolveMaskLookup(expr, val_rtrn, SimpleLookup,
+                                 (char *) values);
+}
+
+int
+ExprResolveModMask(ExprDef * expr,
+                   ExprResult * val_rtrn)
+{
+    LookupPriv priv;
+
+    priv.priv = NULL;
+    priv.chain = NULL;
+    priv.chainPriv = NULL;
+    return ExprResolveMaskLookup(expr, val_rtrn, LookupModMask,
+                                 (char *) & priv);
+}
+
+int
+ExprResolveVModMask(ExprDef * expr,
+                    ExprResult * val_rtrn,
+                    struct xkb_desc *xkb)
+{
+    LookupPriv priv;
+
+    priv.priv = NULL;
+    priv.chain = LookupVModMask;
+    priv.chainPriv = (char *) xkb;
+    return ExprResolveMaskLookup(expr, val_rtrn, LookupModMask,
+                                 (char *) & priv);
+}
+
+int
 ExprResolveKeySym(ExprDef * expr,
                   ExprResult * val_rtrn)
 {
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index 8a3471c..c10be24 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -36,7 +36,6 @@ typedef union _ExprResult
 } ExprResult;
 
 typedef Bool(*IdentLookupFunc) (char * /* priv */ ,
-                                uint32_t /* elem */ ,
                                 uint32_t /* field */ ,
                                 unsigned /* type */ ,
                                 ExprResult *    /* val_rtrn */
@@ -73,21 +72,18 @@ extern char *exprOpText(unsigned        /* type */
     );
 
 extern int RadioLookup(char * /* priv */ ,
-                       uint32_t /* elem */ ,
                        uint32_t /* field */ ,
                        unsigned /* type */ ,
                        ExprResult *     /* val_rtrn */
     );
 
 extern int SimpleLookup(char * /* priv */ ,
-                        uint32_t /* elem */ ,
                         uint32_t /* field */ ,
                         unsigned /* type */ ,
                         ExprResult *    /* val_rtrn */
     );
 
 extern int LookupModIndex(char * /* priv */ ,
-                          uint32_t /* elem */ ,
                           uint32_t /* field */ ,
                           unsigned /* type */ ,
                           ExprResult *  /* val_rtrn */
@@ -149,8 +145,7 @@ extern int ExprResolveEnum(ExprDef * /* expr */ ,
 
 extern int ExprResolveMask(ExprDef * /* expr */ ,
                            ExprResult * /* val_rtrn */ ,
-                           IdentLookupFunc /* lookup */ ,
-                           char *     /* lookupPriv */
+                           LookupEntry * /* values */
     );
 
 extern int ExprResolveKeySym(ExprDef * /* expr */ ,
diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c
index d999144..34d6a64 100644
--- a/src/xkbcomp/indicators.c
+++ b/src/xkbcomp/indicators.c
@@ -244,8 +244,7 @@ SetIndicatorMapField(LEDInfo * led,
     {
         if (arrayNdx != NULL)
             return ReportIndicatorNotArray(led, field);
-        if (!ExprResolveMask
-            (value, &rtrn, SimpleLookup, (char *) groupNames))
+        if (!ExprResolveMask(value, &rtrn, groupNames))
             return ReportIndicatorBadType(led, field, "group mask");
         led->groups = rtrn.uval;
         led->defs.defined |= _LED_Groups;
@@ -255,8 +254,7 @@ SetIndicatorMapField(LEDInfo * led,
     {
         if (arrayNdx != NULL)
             return ReportIndicatorNotArray(led, field);
-        if (!ExprResolveMask
-            (value, &rtrn, SimpleLookup, (char *) ctrlNames))
+        if (!ExprResolveMask(value, &rtrn, ctrlNames))
             return ReportIndicatorBadType(led, field,
                                           "controls mask");
         led->ctrls = rtrn.uval;
@@ -279,8 +277,7 @@ SetIndicatorMapField(LEDInfo * led,
     {
         if (arrayNdx != NULL)
             return ReportIndicatorNotArray(led, field);
-        if (!ExprResolveMask(value, &rtrn, SimpleLookup,
-                             (char *) modComponentNames))
+        if (!ExprResolveMask(value, &rtrn, modComponentNames))
         {
             return ReportIndicatorBadType(led, field,
                                           "mask of modifier state components");
@@ -291,8 +288,7 @@ SetIndicatorMapField(LEDInfo * led,
     {
         if (arrayNdx != NULL)
             return ReportIndicatorNotArray(led, field);
-        if (!ExprResolveMask(value, &rtrn, SimpleLookup,
-                             (char *) groupComponentNames))
+        if (!ExprResolveMask(value, &rtrn, groupComponentNames))
         {
             return ReportIndicatorBadType(led, field,
                                           "mask of group state components");
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index d2dc4bc..6011c26 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1609,7 +1609,7 @@ HandleModMapDef(ModMapDef * def,
     ExprResult rtrn;
     Bool ok;
 
-    if (!LookupModIndex(NULL, None, def->modifier, TypeInt, &rtrn))
+    if (!LookupModIndex(NULL, def->modifier, TypeInt, &rtrn))
     {
         ERROR("Illegal modifier map definition\n");
         ACTION("Ignoring map for non-modifier \"%s\"\n",
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 29ef628..17a9892 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -154,7 +154,6 @@ HandleVModDef(VModDef * stmt, struct xkb_desc *xkb, unsigned mergeMode,
  * Returns the index of the given modifier in the xkb->names->vmods array.
  *
  * @param priv Pointer to the xkb data structure.
- * @param elem Must be None, otherwise return False.
  * @param field The Atom of the modifier's name (e.g. Atom for LAlt)
  * @param type Must be TypeInt, otherwise return False.
  * @param val_rtrn Set to the index of the modifier that matches.
@@ -163,15 +162,14 @@ HandleVModDef(VModDef * stmt, struct xkb_desc *xkb, unsigned mergeMode,
  * undefined.
  */
 static int
-LookupVModIndex(char * priv,
-                uint32_t elem, uint32_t field, unsigned type, ExprResult * val_rtrn)
+LookupVModIndex(char * priv, uint32_t field, unsigned type,
+                ExprResult * val_rtrn)
 {
     int i;
     struct xkb_desc * xkb;
 
     xkb = (struct xkb_desc *) priv;
-    if ((xkb == NULL) || (xkb->names == NULL) || (elem != None)
-        || (type != TypeInt))
+    if ((xkb == NULL) || (xkb->names == NULL) || (type != TypeInt))
     {
         return False;
     }
@@ -202,10 +200,9 @@ LookupVModIndex(char * priv,
  * undefined.
  */
 int
-LookupVModMask(char * priv,
-               uint32_t elem, uint32_t field, unsigned type, ExprResult * val_rtrn)
+LookupVModMask(char * priv, uint32_t field, unsigned type, ExprResult * val_rtrn)
 {
-    if (LookupVModIndex(priv, elem, field, type, val_rtrn))
+    if (LookupVModIndex(priv, field, type, val_rtrn))
     {
         register unsigned ndx = val_rtrn->uval;
         val_rtrn->uval = (1 << (XkbNumModifiers + ndx));
@@ -221,7 +218,7 @@ FindKeypadVMod(struct xkb_desc * xkb)
     ExprResult rtrn;
 
     name = xkb_intern_atom("NumLock");
-    if ((xkb) && LookupVModIndex((char *) xkb, None, name, TypeInt, &rtrn))
+    if ((xkb) && LookupVModIndex((char *) xkb, name, TypeInt, &rtrn))
     {
         return rtrn.ival;
     }
diff --git a/src/xkbcomp/vmod.h b/src/xkbcomp/vmod.h
index 1e0bb5c..55de95c 100644
--- a/src/xkbcomp/vmod.h
+++ b/src/xkbcomp/vmod.h
@@ -55,7 +55,6 @@ extern Bool ApplyVModDefs(VModInfo * /* info */ ,
     );
 
 extern int LookupVModMask(char * /* priv */ ,
-                          uint32_t /* elem */ ,
                           uint32_t /* field */ ,
                           unsigned /* type */ ,
                           ExprResult *  /* val_rtrn */