Run source tree through uncrustify
[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     unsigned stmtType;
59     struct _ParseCommon *next;
60 } ParseCommon;
61
62 #define ExprValue      0
63 #define ExprIdent      1
64 #define ExprActionDecl 2
65 #define ExprFieldRef   3
66 #define ExprArrayRef   4
67 #define ExprKeysymList 5
68 #define ExprActionList 6
69
70 #define OpAdd          20
71 #define OpSubtract     21
72 #define OpMultiply     22
73 #define OpDivide       23
74 #define OpAssign       24
75 #define OpNot          25
76 #define OpNegate       26
77 #define OpInvert       27
78 #define OpUnaryPlus    28
79
80 enum merge_mode {
81     MERGE_DEFAULT,
82     MERGE_AUGMENT,
83     MERGE_OVERRIDE,
84     MERGE_REPLACE,
85 };
86
87 #define AutoKeyNames (1L << 0)
88 #define CreateKeyNames(x) ((x)->flags & AutoKeyNames)
89
90 extern unsigned warningLevel;
91
92 typedef struct _IncludeStmt {
93     ParseCommon common;
94     enum merge_mode merge;
95     char *stmt;
96     char *file;
97     char *map;
98     char *modifier;
99     char *path;
100     struct _IncludeStmt *next;
101 } IncludeStmt;
102
103 typedef struct _Expr {
104     ParseCommon common;
105     unsigned op;
106     unsigned type;
107     union {
108         struct {
109             struct _Expr *left;
110             struct _Expr *right;
111         } binary;
112         struct {
113             xkb_atom_t element;
114             xkb_atom_t field;
115         } field;
116         struct {
117             xkb_atom_t element;
118             xkb_atom_t field;
119             struct _Expr *entry;
120         } array;
121         struct {
122             xkb_atom_t name;
123             struct _Expr *args;
124         } action;
125         struct {
126             darray(char *) syms;
127             darray(int) symsMapIndex;
128             darray(unsigned int) symsNumEntries;
129         } list;
130         struct _Expr *child;
131         xkb_atom_t str;
132         unsigned uval;
133         int ival;
134         char keyName[5];
135     } value;
136 } ExprDef;
137
138 typedef struct _VarDef {
139     ParseCommon common;
140     enum merge_mode merge;
141     ExprDef *name;
142     ExprDef *value;
143 } VarDef;
144
145 typedef struct _VModDef {
146     ParseCommon common;
147     enum merge_mode merge;
148     xkb_atom_t name;
149     ExprDef *value;
150 } VModDef;
151
152 typedef struct _KeycodeDef {
153     ParseCommon common;
154     enum merge_mode merge;
155     char name[5];
156     unsigned long value;
157 } KeycodeDef;
158
159 typedef struct _KeyAliasDef {
160     ParseCommon common;
161     enum merge_mode merge;
162     char alias[5];
163     char real[5];
164 } KeyAliasDef;
165
166 typedef struct _KeyTypeDef {
167     ParseCommon common;
168     enum merge_mode merge;
169     xkb_atom_t name;
170     VarDef *body;
171 } KeyTypeDef;
172
173 typedef struct _SymbolsDef {
174     ParseCommon common;
175     enum merge_mode merge;
176     char keyName[5];
177     ExprDef *symbols;
178 } SymbolsDef;
179
180 typedef struct _ModMapDef {
181     ParseCommon common;
182     enum merge_mode merge;
183     xkb_atom_t modifier;
184     ExprDef *keys;
185 } ModMapDef;
186
187 typedef struct _GroupCompatDef {
188     ParseCommon common;
189     enum merge_mode merge;
190     int group;
191     ExprDef *def;
192 } GroupCompatDef;
193
194 typedef struct _InterpDef {
195     ParseCommon common;
196     enum merge_mode merge;
197     char *sym;
198     ExprDef *match;
199     VarDef *def;
200 } InterpDef;
201
202 typedef struct _IndicatorNameDef {
203     ParseCommon common;
204     enum merge_mode merge;
205     int ndx;
206     ExprDef *name;
207     bool virtual;
208 } IndicatorNameDef;
209
210 typedef struct _IndicatorMapDef {
211     ParseCommon common;
212     enum merge_mode merge;
213     unsigned type;
214     xkb_atom_t name;
215     VarDef *body;
216 } IndicatorMapDef;
217
218 typedef struct _XkbFile {
219     ParseCommon common;
220     enum xkb_file_type type;
221     char *topName;
222     char *name;
223     ParseCommon *defs;
224     int id;
225     unsigned flags;
226 } XkbFile;
227
228 extern bool
229 CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
230                 enum merge_mode merge);
231
232 extern bool
233 CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap,
234                 enum merge_mode merge);
235
236 extern bool
237 CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
238                  enum merge_mode merge);
239
240 extern bool
241 CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
242                enum merge_mode merge);
243
244 #endif /* XKBCOMP_H */