Introduce xkb_atom_t type
[platform/upstream/libxkbcommon.git] / src / xkbcomp / xkbcomp.h
1 /************************************************************
2  Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
3
4  Permission to use, copy, modify, and distribute this
5  software and its documentation for any purpose and without
6  fee is hereby granted, provided that the above copyright
7  notice appear in all copies and that both that copyright
8  notice and this permission notice appear in supporting
9  documentation, and that the name of Silicon Graphics not be
10  used in advertising or publicity pertaining to distribution
11  of the software without specific prior written permission.
12  Silicon Graphics makes no representation about the suitability
13  of this software for any purpose. It is provided "as is"
14  without any express or implied warranty.
15
16  SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
17  SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18  AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
19  GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
20  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
21  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
22  OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
23  THE USE OR PERFORMANCE OF THIS SOFTWARE.
24
25  ********************************************************/
26
27 #ifndef XKBCOMP_H
28 #define XKBCOMP_H 1
29
30 #ifndef DEBUG_VAR
31 #define DEBUG_VAR debugFlags
32 #endif
33
34 #include <X11/X.h>
35 #include <X11/Xdefs.h>
36
37 #include "utils.h"
38
39 #include "xkbcommon/xkbcommon.h"
40 #include "XKBcommonint.h"
41 #include "xkbmisc.h"
42
43 extern char *scanFile;
44
45 #define TypeUnknown     0
46 #define TypeBoolean     1
47 #define TypeInt         2
48 #define TypeFloat       3
49 #define TypeString      4
50 #define TypeAction      5
51 #define TypeKeyName     6
52 #define TypeSymbols     7
53
54 #define StmtUnknown             0
55 #define StmtInclude             1
56 #define StmtKeycodeDef          2
57 #define StmtKeyAliasDef         3
58 #define StmtExpr                4
59 #define StmtVarDef              5
60 #define StmtKeyTypeDef          6
61 #define StmtInterpDef           7
62 #define StmtVModDef             8
63 #define StmtSymbolsDef          9
64 #define StmtModMapDef           10
65 #define StmtGroupCompatDef      11
66 #define StmtIndicatorMapDef     12
67 #define StmtIndicatorNameDef    13
68 #define StmtOutlineDef          14
69 #define StmtShapeDef            15
70 #define StmtKeyDef              16
71 #define StmtRowDef              17
72 #define StmtSectionDef          18
73 #define StmtOverlayKeyDef       19
74 #define StmtOverlayDef          20
75 #define StmtDoodadDef           21
76
77 #define FileSymInterp   100
78
79 typedef struct _ParseCommon
80 {
81     unsigned stmtType;
82     struct _ParseCommon *next;
83 } ParseCommon;
84
85 #define ExprValue       0
86 #define ExprIdent       1
87 #define ExprActionDecl  2
88 #define ExprFieldRef    3
89 #define ExprArrayRef    4
90 #define ExprKeysymList  5
91 #define ExprActionList  6
92 #define ExprCoord       7
93
94 #define OpAdd           20
95 #define OpSubtract      21
96 #define OpMultiply      22
97 #define OpDivide        23
98 #define OpAssign        24
99 #define OpNot           25
100 #define OpNegate        26
101 #define OpInvert        27
102 #define OpUnaryPlus     28
103
104 #define MergeDefault    0
105 #define MergeAugment    1
106 #define MergeOverride   2
107 #define MergeReplace    3
108 #define MergeAltForm    4
109
110 #define AutoKeyNames    (1L <<  0)
111 #define CreateKeyNames(x)       ((x)->flags&AutoKeyNames)
112
113 extern unsigned warningLevel;
114
115 typedef struct _IncludeStmt
116 {
117     ParseCommon common;
118     unsigned merge;
119     char *stmt;
120     char *file;
121     char *map;
122     char *modifier;
123     char *path;
124     struct _IncludeStmt *next;
125 } IncludeStmt;
126
127 typedef struct _Expr
128 {
129     ParseCommon common;
130     unsigned op;
131     unsigned type;
132     union
133     {
134         struct
135         {
136             struct _Expr *left;
137             struct _Expr *right;
138         } binary;
139         struct
140         {
141             xkb_atom_t element;
142             xkb_atom_t field;
143         } field;
144         struct
145         {
146             xkb_atom_t element;
147             xkb_atom_t field;
148             struct _Expr *entry;
149         } array;
150         struct
151         {
152             xkb_atom_t name;
153             struct _Expr *args;
154         } action;
155         struct
156         {
157             int nSyms;
158             int szSyms;
159             char **syms;
160         } list;
161         struct
162         {
163             int x;
164             int y;
165         } coord;
166         struct _Expr *child;
167         xkb_atom_t str;
168         unsigned uval;
169         int ival;
170         char keyName[5];
171         void * ptr;
172     } value;
173 } ExprDef;
174
175 typedef struct _VarDef
176 {
177     ParseCommon common;
178     unsigned merge;
179     ExprDef *name;
180     ExprDef *value;
181 } VarDef;
182
183 typedef struct _VModDef
184 {
185     ParseCommon common;
186     unsigned merge;
187     xkb_atom_t name;
188     ExprDef *value;
189 } VModDef;
190
191 typedef struct _KeycodeDef
192 {
193     ParseCommon common;
194     unsigned merge;
195     char name[5];
196     unsigned long value;
197 } KeycodeDef;
198
199 typedef struct _KeyAliasDef
200 {
201     ParseCommon common;
202     unsigned merge;
203     char alias[5];
204     char real[5];
205 } KeyAliasDef;
206
207 typedef struct _KeyTypeDef
208 {
209     ParseCommon common;
210     unsigned merge;
211     xkb_atom_t name;
212     VarDef *body;
213 } KeyTypeDef;
214
215 typedef struct _SymbolsDef
216 {
217     ParseCommon common;
218     unsigned merge;
219     char keyName[5];
220     ExprDef *symbols;
221 } SymbolsDef;
222
223 typedef struct _ModMapDef
224 {
225     ParseCommon common;
226     unsigned merge;
227     xkb_atom_t modifier;
228     ExprDef *keys;
229 } ModMapDef;
230
231 typedef struct _GroupCompatDef
232 {
233     ParseCommon common;
234     unsigned merge;
235     int group;
236     ExprDef *def;
237 } GroupCompatDef;
238
239 typedef struct _InterpDef
240 {
241     ParseCommon common;
242     unsigned merge;
243     char *sym;
244     ExprDef *match;
245     VarDef *def;
246 } InterpDef;
247
248 typedef struct _IndicatorNameDef
249 {
250     ParseCommon common;
251     unsigned merge;
252     int ndx;
253     ExprDef *name;
254     Bool virtual;
255 } IndicatorNameDef;
256
257 typedef struct _OutlineDef
258 {
259     ParseCommon common;
260     xkb_atom_t field;
261     int nPoints;
262     ExprDef *points;
263 } OutlineDef;
264
265 typedef struct _ShapeDef
266 {
267     ParseCommon common;
268     unsigned merge;
269     xkb_atom_t name;
270     int nOutlines;
271     OutlineDef *outlines;
272 } ShapeDef;
273
274 typedef struct _KeyDef
275 {
276     ParseCommon common;
277     unsigned defined;
278     char *name;
279     ExprDef *expr;
280 } KeyDef;
281
282 typedef struct _RowDef
283 {
284     ParseCommon common;
285     int nKeys;
286     KeyDef *keys;
287 } RowDef;
288
289 typedef struct _SectionDef
290 {
291     ParseCommon common;
292     unsigned merge;
293     xkb_atom_t name;
294     int nRows;
295     RowDef *rows;
296 } SectionDef;
297
298 typedef struct _OverlayKeyDef
299 {
300     ParseCommon common;
301     char over[5];
302     char under[5];
303 } OverlayKeyDef;
304
305 typedef struct _OverlayDef
306 {
307     ParseCommon common;
308     unsigned merge;
309     xkb_atom_t name;
310     int nKeys;
311     OverlayKeyDef *keys;
312 } OverlayDef;
313
314 typedef struct _DoodadDef
315 {
316     ParseCommon common;
317     unsigned merge;
318     unsigned type;
319     xkb_atom_t name;
320     VarDef *body;
321 } DoodadDef;
322
323 /* IndicatorMapDef doesn't use the type field, but the rest of the fields
324    need to be at the same offsets as in DoodadDef.  Use #define to avoid
325    any strict aliasing problems.  */
326 #define IndicatorMapDef DoodadDef
327
328 typedef struct _XkbFile
329 {
330     ParseCommon common;
331     int type;
332     char *topName;
333     char *name;
334     ParseCommon *defs;
335     int id;
336     unsigned flags;
337     Bool compiled;
338 } XkbFile;
339
340 extern Bool
341 CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
342
343 extern Bool
344 CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
345
346 extern Bool
347 CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
348
349 typedef struct _LEDInfo *LEDInfoPtr;
350
351 extern Bool
352 CompileCompatMap(XkbFile *file, struct xkb_desc * xkb, unsigned merge,
353                  LEDInfoPtr *unboundLEDs);
354
355 extern Bool
356 CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
357
358 #endif /* XKBCOMP_H */