xkbcomp.h revision bfe6082c
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
42extern 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
78typedef 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
112extern unsigned warningLevel;
113extern unsigned optionalParts;
114
115typedef 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
127typedef 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
175typedef struct _VarDef
176{
177    ParseCommon common;
178    unsigned merge;
179    ExprDef *name;
180    ExprDef *value;
181} VarDef;
182
183typedef struct _VModDef
184{
185    ParseCommon common;
186    unsigned merge;
187    Atom name;
188    ExprDef *value;
189} VModDef;
190
191typedef struct _KeycodeDef
192{
193    ParseCommon common;
194    unsigned merge;
195    char name[5];
196    ExprDef *value;
197} KeycodeDef;
198
199typedef struct _KeyAliasDef
200{
201    ParseCommon common;
202    unsigned merge;
203    char alias[5];
204    char real[5];
205} KeyAliasDef;
206
207typedef struct _KeyTypeDef
208{
209    ParseCommon common;
210    unsigned merge;
211    Atom name;
212    VarDef *body;
213} KeyTypeDef;
214
215typedef struct _SymbolsDef
216{
217    ParseCommon common;
218    unsigned merge;
219    char keyName[5];
220    ExprDef *symbols;
221} SymbolsDef;
222
223typedef struct _ModMapDef
224{
225    ParseCommon common;
226    unsigned merge;
227    Atom modifier;
228    ExprDef *keys;
229} ModMapDef;
230
231typedef struct _GroupCompatDef
232{
233    ParseCommon common;
234    unsigned merge;
235    int group;
236    ExprDef *def;
237} GroupCompatDef;
238
239typedef struct _InterpDef
240{
241    ParseCommon common;
242    unsigned merge;
243    KeySym sym;
244    ExprDef *match;
245    VarDef *def;
246    Bool ignore;
247} InterpDef;
248
249typedef struct _IndicatorNameDef
250{
251    ParseCommon common;
252    unsigned merge;
253    int ndx;
254    ExprDef *name;
255    Bool virtual;
256} IndicatorNameDef;
257
258typedef struct _OutlineDef
259{
260    ParseCommon common;
261    Atom field;
262    int nPoints;
263    ExprDef *points;
264} OutlineDef;
265
266typedef struct _ShapeDef
267{
268    ParseCommon common;
269    unsigned merge;
270    Atom name;
271    int nOutlines;
272    OutlineDef *outlines;
273} ShapeDef;
274
275typedef struct _KeyDef
276{
277    ParseCommon common;
278    unsigned defined;
279    char *name;
280    ExprDef *expr;
281} KeyDef;
282
283typedef struct _RowDef
284{
285    ParseCommon common;
286    int nKeys;
287    KeyDef *keys;
288} RowDef;
289
290typedef struct _SectionDef
291{
292    ParseCommon common;
293    unsigned merge;
294    Atom name;
295    int nRows;
296    RowDef *rows;
297} SectionDef;
298
299typedef struct _OverlayKeyDef
300{
301    ParseCommon common;
302    char over[5];
303    char under[5];
304} OverlayKeyDef;
305
306typedef struct _OverlayDef
307{
308    ParseCommon common;
309    unsigned merge;
310    Atom name;
311    int nKeys;
312    OverlayKeyDef *keys;
313} OverlayDef;
314
315typedef struct _DoodadDef
316{
317    ParseCommon common;
318    unsigned merge;
319    unsigned type;
320    Atom name;
321    VarDef *body;
322} DoodadDef;
323
324/* IndicatorMapDef doesn't use the type field, but the rest of the fields
325   need to be at the same offsets as in DoodadDef.  Use #define to avoid
326   any strict aliasing problems.  */
327#define IndicatorMapDef DoodadDef
328
329typedef struct _XkbFile
330{
331    ParseCommon common;
332    int type;
333    char *topName;
334    char *name;
335    ParseCommon *defs;
336    int id;
337    unsigned flags;
338    Bool compiled;
339} XkbFile;
340
341extern Bool CompileKeymap(XkbFile * /* file */ ,
342                          XkbFileInfo * /* result */ ,
343                          unsigned      /* merge */
344    );
345
346extern Bool CompileKeycodes(XkbFile * /* file */ ,
347                            XkbFileInfo * /* result */ ,
348                            unsigned    /* merge */
349    );
350
351extern Bool CompileGeometry(XkbFile * /* file */ ,
352                            XkbFileInfo * /* result */ ,
353                            unsigned    /* merge */
354    );
355
356extern Bool CompileKeyTypes(XkbFile * /* file */ ,
357                            XkbFileInfo * /* result */ ,
358                            unsigned    /* merge */
359    );
360
361typedef struct _LEDInfo *LEDInfoPtr;
362
363extern Bool CompileCompatMap(XkbFile * /* file */ ,
364                             XkbFileInfo * /* result */ ,
365                             unsigned /* merge */ ,
366                             LEDInfoPtr *       /* unboundLEDs */
367    );
368
369extern Bool CompileSymbols(XkbFile * /* file */ ,
370                           XkbFileInfo * /* result */ ,
371                           unsigned     /* merge */
372    );
373
374#define	WantLongListing	(1<<0)
375#define	WantPartialMaps	(1<<1)
376#define	WantHiddenMaps	(1<<2)
377#define	WantFullNames	(1<<3)
378#define	ListRecursive	(1<<4)
379
380extern char *rootDir;
381extern unsigned verboseLevel;
382extern unsigned dirsToStrip;
383
384extern Bool AddListing(char * /* file */ ,
385                       char *   /* map */
386    );
387
388extern Bool AddMatchingFiles(char *     /* head_in */
389    );
390
391extern int AddMapOnly(char *    /* map */
392    );
393
394extern int GenerateListing(char *       /* filename */
395    );
396
397#endif /* XKBCOMP_H */
398