e9d5f47f60c6ffab346a76277daad509ca33a6df
[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 <X11/extensions/XKM.h>
40 #include <X11/extensions/XKBstrcommon.h>
41 #include <X11/extensions/XKBrulescommon.h>
42 #include "X11/extensions/XKBcommon.h"
43 #include "XKBcommonint.h"
44
45 extern char *scanFile;
46
47 #define TypeUnknown     0
48 #define TypeBoolean     1
49 #define TypeInt         2
50 #define TypeFloat       3
51 #define TypeString      4
52 #define TypeAction      5
53 #define TypeKeyName     6
54 #define TypeSymbols     7
55
56 #define StmtUnknown             0
57 #define StmtInclude             1
58 #define StmtKeycodeDef          2
59 #define StmtKeyAliasDef         3
60 #define StmtExpr                4
61 #define StmtVarDef              5
62 #define StmtKeyTypeDef          6
63 #define StmtInterpDef           7
64 #define StmtVModDef             8
65 #define StmtSymbolsDef          9
66 #define StmtModMapDef           10
67 #define StmtGroupCompatDef      11
68 #define StmtIndicatorMapDef     12
69 #define StmtIndicatorNameDef    13
70 #define StmtOutlineDef          14
71 #define StmtShapeDef            15
72 #define StmtKeyDef              16
73 #define StmtRowDef              17
74 #define StmtSectionDef          18
75 #define StmtOverlayKeyDef       19
76 #define StmtOverlayDef          20
77 #define StmtDoodadDef           21
78
79 #define FileSymInterp   100
80
81 typedef struct _ParseCommon
82 {
83     unsigned stmtType;
84     struct _ParseCommon *next;
85 } ParseCommon;
86
87 #define ExprValue       0
88 #define ExprIdent       1
89 #define ExprActionDecl  2
90 #define ExprFieldRef    3
91 #define ExprArrayRef    4
92 #define ExprKeysymList  5
93 #define ExprActionList  6
94 #define ExprCoord       7
95
96 #define OpAdd           20
97 #define OpSubtract      21
98 #define OpMultiply      22
99 #define OpDivide        23
100 #define OpAssign        24
101 #define OpNot           25
102 #define OpNegate        26
103 #define OpInvert        27
104 #define OpUnaryPlus     28
105
106 #define MergeDefault    0
107 #define MergeAugment    1
108 #define MergeOverride   2
109 #define MergeReplace    3
110 #define MergeAltForm    4
111
112 #define AutoKeyNames    (1L <<  0)
113 #define CreateKeyNames(x)       ((x)->flags&AutoKeyNames)
114
115 extern unsigned warningLevel;
116 extern unsigned optionalParts;
117
118 typedef struct _IncludeStmt
119 {
120     ParseCommon common;
121     unsigned merge;
122     char *stmt;
123     char *file;
124     char *map;
125     char *modifier;
126     char *path;
127     struct _IncludeStmt *next;
128 } IncludeStmt;
129
130 typedef struct _Expr
131 {
132     ParseCommon common;
133     unsigned op;
134     unsigned type;
135     union
136     {
137         struct
138         {
139             struct _Expr *left;
140             struct _Expr *right;
141         } binary;
142         struct
143         {
144             Atom element;
145             Atom field;
146         } field;
147         struct
148         {
149             Atom element;
150             Atom field;
151             struct _Expr *entry;
152         } array;
153         struct
154         {
155             Atom name;
156             struct _Expr *args;
157         } action;
158         struct
159         {
160             int nSyms;
161             int szSyms;
162             KeySym *syms;
163         } list;
164         struct
165         {
166             int x;
167             int y;
168         } coord;
169         struct _Expr *child;
170         Atom str;
171         unsigned uval;
172         int ival;
173         char keyName[5];
174         Opaque ptr;
175     } value;
176 } ExprDef;
177
178 typedef struct _VarDef
179 {
180     ParseCommon common;
181     unsigned merge;
182     ExprDef *name;
183     ExprDef *value;
184 } VarDef;
185
186 typedef struct _VModDef
187 {
188     ParseCommon common;
189     unsigned merge;
190     Atom name;
191     ExprDef *value;
192 } VModDef;
193
194 typedef struct _KeycodeDef
195 {
196     ParseCommon common;
197     unsigned merge;
198     char name[5];
199     ExprDef *value;
200 } KeycodeDef;
201
202 typedef struct _KeyAliasDef
203 {
204     ParseCommon common;
205     unsigned merge;
206     char alias[5];
207     char real[5];
208 } KeyAliasDef;
209
210 typedef struct _KeyTypeDef
211 {
212     ParseCommon common;
213     unsigned merge;
214     Atom name;
215     VarDef *body;
216 } KeyTypeDef;
217
218 typedef struct _SymbolsDef
219 {
220     ParseCommon common;
221     unsigned merge;
222     char keyName[5];
223     ExprDef *symbols;
224 } SymbolsDef;
225
226 typedef struct _ModMapDef
227 {
228     ParseCommon common;
229     unsigned merge;
230     Atom modifier;
231     ExprDef *keys;
232 } ModMapDef;
233
234 typedef struct _GroupCompatDef
235 {
236     ParseCommon common;
237     unsigned merge;
238     int group;
239     ExprDef *def;
240 } GroupCompatDef;
241
242 typedef struct _InterpDef
243 {
244     ParseCommon common;
245     unsigned merge;
246     KeySym sym;
247     ExprDef *match;
248     VarDef *def;
249 } InterpDef;
250
251 typedef struct _IndicatorNameDef
252 {
253     ParseCommon common;
254     unsigned merge;
255     int ndx;
256     ExprDef *name;
257     Bool virtual;
258 } IndicatorNameDef;
259
260 typedef struct _OutlineDef
261 {
262     ParseCommon common;
263     Atom field;
264     int nPoints;
265     ExprDef *points;
266 } OutlineDef;
267
268 typedef struct _ShapeDef
269 {
270     ParseCommon common;
271     unsigned merge;
272     Atom name;
273     int nOutlines;
274     OutlineDef *outlines;
275 } ShapeDef;
276
277 typedef struct _KeyDef
278 {
279     ParseCommon common;
280     unsigned defined;
281     char *name;
282     ExprDef *expr;
283 } KeyDef;
284
285 typedef struct _RowDef
286 {
287     ParseCommon common;
288     int nKeys;
289     KeyDef *keys;
290 } RowDef;
291
292 typedef struct _SectionDef
293 {
294     ParseCommon common;
295     unsigned merge;
296     Atom name;
297     int nRows;
298     RowDef *rows;
299 } SectionDef;
300
301 typedef struct _OverlayKeyDef
302 {
303     ParseCommon common;
304     char over[5];
305     char under[5];
306 } OverlayKeyDef;
307
308 typedef struct _OverlayDef
309 {
310     ParseCommon common;
311     unsigned merge;
312     Atom name;
313     int nKeys;
314     OverlayKeyDef *keys;
315 } OverlayDef;
316
317 typedef struct _DoodadDef
318 {
319     ParseCommon common;
320     unsigned merge;
321     unsigned type;
322     Atom name;
323     VarDef *body;
324 } DoodadDef;
325
326 /* IndicatorMapDef doesn't use the type field, but the rest of the fields
327    need to be at the same offsets as in DoodadDef.  Use #define to avoid
328    any strict aliasing problems.  */
329 #define IndicatorMapDef DoodadDef
330
331 typedef struct _XkbFile
332 {
333     ParseCommon common;
334     int type;
335     char *topName;
336     char *name;
337     ParseCommon *defs;
338     int id;
339     unsigned flags;
340     Bool compiled;
341 } XkbFile;
342
343 extern Bool
344 CompileKeymap(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
345
346 extern Bool
347 CompileKeycodes(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
348
349 extern Bool
350 CompileGeometry(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
351
352 extern Bool
353 CompileKeyTypes(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
354
355 typedef struct _LEDInfo *LEDInfoPtr;
356
357 extern Bool
358 CompileCompatMap(XkbFile *file, XkbcDescPtr xkb, unsigned merge,
359                  LEDInfoPtr *unboundLEDs);
360
361 extern Bool
362 CompileSymbols(XkbFile *file, XkbcDescPtr xkb, unsigned merge);
363
364 #define WantLongListing (1<<0)
365 #define WantPartialMaps (1<<1)
366 #define WantHiddenMaps  (1<<2)
367 #define WantFullNames   (1<<3)
368 #define ListRecursive   (1<<4)
369
370 extern char *rootDir;
371 extern unsigned verboseLevel;
372 extern unsigned dirsToStrip;
373
374 extern Bool AddListing(char * /* file */ ,
375                        char *   /* map */
376     );
377
378 extern Bool AddMatchingFiles(char *     /* head_in */
379     );
380
381 extern int AddMapOnly(char *    /* map */
382     );
383
384 extern int GenerateListing(char *       /* filename */
385     );
386
387 #endif /* XKBCOMP_H */