summaryrefslogtreecommitdiff
path: root/py/parse.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2019-01-30 18:49:52 +1100
committerDamien George <damien.p.george@gmail.com>2019-02-12 14:54:51 +1100
commiteee1e8841a852f374b83e0a3e3b0ff7b66e54243 (patch)
treec928ad701fc0df71dc2863178ea8d2e8bea4946b /py/parse.c
parent019433a17e82f22e8ee24ad1b53156403d4f4a67 (diff)
py: Downcase all MP_OBJ_IS_xxx macros to make a more consistent C API.
These macros could in principle be (inline) functions so it makes sense to have them lower case, to match the other C API functions. The remaining macros that are upper case are: - MP_OBJ_TO_PTR, MP_OBJ_FROM_PTR - MP_OBJ_NEW_SMALL_INT, MP_OBJ_SMALL_INT_VALUE - MP_OBJ_NEW_QSTR, MP_OBJ_QSTR_VALUE - MP_OBJ_FUN_MAKE_SIG - MP_DECLARE_CONST_xxx - MP_DEFINE_CONST_xxx These must remain macros because they are used when defining const data (at least, MP_OBJ_NEW_SMALL_INT is so it makes sense to have MP_OBJ_SMALL_INT_VALUE also a macro). For those macros that have been made lower case, compatibility macros are provided for the old names so that users do not need to change their code immediately.
Diffstat (limited to 'py/parse.c')
-rw-r--r--py/parse.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/py/parse.c b/py/parse.c
index 6c5ebbeaf..66110e7c3 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -338,7 +338,7 @@ bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) {
#else
*o = (mp_obj_t)pns->nodes[0];
#endif
- return MP_OBJ_IS_INT(*o);
+ return mp_obj_is_int(*o);
} else {
return false;
}
@@ -477,7 +477,7 @@ STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
mp_map_elem_t *elem;
if (rule_id == RULE_atom
&& (elem = mp_map_lookup(&parser->consts, MP_OBJ_NEW_QSTR(id), MP_MAP_LOOKUP)) != NULL) {
- if (MP_OBJ_IS_SMALL_INT(elem->value)) {
+ if (mp_obj_is_small_int(elem->value)) {
pn = mp_parse_node_new_small_int_checked(parser, elem->value);
} else {
pn = make_node_const_object(parser, lex->tok_line, elem->value);
@@ -491,7 +491,7 @@ STATIC void push_result_token(parser_t *parser, uint8_t rule_id) {
#endif
} else if (lex->tok_kind == MP_TOKEN_INTEGER) {
mp_obj_t o = mp_parse_num_integer(lex->vstr.buf, lex->vstr.len, 0, lex);
- if (MP_OBJ_IS_SMALL_INT(o)) {
+ if (mp_obj_is_small_int(o)) {
pn = mp_parse_node_new_small_int_checked(parser, o);
} else {
pn = make_node_const_object(parser, lex->tok_line, o);
@@ -768,7 +768,7 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
}
mp_obj_t dest[2];
mp_load_method_maybe(elem->value, q_attr, dest);
- if (!(dest[0] != MP_OBJ_NULL && MP_OBJ_IS_INT(dest[0]) && dest[1] == MP_OBJ_NULL)) {
+ if (!(dest[0] != MP_OBJ_NULL && mp_obj_is_int(dest[0]) && dest[1] == MP_OBJ_NULL)) {
return false;
}
arg0 = dest[0];
@@ -783,7 +783,7 @@ STATIC bool fold_constants(parser_t *parser, uint8_t rule_id, size_t num_args) {
for (size_t i = num_args; i > 0; i--) {
pop_result(parser);
}
- if (MP_OBJ_IS_SMALL_INT(arg0)) {
+ if (mp_obj_is_small_int(arg0)) {
push_result_node(parser, mp_parse_node_new_small_int_checked(parser, arg0));
} else {
// TODO reuse memory for parse node struct?