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