Import xkbcomp sources for CompileKeymap
[platform/upstream/libxkbcommon.git] / src / xkbcomp / expr.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 EXPR_H
28 #define EXPR_H 1
29
30 typedef union _ExprResult
31 {
32     char *str;
33     int ival;
34     unsigned uval;
35     XkbKeyNameRec keyName;
36 } ExprResult;
37
38 typedef Bool(*IdentLookupFunc) (XPointer /* priv */ ,
39                                 Atom /* elem */ ,
40                                 Atom /* field */ ,
41                                 unsigned /* type */ ,
42                                 ExprResult *    /* val_rtrn */
43     );
44
45 extern char *exprTypeText(unsigned      /* type */
46     );
47
48 extern int ExprResolveLhs(ExprDef * /* expr */ ,
49                           ExprResult * /* elem_rtrn */ ,
50                           ExprResult * /* field_rtrn */ ,
51                           ExprDef **    /* index_rtrn */
52     );
53
54 typedef struct _LookupPriv
55 {
56     XPointer priv;
57     IdentLookupFunc chain;
58     XPointer chainPriv;
59 } LookupPriv;
60
61 typedef struct _LookupEntry
62 {
63     const char *name;
64     unsigned result;
65 } LookupEntry;
66
67 typedef struct _LookupTable
68 {
69     char *element;
70     LookupEntry *entries;
71     struct _LookupTable *nextElement;
72 } LookupTable;
73
74
75 extern char *exprOpText(unsigned        /* type */
76     );
77
78 extern int RadioLookup(XPointer /* priv */ ,
79                        Atom /* elem */ ,
80                        Atom /* field */ ,
81                        unsigned /* type */ ,
82                        ExprResult *     /* val_rtrn */
83     );
84
85 extern int SimpleLookup(XPointer /* priv */ ,
86                         Atom /* elem */ ,
87                         Atom /* field */ ,
88                         unsigned /* type */ ,
89                         ExprResult *    /* val_rtrn */
90     );
91
92 extern int TableLookup(XPointer /* priv */ ,
93                        Atom /* elem */ ,
94                        Atom /* field */ ,
95                        unsigned /* type */ ,
96                        ExprResult *     /* val_rtrn */
97     );
98
99 extern int LookupModIndex(XPointer /* priv */ ,
100                           Atom /* elem */ ,
101                           Atom /* field */ ,
102                           unsigned /* type */ ,
103                           ExprResult *  /* val_rtrn */
104     );
105
106 extern int LookupModMask(XPointer /* priv */ ,
107                          Atom /* elem */ ,
108                          Atom /* field */ ,
109                          unsigned /* type */ ,
110                          ExprResult *   /* val_rtrn */
111     );
112
113 extern int ExprResolveModIndex(ExprDef * /* expr */ ,
114                                ExprResult * /* val_rtrn */ ,
115                                IdentLookupFunc /* lookup */ ,
116                                XPointer /* lookupPriv */
117     );
118
119 extern int ExprResolveModMask(ExprDef * /* expr */ ,
120                               ExprResult * /* val_rtrn */ ,
121                               IdentLookupFunc /* lookup */ ,
122                               XPointer  /* priv */
123     );
124
125 extern int ExprResolveBoolean(ExprDef * /* expr */ ,
126                               ExprResult * /* val_rtrn */ ,
127                               IdentLookupFunc /* lookup */ ,
128                               XPointer  /* lookupPriv */
129     );
130
131 extern int ExprResolveInteger(ExprDef * /* expr */ ,
132                               ExprResult * /* val_rtrn */ ,
133                               IdentLookupFunc /* lookup */ ,
134                               XPointer  /* lookupPriv */
135     );
136
137 extern int ExprResolveFloat(ExprDef * /* expr */ ,
138                             ExprResult * /* val_rtrn */ ,
139                             IdentLookupFunc /* lookup */ ,
140                             XPointer    /* lookupPriv */
141     );
142
143 extern int ExprResolveString(ExprDef * /* expr */ ,
144                              ExprResult * /* val_rtrn */ ,
145                              IdentLookupFunc /* lookup */ ,
146                              XPointer   /* lookupPriv */
147     );
148
149 extern int ExprResolveKeyName(ExprDef * /* expr */ ,
150                               ExprResult * /* val_rtrn */ ,
151                               IdentLookupFunc /* lookup */ ,
152                               XPointer  /* lookupPriv */
153     );
154
155 extern int ExprResolveEnum(ExprDef * /* expr */ ,
156                            ExprResult * /* val_rtrn */ ,
157                            LookupEntry *        /* values */
158     );
159
160 extern int ExprResolveMask(ExprDef * /* expr */ ,
161                            ExprResult * /* val_rtrn */ ,
162                            IdentLookupFunc /* lookup */ ,
163                            XPointer     /* lookupPriv */
164     );
165
166 extern int ExprResolveKeySym(ExprDef * /* expr */ ,
167                              ExprResult * /* val_rtrn */ ,
168                              IdentLookupFunc /* lookup */ ,
169                              XPointer   /* lookupPriv */
170     );
171
172 #endif /* EXPR_H */