expr: make Expr creation naming and file location consistent
Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
07334f4db6
commit
b63fa3b1e7
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue