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