summaryrefslogtreecommitdiff
path: root/py/objset.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/objset.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/objset.c')
-rw-r--r--py/objset.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/py/objset.c b/py/objset.c
index 799ba9df0..d58adb1ff 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -48,15 +48,15 @@ typedef struct _mp_obj_set_it_t {
STATIC mp_obj_t set_it_iternext(mp_obj_t self_in);
STATIC bool is_set_or_frozenset(mp_obj_t o) {
- return MP_OBJ_IS_TYPE(o, &mp_type_set)
+ return mp_obj_is_type(o, &mp_type_set)
#if MICROPY_PY_BUILTINS_FROZENSET
- || MP_OBJ_IS_TYPE(o, &mp_type_frozenset)
+ || mp_obj_is_type(o, &mp_type_frozenset)
#endif
;
}
// This macro is shorthand for mp_check_self to verify the argument is a set.
-#define check_set(o) mp_check_self(MP_OBJ_IS_TYPE(o, &mp_type_set))
+#define check_set(o) mp_check_self(mp_obj_is_type(o, &mp_type_set))
// This macro is shorthand for mp_check_self to verify the argument is a
// set or frozenset for methods that operate on both of these types.
@@ -66,7 +66,7 @@ STATIC void set_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t
(void)kind;
mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
#if MICROPY_PY_BUILTINS_FROZENSET
- bool is_frozen = MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset);
+ bool is_frozen = mp_obj_is_type(self_in, &mp_type_frozenset);
#endif
if (self->set.used == 0) {
#if MICROPY_PY_BUILTINS_FROZENSET
@@ -434,7 +434,7 @@ STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->set.used);
#if MICROPY_PY_BUILTINS_FROZENSET
case MP_UNARY_OP_HASH:
- if (MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset)) {
+ if (mp_obj_is_type(self_in, &mp_type_frozenset)) {
// start hash with unique value
mp_int_t hash = (mp_int_t)(uintptr_t)&mp_type_frozenset;
size_t max = self->set.alloc;
@@ -455,7 +455,7 @@ STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
STATIC mp_obj_t set_binary_op(mp_binary_op_t op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_t args[] = {lhs, rhs};
#if MICROPY_PY_BUILTINS_FROZENSET
- bool update = MP_OBJ_IS_TYPE(lhs, &mp_type_set);
+ bool update = mp_obj_is_type(lhs, &mp_type_set);
#else
bool update = true;
#endif
@@ -590,7 +590,7 @@ mp_obj_t mp_obj_new_set(size_t n_args, mp_obj_t *items) {
}
void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item) {
- mp_check_self(MP_OBJ_IS_TYPE(self_in, &mp_type_set));
+ mp_check_self(mp_obj_is_type(self_in, &mp_type_set));
mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
}