Use xkb_contexts in keymap compilation
[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 #include "utils.h"
31
32 #include "xkbcommon/xkbcommon.h"
33 #include "XKBcommonint.h"
34 #include "xkbmisc.h"
35
36 extern char *scanFile;
37
38 #define TypeUnknown     0
39 #define TypeBoolean     1
40 #define TypeInt         2
41 #define TypeString      4
42 #define TypeAction      5
43 #define TypeKeyName     6
44 #define TypeSymbols     7
45
46 #define StmtUnknown             0
47 #define StmtInclude             1
48 #define StmtKeycodeDef          2
49 #define StmtKeyAliasDef         3
50 #define StmtExpr                4
51 #define StmtVarDef              5
52 #define StmtKeyTypeDef          6
53 #define StmtInterpDef           7
54 #define StmtVModDef             8
55 #define StmtSymbolsDef          9
56 #define StmtModMapDef           10
57 #define StmtGroupCompatDef      11
58 #define StmtIndicatorMapDef     12
59 #define StmtIndicatorNameDef    13
60
61 #define FileSymInterp   100
62
63 typedef struct _ParseCommon
64 {
65     unsigned stmtType;
66     struct _ParseCommon *next;
67 } ParseCommon;
68
69 #define ExprValue       0
70 #define ExprIdent       1
71 #define ExprActionDecl  2
72 #define ExprFieldRef    3
73 #define ExprArrayRef    4
74 #define ExprKeysymList  5
75 #define ExprActionList  6
76
77 #define OpAdd           20
78 #define OpSubtract      21
79 #define OpMultiply      22
80 #define OpDivide        23
81 #define OpAssign        24
82 #define OpNot           25
83 #define OpNegate        26
84 #define OpInvert        27
85 #define OpUnaryPlus     28
86
87 #define MergeDefault    0
88 #define MergeAugment    1
89 #define MergeOverride   2
90 #define MergeReplace    3
91 #define MergeAltForm    4
92
93 #define AutoKeyNames    (1L <<  0)
94 #define CreateKeyNames(x)       ((x)->flags&AutoKeyNames)
95
96 extern unsigned warningLevel;
97
98 typedef struct _IncludeStmt
99 {
100     ParseCommon common;
101     unsigned merge;
102     char *stmt;
103     char *file;
104     char *map;
105     char *modifier;
106     char *path;
107     struct _IncludeStmt *next;
108 } IncludeStmt;
109
110 typedef struct _Expr
111 {
112     ParseCommon common;
113     unsigned op;
114     unsigned type;
115     union
116     {
117         struct
118         {
119             struct _Expr *left;
120             struct _Expr *right;
121         } binary;
122         struct
123         {
124             xkb_atom_t element;
125             xkb_atom_t field;
126         } field;
127         struct
128         {
129             xkb_atom_t element;
130             xkb_atom_t field;
131             struct _Expr *entry;
132         } array;
133         struct
134         {
135             xkb_atom_t name;
136             struct _Expr *args;
137         } action;
138         struct
139         {
140             int nSyms;
141             int szSyms;
142             char **syms;
143         } list;
144         struct _Expr *child;
145         xkb_atom_t str;
146         unsigned uval;
147         int ival;
148         char keyName[5];
149     } value;
150 } ExprDef;
151
152 typedef struct _VarDef
153 {
154     ParseCommon common;
155     unsigned merge;
156     ExprDef *name;
157     ExprDef *value;
158 } VarDef;
159
160 typedef struct _VModDef
161 {
162     ParseCommon common;
163     unsigned merge;
164     xkb_atom_t name;
165     ExprDef *value;
166 } VModDef;
167
168 typedef struct _KeycodeDef
169 {
170     ParseCommon common;
171     unsigned merge;
172     char name[5];
173     unsigned long value;
174 } KeycodeDef;
175
176 typedef struct _KeyAliasDef
177 {
178     ParseCommon common;
179     unsigned merge;
180     char alias[5];
181     char real[5];
182 } KeyAliasDef;
183
184 typedef struct _KeyTypeDef
185 {
186     ParseCommon common;
187     unsigned merge;
188     xkb_atom_t name;
189     VarDef *body;
190 } KeyTypeDef;
191
192 typedef struct _SymbolsDef
193 {
194     ParseCommon common;
195     unsigned merge;
196     char keyName[5];
197     ExprDef *symbols;
198 } SymbolsDef;
199
200 typedef struct _ModMapDef
201 {
202     ParseCommon common;
203     unsigned merge;
204     xkb_atom_t modifier;
205     ExprDef *keys;
206 } ModMapDef;
207
208 typedef struct _GroupCompatDef
209 {
210     ParseCommon common;
211     unsigned merge;
212     int group;
213     ExprDef *def;
214 } GroupCompatDef;
215
216 typedef struct _InterpDef
217 {
218     ParseCommon common;
219     unsigned merge;
220     char *sym;
221     ExprDef *match;
222     VarDef *def;
223 } InterpDef;
224
225 typedef struct _IndicatorNameDef
226 {
227     ParseCommon common;
228     unsigned merge;
229     int ndx;
230     ExprDef *name;
231     Bool virtual;
232 } IndicatorNameDef;
233
234 typedef struct _IndicatorMapDef
235 {
236     ParseCommon common;
237     unsigned merge;
238     unsigned type;
239     xkb_atom_t name;
240     VarDef *body;
241 } IndicatorMapDef;
242
243 typedef struct _XkbFile
244 {
245     ParseCommon common;
246     unsigned type;
247     char *topName;
248     char *name;
249     ParseCommon *defs;
250     int id;
251     unsigned flags;
252     Bool compiled;
253 } XkbFile;
254
255 extern struct xkb_desc *
256 CompileKeymap(struct xkb_context *context, XkbFile *file, unsigned merge);
257
258 extern Bool
259 CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
260
261 extern Bool
262 CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
263
264 typedef struct _LEDInfo *LEDInfoPtr;
265
266 extern Bool
267 CompileCompatMap(XkbFile *file, struct xkb_desc * xkb, unsigned merge,
268                  LEDInfoPtr *unboundLEDs);
269
270 extern Bool
271 CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge);
272
273 extern Bool
274 UpdateModifiersFromCompat(struct xkb_desc *xkb);
275
276 #endif /* XKBCOMP_H */