Shorter name for internal enum get_item_result
This commit is contained in:
parent
78bd057c37
commit
dd314c5abb
3 changed files with 17 additions and 17 deletions
|
|
@ -1240,7 +1240,7 @@ evaluate_dot(apfl_ctx ctx, struct apfl_expr_dot *dot)
|
|||
};
|
||||
|
||||
struct apfl_value out;
|
||||
if (apfl_value_get_item(ctx->allocator, apfl_value_move(&lhs), apfl_value_move(&key), &out) != APFL_VALUE_GET_ITEM_OK) {
|
||||
if (apfl_value_get_item(ctx->allocator, apfl_value_move(&lhs), apfl_value_move(&key), &out) != GET_ITEM_OK) {
|
||||
return APFL_RESULT_ERR; // TODO: Describe error
|
||||
}
|
||||
|
||||
|
|
@ -1260,7 +1260,7 @@ evaluate_at(apfl_ctx ctx, struct apfl_expr_at *at)
|
|||
struct apfl_value lhs = stack_must_pop(ctx, -1);
|
||||
|
||||
struct apfl_value out;
|
||||
if (apfl_value_get_item(ctx->allocator, apfl_value_move(&lhs), apfl_value_move(&rhs), &out) != APFL_VALUE_GET_ITEM_OK) {
|
||||
if (apfl_value_get_item(ctx->allocator, apfl_value_move(&lhs), apfl_value_move(&rhs), &out) != GET_ITEM_OK) {
|
||||
return APFL_RESULT_ERR; // TODO: Describe error
|
||||
}
|
||||
|
||||
|
|
|
|||
18
src/value.c
18
src/value.c
|
|
@ -589,12 +589,12 @@ apfl_dict_get_item(struct apfl_allocator allocator, apfl_dict dict, struct apfl_
|
|||
return ok;
|
||||
}
|
||||
|
||||
static enum apfl_value_get_item_result
|
||||
static enum get_item_result
|
||||
get_item(struct apfl_allocator allocator, /*borrowed*/ struct apfl_value container, /*borrowed*/ struct apfl_value key, struct apfl_value *out)
|
||||
{
|
||||
if (container.type == APFL_VALUE_LIST) {
|
||||
if (key.type != APFL_VALUE_NUMBER) {
|
||||
return APFL_VALUE_GET_ITEM_WRONG_KEY_TYPE;
|
||||
return GET_ITEM_WRONG_KEY_TYPE;
|
||||
}
|
||||
|
||||
return apfl_list_get_item(
|
||||
|
|
@ -603,8 +603,8 @@ get_item(struct apfl_allocator allocator, /*borrowed*/ struct apfl_value contain
|
|||
(size_t)key.number,
|
||||
out
|
||||
)
|
||||
? APFL_VALUE_GET_ITEM_OK
|
||||
: APFL_VALUE_GET_ITEM_KEY_DOESNT_EXIST;
|
||||
? GET_ITEM_OK
|
||||
: GET_ITEM_KEY_DOESNT_EXIST;
|
||||
} else if (container.type == APFL_VALUE_DICT) {
|
||||
return apfl_dict_get_item(
|
||||
allocator,
|
||||
|
|
@ -612,17 +612,17 @@ get_item(struct apfl_allocator allocator, /*borrowed*/ struct apfl_value contain
|
|||
apfl_value_incref(key),
|
||||
out
|
||||
)
|
||||
? APFL_VALUE_GET_ITEM_OK
|
||||
: APFL_VALUE_GET_ITEM_KEY_DOESNT_EXIST;
|
||||
? GET_ITEM_OK
|
||||
: GET_ITEM_KEY_DOESNT_EXIST;
|
||||
} else {
|
||||
return APFL_VALUE_GET_ITEM_NOT_A_CONTAINER;
|
||||
return GET_ITEM_NOT_A_CONTAINER;
|
||||
}
|
||||
}
|
||||
|
||||
enum apfl_value_get_item_result
|
||||
enum get_item_result
|
||||
apfl_value_get_item(struct apfl_allocator allocator, struct apfl_value container, struct apfl_value key, struct apfl_value *out)
|
||||
{
|
||||
enum apfl_value_get_item_result result = get_item(allocator, container, key, out);
|
||||
enum get_item_result result = get_item(allocator, container, key, out);
|
||||
apfl_value_deinit(allocator, &container);
|
||||
apfl_value_deinit(allocator, &key);
|
||||
return result;
|
||||
|
|
|
|||
12
src/value.h
12
src/value.h
|
|
@ -44,14 +44,14 @@ struct apfl_value apfl_value_incref(struct apfl_value);
|
|||
void apfl_value_print(struct apfl_value, FILE *);
|
||||
void apfl_value_deinit(struct apfl_allocator, struct apfl_value *);
|
||||
|
||||
enum apfl_value_get_item_result {
|
||||
APFL_VALUE_GET_ITEM_OK,
|
||||
APFL_VALUE_GET_ITEM_KEY_DOESNT_EXIST,
|
||||
APFL_VALUE_GET_ITEM_NOT_A_CONTAINER,
|
||||
APFL_VALUE_GET_ITEM_WRONG_KEY_TYPE,
|
||||
enum get_item_result {
|
||||
GET_ITEM_OK,
|
||||
GET_ITEM_KEY_DOESNT_EXIST,
|
||||
GET_ITEM_NOT_A_CONTAINER,
|
||||
GET_ITEM_WRONG_KEY_TYPE,
|
||||
};
|
||||
|
||||
enum apfl_value_get_item_result apfl_value_get_item(struct apfl_allocator allocator, struct apfl_value container, struct apfl_value key, struct apfl_value *out);
|
||||
enum get_item_result apfl_value_get_item(struct apfl_allocator allocator, struct apfl_value container, struct apfl_value key, struct apfl_value *out);
|
||||
|
||||
apfl_list apfl_list_incref(apfl_list);
|
||||
size_t apfl_list_len(apfl_list);
|
||||
|
|
|
|||
Loading…
Reference in a new issue