Commit c117318ff11886e7aad42031c630eb4cc9a13a83

Ran Benita 2012-05-09T11:47:20

Make the context available to xkb_intern_atom In preparation of contextualizing the atom table. Since we touch every function call, also rename the function to xkb_atom_intern, to match better with the rest (which will also be renamed). Signed-off-by: Ran Benita <ran234@gmail.com> [daniels: Fixed for 'xkb' -> 'keymap'.]

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
diff --git a/src/atom.c b/src/atom.c
index a65bfc6..0a49ac3 100644
--- a/src/atom.c
+++ b/src/atom.c
@@ -108,7 +108,7 @@ XkbcAtomGetString(xkb_atom_t atom)
 }
 
 xkb_atom_t
-xkb_intern_atom(const char *string)
+xkb_atom_intern(struct xkb_context *context, const char *string)
 {
     NodePtr *np;
     NodePtr nd;
diff --git a/src/atom.h b/src/atom.h
index 25443fa..bd80b41 100644
--- a/src/atom.h
+++ b/src/atom.h
@@ -34,7 +34,7 @@ typedef uint32_t xkb_atom_t;
 #define XKB_ATOM_NONE 0
 
 extern xkb_atom_t
-xkb_intern_atom(const char *string);
+xkb_atom_intern(struct xkb_context *context, const char *string);
 
 extern char *
 XkbcAtomGetString(xkb_atom_t atom);
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 624f766..e5cd6e5 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -1085,7 +1085,7 @@ ApplyActionFactoryDefaults(union xkb_action * action)
 }
 
 static void
