8000 C API: downcase all MP_OBJ_IS_xxx macros and MP_xxx_SLOT_IS_FILLED functions by dpgeorge · Pull Request #4446 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

C API: downcase all MP_OBJ_IS_xxx macros and MP_xxx_SLOT_IS_FILLED functions #4446

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extmod/machine_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, size_t
#if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW)
mp_pin_p_t *pin_p = NULL;

if (MP_OBJ_IS_OBJ(pin)) {
if (mp_obj_is_obj(pin)) {
mp_obj_base_t *pin_base = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
pin_p = (mp_pin_p_t*)pin_base->type->protocol;
}
Expand Down
38 changes: 19 additions & 19 deletions extmod/moductypes.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ STATIC void uctypes_struct_print(const mp_print_t *print, mp_obj_t self_in, mp_p
(void)kind;
mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in);
const char *typen = "unk";
if (MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)
if (mp_obj_is_type(self->desc, &mp_type_dict)
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
|| MP_OBJ_IS_TYPE(self->desc, &mp_type_ordereddict)
|| mp_obj_is_type(self->desc, &mp_type_ordereddict)
#endif
) {
typen = "STRUCT";
} else if (MP_OBJ_IS_TYPE(self->desc, &mp_type_tuple)) {
} else if (mp_obj_is_type(self->desc, &mp_type_tuple)) {
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->desc);
mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(t->items[0]);
uint agg_type = GET_TYPE(offset, AGG_TYPE_BITS);
Expand Down Expand Up @@ -210,14 +210,14 @@ STATIC mp_uint_t uctypes_struct_agg_size(mp_obj_tuple_t *t, int layout_type, mp_
}

STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_t *max_field_size) {
if (!MP_OBJ_IS_TYPE(desc_in, &mp_type_dict)
if (!mp_obj_is_type(desc_in, &mp_type_dict)
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
&& !MP_OBJ_IS_TYPE(desc_in, &mp_type_ordereddict)
&& !mp_obj_is_type(desc_in, &mp_type_ordereddict)
#endif
) {
if (MP_OBJ_IS_TYPE(desc_in, &mp_type_tuple)) {
if (mp_obj_is_type(desc_in, &mp_type_tuple)) {
return uctypes_struct_agg_size((mp_obj_tuple_t*)MP_OBJ_TO_PTR(desc_in), layout_type, max_field_size);
} else if (MP_OBJ_IS_SMALL_INT(desc_in)) {
} else if (mp_obj_is_small_int(desc_in)) {
// We allow sizeof on both type definitions and structures/structure fields,
// but scalar structure field is lowered into native Python int, so all
// type info is lost. So, we cannot say if it's scalar type description,
Expand All @@ -231,9 +231,9 @@ STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_
mp_uint_t total_size = 0;

for (mp_uint_t i = 0; i < d->map.alloc; i++) {
if (MP_MAP_SLOT_IS_FILLED(&d->map, i)) {
if (mp_map_slot_is_filled(&d->map, i)) {
mp_obj_t v = d->map.table[i].value;
if (MP_OBJ_IS_SMALL_INT(v)) {
if (mp_obj_is_small_int(v)) {
mp_uint_t offset = MP_OBJ_SMALL_INT_VALUE(v);
mp_uint_t val_type = GET_TYPE(offset, VAL_TYPE_BITS);
offset &= VALUE_MASK(VAL_TYPE_BITS);
Expand All @@ -248,7 +248,7 @@ STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_
total_size = offset + s;
}
} else {
if (!MP_OBJ_IS_TYPE(v, &mp_type_tuple)) {
if (!mp_obj_is_type(v, &mp_type_tuple)) {
syntax_error();
}
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(v);
Expand All @@ -272,13 +272,13 @@ STATIC mp_uint_t uctypes_struct_size(mp_obj_t desc_in, int layout_type, mp_uint_
STATIC mp_obj_t uctypes_struct_sizeof(size_t n_args, const mp_obj_t *args) {
mp_obj_t obj_in = args[0];
mp_uint_t max_field_size = 0;
if (MP_OBJ_IS_TYPE(obj_in, &mp_type_bytearray)) {
if (mp_obj_is_type(obj_in, &mp_type_bytearray)) {
return mp_obj_len(obj_in);
}
int layout_type = LAYOUT_NATIVE;
// We can apply sizeof either to structure definition (a dict)
// or to instantiated structure
if (MP_OBJ_IS_TYPE(obj_in, &uctypes_struct_type)) {
if (mp_obj_is_type(obj_in, &uctypes_struct_type)) {
if (n_args != 1) {
mp_raise_TypeError(NULL);
}
Expand Down Expand Up @@ -406,16 +406,16 @@ STATIC void set_aligned(uint val_type, void *p, mp_int_t index, mp_obj_t val) {
STATIC mp_obj_t uctypes_struct_attr_op(mp_obj_t self_in, qstr attr, mp_obj_t set_val) {
mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in);

if (!MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)
if (!mp_obj_is_type(self->desc, &mp_type_dict)
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT
&& !MP_OBJ_IS_TYPE(self->desc, &mp_type_ordereddict)
&& !mp_obj_is_type(self->desc, &mp_type_ordereddict)
#endif
) {
mp_raise_TypeError("struct: no fields");
}

mp_obj_t deref = mp_obj_dict_get(self->desc, MP_OBJ_NEW_QSTR(attr));
if (MP_OBJ_IS_SMALL_INT(deref)) {
if (mp_obj_is_small_int(deref)) {
mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(deref);
mp_uint_t val_type = GET_TYPE(offset, VAL_TYPE_BITS);
offset &= VALUE_MASK(VAL_TYPE_BITS);
Expand Down Expand Up @@ -476,7 +476,7 @@ STATIC mp_obj_t uctypes_struct_attr_op(mp_obj_t self_in, qstr attr, mp_obj_t set
return MP_OBJ_NULL;
}

if (!MP_OBJ_IS_TYPE(deref, &mp_type_tuple)) {
if (!mp_obj_is_type(deref, &mp_type_tuple)) {
syntax_error();
}

Expand Down Expand Up @@ -543,7 +543,7 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
return MP_OBJ_NULL; // op not supported
} else {
// load / store
if (!MP_OBJ_IS_TYPE(self->desc, &mp_type_tuple)) {
if (!mp_obj_is_type(self->desc, &mp_type_tuple)) {
mp_raise_TypeError("struct: cannot index");
}

Expand Down Expand Up @@ -594,7 +594,7 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob

} else if (agg_type == PTR) {
byte *p = *(void**)self->addr;
if (MP_OBJ_IS_SMALL_INT(t->items[1])) {
if (mp_obj_is_small_int(t->items[1])) {
uint val_type = GET_TYPE(MP_OBJ_SMALL_INT_VALUE(t->items[1]), VAL_TYPE_BITS);
return get_aligned(val_type, p, index);
} else {
Expand All @@ -618,7 +618,7 @@ STATIC mp_obj_t uctypes_struct_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_uctypes_struct_t *self = MP_OBJ_TO_PTR(self_in);
switch (op) {
case MP_UNARY_OP_INT:
if (MP_OBJ_IS_TYPE(self->desc, &mp_type_tuple)) {
if (mp_obj_is_type(self->desc, &mp_type_tuple)) {
mp_obj_tuple_t *t = MP_OBJ_TO_PTR(self->desc);
mp_int_t offset = MP_OBJ_SMALL_INT_VALUE(t->items[0]);
uint agg_type = GET_TYPE(offset, AGG_TYPE_BITS);
Expand Down
2 changes: 1 addition & 1 deletion extmod/moduheapq.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
// the algorithm here is modelled on CPython's heapq.py

STATIC mp_obj_list_t *get_heap(mp_obj_t heap_in) {
if (!MP_OBJ_IS_TYPE(heap_in, &mp_type_list)) {
if (!mp_obj_is_type(heap_in, &mp_type_list)) {
mp_raise_TypeError("heap must be a list");
}
return MP_OBJ_TO_PTR(heap_in);
Expand Down
8 changes: 4 additions & 4 deletions extmod/moduselect.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ STATIC void poll_map_add(mp_map_t *poll_map, const mp_obj_t *obj, mp_uint_t obj_
STATIC mp_uint_t poll_map_poll(mp_map_t *poll_map, size_t *rwx_num) {
mp_uint_t n_ready = 0;
for (mp_uint_t i = 0; i < poll_map->alloc; ++i) {
if (!MP_MAP_SLOT_IS_FILLED(poll_map, i)) {
if (!mp_map_slot_is_filled(poll_map, i)) {
continue;
}

Expand Down Expand Up @@ -155,7 +155,7 @@ STATIC mp_obj_t select_select(uint n_args, const mp_obj_t *args) {
list_array[2] = mp_obj_new_list(rwx_len[2], NULL);
rwx_len[0] = rwx_len[1] = rwx_len[2] = 0;
for (mp_uint_t i = 0; i < poll_map.alloc; ++i) {
if (!MP_MAP_SLOT_IS_FILLED(&poll_map, i)) {
if (!mp_map_slot_is_filled(&poll_map, i)) {
continue;
}
poll_obj_t *poll_obj = MP_OBJ_TO_PTR(poll_map.table[i].value);
Expand Down Expand Up @@ -266,7 +266,7 @@ STATIC mp_obj_t poll_poll(size_t n_args, const mp_obj_t *args) {
mp_obj_list_t *ret_list = MP_OBJ_TO_PTR(mp_obj_new_list(n_ready, NULL));
n_ready = 0;
for (mp_uint_t i = 0; i < self->poll_map.alloc; ++i) {
if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) {
if (!mp_map_slot_is_filled(&self->poll_map, i)) {
continue;
}
poll_obj_t *poll_obj = MP_OBJ_TO_PTR(self->poll_map.table[i].value);
Expand Down Expand Up @@ -309,7 +309,7 @@ STATIC mp_obj_t poll_iternext(mp_obj_t self_in) {

for (mp_uint_t i = self->iter_idx; i < self->poll_map.alloc; ++i) {
self->iter_idx++;
if (!MP_MAP_SLOT_IS_FILLED(&self->poll_map, i)) {
if (!mp_map_slot_is_filled(&self->poll_map, i)) {
continue;
}
poll_obj_t *poll_obj = MP_OBJ_TO_PTR(self->poll_map.table[i].value);
Expand Down
2 changes: 1 addition & 1 deletion extmod/modutimeq.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
}
mp_obj_list_t *ret = MP_OBJ_TO_PTR(list_ref);
if (!MP_OBJ_IS_TYPE(list_ref, &mp_type_list) || ret->len < 3) {
if (!mp_obj_is_type(list_ref, &mp_type_list) || ret->len < 3) {
mp_raise_TypeError(NULL);
}

Expand Down
4 changes: 2 additions & 2 deletions extmod/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) {
mp_vfs_mount_t *vfs = NULL;
size_t mnt_len;
const char *mnt_str = NULL;
if (MP_OBJ_IS_STR(mnt_in)) {
if (mp_obj_is_str(mnt_in)) {
mnt_str = mp_obj_str_get_data(mnt_in, &mnt_len);
}
for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) {
Expand Down Expand Up @@ -270,7 +270,7 @@ mp_obj_t mp_vfs_open(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args)

#if MICROPY_VFS_POSIX
// If the file is an integer then delegate straight to the POSIX handler
if (MP_OBJ_IS_SMALL_INT(args[ARG_file].u_obj)) {
if (mp_obj_is_small_int(args[ARG_file].u_obj)) {
return mp_vfs_posix_file_open(&mp_type_textio, args[ARG_file].u_obj, args[ARG_mode].u_obj);
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion extmod/vfs_posix.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ STATIC mp_obj_t vfs_posix_open(mp_obj_t self_in, mp_obj_t path_in, mp_obj_t mode
&& (strchr(mode, 'w') != NULL || strchr(mode, 'a') != NULL || strchr(mode, '+') != NULL)) {
mp_raise_OSError(MP_EROFS);
}
if (!MP_OBJ_IS_SMALL_INT(path_in)) {
if (!mp_obj_is_small_int(path_in)) {
path_in = vfs_posix_get_path_obj(self, path_in);
}
return mp_vfs_posix_file_open(&mp_type_textio, path_in, mode_in);
Expand Down
2 changes: 1 addition & 1 deletion extmod/vfs_posix_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ mp_obj_t mp_vfs_posix_file_open(const mp_obj_type_t *type, mp_obj_t file_in, mp_

mp_obj_t fid = file_in;

if (MP_OBJ_IS_SMALL_INT(fid)) {
if (mp_obj_is_small_int(fid)) {
o->fd = MP_OBJ_SMALL_INT_VALUE(fid);
return MP_OBJ_FROM_PTR(o);
}
Expand Down
4 changes: 2 additions & 2 deletions ports/cc3200/hal/cc3200_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ void mp_hal_stdout_tx_str(const char *str) {

void mp_hal_stdout_tx_strn(const char *str, size_t len) {
if (MP_STATE_PORT(os_term_dup_obj)) {
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
if (mp_obj_is_type(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len);
} else {
MP_STATE_PORT(os_term_dup_obj)->write[2] = mp_obj_new_str_of_type(&mp_type_str, (const byte *)str, len);
Expand Down Expand Up @@ -184,7 +184,7 @@ int mp_hal_stdin_rx_chr(void) {
if (telnet_rx_any()) {
return telnet_rx_char();
} else if (MP_STATE_PORT(os_term_dup_obj)) { // then the stdio_dup
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
if (mp_obj_is_type(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
if (uart_rx_any(MP_STATE_PORT(os_term_dup_obj)->stream_o)) {
return uart_rx_char(MP_STATE_PORT(os_term_dup_obj)->stream_o);
}
Expand Down
2 changes: 1 addition & 1 deletion ports/cc3200/mods/modmachine.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ STATIC mp_obj_t machine_unique_id(void) {
STATIC MP_DEFINE_CONST_FUN_OBJ_0(machine_unique_id_obj, machine_unique_id);

STATIC mp_obj_t machine_main(mp_obj_t main) {
if (MP_OBJ_IS_STR(main)) {
if (mp_obj_is_str(main)) {
MP_STATE_PORT(machine_config_main) = main;
} else {
mp_raise_ValueError(mpexception_value_invalid_arguments);
Expand Down
2 changes: 1 addition & 1 deletion ports/cc3200/mods/moduos.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ STATIC mp_obj_t os_dupterm(uint n_args, const mp_obj_t *args) {
if (stream_o == mp_const_none) {
MP_STATE_PORT(os_term_dup_obj) = MP_OBJ_NULL;
} else {
if (!MP_OBJ_IS_TYPE(stream_o, &pyb_uart_type)) {
if (!mp_obj_is_type(stream_o, &pyb_uart_type)) {
// must be a stream-like object providing at least read and write methods
mp_load_method(stream_o, MP_QSTR_read, os_term_dup_obj.read);
mp_load_method(stream_o, MP_QSTR_write, os_term_dup_obj.write);
Expand Down
2 changes: 1 addition & 1 deletion ports/cc3200/mods/modwlan.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ STATIC mp_obj_t wlan_ifconfig(size_t n_args, const mp_obj_t *pos_args, mp_map_t
};
return mp_obj_new_tuple(4, ifconfig);
} else { // set the configuration
if (MP_OBJ_IS_TYPE(args[1].u_obj, &mp_type_tuple)) {
if (mp_obj_is_type(args[1].u_obj, &mp_type_tuple)) {
// set a static ip
mp_obj_t *items;
mp_obj_get_array_fixed_n(args[1].u_obj, 4, &items);
Expand Down
2 changes: 1 addition & 1 deletion ports/cc3200/mods/pybpin.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ pin_obj_t *pin_find(mp_obj_t user_obj) {
pin_obj_t *pin_obj;

// if a pin was provided, use it
if (MP_OBJ_IS_TYPE(user_obj, &pin_type)) {
if (mp_obj_is_type(user_obj, &pin_type)) {
pin_obj = user_obj;
return pin_obj;
}
Expand Down
2 changes: 1 addition & 1 deletion ports/cc3200/mods/pybrtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ STATIC mp_obj_t pyb_rtc_alarm(size_t n_args, const mp_obj_t *pos_args, mp_map_t
uint32_t f_seconds;
uint16_t f_mseconds;
bool repeat = args[2].u_bool;
if (MP_OBJ_IS_TYPE(args[1].u_obj, &mp_type_tuple)) { // datetime tuple given
if (mp_obj_is_type(args[1].u_obj, &mp_type_tuple)) { // datetime tuple given
// repeat cannot be used with a datetime tuple
if (repeat) {
mp_raise_ValueError(mpexception_value_invalid_arguments);
Expand Down
4 changes: 2 additions & 2 deletions ports/esp32/modnetwork.c
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) {
return mp_obj_new_tuple(4, tuple);
} else {
// set
if (MP_OBJ_IS_TYPE(args[1], &mp_type_tuple) || MP_OBJ_IS_TYPE(args[1], &mp_type_list)) {
if (mp_obj_is_type(args[1], &mp_type_tuple) || mp_obj_is_type(args[1], &mp_type_list)) {
mp_obj_t *items;
mp_obj_get_array_fixed_n(args[1], 4, &items);
netutils_parse_ipv4_addr(items[0], (void*)&info.ip, NETUTILS_BIG);
Expand Down Expand Up @@ -518,7 +518,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
if (kwargs->used != 0) {

for (size_t i = 0; i < kwargs->alloc; i++) {
if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) {
if (mp_map_slot_is_filled(kwargs, i)) {
int req_if = -1;

#define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
Expand Down
2 changes: 1 addition & 1 deletion ports/esp32/modsocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ static int _socket_getaddrinfo2(const mp_obj_t host, const mp_obj_t portx, struc
};

mp_obj_t port = portx;
if (MP_OBJ_IS_SMALL_INT(port)) {
if (mp_obj_is_small_int(port)) {
// This is perverse, because lwip_getaddrinfo promptly converts it back to an int, but
// that's the API we have to work with ...
port = mp_obj_str_binary_op(MP_BINARY_OP_MODULO, mp_obj_new_str_via_qstr("%s", 2), port);
Expand Down
2 changes: 1 addition & 1 deletion ports/esp8266/modesp.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ STATIC mp_obj_t esp_flash_read(mp_obj_t offset_in, mp_obj_t len_or_buf_in) {

mp_int_t len;
byte *buf;
bool alloc_buf = MP_OBJ_IS_INT(len_or_buf_in);
bool alloc_buf = mp_obj_is_int(len_or_buf_in);

if (alloc_buf) {
len = mp_obj_get_int(len_or_buf_in);
Expand Down
2 changes: 1 addition & 1 deletion ports/esp8266/modnetwork.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
if (kwargs->used != 0) {

for (mp_uint_t i = 0; i < kwargs->alloc; i++) {
if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) {
if (mp_map_slot_is_filled(kwargs, i)) {
#define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
switch ((uintptr_t)kwargs->table[i].key) {
case QS(MP_QSTR_mac): {
Expand Down
4 changes: 2 additions & 2 deletions ports/nrf/boards/microbit/modules/microbitdisplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ mp_obj_t microbit_display_show_func(mp_uint_t n_args, const mp_obj_t *pos_args,
bool wait = args[3].u_bool;
bool loop = args[4].u_bool;

if (MP_OBJ_IS_STR(image)) {
if (mp_obj_is_str(image)) {
// arg is a string object
mp_uint_t len;
const char *str = mp_obj_str_get_data(image, &len);
Expand Down Expand Up @@ -296,7 +296,7 @@ static void draw_object(mp_obj_t obj) {
}
} else if (mp_obj_get_type(obj) == &microbit_image_type) {
microbit_display_show(display, (microbit_image_obj_t *)obj);
} else if (MP_OBJ_IS_STR(obj)) {
} else if (mp_obj_is_str(obj)) {
mp_uint_t len;
const char *str = mp_obj_str_get_data(obj, &len);
if (len == 1) {
Expand Down
2 changes: 1 addition & 1 deletion ports/nrf/boards/microbit/modules/microbitimage.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
}

case 1: {
if (MP_OBJ_IS_STR(args[0])) {
if (mp_obj_is_str(args[0])) {
// arg is a string object
mp_uint_t len;
const char *str = mp_obj_str_get_data(args[0], &len);
Expand Down
6 changes: 3 additions & 3 deletions ports/nrf/modules/machine/pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void pin_init0(void) {
const pin_obj_t *pin_find(mp_obj_t user_obj) {
const pin_obj_t *pin_obj;
// If pin is SMALL_INT
if (MP_OBJ_IS_SMALL_INT(user_obj)) {
if (mp_obj_is_small_int(user_obj)) {
uint8_t value = MP_OBJ_SMALL_INT_VALUE(user_obj);
for (uint8_t i = 0; i < machine_pin_num_of_pins; i++) {
if (machine_pin_obj[i].pin == value) {
Expand All @@ -136,7 +136,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
}

// If a pin was provided, then use it
if (MP_OBJ_IS_TYPE(user_obj, &pin_type)) {
if (mp_obj_is_type(user_obj, &pin_type)) {
pin_obj = user_obj;
if (pin_class_debug) {
printf("Pin map passed pin ");
Expand All @@ -149,7 +149,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
if (MP_STATE_PORT(pin_class_mapper) != mp_const_none) {
pin_obj = mp_call_function_1(MP_STATE_PORT(pin_class_mapper), user_obj);
if (pin_obj != mp_const_none) {
if (!MP_OBJ_IS_TYPE(pin_obj, &pin_type)) {
if (!mp_obj_is_type(pin_obj, &pin_type)) {
mp_raise_ValueError("Pin.mapper didn't return a Pin object");
}
if (pin_class_debug) {
Expand Down
2 changes: 1 addition & 1 deletion ports/nrf/modules/machine/pwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void pwm_init0(void) {


STATIC int hard_pwm_find(mp_obj_t id) {
if (MP_OBJ_IS_INT(id)) {
if (mp_obj_is_int(id)) {
// given an integer id
int pwm_id = mp_obj_get_int(id);
if (pwm_id >= 0 && pwm_id < MP_ARRAY_SIZE(machine_hard_pwm_obj)) {
Expand Down
Loading
0