From 6e30f96b0b0ab14853085e5300d80d7c1a6f67c5 Mon Sep 17 00:00:00 2001 From: Damien George Date: Wed, 30 Jan 2019 22:05:48 +1100 Subject: [PATCH] ports: Convert legacy uppercase macro names to lowercase. --- ports/cc3200/hal/cc3200_hal.c | 4 ++-- ports/cc3200/mods/modmachine.c | 2 +- ports/cc3200/mods/moduos.c | 2 +- ports/cc3200/mods/modwlan.c | 2 +- ports/cc3200/mods/pybpin.c | 2 +- ports/cc3200/mods/pybrtc.c | 2 +- ports/esp32/modnetwork.c | 4 ++-- ports/esp32/modsocket.c | 2 +- ports/esp8266/modesp.c | 2 +- ports/esp8266/modnetwork.c | 2 +- ports/nrf/boards/microbit/modules/microbitdisplay.c | 4 ++-- ports/nrf/boards/microbit/modules/microbitimage.c | 2 +- ports/nrf/modules/machine/pin.c | 6 +++--- ports/nrf/modules/machine/pwm.c | 2 +- ports/nrf/modules/machine/rtcounter.c | 2 +- ports/nrf/modules/machine/spi.c | 2 +- ports/nrf/modules/machine/timer.c | 2 +- ports/nrf/modules/music/modmusic.c | 2 +- ports/nrf/modules/ubluepy/ubluepy_characteristic.c | 2 +- ports/nrf/modules/ubluepy/ubluepy_peripheral.c | 4 ++-- ports/nrf/modules/ubluepy/ubluepy_service.c | 4 ++-- ports/nrf/modules/ubluepy/ubluepy_uuid.c | 6 +++--- ports/stm32/adc.c | 2 +- ports/stm32/bufhelper.c | 4 ++-- ports/stm32/can.c | 8 ++++---- ports/stm32/dac.c | 2 +- ports/stm32/extint.c | 4 ++-- ports/stm32/machine_i2c.c | 2 +- ports/stm32/machine_uart.c | 2 +- ports/stm32/main.c | 2 +- ports/stm32/pin.c | 4 ++-- ports/stm32/pyb_i2c.c | 2 +- ports/stm32/spi.c | 6 +++--- ports/stm32/timer.c | 6 +++--- ports/teensy/main.c | 6 +++--- ports/teensy/reg.c | 2 +- ports/teensy/timer.c | 4 ++-- ports/teensy/uart.c | 2 +- ports/unix/coverage.c | 2 +- ports/unix/file.c | 2 +- ports/unix/modffi.c | 8 ++++---- ports/unix/modjni.c | 4 ++-- ports/unix/modtermios.c | 2 +- ports/unix/moduselect.c | 4 ++-- ports/unix/modusocket.c | 10 +++++----- ports/zephyr/machine_pin.c | 2 +- 46 files changed, 77 insertions(+), 77 deletions(-) diff --git a/ports/cc3200/hal/cc3200_hal.c b/ports/cc3200/hal/cc3200_hal.c index 0285d05856..526874f33b 100644 --- a/ports/cc3200/hal/cc3200_hal.c +++ b/ports/cc3200/hal/cc3200_hal.c @@ -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); @@ -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); } diff --git a/ports/cc3200/mods/modmachine.c b/ports/cc3200/mods/modmachine.c index 1ae26f3be9..9e49e23436 100644 --- a/ports/cc3200/mods/modmachine.c +++ b/ports/cc3200/mods/modmachine.c @@ -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); diff --git a/ports/cc3200/mods/moduos.c b/ports/cc3200/mods/moduos.c index 7d99c8e80d..4c9d4a87a7 100644 --- a/ports/cc3200/mods/moduos.c +++ b/ports/cc3200/mods/moduos.c @@ -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); diff --git a/ports/cc3200/mods/modwlan.c b/ports/cc3200/mods/modwlan.c index 8acc89da38..d6f7638c70 100644 --- a/ports/cc3200/mods/modwlan.c +++ b/ports/cc3200/mods/modwlan.c @@ -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); diff --git a/ports/cc3200/mods/pybpin.c b/ports/cc3200/mods/pybpin.c index 9e7526fa91..3872f70c5f 100644 --- a/ports/cc3200/mods/pybpin.c +++ b/ports/cc3200/mods/pybpin.c @@ -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; } diff --git a/ports/cc3200/mods/pybrtc.c b/ports/cc3200/mods/pybrtc.c index e7b9cf258f..a8e001efb4 100644 --- a/ports/cc3200/mods/pybrtc.c +++ b/ports/cc3200/mods/pybrtc.c @@ -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); diff --git a/ports/esp32/modnetwork.c b/ports/esp32/modnetwork.c index e2e1560c1a..6342f336b0 100644 --- a/ports/esp32/modnetwork.c +++ b/ports/esp32/modnetwork.c @@ -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); @@ -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) diff --git a/ports/esp32/modsocket.c b/ports/esp32/modsocket.c index 9d14fd46a1..49e48aaa31 100644 --- a/ports/esp32/modsocket.c +++ b/ports/esp32/modsocket.c @@ -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); diff --git a/ports/esp8266/modesp.c b/ports/esp8266/modesp.c index 46cd24c030..6c9fa9e131 100644 --- a/ports/esp8266/modesp.c +++ b/ports/esp8266/modesp.c @@ -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); diff --git a/ports/esp8266/modnetwork.c b/ports/esp8266/modnetwork.c index 6ef2d315d6..c58aae1cbd 100644 --- a/ports/esp8266/modnetwork.c +++ b/ports/esp8266/modnetwork.c @@ -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): { diff --git a/ports/nrf/boards/microbit/modules/microbitdisplay.c b/ports/nrf/boards/microbit/modules/microbitdisplay.c index e8e7b2befb..11ec004d07 100644 --- a/ports/nrf/boards/microbit/modules/microbitdisplay.c +++ b/ports/nrf/boards/microbit/modules/microbitdisplay.c @@ -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); @@ -296,7 +296,7 @@ static void draw_object(mp_obj_t obj) { } } else if (mp_obj_get_type(obj) == µbit_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) { diff --git a/ports/nrf/boards/microbit/modules/microbitimage.c b/ports/nrf/boards/microbit/modules/microbitimage.c index 046b9255cf..aa519b4a2a 100644 --- a/ports/nrf/boards/microbit/modules/microbitimage.c +++ b/ports/nrf/boards/microbit/modules/microbitimage.c @@ -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); diff --git a/ports/nrf/modules/machine/pin.c b/ports/nrf/modules/machine/pin.c index 8a16dc4081..d56abfd04e 100644 --- a/ports/nrf/modules/machine/pin.c +++ b/ports/nrf/modules/machine/pin.c @@ -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) { @@ -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 "); @@ -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) { diff --git a/ports/nrf/modules/machine/pwm.c b/ports/nrf/modules/machine/pwm.c index 8e5c2e23fd..e3b40930fd 100644 --- a/ports/nrf/modules/machine/pwm.c +++ b/ports/nrf/modules/machine/pwm.c @@ -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)) { diff --git a/ports/nrf/modules/machine/rtcounter.c b/ports/nrf/modules/machine/rtcounter.c index 0afdf5bd21..d51791905c 100644 --- a/ports/nrf/modules/machine/rtcounter.c +++ b/ports/nrf/modules/machine/rtcounter.c @@ -159,7 +159,7 @@ STATIC mp_obj_t machine_rtc_make_new(const mp_obj_type_t *type, size_t n_args, s if (args[ARG_callback].u_obj == mp_const_none) { config->callback = NULL; - } else if (MP_OBJ_IS_FUN(args[ARG_callback].u_obj)) { + } else if (mp_obj_is_fun(args[ARG_callback].u_obj)) { config->callback = args[ARG_callback].u_obj; } else { mp_raise_ValueError("callback must be a function"); diff --git a/ports/nrf/modules/machine/spi.c b/ports/nrf/modules/machine/spi.c index 95331e2414..1c401b76d2 100644 --- a/ports/nrf/modules/machine/spi.c +++ b/ports/nrf/modules/machine/spi.c @@ -131,7 +131,7 @@ void spi_init0(void) { } STATIC int spi_find(mp_obj_t id) { - if (MP_OBJ_IS_STR(id)) { + if (mp_obj_is_str(id)) { // given a string id const char *port = mp_obj_str_get_str(id); if (0) { diff --git a/ports/nrf/modules/machine/timer.c b/ports/nrf/modules/machine/timer.c index 4b7c995397..00a3591185 100644 --- a/ports/nrf/modules/machine/timer.c +++ b/ports/nrf/modules/machine/timer.c @@ -126,7 +126,7 @@ STATIC mp_obj_t machine_timer_make_new(const mp_obj_type_t *type, size_t n_args, machine_timer_obj_t *self = (machine_timer_obj_t*)&machine_timer_obj[timer_id]; - if (MP_OBJ_IS_FUN(args[ARG_callback].u_obj)) { + if (mp_obj_is_fun(args[ARG_callback].u_obj)) { machine_timer_callbacks[timer_id] = args[ARG_callback].u_obj; } else if (args[ARG_callback].u_obj == mp_const_none) { machine_timer_callbacks[timer_id] = NULL; diff --git a/ports/nrf/modules/music/modmusic.c b/ports/nrf/modules/music/modmusic.c index 71f6d3658b..84a014c12d 100644 --- a/ports/nrf/modules/music/modmusic.c +++ b/ports/nrf/modules/music/modmusic.c @@ -320,7 +320,7 @@ STATIC mp_obj_t microbit_music_play(mp_uint_t n_args, const mp_obj_t *pos_args, // get either a single note or a list of notes mp_uint_t len; mp_obj_t *items; - if (MP_OBJ_IS_STR_OR_BYTES(args[0].u_obj)) { + if (mp_obj_is_str_or_bytes(args[0].u_obj)) { len = 1; items = &args[0].u_obj; } else { diff --git a/ports/nrf/modules/ubluepy/ubluepy_characteristic.c b/ports/nrf/modules/ubluepy/ubluepy_characteristic.c index e271132cb4..2ca7f2f427 100644 --- a/ports/nrf/modules/ubluepy/ubluepy_characteristic.c +++ b/ports/nrf/modules/ubluepy/ubluepy_characteristic.c @@ -59,7 +59,7 @@ STATIC mp_obj_t ubluepy_characteristic_make_new(const mp_obj_type_t *type, size_ return MP_OBJ_FROM_PTR(s); } - if (MP_OBJ_IS_TYPE(uuid_obj, &ubluepy_uuid_type)) { + if (mp_obj_is_type(uuid_obj, &ubluepy_uuid_type)) { s->p_uuid = MP_OBJ_TO_PTR(uuid_obj); // (void)sd_characterstic_add(s); } else { diff --git a/ports/nrf/modules/ubluepy/ubluepy_peripheral.c b/ports/nrf/modules/ubluepy/ubluepy_peripheral.c index 48e4673748..3a45e56a07 100644 --- a/ports/nrf/modules/ubluepy/ubluepy_peripheral.c +++ b/ports/nrf/modules/ubluepy/ubluepy_peripheral.c @@ -193,7 +193,7 @@ STATIC mp_obj_t peripheral_advertise(mp_uint_t n_args, const mp_obj_t *pos_args, ubluepy_advertise_data_t adv_data; memset(&adv_data, 0, sizeof(ubluepy_advertise_data_t)); - if (device_name_obj != mp_const_none && MP_OBJ_IS_STR(device_name_obj)) { + if (device_name_obj != mp_const_none && mp_obj_is_str(device_name_obj)) { GET_STR_DATA_LEN(device_name_obj, str_data, str_len); adv_data.p_device_name = (uint8_t *)str_data; @@ -361,7 +361,7 @@ STATIC mp_obj_t peripheral_connect(mp_uint_t n_args, const mp_obj_t *pos_args, m ble_drv_gap_event_handler_set(MP_OBJ_FROM_PTR(self), gap_event_handler); - if (MP_OBJ_IS_STR(dev_addr)) { + if (mp_obj_is_str(dev_addr)) { GET_STR_DATA_LEN(dev_addr, str_data, str_len); if (str_len == 17) { // Example "11:22:33:aa:bb:cc" diff --git a/ports/nrf/modules/ubluepy/ubluepy_service.c b/ports/nrf/modules/ubluepy/ubluepy_service.c index e83ed1f223..e5bf42a09f 100644 --- a/ports/nrf/modules/ubluepy/ubluepy_service.c +++ b/ports/nrf/modules/ubluepy/ubluepy_service.c @@ -61,7 +61,7 @@ STATIC mp_obj_t ubluepy_service_make_new(const mp_obj_type_t *type, size_t n_arg return MP_OBJ_FROM_PTR(s); } - if (MP_OBJ_IS_TYPE(uuid_obj, &ubluepy_uuid_type)) { + if (mp_obj_is_type(uuid_obj, &ubluepy_uuid_type)) { s->p_uuid = MP_OBJ_TO_PTR(uuid_obj); uint8_t type = args[ARG_NEW_TYPE].u_int; @@ -124,7 +124,7 @@ STATIC mp_obj_t service_get_characteristic(mp_obj_t self_in, mp_obj_t uuid) { ubluepy_uuid_obj_t * p_uuid = MP_OBJ_TO_PTR(uuid); // validate that there is an UUID object passed in as parameter - if (!(MP_OBJ_IS_TYPE(uuid, &ubluepy_uuid_type))) { + if (!(mp_obj_is_type(uuid, &ubluepy_uuid_type))) { mp_raise_ValueError("Invalid UUID parameter"); } diff --git a/ports/nrf/modules/ubluepy/ubluepy_uuid.c b/ports/nrf/modules/ubluepy/ubluepy_uuid.c index 98dba912a7..cbcb100968 100644 --- a/ports/nrf/modules/ubluepy/ubluepy_uuid.c +++ b/ports/nrf/modules/ubluepy/ubluepy_uuid.c @@ -66,11 +66,11 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args, return MP_OBJ_FROM_PTR(s); } - if (MP_OBJ_IS_INT(uuid_obj)) { + if (mp_obj_is_int(uuid_obj)) { s->type = UBLUEPY_UUID_16_BIT; s->value[1] = (((uint16_t)mp_obj_get_int(uuid_obj)) >> 8) & 0xFF; s->value[0] = ((uint8_t)mp_obj_get_int(uuid_obj)) & 0xFF; - } else if (MP_OBJ_IS_STR(uuid_obj)) { + } else if (mp_obj_is_str(uuid_obj)) { GET_STR_DATA_LEN(uuid_obj, str_data, str_len); if (str_len == 6) { // Assume hex digit prefixed with 0x s->type = UBLUEPY_UUID_16_BIT; @@ -124,7 +124,7 @@ STATIC mp_obj_t ubluepy_uuid_make_new(const mp_obj_type_t *type, size_t n_args, } else { mp_raise_ValueError("Invalid UUID string length"); } - } else if (MP_OBJ_IS_TYPE(uuid_obj, &ubluepy_uuid_type)) { + } else if (mp_obj_is_type(uuid_obj, &ubluepy_uuid_type)) { // deep copy instance ubluepy_uuid_obj_t * p_old = MP_OBJ_TO_PTR(uuid_obj); s->type = p_old->type; diff --git a/ports/stm32/adc.c b/ports/stm32/adc.c index 376b48d4ed..73588e4a3f 100644 --- a/ports/stm32/adc.c +++ b/ports/stm32/adc.c @@ -395,7 +395,7 @@ STATIC mp_obj_t adc_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_ uint32_t channel; - if (MP_OBJ_IS_INT(pin_obj)) { + if (mp_obj_is_int(pin_obj)) { channel = adc_get_internal_channel(mp_obj_get_int(pin_obj)); } else { const pin_obj_t *pin = pin_find(pin_obj); diff --git a/ports/stm32/bufhelper.c b/ports/stm32/bufhelper.c index 79511969b7..5e9555f534 100644 --- a/ports/stm32/bufhelper.c +++ b/ports/stm32/bufhelper.c @@ -28,7 +28,7 @@ #include "bufhelper.h" void pyb_buf_get_for_send(mp_obj_t o, mp_buffer_info_t *bufinfo, byte *tmp_data) { - if (MP_OBJ_IS_INT(o)) { + if (mp_obj_is_int(o)) { tmp_data[0] = mp_obj_get_int(o); bufinfo->buf = tmp_data; bufinfo->len = 1; @@ -39,7 +39,7 @@ void pyb_buf_get_for_send(mp_obj_t o, mp_buffer_info_t *bufinfo, byte *tmp_data) } mp_obj_t pyb_buf_get_for_recv(mp_obj_t o, vstr_t *vstr) { - if (MP_OBJ_IS_INT(o)) { + if (mp_obj_is_int(o)) { // allocate a new bytearray of given length vstr_init_len(vstr, mp_obj_get_int(o)); return MP_OBJ_NULL; diff --git a/ports/stm32/can.c b/ports/stm32/can.c index b92389aaf0..2293f94db8 100644 --- a/ports/stm32/can.c +++ b/ports/stm32/can.c @@ -409,7 +409,7 @@ STATIC mp_obj_t pyb_can_make_new(const mp_obj_type_t *type, size_t n_args, size_ // work out port mp_uint_t can_idx; - if (MP_OBJ_IS_STR(args[0])) { + if (mp_obj_is_str(args[0])) { const char *port = mp_obj_str_get_str(args[0]); if (0) { #ifdef MICROPY_HW_CAN1_NAME @@ -540,7 +540,7 @@ STATIC mp_obj_t pyb_can_info(size_t n_args, const mp_obj_t *args) { if (n_args == 1) { list = MP_OBJ_TO_PTR(mp_obj_new_list(8, NULL)); } else { - if (!MP_OBJ_IS_TYPE(args[1], &mp_type_list)) { + if (!mp_obj_is_type(args[1], &mp_type_list)) { mp_raise_TypeError(NULL); } list = MP_OBJ_TO_PTR(args[1]); @@ -709,7 +709,7 @@ STATIC mp_obj_t pyb_can_recv(size_t n_args, const mp_obj_t *pos_args, mp_map_t * items[3] = mp_obj_new_bytes(&rx_msg.Data[0], rx_msg.DLC); } else { // User should provide a list of length at least 4 to hold the values - if (!MP_OBJ_IS_TYPE(ret_obj, &mp_type_list)) { + if (!mp_obj_is_type(ret_obj, &mp_type_list)) { mp_raise_TypeError(NULL); } mp_obj_list_t *list = MP_OBJ_TO_PTR(ret_obj); @@ -719,7 +719,7 @@ STATIC mp_obj_t pyb_can_recv(size_t n_args, const mp_obj_t *pos_args, mp_map_t * items = list->items; // Fourth element must be a memoryview which we assume points to a // byte-like array which is large enough, and then we resize it inplace - if (!MP_OBJ_IS_TYPE(items[3], &mp_type_memoryview)) { + if (!mp_obj_is_type(items[3], &mp_type_memoryview)) { mp_raise_TypeError(NULL); } mp_obj_array_t *mv = MP_OBJ_TO_PTR(items[3]); diff --git a/ports/stm32/dac.c b/ports/stm32/dac.c index 808e4d1bd1..3a92258ffb 100644 --- a/ports/stm32/dac.c +++ b/ports/stm32/dac.c @@ -238,7 +238,7 @@ STATIC mp_obj_t pyb_dac_make_new(const mp_obj_type_t *type, size_t n_args, size_ // get pin/channel to output on mp_int_t dac_id; - if (MP_OBJ_IS_INT(args[0])) { + if (mp_obj_is_int(args[0])) { dac_id = mp_obj_get_int(args[0]); } else { const pin_obj_t *pin = pin_find(args[0]); diff --git a/ports/stm32/extint.c b/ports/stm32/extint.c index b6e980101a..fedb60d139 100644 --- a/ports/stm32/extint.c +++ b/ports/stm32/extint.c @@ -163,7 +163,7 @@ uint extint_register(mp_obj_t pin_obj, uint32_t mode, uint32_t pull, mp_obj_t ca const pin_obj_t *pin = NULL; uint v_line; - if (MP_OBJ_IS_INT(pin_obj)) { + if (mp_obj_is_int(pin_obj)) { // If an integer is passed in, then use it to identify lines 16 thru 22 // We expect lines 0 thru 15 to be passed in as a pin, so that we can // get both the port number and line number. @@ -234,7 +234,7 @@ void extint_register_pin(const pin_obj_t *pin, uint32_t mode, bool hard_irq, mp_ // Check if the ExtInt line is already in use by another Pin/ExtInt mp_obj_t *cb = &MP_STATE_PORT(pyb_extint_callback)[line]; if (*cb != mp_const_none && MP_OBJ_FROM_PTR(pin) != pyb_extint_callback_arg[line]) { - if (MP_OBJ_IS_SMALL_INT(pyb_extint_callback_arg[line])) { + if (mp_obj_is_small_int(pyb_extint_callback_arg[line])) { nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "ExtInt vector %d is already in use", line)); } else { diff --git a/ports/stm32/machine_i2c.c b/ports/stm32/machine_i2c.c index b7a9ea69bf..940e98d715 100644 --- a/ports/stm32/machine_i2c.c +++ b/ports/stm32/machine_i2c.c @@ -197,7 +197,7 @@ mp_obj_t machine_hard_i2c_make_new(const mp_obj_type_t *type, size_t n_args, siz // work out i2c bus int i2c_id = 0; - if (MP_OBJ_IS_STR(args[ARG_id].u_obj)) { + if (mp_obj_is_str(args[ARG_id].u_obj)) { const char *port = mp_obj_str_get_str(args[ARG_id].u_obj); if (0) { #ifdef MICROPY_HW_I2C1_NAME diff --git a/ports/stm32/machine_uart.c b/ports/stm32/machine_uart.c index c453960467..c1e5948071 100644 --- a/ports/stm32/machine_uart.c +++ b/ports/stm32/machine_uart.c @@ -350,7 +350,7 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, size_t n_args, size // work out port int uart_id = 0; - if (MP_OBJ_IS_STR(args[0])) { + if (mp_obj_is_str(args[0])) { const char *port = mp_obj_str_get_str(args[0]); if (0) { #ifdef MICROPY_HW_UART1_NAME diff --git a/ports/stm32/main.c b/ports/stm32/main.c index 1a00ef3a18..3028f907b6 100644 --- a/ports/stm32/main.c +++ b/ports/stm32/main.c @@ -132,7 +132,7 @@ STATIC mp_obj_t pyb_main(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_a { MP_QSTR_opt, MP_ARG_INT, {.u_int = 0} } }; - if (MP_OBJ_IS_STR(pos_args[0])) { + if (mp_obj_is_str(pos_args[0])) { MP_STATE_PORT(pyb_config_main) = pos_args[0]; // parse args diff --git a/ports/stm32/pin.c b/ports/stm32/pin.c index 58c01e22cf..a8068d8998 100644 --- a/ports/stm32/pin.c +++ b/ports/stm32/pin.c @@ -105,7 +105,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) { const pin_obj_t *pin_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 = MP_OBJ_TO_PTR(user_obj); if (pin_class_debug) { printf("Pin map passed pin "); @@ -118,7 +118,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) { if (MP_STATE_PORT(pin_class_mapper) != mp_const_none) { mp_obj_t o = mp_call_function_1(MP_STATE_PORT(pin_class_mapper), user_obj); if (o != mp_const_none) { - if (!MP_OBJ_IS_TYPE(o, &pin_type)) { + if (!mp_obj_is_type(o, &pin_type)) { mp_raise_ValueError("Pin.mapper didn't return a Pin object"); } if (pin_class_debug) { diff --git a/ports/stm32/pyb_i2c.c b/ports/stm32/pyb_i2c.c index d6b9ec6cc1..233cbba512 100644 --- a/ports/stm32/pyb_i2c.c +++ b/ports/stm32/pyb_i2c.c @@ -636,7 +636,7 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_ // work out i2c bus int i2c_id = 0; - if (MP_OBJ_IS_STR(args[0])) { + if (mp_obj_is_str(args[0])) { const char *port = mp_obj_str_get_str(args[0]); if (0) { #ifdef MICROPY_HW_I2C1_NAME diff --git a/ports/stm32/spi.c b/ports/stm32/spi.c index ae97d9ab40..b7298b4aaa 100644 --- a/ports/stm32/spi.c +++ b/ports/stm32/spi.c @@ -121,7 +121,7 @@ void spi_init0(void) { } int spi_find_index(mp_obj_t id) { - if (MP_OBJ_IS_STR(id)) { + if (mp_obj_is_str(id)) { // given a string id const char *port = mp_obj_str_get_str(id); if (0) { @@ -583,10 +583,10 @@ void spi_print(const mp_print_t *print, const spi_t *spi_obj, bool legacy) { } const spi_t *spi_from_mp_obj(mp_obj_t o) { - if (MP_OBJ_IS_TYPE(o, &pyb_spi_type)) { + if (mp_obj_is_type(o, &pyb_spi_type)) { pyb_spi_obj_t *self = MP_OBJ_TO_PTR(o); return self->spi; - } else if (MP_OBJ_IS_TYPE(o, &machine_hard_spi_type)) { + } else if (mp_obj_is_type(o, &machine_hard_spi_type)) { machine_hard_spi_obj_t *self = MP_OBJ_TO_PTR(o); return self->spi; } else { diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c index 983f7cbc6f..28dc749b4e 100644 --- a/ports/stm32/timer.c +++ b/ports/stm32/timer.c @@ -275,7 +275,7 @@ STATIC uint32_t compute_prescaler_period_from_freq(pyb_timer_obj_t *self, mp_obj uint32_t period; if (0) { #if MICROPY_PY_BUILTINS_FLOAT - } else if (MP_OBJ_IS_TYPE(freq_in, &mp_type_float)) { + } else if (mp_obj_is_type(freq_in, &mp_type_float)) { float freq = mp_obj_get_float(freq_in); if (freq <= 0) { goto bad_freq; @@ -370,7 +370,7 @@ STATIC uint32_t compute_pwm_value_from_percent(uint32_t period, mp_obj_t percent uint32_t cmp; if (0) { #if MICROPY_PY_BUILTINS_FLOAT - } else if (MP_OBJ_IS_TYPE(percent_in, &mp_type_float)) { + } else if (mp_obj_is_type(percent_in, &mp_type_float)) { mp_float_t percent = mp_obj_get_float(percent_in); if (percent <= 0.0) { cmp = 0; @@ -988,7 +988,7 @@ STATIC mp_obj_t pyb_timer_channel(size_t n_args, const mp_obj_t *pos_args, mp_ma mp_obj_t pin_obj = args[2].u_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 argument needs to be be a Pin type"); } const pin_obj_t *pin = MP_OBJ_TO_PTR(pin_obj); diff --git a/ports/teensy/main.c b/ports/teensy/main.c index 3edaa28a06..3ae049883f 100644 --- a/ports/teensy/main.c +++ b/ports/teensy/main.c @@ -194,7 +194,7 @@ STATIC mp_obj_t pyb_config_main = MP_OBJ_NULL; STATIC mp_obj_t pyb_config_usb_mode = MP_OBJ_NULL; mp_obj_t pyb_source_dir(mp_obj_t source_dir) { - if (MP_OBJ_IS_STR(source_dir)) { + if (mp_obj_is_str(source_dir)) { pyb_config_source_dir = source_dir; } return mp_const_none; @@ -203,7 +203,7 @@ mp_obj_t pyb_source_dir(mp_obj_t source_dir) { MP_DEFINE_CONST_FUN_OBJ_1(pyb_source_dir_obj, pyb_source_dir); mp_obj_t pyb_main(mp_obj_t main) { - if (MP_OBJ_IS_STR(main)) { + if (mp_obj_is_str(main)) { pyb_config_main = main; } return mp_const_none; @@ -212,7 +212,7 @@ mp_obj_t pyb_main(mp_obj_t main) { MP_DEFINE_CONST_FUN_OBJ_1(pyb_main_obj, pyb_main); STATIC mp_obj_t pyb_usb_mode(mp_obj_t usb_mode) { - if (MP_OBJ_IS_STR(usb_mode)) { + if (mp_obj_is_str(usb_mode)) { pyb_config_usb_mode = usb_mode; } return mp_const_none; diff --git a/ports/teensy/reg.c b/ports/teensy/reg.c index cbc427d876..4f1fd52c29 100644 --- a/ports/teensy/reg.c +++ b/ports/teensy/reg.c @@ -18,7 +18,7 @@ mp_obj_t reg_cmd(void *base, reg_t *reg, mp_uint_t num_regs, uint n_args, const mp_uint_t addr = 0; - if (MP_OBJ_IS_STR(args[0])) { + if (mp_obj_is_str(args[0])) { const char *name = mp_obj_str_get_str(args[0]); mp_uint_t reg_idx; for (reg_idx = 0; reg_idx < num_regs; reg_idx++, reg++) { diff --git a/ports/teensy/timer.c b/ports/teensy/timer.c index b823e6c3b9..c958f5349f 100644 --- a/ports/teensy/timer.c +++ b/ports/teensy/timer.c @@ -142,7 +142,7 @@ STATIC uint32_t compute_pwm_value_from_percent(uint32_t period, mp_obj_t percent uint32_t cmp; if (0) { #if MICROPY_PY_BUILTINS_FLOAT - } else if (MP_OBJ_IS_TYPE(percent_in, &mp_type_float)) { + } else if (mp_obj_is_type(percent_in, &mp_type_float)) { float percent = mp_obj_get_float(percent_in); if (percent <= 0.0) { cmp = 0; @@ -496,7 +496,7 @@ STATIC mp_obj_t pyb_timer_channel(size_t n_args, const mp_obj_t *args, mp_map_t mp_obj_t pin_obj = vals[1].u_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 argument needs to be be a Pin type"); } const pin_obj_t *pin = pin_obj; diff --git a/ports/teensy/uart.c b/ports/teensy/uart.c index a8cfd63eac..ee0eae39ae 100644 --- a/ports/teensy/uart.c +++ b/ports/teensy/uart.c @@ -316,7 +316,7 @@ STATIC mp_obj_t pyb_uart_make_new(const mp_obj_type_t *type, uint n_args, uint n // work out port o->uart_id = 0; #if 0 - if (MP_OBJ_IS_STR(args[0])) { + if (mp_obj_is_str(args[0])) { const char *port = mp_obj_str_get_str(args[0]); if (0) { #if defined(PYBV10) diff --git a/ports/unix/coverage.c b/ports/unix/coverage.c index 7820f6d736..3c121a1538 100644 --- a/ports/unix/coverage.c +++ b/ports/unix/coverage.c @@ -250,7 +250,7 @@ STATIC mp_obj_t extra_coverage(void) { mp_printf(&mp_plat_print, "# str\n"); // intern string - mp_printf(&mp_plat_print, "%d\n", MP_OBJ_IS_QSTR(mp_obj_str_intern(mp_obj_new_str("intern me", 9)))); + mp_printf(&mp_plat_print, "%d\n", mp_obj_is_qstr(mp_obj_str_intern(mp_obj_new_str("intern me", 9)))); } // bytearray diff --git a/ports/unix/file.c b/ports/unix/file.c index a54d1d03df..bb841da209 100644 --- a/ports/unix/file.c +++ b/ports/unix/file.c @@ -192,7 +192,7 @@ STATIC mp_obj_t fdfile_open(const mp_obj_type_t *type, mp_arg_val_t *args) { mp_obj_t fid = args[0].u_obj; - 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); } diff --git a/ports/unix/modffi.c b/ports/unix/modffi.c index c262721ebb..4dea887688 100644 --- a/ports/unix/modffi.c +++ b/ports/unix/modffi.c @@ -126,7 +126,7 @@ STATIC ffi_type *char2ffi_type(char c) STATIC ffi_type *get_ffi_type(mp_obj_t o_in) { - if (MP_OBJ_IS_STR(o_in)) { + if (mp_obj_is_str(o_in)) { const char *s = mp_obj_str_get_str(o_in); ffi_type *t = char2ffi_type(*s); if (t != NULL) { @@ -370,9 +370,9 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const #endif } else if (a == mp_const_none) { values[i] = 0; - } else if (MP_OBJ_IS_INT(a)) { + } else if (mp_obj_is_int(a)) { values[i] = mp_obj_int_get_truncated(a); - } else if (MP_OBJ_IS_STR(a)) { + } else if (mp_obj_is_str(a)) { const char *s = mp_obj_str_get_str(a); values[i] = (ffi_arg)(intptr_t)s; } else if (((mp_obj_base_t*)MP_OBJ_TO_PTR(a))->type->buffer_p.get_buffer != NULL) { @@ -383,7 +383,7 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const goto error; } values[i] = (ffi_arg)(intptr_t)bufinfo.buf; - } else if (MP_OBJ_IS_TYPE(a, &fficallback_type)) { + } else if (mp_obj_is_type(a, &fficallback_type)) { mp_obj_fficallback_t *p = MP_OBJ_TO_PTR(a); values[i] = (ffi_arg)(intptr_t)p->func; } else { diff --git a/ports/unix/modjni.c b/ports/unix/modjni.c index 9e8c232094..902c34f10b 100644 --- a/ports/unix/modjni.c +++ b/ports/unix/modjni.c @@ -658,12 +658,12 @@ STATIC mp_obj_t mod_jni_array(mp_obj_t type_in, mp_obj_t size_in) { mp_int_t size = mp_obj_get_int(size_in); jobject res = NULL; - if (MP_OBJ_IS_TYPE(type_in, &jclass_type)) { + if (mp_obj_is_type(type_in, &jclass_type)) { mp_obj_jclass_t *jcls = MP_OBJ_TO_PTR(type_in); res = JJ(NewObjectArray, size, jcls->cls, NULL); - } else if (MP_OBJ_IS_STR(type_in)) { + } else if (mp_obj_is_str(type_in)) { const char *type = mp_obj_str_get_str(type_in); switch (*type) { case 'Z': diff --git a/ports/unix/modtermios.c b/ports/unix/modtermios.c index fe19aac83c..7e46ba2f52 100644 --- a/ports/unix/modtermios.c +++ b/ports/unix/modtermios.c @@ -77,7 +77,7 @@ STATIC mp_obj_t mod_termios_tcsetattr(mp_obj_t fd_in, mp_obj_t when_in, mp_obj_t when = TCSANOW; } - assert(MP_OBJ_IS_TYPE(attrs_in, &mp_type_list)); + assert(mp_obj_is_type(attrs_in, &mp_type_list)); mp_obj_list_t *attrs = MP_OBJ_TO_PTR(attrs_in); term.c_iflag = mp_obj_get_int(attrs->items[0]); diff --git a/ports/unix/moduselect.c b/ports/unix/moduselect.c index a95663e31f..d9b02ddc62 100644 --- a/ports/unix/moduselect.c +++ b/ports/unix/moduselect.c @@ -66,7 +66,7 @@ typedef struct _mp_obj_poll_t { } mp_obj_poll_t; STATIC int get_fd(mp_obj_t fdlike) { - if (MP_OBJ_IS_OBJ(fdlike)) { + if (mp_obj_is_obj(fdlike)) { const mp_stream_p_t *stream_p = mp_get_stream_raise(fdlike, MP_STREAM_OP_IOCTL); int err; mp_uint_t res = stream_p->ioctl(fdlike, MP_STREAM_GET_FILENO, 0, &err); @@ -80,7 +80,7 @@ STATIC int get_fd(mp_obj_t fdlike) { /// \method register(obj[, eventmask]) STATIC mp_obj_t poll_register(size_t n_args, const mp_obj_t *args) { mp_obj_poll_t *self = MP_OBJ_TO_PTR(args[0]); - bool is_fd = MP_OBJ_IS_INT(args[1]); + bool is_fd = mp_obj_is_int(args[1]); int fd = get_fd(args[1]); mp_uint_t flags; diff --git a/ports/unix/modusocket.c b/ports/unix/modusocket.c index 61402e001d..fd4092a622 100644 --- a/ports/unix/modusocket.c +++ b/ports/unix/modusocket.c @@ -299,7 +299,7 @@ STATIC mp_obj_t socket_setsockopt(size_t n_args, const mp_obj_t *args) { const void *optval; socklen_t optlen; int val; - if (MP_OBJ_IS_INT(args[3])) { + if (mp_obj_is_int(args[3])) { val = mp_obj_int_get_truncated(args[3]); optval = &val; optlen = sizeof(val); @@ -391,13 +391,13 @@ STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type_in, size_t n_args, siz int proto = 0; if (n_args > 0) { - assert(MP_OBJ_IS_SMALL_INT(args[0])); + assert(mp_obj_is_small_int(args[0])); family = MP_OBJ_SMALL_INT_VALUE(args[0]); if (n_args > 1) { - assert(MP_OBJ_IS_SMALL_INT(args[1])); + assert(mp_obj_is_small_int(args[1])); type = MP_OBJ_SMALL_INT_VALUE(args[1]); if (n_args > 2) { - assert(MP_OBJ_IS_SMALL_INT(args[2])); + assert(mp_obj_is_small_int(args[2])); proto = MP_OBJ_SMALL_INT_VALUE(args[2]); } } @@ -494,7 +494,7 @@ STATIC mp_obj_t mod_socket_getaddrinfo(size_t n_args, const mp_obj_t *args) { memset(&hints, 0, sizeof(hints)); // getaddrinfo accepts port in string notation, so however // it may seem stupid, we need to convert int to str - if (MP_OBJ_IS_SMALL_INT(args[1])) { + if (mp_obj_is_small_int(args[1])) { unsigned port = (unsigned short)MP_OBJ_SMALL_INT_VALUE(args[1]); snprintf(buf, sizeof(buf), "%u", port); serv = buf; diff --git a/ports/zephyr/machine_pin.c b/ports/zephyr/machine_pin.c index 4dcd956cf8..c4ea328a2a 100644 --- a/ports/zephyr/machine_pin.c +++ b/ports/zephyr/machine_pin.c @@ -84,7 +84,7 @@ mp_obj_t mp_pin_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, mp_arg_check_num(n_args, n_kw, 1, MP_OBJ_FUN_ARGS_MAX, true); // get the wanted port - if (!MP_OBJ_IS_TYPE(args[0], &mp_type_tuple)) { + if (!mp_obj_is_type(args[0], &mp_type_tuple)) { mp_raise_ValueError("Pin id must be tuple of (\"GPIO_x\", pin#)"); } mp_obj_t *items;