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.
diff --git a/py/objcomplex.c b/py/objcomplex.c
index 42b396d..bf6fb51 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -79,12 +79,12 @@
return mp_obj_new_complex(0, 0);
case 1:
- if (MP_OBJ_IS_STR(args[0])) {
+ if (mp_obj_is_str(args[0])) {
// a string, parse it
size_t l;
const char *s = mp_obj_str_get_data(args[0], &l);
return mp_parse_num_decimal(s, l, true, true, NULL);
- } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) {
+ } else if (mp_obj_is_type(args[0], &mp_type_complex)) {
// a complex, just return it
return args[0];
} else {
@@ -95,13 +95,13 @@
case 2:
default: {
mp_float_t real, imag;
- if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) {
+ if (mp_obj_is_type(args[0], &mp_type_complex)) {
mp_obj_complex_get(args[0], &real, &imag);
} else {
real = mp_obj_get_float(args[0]);
imag = 0;
}
- if (MP_OBJ_IS_TYPE(args[1], &mp_type_complex)) {
+ if (mp_obj_is_type(args[1], &mp_type_complex)) {
mp_float_t real2, imag2;
mp_obj_complex_get(args[1], &real2, &imag2);
real -= imag2;
@@ -164,7 +164,7 @@
}
void mp_obj_complex_get(mp_obj_t self_in, mp_float_t *real, mp_float_t *imag) {
- assert(MP_OBJ_IS_TYPE(self_in, &mp_type_complex));
+ assert(mp_obj_is_type(self_in, &mp_type_complex));
mp_obj_complex_t *self = MP_OBJ_TO_PTR(self_in);
*real = self->real;
*imag = self->imag;