expr: make Expr creation naming and file location consistent Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index 9c6b5d9..cc16196 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -174,6 +174,73 @@ ExprCreateArrayRef(xkb_atom_t element, xkb_atom_t field, ExprDef *entry)
return expr;
}
+ExprDef *
+ExprCreateAction(xkb_atom_t name, ExprDef *args)
+{
+ EXPR_CREATE(ExprAction, expr, EXPR_ACTION_DECL, EXPR_TYPE_UNKNOWN);
+ expr->action.name = name;
+ expr->action.args = args;
+ return expr;
+}
+
+ExprDef *
+ExprCreateKeysymList(xkb_keysym_t sym)
+{
+ EXPR_CREATE(ExprKeysymList, expr, EXPR_KEYSYM_LIST, EXPR_TYPE_SYMBOLS);
+
+ darray_init(expr->keysym_list.syms);
+ darray_init(expr->keysym_list.symsMapIndex);
+ darray_init(expr->keysym_list.symsNumEntries);
+
+ darray_append(expr->keysym_list.syms, sym);
+ darray_append(expr->keysym_list.symsMapIndex, 0);
+ darray_append(expr->keysym_list.symsNumEntries, 1);
+
+ return expr;
+}
+
+ExprDef *
+ExprCreateMultiKeysymList(ExprDef *expr)
+{
+ size_t nLevels = darray_size(expr->keysym_list.symsMapIndex);
+
+ darray_resize(expr->keysym_list.symsMapIndex, 1);
+ darray_resize(expr->keysym_list.symsNumEntries, 1);
+ darray_item(expr->keysym_list.symsMapIndex, 0) = 0;
+ darray_item(expr->keysym_list.symsNumEntries, 0) = nLevels;
+
+ return expr;
+}
+
+ExprDef *
+ExprAppendKeysymList(ExprDef *expr, xkb_keysym_t sym)
+{
+ size_t nSyms = darray_size(expr->keysym_list.syms);
+
+ darray_append(expr->keysym_list.symsMapIndex, nSyms);
+ darray_append(expr->keysym_list.symsNumEntries, 1);
+ darray_append(expr->keysym_list.syms, sym);
+
+ return expr;
+}
+
+ExprDef *
+ExprAppendMultiKeysymList(ExprDef *expr, ExprDef *append)
+{
+ size_t nSyms = darray_size(expr->keysym_list.syms);
+ size_t numEntries = darray_size(append->keysym_list.syms);
+
+ darray_append(expr->keysym_list.symsMapIndex, nSyms);
+ darray_append(expr->keysym_list.symsNumEntries, numEntries);
+ darray_append_items(expr->keysym_list.syms,
+ darray_mem(append->keysym_list.syms, 0), numEntries);
+
+ darray_resize(append->keysym_list.syms, 0);
+ FreeStmt(&append->common);
+
+ return expr;
+}
+
KeycodeDef *
KeycodeCreate(xkb_atom_t name, int64_t value)
{
@@ -353,73 +420,6 @@ LedNameCreate(int ndx, ExprDef *name, bool virtual)
return def;
}
-ExprDef *
-ActionCreate(xkb_atom_t name, ExprDef *args)
-{
- EXPR_CREATE(ExprAction, expr, EXPR_ACTION_DECL, EXPR_TYPE_UNKNOWN);
- expr->action.name = name;
- expr->action.args = args;
- return expr;
-}
-
-ExprDef *
-CreateKeysymList(xkb_keysym_t sym)
-{
- EXPR_CREATE(ExprKeysymList, expr, EXPR_KEYSYM_LIST, EXPR_TYPE_SYMBOLS);
-
- darray_init(expr->keysym_list.syms);
- darray_init(expr->keysym_list.symsMapIndex);
- darray_init(expr->keysym_list.symsNumEntries);
-
- darray_append(expr->keysym_list.syms, sym);
- darray_append(expr->keysym_list.symsMapIndex, 0);
- darray_append(expr->keysym_list.symsNumEntries, 1);
-
- return expr;
-}
-
-ExprDef *
-CreateMultiKeysymList(ExprDef *expr)
-{
- size_t nLevels = darray_size(expr->keysym_list.symsMapIndex);
-
- darray_resize(expr->keysym_list.symsMapIndex, 1);
- darray_resize(expr->keysym_list.symsNumEntries, 1);
- darray_item(expr->keysym_list.symsMapIndex, 0) = 0;
- darray_item(expr->keysym_list.symsNumEntries, 0) = nLevels;
-
- return expr;
-}
-
-ExprDef *
-AppendKeysymList(ExprDef *expr, xkb_keysym_t sym)
-{
- size_t nSyms = darray_size(expr->keysym_list.syms);
-
- darray_append(expr->keysym_list.symsMapIndex, nSyms);
- darray_append(expr->keysym_list.symsNumEntries, 1);
- darray_append(expr->keysym_list.syms, sym);
-
- return expr;
-}
-
-ExprDef *
-AppendMultiKeysymList(ExprDef *expr, ExprDef *append)
-{
- size_t nSyms = darray_size(expr->keysym_list.syms);
- size_t numEntries = darray_size(append->keysym_list.syms);
-
- darray_append(expr->keysym_list.symsMapIndex, nSyms);
- darray_append(expr->keysym_list.symsNumEntries, numEntries);
- darray_append_items(expr->keysym_list.syms,
- darray_mem(append->keysym_list.syms, 0), numEntries);
-
- darray_resize(append->keysym_list.syms, 0);
- FreeStmt(&append->common);
-
- return expr;
-}
-
static void
FreeInclude(IncludeStmt *incl);
diff --git a/src/xkbcomp/ast-build.h b/src/xkbcomp/ast-build.h
index 35a4ca7..8146b06 100644
--- a/src/xkbcomp/ast-build.h
+++ b/src/xkbcomp/ast-build.h
@@ -58,6 +58,21 @@ ExprCreateFieldRef(xkb_atom_t element, xkb_atom_t field);
ExprDef *
ExprCreateArrayRef(xkb_atom_t element, xkb_atom_t field, ExprDef *entry);
+ExprDef *
+ExprCreateAction(xkb_atom_t name, ExprDef *args);
+
+ExprDef *
+ExprCreateMultiKeysymList(ExprDef *list);
+
+ExprDef *
+ExprCreateKeysymList(xkb_keysym_t sym);
+
+ExprDef *
+ExprAppendMultiKeysymList(ExprDef *list, ExprDef *append);
+
+ExprDef *
+ExprAppendKeysymList(ExprDef *list, xkb_keysym_t sym);
+
KeycodeDef *
KeycodeCreate(xkb_atom_t name, int64_t value);
@@ -94,21 +109,6 @@ LedMapCreate(xkb_atom_t name, VarDef *body);
LedNameDef *
LedNameCreate(int ndx, ExprDef *name, bool virtual);
-ExprDef *
-ActionCreate(xkb_atom_t name, ExprDef *args);
-
-ExprDef *
-CreateMultiKeysymList(ExprDef *list);
-
-ExprDef *
-CreateKeysymList(xkb_keysym_t sym);
-
-ExprDef *
-AppendMultiKeysymList(ExprDef *list, ExprDef *append);
-
-ExprDef *
-AppendKeysymList(ExprDef *list, xkb_keysym_t sym);
-
IncludeStmt *
IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge);
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index 167af8e..f846724 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -646,7 +646,7 @@ Term : MINUS Term
| Lhs
{ $$ = $1; }
| FieldSpec OPAREN OptExprList CPAREN %prec OPAREN
- { $$ = ActionCreate($1, $3); }
+ { $$ = ExprCreateAction($1, $3); }
| Terminal
{ $$ = $1; }
| OPAREN Expr CPAREN
@@ -660,7 +660,7 @@ ActionList : ActionList COMMA Action
;
Action : FieldSpec OPAREN OptExprList CPAREN
- { $$ = ActionCreate($1, $3); }
+ { $$ = ExprCreateAction($1, $3); }
;
Lhs : FieldSpec
@@ -688,13 +688,13 @@ OptKeySymList : KeySymList { $$ = $1; }
;
KeySymList : KeySymList COMMA KeySym
- { $$ = AppendKeysymList($1, $3); }
+ { $$ = ExprAppendKeysymList($1, $3); }
| KeySymList COMMA KeySyms
- { $$ = AppendMultiKeysymList($1, $3); }
+ { $$ = ExprAppendMultiKeysymList($1, $3); }
| KeySym
- { $$ = CreateKeysymList($1); }
+ { $$ = ExprCreateKeysymList($1); }
| KeySyms
- { $$ = CreateMultiKeysymList($1); }
+ { $$ = ExprCreateMultiKeysymList($1); }
;
KeySyms : OBRACE KeySymList CBRACE