-ActionsInit(void);
+ActionsInit(struct xkb_context *context);
 
 int
 HandleActionDef(ExprDef * def,
@@ -1097,7 +1097,7 @@ HandleActionDef(ExprDef * def,
     unsigned tmp, hndlrType;
 
     if (!actionsInitialized)
-        ActionsInit();
+        ActionsInit(xkb->context);
 
     if (def->op != ExprActionDecl)
     {
@@ -1153,13 +1153,13 @@ HandleActionDef(ExprDef * def,
             if ((arg->op == OpNot) || (arg->op == OpInvert))
             {
                 field = arg->value.child;
-                constFalse.value.str = xkb_intern_atom("false");
+                constFalse.value.str = xkb_atom_intern(xkb->context, "false");
                 value = &constFalse;
             }
             else
             {
                 field = arg;
-                constTrue.value.str = xkb_intern_atom("true");
+                constTrue.value.str = xkb_atom_intern(xkb->context, "true");
                 value = &constTrue;
             }
         }
@@ -1202,7 +1202,7 @@ SetActionField(struct xkb_keymap *keymap,
     ActionInfo *new, *old;
 
     if (!actionsInitialized)
-        ActionsInit();
+        ActionsInit(xkb->context);
 
     new = uTypedAlloc(ActionInfo);
     if (new == NULL)
@@ -1249,7 +1249,7 @@ SetActionField(struct xkb_keymap *keymap,
 /***====================================================================***/
 
 static void
-ActionsInit(void)
+ActionsInit(struct xkb_context *context)
 {
     if (!actionsInitialized)
     {
@@ -1259,12 +1259,12 @@ ActionsInit(void)
         constTrue.common.next = NULL;
         constTrue.op = ExprIdent;
         constTrue.type = TypeBoolean;
-        constTrue.value.str = xkb_intern_atom("true");
+        constTrue.value.str = xkb_atom_intern(context, "true");
         constFalse.common.stmtType = StmtExpr;
         constFalse.common.next = NULL;
         constFalse.op = ExprIdent;
         constFalse.type = TypeBoolean;
-        constFalse.value.str = xkb_intern_atom("false");
+        constFalse.value.str = xkb_atom_intern(context, "false");
         actionsInitialized = 1;
     }
 }
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index b0b4707..78d5771 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -115,7 +115,7 @@ InitCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
     info->dflt.interp.act.type = XkbSA_NoAction;
     for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++)
         info->dflt.interp.act.any.data[i] = 0;
-    ClearIndicatorMapInfo(&info->ledDflt);
+    ClearIndicatorMapInfo(xkb->context, &info->ledDflt);
     info->ledDflt.defs.fileID = info->fileID;
     info->ledDflt.defs.defined = 0;
     info->ledDflt.defs.merge = MergeOverride;
@@ -140,7 +140,7 @@ ClearCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
     info->dflt.interp.act.type = XkbSA_NoAction;
     for (i = 0; i < sizeof(info->dflt.interp.act.any.data); i++)
         info->dflt.interp.act.any.data[i] = 0;
-    ClearIndicatorMapInfo(&info->ledDflt);
+    ClearIndicatorMapInfo(xkb->context, &info->ledDflt);
     info->nInterps = 0;
     info->interps = (SymInterpInfo *) ClearCommonInfo(&info->interps->defs);
     memset(&info->groupCompat[0], 0,
diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c
index fc75a4d..231fb2f 100644
--- a/src/xkbcomp/indicators.c
+++ b/src/xkbcomp/indicators.c
@@ -38,9 +38,9 @@
 /***====================================================================***/
 
 void
-ClearIndicatorMapInfo(LEDInfo * info)
+ClearIndicatorMapInfo(struct xkb_context *context, LEDInfo * info)
 {
-    info->name = xkb_intern_atom("default");
+    info->name = xkb_atom_intern(context, "default");
     info->indicator = _LED_NotBound;
     info->flags = info->which_mods = info->real_mods = 0;
     info->vmods = 0;
diff --git a/src/xkbcomp/indicators.h b/src/xkbcomp/indicators.h
index 829f5d2..83cd408 100644
--- a/src/xkbcomp/indicators.h
+++ b/src/xkbcomp/indicators.h
@@ -54,7 +54,7 @@ typedef struct _LEDInfo
 } LEDInfo;
 
 extern void
-ClearIndicatorMapInfo(LEDInfo *info);
+ClearIndicatorMapInfo(struct xkb_context *context, LEDInfo *info);
 
 
 extern LEDInfo *
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 7fdd688..f05cf1c 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -754,7 +754,8 @@ err_out:
 }
 
 static int
-HandleIndicatorNameDef(IndicatorNameDef *def, KeyNamesInfo *info)
+HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *xkb,
+                       KeyNamesInfo *info)
 {
     IndicatorNameInfo ii;
     ExprResult tmp;
@@ -775,7 +776,7 @@ HandleIndicatorNameDef(IndicatorNameDef *def, KeyNamesInfo *info)
         info->errorCount++;
         return ReportBadType("indicator", "name", buf, "string");
     }
-    ii.name = xkb_intern_atom(tmp.str);
+    ii.name = xkb_atom_intern(xkb->context, tmp.str);
     free(tmp.str);
     ii.virtual = def->virtual;
     if (!AddIndicatorName(info, &ii))
@@ -827,7 +828,7 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
                 info->errorCount++;
             break;
         case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */
-            if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, info))
+            if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap, info))
                 info->errorCount++;
             break;
         case StmtInterpDef:
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index f5d50dd..7867d9a 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -104,10 +104,10 @@ static void
 InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
                  KeyTypesInfo *from)
 {
-    tok_ONE_LEVEL = xkb_intern_atom("ONE_LEVEL");
-    tok_TWO_LEVEL = xkb_intern_atom("TWO_LEVEL");
-    tok_ALPHABETIC = xkb_intern_atom("ALPHABETIC");
-    tok_KEYPAD = xkb_intern_atom("KEYPAD");
+    tok_ONE_LEVEL = xkb_atom_intern(xkb->context, "ONE_LEVEL");
+    tok_TWO_LEVEL = xkb_atom_intern(xkb->context, "TWO_LEVEL");
+    tok_ALPHABETIC = xkb_atom_intern(xkb->context, "ALPHABETIC");
+    tok_KEYPAD = xkb_atom_intern(xkb->context, "KEYPAD");
     info->name = strdup("default");
     info->errorCount = 0;
     info->stdPresent = 0;
@@ -775,7 +775,8 @@ AddLevelName(KeyTypeInfo *type, unsigned level, xkb_atom_t name, bool clobber)
 }
 
 static bool
-SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
+SetLevelName(KeyTypeInfo *type, struct xkb_keymap *xkb, ExprDef *arrayNdx,
+             ExprDef *value)
 {
     ExprResult rtrn;
     unsigned level;
@@ -793,7 +794,7 @@ SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
         ACTION("Ignoring illegal level name definition\n");
         return false;
     }
-    level_name = xkb_intern_atom(rtrn.str);
+    level_name = xkb_atom_intern(xkb->context, rtrn.str);
     free(rtrn.str);
     return AddLevelName(type, level, level_name, true);
 }
