ast-build: get rid of unhelpful macro Straightforward code is better here. Signed-off-by: Ran Benita <ran@unusedvar.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
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index 365ff51..d01aa24 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -84,15 +84,12 @@ ExprCreate(enum expr_op_type op, enum expr_value_type type, size_t size)
return expr;
}
-#define EXPR_CREATE(type_, name_, op_, value_type_) \
- ExprDef *name_ = ExprCreate(op_, value_type_, sizeof(type_)); \
- if (!name_) \
- return NULL;
-
ExprDef *
ExprCreateString(xkb_atom_t str)
{
- EXPR_CREATE(ExprString, expr, EXPR_VALUE, EXPR_TYPE_STRING);
+ ExprDef *expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_STRING, sizeof(ExprString));
+ if (!expr)
+ return NULL;
expr->string.str = str;
return expr;
}
@@ -100,7 +97,9 @@ ExprCreateString(xkb_atom_t str)
ExprDef *
ExprCreateInteger(int ival)
{
- EXPR_CREATE(ExprInteger, expr, EXPR_VALUE, EXPR_TYPE_INT);
+ ExprDef *expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_INT, sizeof(ExprInteger));
+ if (!expr)
+ return NULL;
expr->integer.ival = ival;
return expr;
}
@@ -108,14 +107,18 @@ ExprCreateInteger(int ival)
ExprDef *
ExprCreateFloat(void)
{
- EXPR_CREATE(ExprFloat, expr, EXPR_VALUE, EXPR_TYPE_FLOAT);
+ ExprDef *expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_FLOAT, sizeof(ExprFloat));
+ if (!expr)
+ return NULL;
return expr;
}
ExprDef *
ExprCreateBoolean(bool set)
{
- EXPR_CREATE(ExprBoolean, expr, EXPR_VALUE, EXPR_TYPE_BOOLEAN);
+ ExprDef *expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_BOOLEAN, sizeof(ExprBoolean));
+ if (!expr)
+ return NULL;
expr->boolean.set = set;
return expr;
}
@@ -123,7 +126,9 @@ ExprCreateBoolean(bool set)
ExprDef *
ExprCreateKeyName(xkb_atom_t key_name)
{
- EXPR_CREATE(ExprKeyName, expr, EXPR_VALUE, EXPR_TYPE_KEYNAME);
+ ExprDef *expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_KEYNAME, sizeof(ExprKeyName));
+ if (!expr)
+ return NULL;
expr->key_name.key_name = key_name;
return expr;
}
@@ -131,7 +136,9 @@ ExprCreateKeyName(xkb_atom_t key_name)
ExprDef *
ExprCreateIdent(xkb_atom_t ident)
{
- EXPR_CREATE(ExprIdent, expr, EXPR_IDENT, EXPR_TYPE_UNKNOWN);
+ ExprDef *expr = ExprCreate(EXPR_IDENT, EXPR_TYPE_UNKNOWN, sizeof(ExprIdent));
+ if (!expr)
+ return NULL;
expr->ident.ident = ident;
return expr;
}
@@ -140,7 +147,9 @@ ExprDef *
ExprCreateUnary(enum expr_op_type op, enum expr_value_type type,
ExprDef *child)
{
- EXPR_CREATE(ExprUnary, expr, op, type);
+ ExprDef *expr = ExprCreate(op, type, sizeof(ExprUnary));
+ if (!expr)
+ return NULL;
expr->unary.child = child;
return expr;
}
@@ -148,7 +157,9 @@ ExprCreateUnary(enum expr_op_type op, enum expr_value_type type,
ExprDef *
ExprCreateBinary(enum expr_op_type op, ExprDef *left, ExprDef *right)
{
- EXPR_CREATE(ExprBinary, expr, op, EXPR_TYPE_UNKNOWN);
+ ExprDef *expr = ExprCreate(op, EXPR_TYPE_UNKNOWN, sizeof(ExprBinary));
+ if (!expr)
+ return NULL;
if (op == EXPR_ASSIGN || left->expr.value_type == EXPR_TYPE_UNKNOWN)
expr->expr.value_type = right->expr.value_type;
@@ -164,7 +175,9 @@ ExprCreateBinary(enum expr_op_type op, ExprDef *left, ExprDef *right)
ExprDef *
ExprCreateFieldRef(xkb_atom_t element, xkb_atom_t field)
{
- EXPR_CREATE(ExprFieldRef, expr, EXPR_FIELD_REF, EXPR_TYPE_UNKNOWN);
+ ExprDef *expr = ExprCreate(EXPR_FIELD_REF, EXPR_TYPE_UNKNOWN, sizeof(ExprFieldRef));
+ if (!expr)
+ return NULL;
expr->field_ref.element = element;
expr->field_ref.field = field;
return expr;
@@ -173,7 +186,9 @@ ExprCreateFieldRef(xkb_atom_t element, xkb_atom_t field)
ExprDef *
ExprCreateArrayRef(xkb_atom_t element, xkb_atom_t field, ExprDef *entry)
{
- EXPR_CREATE(ExprArrayRef, expr, EXPR_ARRAY_REF, EXPR_TYPE_UNKNOWN);
+ ExprDef *expr = ExprCreate(EXPR_ARRAY_REF, EXPR_TYPE_UNKNOWN, sizeof(ExprArrayRef));
+ if (!expr)
+ return NULL;
expr->array_ref.element = element;
expr->array_ref.field = field;
expr->array_ref.entry = entry;
@@ -183,7 +198,9 @@ ExprCreateArrayRef(xkb_atom_t element, xkb_atom_t field, ExprDef *entry)
ExprDef *
ExprCreateAction(xkb_atom_t name, ExprDef *args)
{
- EXPR_CREATE(ExprAction, expr, EXPR_ACTION_DECL, EXPR_TYPE_UNKNOWN);
+ ExprDef *expr = ExprCreate(EXPR_ACTION_DECL, EXPR_TYPE_UNKNOWN, sizeof(ExprAction));
+ if (!expr)
+ return NULL;
expr->action.name = name;
expr->action.args = args;
return expr;
@@ -192,7 +209,9 @@ ExprCreateAction(xkb_atom_t name, ExprDef *args)
ExprDef *
ExprCreateKeysymList(xkb_keysym_t sym)
{
- EXPR_CREATE(ExprKeysymList, expr, EXPR_KEYSYM_LIST, EXPR_TYPE_SYMBOLS);
+ ExprDef *expr = ExprCreate(EXPR_KEYSYM_LIST, EXPR_TYPE_SYMBOLS, sizeof(ExprKeysymList));
+ if (!expr)
+ return NULL;
darray_init(expr->keysym_list.syms);
darray_init(expr->keysym_list.symsMapIndex);