d6a7185412b02ae01d06ae42f83e9151df651edb
[framework/uifw/xorg/util/x11-xkb-utils.git] / 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/Xlib.h>
35 #include <X11/XKBlib.h>
36
37 #include "utils.h"
38
39 #include <X11/extensions/XKM.h>
40 #include <X11/extensions/XKBfile.h>
41
42 extern char *scanFile;
43
44 #define TypeUnknown     0
45 #define TypeBoolean     1
46 #define TypeInt         2
47 #define TypeFloat       3
48 #define TypeString      4
49 #define TypeAction      5
50 #define TypeKeyName     6
51 #define TypeSymbols     7
52
53 #define StmtUnknown             0
54 #define StmtInclude             1
55 #define StmtKeycodeDef          2
56 #define StmtKeyAliasDef         3
57 #define StmtExpr                4
58 #define StmtVarDef              5
59 #define StmtKeyTypeDef          6
60 #define StmtInterpDef           7
61 #define StmtVModDef             8
62 #define StmtSymbolsDef          9
63 #define StmtModMapDef           10
64 #define StmtGroupCompatDef      11
65 #define StmtIndicatorMapDef     12
66 #define StmtIndicatorNameDef    13
67 #define StmtOutlineDef          14
68 #define StmtShapeDef            15
69 #define StmtKeyDef              16
70 #define StmtRowDef              17
71 #define StmtSectionDef          18
72 #define StmtOverlayKeyDef       19
73 #define StmtOverlayDef          20
74 #define StmtDoodadDef           21
75
76 #define FileSymInterp   100
77
78 typedef struct _ParseCommon
79 {
80     unsigned stmtType;
81     struct _ParseCommon *next;
82 } ParseCommon;
83
84 #define ExprValue       0
85 #define ExprIdent       1
86 #define ExprActionDecl  2
87 #define ExprFieldRef    3
88 #define ExprArrayRef    4
89 #define ExprKeysymList  5
90 #define ExprActionList  6
91 #define ExprCoord       7
92
93 #define OpAdd           20
94 #define OpSubtract      21
95 #define OpMultiply      22
96 #define OpDivide        23
97 #define OpAssign        24
98 #define OpNot           25
99 #define OpNegate        26
100 #define OpInvert        27
101 #define OpUnaryPlus     28
102
103 #define MergeDefault    0
104 #define MergeAugment    1
105 #define MergeOverride   2
106 #define MergeReplace    3
107 #define MergeAltForm    4
108
109 #define AutoKeyNames    (1L <<  0)
110 #define CreateKeyNames(x)       ((x)->flags&AutoKeyNames)
111
112 extern unsigned warningLevel;
113 extern unsigned optionalParts;
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             Atom element;
142             Atom field;
143         } field;
144         struct
145         {
146             Atom element;
147             Atom field;
148             struct _Expr *entry;
149         } array;
150         struct
151         {
152             Atom 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         Atom str;
168         unsigned uval;
169         int ival;
170         char keyName[5];
171         Opaque 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     Atom name;
188     ExprDef *value;
189 } VModDef;
190
191 typedef struct _KeycodeDef
192 {
193     ParseCommon common;
194     unsigned merge;
195     char name[5];
196     ExprDef *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     Atom 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     Atom 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     KeySym 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     Atom field;
261     int nPoints;
262     ExprDef *points;
263 } OutlineDef;
264
265 typedef struct _ShapeDef
266 {
267     ParseCommon common;
268     unsigned merge;
269     Atom 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     Atom 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     Atom 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     Atom 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 CompileKeymap(XkbFile * /* file */ ,
341                           XkbFileInfo * /* result */ ,
342                           unsigned      /* merge */
343     );
344
345 extern Bool CompileKeycodes(XkbFile * /* file */ ,
346                             XkbFileInfo * /* result */ ,
347                             unsigned    /* merge */
348     );
349
350 extern Bool CompileGeometry(XkbFile * /* file */ ,
351                             XkbFileInfo * /* result */ ,
352                             unsigned    /* merge */
353     );
354
355 extern Bool CompileKeyTypes(XkbFile * /* file */ ,
356                             XkbFileInfo * /* result */ ,
357                             unsigned    /* merge */
358     );
359
360 typedef struct _LEDInfo *LEDInfoPtr;
361
362 extern Bool CompileCompatMap(XkbFile * /* file */ ,
363                              XkbFileInfo * /* result */ ,
364                              unsigned /* merge */ ,
365                              LEDInfoPtr *       /* unboundLEDs */
366     );
367
368 extern Bool CompileSymbols(XkbFile * /* file */ ,
369                            XkbFileInfo * /* result */ ,
370                            unsigned     /* merge */
371     );
372
373 #define WantLongListing (1<<0)
374 #define WantPartialMaps (1<<1)
375 #define WantHiddenMaps  (1<<2)
376 #define WantFullNames   (1<<3)
377 #define ListRecursive   (1<<4)
378
379 extern char *rootDir;
380 extern unsigned verboseLevel;
381 extern unsigned dirsToStrip;
382
383 extern Bool AddListing(char * /* file */ ,
384                        char *   /* map */
385     );
386
387 extern Bool AddMatchingFiles(char *     /* head_in */
388     );
389
390 extern int AddMapOnly(char *    /* map */
391     );
392
393 extern int GenerateListing(char *       /* filename */
394     );
395
396 #endif /* XKBCOMP_H */