@@ -856,7 +857,7 @@ SetKeyTypeField(KeyTypeInfo *type, struct xkb_keymap *keymap,
              (strcasecmp(field, "level_name") == 0))
     {
         type->defs.defined |= _KT_LevelNames;
-        return SetLevelName(type, arrayNdx, value);
+        return SetLevelName(type, xkb, arrayNdx, value);
     }
     ERROR("Unknown field %s in key type %s\n", field, TypeTxt(type));
     ACTION("Definition ignored\n");
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index ce775b4..df9232c 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -563,21 +563,21 @@ FieldSpec	:	Ident			{ $$= $1; }
 		;
 
 Element		:	ACTION_TOK		
-			{ $$= xkb_intern_atom("action"); }
+			{ $$= xkb_atom_intern(param->context, "action"); }
 		|	INTERPRET
-			{ $$= xkb_intern_atom("interpret"); }
+			{ $$= xkb_atom_intern(param->context, "interpret"); }
 		|	TYPE
-			{ $$= xkb_intern_atom("type"); }
+			{ $$= xkb_atom_intern(param->context, "type"); }
 		|	KEY
-			{ $$= xkb_intern_atom("key"); }
+			{ $$= xkb_atom_intern(param->context, "key"); }
 		|	GROUP
-			{ $$= xkb_intern_atom("group"); }
+			{ $$= xkb_atom_intern(param->context, "group"); }
 		|	MODIFIER_MAP
-			{$$= xkb_intern_atom("modifier_map");}
+			{$$= xkb_atom_intern(param->context, "modifier_map");}
 		|	INDICATOR
-			{ $$= xkb_intern_atom("indicator"); }
+			{ $$= xkb_atom_intern(param->context, "indicator"); }
 		|	SHAPE	
-			{ $$= xkb_intern_atom("shape"); }
+			{ $$= xkb_atom_intern(param->context, "shape"); }
 		|	ROW	
 			{ $$= XKB_ATOM_NONE; }
 		|	SECTION	
@@ -767,11 +767,22 @@ KeyCode         :       INTEGER         { $$= $1; }
 KeyName		:	KEYNAME		{ $$= $1; }
 		;
 
-Ident		:	IDENT	{ $$= xkb_intern_atom($1); free($1); }
-		|	DEFAULT { $$= xkb_intern_atom("default"); }
+Ident		:	IDENT
+                        {
+                            $$ = xkb_atom_intern(param->context, $1);
+                            free($1);
+                        }
+		|	DEFAULT
+                        {
+                            $$ = xkb_atom_intern(param->context, "default");
+                        }
 		;
 
-String		:	STRING	{ $$= xkb_intern_atom($1); free($1); }
+String		:	STRING
+                        {
+                            $$ = xkb_atom_intern(param->context, $1);
+                            free($1);
+                        }
 		;
 
 OptMapName	:	MapName	{ $$= $1; }
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 51bdc36..4b62f41 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1188,7 +1188,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
         }
         if (arrayNdx == NULL)
         {
-            key->dfltType = xkb_intern_atom(tmp.str);
+            key->dfltType = xkb_atom_intern(xkb->context, tmp.str);
             key->defs.defined |= _Key_Type_Dflt;
         }
         else if (!ExprResolveGroup(arrayNdx, &ndx))
@@ -1201,7 +1201,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
         }
         else
         {
-            key->types[ndx.uval - 1] = xkb_intern_atom(tmp.str);
+            key->types[ndx.uval - 1] = xkb_atom_intern(xkb->context, tmp.str);
             key->typesDefined |= (1 << (ndx.uval - 1));
         }
         free(tmp.str);
@@ -1324,7 +1324,8 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
 }
 
 static int
-SetGroupName(SymbolsInfo * info, ExprDef * arrayNdx, ExprDef * value)
+SetGroupName(SymbolsInfo *info, struct xkb_keymap *xkb, ExprDef *arrayNdx,
+             ExprDef *value)
 {
     ExprResult tmp, name;
 
@@ -1347,7 +1348,7 @@ SetGroupName(SymbolsInfo * info, ExprDef * arrayNdx, ExprDef * value)
         return false;
     }
     info->groupNames[tmp.uval - 1 + info->explicit_group] =
