Rename 'ctx' back to 'context' in external API
[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             int nSyms;
135             int szSyms;
136             char **syms;
137             int nLevels;
138             int szLevels;
139             int *symsMapIndex;
140             unsigned int *symsNumEntries;
141         } list;
142         struct _Expr *child;
143         xkb_atom_t str;
144         unsigned uval;
145         int ival;
146         char keyName[5];
147     } value;
148 } ExprDef;
149
150 typedef struct _VarDef
151 {
152     ParseCommon common;
153     unsigned merge;
154     ExprDef *name;
155     ExprDef *value;
156 } VarDef;
157
158 typedef struct _VModDef
159 {
160     ParseCommon common;
161     unsigned merge;
162     xkb_atom_t name;
163     ExprDef *value;
164 } VModDef;
165
166 typedef struct _KeycodeDef
167 {
168     ParseCommon common;
169     unsigned merge;
170     char name[5];
171     unsigned long value;
172 } KeycodeDef;
173
174 typedef struct _KeyAliasDef
175 {
176     ParseCommon common;
177     unsigned merge;
178     char alias[5];
179     char real[5];
180 } KeyAliasDef;
181
182 typedef struct _KeyTypeDef
183 {
184     ParseCommon common;
185     unsigned merge;
186     xkb_atom_t name;
187     VarDef *body;
188 } KeyTypeDef;
189
190 typedef struct _SymbolsDef
191 {
192     ParseCommon common;
193     unsigned merge;
194     char keyName[5];
195     ExprDef *symbols;
196 } SymbolsDef;
197
198 typedef struct _ModMapDef
199 {
200     ParseCommon common;
201     unsigned merge;
202     xkb_atom_t modifier;
203     ExprDef *keys;
204 } ModMapDef;
205
206 typedef struct _GroupCompatDef
207 {
208     ParseCommon common;
209     unsigned merge;
210     int group;
211     ExprDef *def;
212 } GroupCompatDef;
213
214 typedef struct _InterpDef
215 {
216     ParseCommon common;
217     unsigned merge;
218     char *sym;
219     ExprDef *match;
220     VarDef *def;
221 } InterpDef;
222
223 typedef struct _IndicatorNameDef
224 {
225     ParseCommon common;
226     unsigned merge;
227     int ndx;
228     ExprDef *name;
229     bool virtual;
230 } IndicatorNameDef;
231
232 typedef struct _IndicatorMapDef
233 {
234     ParseCommon common;
235     unsigned merge;
236     unsigned type;
237     xkb_atom_t name;
238     VarDef *body;
239 } IndicatorMapDef;
240
241 typedef struct _XkbFile
242 {
243     ParseCommon common;
244     unsigned type;
245     char *topName;
246     char *name;
247     ParseCommon *defs;
248     int id;
249     unsigned flags;
250 } XkbFile;
251
252 extern struct xkb_keymap *
253 CompileKeymap(struct xkb_context *ctx, XkbFile *file);
254
255 extern bool
256 CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge);
257
258 extern bool
259 CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, unsigned merge);
260
261 typedef struct _LEDInfo *LEDInfoPtr;
262
263 extern bool
264 CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, unsigned merge,
265                  LEDInfoPtr *unboundLEDs);
266
267 extern bool
268 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, unsigned merge);
269
270 #endif /* XKBCOMP_H */