Move allocation of xkb_desc into CompileKeymap
[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
69 #define FileSymInterp   100
70
71 typedef struct _ParseCommon
72 {
73     unsigned stmtType;
74     struct _ParseCommon *next;
75 } ParseCommon;
76
77 #define ExprValue       0
78 #define ExprIdent       1
79 #define ExprActionDecl  2
80 #define ExprFieldRef    3
81 #define ExprArrayRef    4
82 #define ExprKeysymList  5
83 #define ExprActionList  6
84 #define ExprCoord       7
85
86 #define OpAdd           20
87 #define OpSubtract      21
88 #define OpMultiply      22
89 #define OpDivide        23
90 #define OpAssign        24
91 #define OpNot           25
92 #define OpNegate        26
93 #define OpInvert        27
94 #define OpUnaryPlus     28
95
96 #define MergeDefault    0
97 #define MergeAugment    1
98 #define MergeOverride   2
99 #define MergeReplace    3
100 #define MergeAltForm    4
101
102 #define AutoKeyNames    (1L <<  0)
103 #define CreateKeyNames(x)       ((x)->flags&AutoKeyNames)
104
105 extern unsigned warningLevel;
106
107 typedef struct _IncludeStmt
108 {
109     ParseCommon common;
110     unsigned merge;
111     char *stmt;
112     char *file;
113     char *map;
114     char *modifier;
115     char *path;
116     struct _IncludeStmt *next;
117 } IncludeStmt;
118
119 typedef struct _Expr
120 {
121     ParseCommon common;
122     unsigned op;
123     unsigned type;
124     union
125     {
126         struct
127         {
128             struct _Expr *left;
129             struct _Expr *right;
130         } binary;
131         struct
132         {
133             xkb_atom_t element;
134             xkb_atom_t field;
135         } field;
136         struct
137         {
138             xkb_atom_t element;
139             xkb_atom_t field;
140             struct _Expr *entry;
141         } array;
142         struct
143         {
144             xkb_atom_t name;
145             struct _Expr *args;
146         } action;
147         struct
148         {
149             int nSyms;
150             int szSyms;
151             char **syms;
152         } list;
153         struct
154         {
155             int x;
156             int y;
157         } coord;
158         struct _Expr *child;
159         xkb_atom_t str;
160         unsigned uval;
161         int ival;
162         char keyName[5];
163         void * ptr;
164     } value;
165 } ExprDef;
166
167 typedef struct _VarDef
168 {
169     ParseCommon common;
170     unsigned merge;
171     ExprDef *name;
172     ExprDef *value;
173 } VarDef;
174
175 typedef struct _VModDef
176 {
177     ParseCommon common;
178     unsigned merge;
179     xkb_atom_t name;
180     ExprDef *value;
181 } VModDef;
182
183 typedef struct _KeycodeDef
184 {
185     ParseCommon common;
186     unsigned merge;
187     char name[5];
188     unsigned long value;
189 } KeycodeDef;
190
191 typedef struct _KeyAliasDef
192 {
193     ParseCommon common;
194     unsigned merge;
195     char alias[5];
196     char real[5];
197 } KeyAliasDef;
198
199 typedef struct _KeyTypeDef
200 {
201     ParseCommon common;
202     unsigned merge;
203     xkb_atom_t name;
204     VarDef *body;
205 } KeyTypeDef;
206
207 typedef struct _SymbolsDef
208 {
209     ParseCommon common;
210     unsigned merge;
211     char keyName[5];
212     ExprDef *symbols;
213 } SymbolsDef;
214
215 typedef struct _ModMapDef
216 {
217     ParseCommon common;
218     unsigned merge;
219     xkb_atom_t modifier;
220     ExprDef *keys;
221 } ModMapDef;
222
223 typedef struct _GroupCompatDef
224 {
225     ParseCommon common;
226     unsigned merge;
227     int group;
228     ExprDef *def;
229 } GroupCompatDef;
230
231 typedef struct _InterpDef
232 {
233     ParseCommon common;
234     unsigned merge;
235     char *sym;
236     ExprDef *match;
237     VarDef *def;
238 } InterpDef;
239
240 typedef struct _IndicatorNameDef
241 {
242     ParseCommon common;
243     unsigned merge;
244     int ndx;
245     ExprDef *name;
246     Bool virtual;
247 } IndicatorNameDef;
248
249 typedef struct _IndicatorMapDef
250 {
251     ParseCommon common;
252     unsigned merge;
253     unsigned type;
254     xkb_atom_t name;
255     VarDef *body;
256 } IndicatorMapDef;
257
258 typedef struct _XkbFile
259 {
260     ParseCommon common;
261     int type;
262     char *topName;
263     char *name;
264     ParseCommon *defs;
265     int id;
266     unsigned flags;
267     Bool compiled;
268 } XkbFile;
269
270 extern struct xkb_desc *
271 CompileKeymap(XkbFile *file, unsigned merge);
272
273 extern Bool
274 CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
275
276 extern Bool
277 CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
278
279 typedef struct _LEDInfo *LEDInfoPtr;
280
281 extern Bool
282 CompileCompatMap(XkbFile *file, struct xkb_desc * xkb, unsigned merge,
283                  LEDInfoPtr *unboundLEDs);
284
285 extern Bool
286 CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
287
288 #endif /* XKBCOMP_H */