-        xkb_intern_atom(name.str);
+        xkb_atom_intern(xkb->context, name.str);
     free(name.str);
 
     return true;
@@ -1371,7 +1372,7 @@ HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
                                     (strcasecmp(field.str, "groupname") ==
                                      0)))
     {
-        ret = SetGroupName(info, arrayNdx, stmt->value);
+        ret = SetGroupName(info, xkb, arrayNdx, stmt->value);
     }
     else if ((elem.str == NULL)
              && ((strcasecmp(field.str, "groupswrap") == 0) ||
@@ -1728,29 +1729,29 @@ FindNamedType(struct xkb_keymap *keymap, xkb_atom_t atom, unsigned *type_rtrn)
  * @returns true if a type could be found, false otherwise.
  */
 static bool
-FindAutomaticType(int width, xkb_keysym_t * syms, xkb_atom_t * typeNameRtrn,
-                  bool * autoType)
+FindAutomaticType(struct xkb_keymap *xkb, int width, xkb_keysym_t *syms,
+                  xkb_atom_t *typeNameRtrn, bool *autoType)
 {
     *autoType = false;
     if ((width == 1) || (width == 0))
     {
-        *typeNameRtrn = xkb_intern_atom("ONE_LEVEL");
+        *typeNameRtrn = xkb_atom_intern(xkb->context, "ONE_LEVEL");
         *autoType = true;
     }
     else if (width == 2)
     {
         if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1]))
         {
-            *typeNameRtrn = xkb_intern_atom("ALPHABETIC");
+            *typeNameRtrn = xkb_atom_intern(xkb->context, "ALPHABETIC");
         }
         else if (syms && (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1])))
         {
-            *typeNameRtrn = xkb_intern_atom("KEYPAD");
+            *typeNameRtrn = xkb_atom_intern(xkb->context, "KEYPAD");
             *autoType = true;
         }
         else
         {
-            *typeNameRtrn = xkb_intern_atom("TWO_LEVEL");
+            *typeNameRtrn = xkb_atom_intern(xkb->context, "TWO_LEVEL");
             *autoType = true;
         }
     }
@@ -1759,14 +1760,15 @@ FindAutomaticType(int width, xkb_keysym_t * syms, xkb_atom_t * typeNameRtrn,
         if (syms && XkbcKSIsLower(syms[0]) && XkbcKSIsUpper(syms[1]))
             if (XkbcKSIsLower(syms[2]) && XkbcKSIsUpper(syms[3]))
                 *typeNameRtrn =
-                    xkb_intern_atom("FOUR_LEVEL_ALPHABETIC");
+                    xkb_atom_intern(xkb->context, "FOUR_LEVEL_ALPHABETIC");
             else
-                *typeNameRtrn = xkb_intern_atom("FOUR_LEVEL_SEMIALPHABETIC");
+                *typeNameRtrn = xkb_atom_intern(xkb->context,
+                                                "FOUR_LEVEL_SEMIALPHABETIC");
 
         else if (syms && (XkbKSIsKeypad(syms[0]) || XkbKSIsKeypad(syms[1])))
-            *typeNameRtrn = xkb_intern_atom("FOUR_LEVEL_KEYPAD");
+            *typeNameRtrn = xkb_atom_intern(xkb->context, "FOUR_LEVEL_KEYPAD");
         else
-            *typeNameRtrn = xkb_intern_atom("FOUR_LEVEL");
+            *typeNameRtrn = xkb_atom_intern(xkb->context, "FOUR_LEVEL");
         /* XXX: why not set autoType here? */
     }
     return ((width >= 0) && (width <= 4));
@@ -1969,7 +1971,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
         {
             if (key->dfltType != XKB_ATOM_NONE)
                 key->types[i] = key->dfltType;
-            else if (FindAutomaticType(key->numLevels[i], key->syms[i],
+            else if (FindAutomaticType(xkb, key->numLevels[i], key->syms[i],
                                        &key->types[i], &autoType))
             {
             }
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 83188b7..f9a08f1 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -211,7 +211,7 @@ FindKeypadVMod(struct xkb_keymap *keymap)
     xkb_atom_t name;
     ExprResult rtrn;
 
-    name = xkb_intern_atom("NumLock");
+    name = xkb_intern_atom(keymap->context, "NumLock");
     if (keymap && LookupVModIndex(keymap, name, TypeInt, &rtrn))
     {
         return rtrn.ival;