Use enum for merge mode
[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     MERGE_ALT_FORM,
87 };
88
89 #define AutoKeyNames    (1L <<  0)
90 #define CreateKeyNames(x)       ((x)->flags&AutoKeyNames)
91
92 extern unsigned warningLevel;
93
94 typedef struct _IncludeStmt
95 {
96     ParseCommon common;
97     enum merge_mode merge;
98     char *stmt;
99     char *file;
100     char *map;
101     char *modifier;
102     char *path;
103     struct _IncludeStmt *next;
104 } IncludeStmt;
105
106 typedef struct _Expr
107 {
108     ParseCommon common;
109     unsigned op;
110     unsigned type;
111     union
112     {
113         struct
114         {
115             struct _Expr *left;
116             struct _Expr *right;
117         } binary;
118         struct
119         {
120             xkb_atom_t element;
121             xkb_atom_t field;
122         } field;
123         struct
124         {
125             xkb_atom_t element;
126             xkb_atom_t field;
127             struct _Expr *entry;
128         } array;
129         struct
130         {
131             xkb_atom_t name;
132             struct _Expr *args;
133         } action;
134         struct
135         {
136             darray(char *) syms;
137             darray(int) symsMapIndex;
138             darray(unsigned int) symsNumEntries;
139         } list;
140         struct _Expr *child;
141         xkb_atom_t str;
142         unsigned uval;
143         int ival;
144         char keyName[5];
145     } value;
146 } ExprDef;
147
148 typedef struct _VarDef
149 {
150     ParseCommon common;
151     enum merge_mode merge;
152     ExprDef *name;
153     ExprDef *value;
154 } VarDef;
155
156 typedef struct _VModDef
157 {
158     ParseCommon common;
159     enum merge_mode merge;
160     xkb_atom_t name;
161     ExprDef *value;
162 } VModDef;
163
164 typedef struct _KeycodeDef
165 {
166     ParseCommon common;
167     enum merge_mode merge;
168     char name[5];
169     unsigned long value;
170 } KeycodeDef;
171
172 typedef struct _KeyAliasDef
173 {
174     ParseCommon common;
175     enum merge_mode merge;
176     char alias[5];
177     char real[5];
178 } KeyAliasDef;
179
180 typedef struct _KeyTypeDef
181 {
182     ParseCommon common;
183     enum merge_mode merge;
184     xkb_atom_t name;
185     VarDef *body;
186 } KeyTypeDef;
187
188 typedef struct _SymbolsDef
189 {
190     ParseCommon common;
191     enum merge_mode merge;
192     char keyName[5];
193     ExprDef *symbols;
194 } SymbolsDef;
195
196 typedef struct _ModMapDef
197 {
198     ParseCommon common;
199     enum merge_mode merge;
200     xkb_atom_t modifier;
201     ExprDef *keys;
202 } ModMapDef;
203
204 typedef struct _GroupCompatDef
205 {
206     ParseCommon common;
207     enum merge_mode merge;
208     int group;
209     ExprDef *def;
210 } GroupCompatDef;
211
212 typedef struct _InterpDef
213 {
214     ParseCommon common;
215     enum merge_mode merge;
216     char *sym;
217     ExprDef *match;
218     VarDef *def;
219 } InterpDef;
220
221 typedef struct _IndicatorNameDef
222 {
223     ParseCommon common;
224     enum merge_mode merge;
225     int ndx;
226     ExprDef *name;
227     bool virtual;
228 } IndicatorNameDef;
229
230 typedef struct _IndicatorMapDef
231 {
232     ParseCommon common;
233     enum merge_mode merge;
234     unsigned type;
235     xkb_atom_t name;
236     VarDef *body;
237 } IndicatorMapDef;
238
239 typedef struct _XkbFile
240 {
241     ParseCommon common;
242     enum xkb_file_type type;
243     char *topName;
244     char *name;
245     ParseCommon *defs;
246     int id;
247     unsigned flags;
248 } XkbFile;
249
250 extern struct xkb_keymap *
251 CompileKeymap(struct xkb_context *ctx, XkbFile *file);
252
253 extern bool
254 CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
255                 enum merge_mode merge);
256
257 extern bool
258 CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap,
259                 enum merge_mode merge);
260
261 typedef struct _LEDInfo *LEDInfoPtr;
262
263 extern bool
264 CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
265                  enum merge_mode merge, LEDInfoPtr *unboundLEDs);
266
267 extern bool
268 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
269                enum merge_mode merge);
270
271 #endif /* XKBCOMP_H */