all: Make all mp_obj_type_t defs use MP_DEFINE_CONST_OBJ_TYPE.
In preparation for upcoming rework of mp_obj_type_t layout. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
committed by
Damien George
parent
cdb880789f
commit
662b9761b3
@@ -43,12 +43,14 @@ static mp_obj_t microbit_repeat_iter_next(mp_obj_t iter_in) {
|
||||
return mp_obj_subscr(iter->iterable, MP_OBJ_NEW_SMALL_INT(iter->index), MP_OBJ_SENTINEL);
|
||||
}
|
||||
|
||||
const mp_obj_type_t microbit_repeat_iterator_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_iterator,
|
||||
.getiter = mp_identity_getiter,
|
||||
.iternext = microbit_repeat_iter_next,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
microbit_repeat_iterator_type,
|
||||
MP_QSTR_iterator,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
getiter, mp_identity_getiter,
|
||||
iternext, microbit_repeat_iter_next
|
||||
);
|
||||
|
||||
mp_obj_t microbit_repeat_iterator(mp_obj_t iterable) {
|
||||
repeat_iterator_t *result = mp_obj_malloc(repeat_iterator_t, µbit_repeat_iterator_type);
|
||||
|
||||
@@ -542,11 +542,13 @@ STATIC const mp_rom_map_elem_t microbit_display_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(microbit_display_locals_dict, microbit_display_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t microbit_display_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_MicroBitDisplay,
|
||||
.locals_dict = (mp_obj_dict_t*)µbit_display_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
microbit_display_type,
|
||||
MP_QSTR_MicroBitDisplay,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
locals_dict, (mp_obj_dict_t*)µbit_display_locals_dict
|
||||
);
|
||||
|
||||
microbit_display_obj_t microbit_display_obj = {
|
||||
{µbit_display_type},
|
||||
|
||||
@@ -678,14 +678,15 @@ STATIC mp_obj_t image_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
|
||||
}
|
||||
|
||||
|
||||
const mp_obj_type_t microbit_image_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_MicroBitImage,
|
||||
.print = microbit_image_print,
|
||||
.make_new = microbit_image_make_new,
|
||||
.binary_op = image_binary_op,
|
||||
.locals_dict = (mp_obj_dict_t*)µbit_image_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
microbit_image_type,
|
||||
MP_QSTR_MicroBitImage,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
microbit_image_make_new,
|
||||
print, microbit_image_print,
|
||||
binary_op, image_binary_op,
|
||||
locals_dict, (mp_obj_dict_t*)µbit_image_locals_dict
|
||||
);
|
||||
|
||||
typedef struct _scrolling_string_t {
|
||||
mp_obj_base_t base;
|
||||
@@ -820,18 +821,22 @@ STATIC mp_obj_t microbit_scrolling_string_iter_next(mp_obj_t o_in) {
|
||||
return iter->img;
|
||||
}
|
||||
|
||||
const mp_obj_type_t microbit_scrolling_string_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_ScrollingString,
|
||||
.getiter = get_microbit_scrolling_string_iter,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
microbit_scrolling_string_type,
|
||||
MP_QSTR_ScrollingString,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
getiter, get_microbit_scrolling_string_iter
|
||||
);
|
||||
|
||||
const mp_obj_type_t microbit_scrolling_string_iterator_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_iterator,
|
||||
.getiter = mp_identity_getiter,
|
||||
.iternext = microbit_scrolling_string_iter_next,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
microbit_scrolling_string_iterator_type,
|
||||
MP_QSTR_iterator,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
getiter, mp_identity_getiter,
|
||||
iternext, microbit_scrolling_string_iter_next
|
||||
);
|
||||
|
||||
/** Facade types to present a string as a sequence of images.
|
||||
* These are necessary to avoid allocation during iteration,
|
||||
@@ -869,13 +874,15 @@ static mp_obj_t facade_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
|
||||
|
||||
static mp_obj_t microbit_facade_iterator(mp_obj_t iterable_in, mp_obj_iter_buf_t *iter_buf);
|
||||
|
||||
const mp_obj_type_t string_image_facade_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Facade,
|
||||
.unary_op = facade_unary_op,
|
||||
.subscr = string_image_facade_subscr,
|
||||
.getiter = microbit_facade_iterator,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
string_image_facade_type,
|
||||
MP_QSTR_Facade,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
unary_op, facade_unary_op,
|
||||
subscr, string_image_facade_subscr,
|
||||
getiter, microbit_facade_iterator
|
||||
);
|
||||
|
||||
|
||||
typedef struct _facade_iterator_t {
|
||||
@@ -904,12 +911,14 @@ static mp_obj_t microbit_facade_iter_next(mp_obj_t iter_in) {
|
||||
return iter->image;
|
||||
}
|
||||
|
||||
const mp_obj_type_t microbit_facade_iterator_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_iterator,
|
||||
.getiter = mp_identity_getiter,
|
||||
.iternext = microbit_facade_iter_next,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
microbit_facade_iterator_type,
|
||||
MP_QSTR_iterator,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
getiter, mp_identity_getiter,
|
||||
iternext, microbit_facade_iter_next
|
||||
);
|
||||
|
||||
mp_obj_t microbit_facade_iterator(mp_obj_t iterable_in, mp_obj_iter_buf_t *iter_buf) {
|
||||
(void)iter_buf;
|
||||
|
||||
@@ -194,13 +194,14 @@ STATIC const mp_rom_map_elem_t led_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(led_locals_dict, led_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t board_led_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_LED,
|
||||
.print = led_obj_print,
|
||||
.make_new = led_obj_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&led_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
board_led_type,
|
||||
MP_QSTR_LED,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
led_obj_make_new,
|
||||
print, led_obj_print,
|
||||
locals_dict, (mp_obj_dict_t*)&led_locals_dict
|
||||
);
|
||||
|
||||
#else
|
||||
// For boards with no LEDs, we leave an empty function here so that we don't
|
||||
|
||||
@@ -294,12 +294,13 @@ STATIC const mp_rom_map_elem_t machine_adc_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(machine_adc_locals_dict, machine_adc_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t machine_adc_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_ADC,
|
||||
.make_new = machine_adc_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&machine_adc_locals_dict,
|
||||
.print = machine_adc_print,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_adc_type,
|
||||
MP_QSTR_ADC,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_adc_make_new,
|
||||
locals_dict, (mp_obj_dict_t*)&machine_adc_locals_dict,
|
||||
print, machine_adc_print
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_MACHINE_ADC
|
||||
|
||||
@@ -161,13 +161,14 @@ STATIC const mp_machine_i2c_p_t machine_hard_i2c_p = {
|
||||
.transfer_single = machine_hard_i2c_transfer_single,
|
||||
};
|
||||
|
||||
const mp_obj_type_t machine_hard_i2c_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_I2C,
|
||||
.print = machine_hard_i2c_print,
|
||||
.make_new = machine_hard_i2c_make_new,
|
||||
.protocol = &machine_hard_i2c_p,
|
||||
.locals_dict = (mp_obj_dict_t*)&mp_machine_i2c_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_hard_i2c_type,
|
||||
MP_QSTR_I2C,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_hard_i2c_make_new,
|
||||
print, machine_hard_i2c_print,
|
||||
protocol, &machine_hard_i2c_p,
|
||||
locals_dict, (mp_obj_dict_t*)&mp_machine_i2c_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_MACHINE_I2C
|
||||
|
||||
@@ -596,14 +596,15 @@ STATIC const mp_rom_map_elem_t pin_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(pin_locals_dict, pin_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t pin_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Pin,
|
||||
.print = pin_print,
|
||||
.make_new = pin_make_new,
|
||||
.call = pin_call,
|
||||
.locals_dict = (mp_obj_dict_t*)&pin_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
pin_type,
|
||||
MP_QSTR_Pin,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
pin_make_new,
|
||||
print, pin_print,
|
||||
call, pin_call,
|
||||
locals_dict, (mp_obj_dict_t*)&pin_locals_dict
|
||||
);
|
||||
|
||||
/// \moduleref machine
|
||||
/// \class PinAF - Pin Alternate Functions
|
||||
@@ -671,12 +672,14 @@ STATIC const mp_rom_map_elem_t pin_af_locals_dict_table[] = {
|
||||
};
|
||||
STATIC MP_DEFINE_CONST_DICT(pin_af_locals_dict, pin_af_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t pin_af_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_PinAF,
|
||||
.print = pin_af_obj_print,
|
||||
.locals_dict = (mp_obj_dict_t*)&pin_af_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
pin_af_type,
|
||||
MP_QSTR_PinAF,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
print, pin_af_obj_print,
|
||||
locals_dict, (mp_obj_dict_t*)&pin_af_locals_dict
|
||||
);
|
||||
|
||||
MP_REGISTER_ROOT_POINTER(mp_obj_t pin_class_mapper);
|
||||
MP_REGISTER_ROOT_POINTER(mp_obj_t pin_class_map_dict);
|
||||
|
||||
@@ -339,12 +339,13 @@ STATIC mp_obj_t machine_hard_pwm_freq(mp_obj_t self_in, mp_arg_val_t *args) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
const mp_obj_type_t machine_hard_pwm_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_PWM,
|
||||
.print = machine_pwm_print,
|
||||
.make_new = machine_pwm_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&machine_pwm_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_hard_pwm_type,
|
||||
MP_QSTR_PWM,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_pwm_make_new,
|
||||
print, machine_pwm_print,
|
||||
locals_dict, (mp_obj_dict_t*)&machine_pwm_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_MACHINE_HW_PWM
|
||||
|
||||
@@ -262,12 +262,13 @@ STATIC const mp_rom_map_elem_t machine_rtc_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(machine_rtc_locals_dict, machine_rtc_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t machine_rtcounter_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_RTCounter,
|
||||
.print = rtc_print,
|
||||
.make_new = machine_rtc_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&machine_rtc_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_rtcounter_type,
|
||||
MP_QSTR_RTCounter,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_rtc_make_new,
|
||||
print, rtc_print,
|
||||
locals_dict, (mp_obj_dict_t*)&machine_rtc_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_MACHINE_RTCOUNTER
|
||||
|
||||
@@ -427,13 +427,14 @@ STATIC const mp_machine_spi_p_t machine_hard_spi_p = {
|
||||
.transfer = machine_hard_spi_transfer,
|
||||
};
|
||||
|
||||
const mp_obj_type_t machine_hard_spi_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_SPI,
|
||||
.print = machine_hard_spi_print,
|
||||
.make_new = machine_spi_make_new,
|
||||
.protocol = &machine_hard_spi_p,
|
||||
.locals_dict = (mp_obj_dict_t*)&machine_spi_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_hard_spi_type,
|
||||
MP_QSTR_SPI,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_spi_make_new,
|
||||
print, machine_hard_spi_print,
|
||||
protocol, &machine_hard_spi_p,
|
||||
locals_dict, (mp_obj_dict_t*)&machine_spi_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_MACHINE_HW_SPI
|
||||
|
||||
@@ -112,12 +112,13 @@ STATIC const mp_rom_map_elem_t machine_temp_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(machine_temp_locals_dict, machine_temp_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t machine_temp_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Temp,
|
||||
.make_new = machine_temp_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&machine_temp_locals_dict,
|
||||
.print = machine_temp_print,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_temp_type,
|
||||
MP_QSTR_Temp,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_temp_make_new,
|
||||
locals_dict, (mp_obj_dict_t*)&machine_temp_locals_dict,
|
||||
print, machine_temp_print
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_MACHINE_TEMP
|
||||
|
||||
@@ -234,12 +234,13 @@ STATIC const mp_rom_map_elem_t machine_timer_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(machine_timer_locals_dict, machine_timer_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t machine_timer_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Timer,
|
||||
.print = timer_print,
|
||||
.make_new = machine_timer_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&machine_timer_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_timer_type,
|
||||
MP_QSTR_Timer,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_timer_make_new,
|
||||
print, timer_print,
|
||||
locals_dict, (mp_obj_dict_t*)&machine_timer_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_MACHINE_TIMER
|
||||
|
||||
@@ -370,15 +370,16 @@ STATIC const mp_stream_p_t uart_stream_p = {
|
||||
.is_text = false,
|
||||
};
|
||||
|
||||
const mp_obj_type_t machine_hard_uart_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_UART,
|
||||
.print = machine_hard_uart_print,
|
||||
.make_new = machine_hard_uart_make_new,
|
||||
.getiter = mp_identity_getiter,
|
||||
.iternext = mp_stream_unbuffered_iter,
|
||||
.protocol = &uart_stream_p,
|
||||
.locals_dict = (mp_obj_dict_t*)&machine_hard_uart_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
machine_hard_uart_type,
|
||||
MP_QSTR_UART,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
machine_hard_uart_make_new,
|
||||
print, machine_hard_uart_print,
|
||||
getiter, mp_identity_getiter,
|
||||
iternext, mp_stream_unbuffered_iter,
|
||||
protocol, &uart_stream_p,
|
||||
locals_dict, (mp_obj_dict_t*)&machine_hard_uart_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_MACHINE_UART
|
||||
|
||||
@@ -183,13 +183,14 @@ STATIC mp_obj_t nrf_flashbdev_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
const mp_obj_type_t nrf_flashbdev_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Flash,
|
||||
.print = nrf_flashbdev_print,
|
||||
.make_new = nrf_flashbdev_make_new,
|
||||
.locals_dict = (mp_obj_dict_t *)&nrf_flashbdev_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
nrf_flashbdev_type,
|
||||
MP_QSTR_Flash,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
nrf_flashbdev_make_new,
|
||||
print, nrf_flashbdev_print,
|
||||
locals_dict, (mp_obj_dict_t *)&nrf_flashbdev_locals_dict
|
||||
);
|
||||
|
||||
void flashbdev_init(void) {
|
||||
// Set start to first aligned page from _fs_start.
|
||||
|
||||
@@ -209,12 +209,13 @@ STATIC const mp_rom_map_elem_t ubluepy_characteristic_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_characteristic_locals_dict, ubluepy_characteristic_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_characteristic_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Characteristic,
|
||||
.print = ubluepy_characteristic_print,
|
||||
.make_new = ubluepy_characteristic_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_characteristic_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_characteristic_type,
|
||||
MP_QSTR_Characteristic,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
ubluepy_characteristic_make_new,
|
||||
print, ubluepy_characteristic_print,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_characteristic_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY_PERIPHERAL || MICROPY_PY_UBLUEPY_CENTRAL
|
||||
|
||||
@@ -69,11 +69,13 @@ STATIC const mp_rom_map_elem_t ubluepy_constants_ad_types_locals_dict_table[] =
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_constants_ad_types_locals_dict, ubluepy_constants_ad_types_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_constants_ad_types_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_ad_types,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_constants_ad_types_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_constants_ad_types_type,
|
||||
MP_QSTR_ad_types,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_constants_ad_types_locals_dict
|
||||
);
|
||||
|
||||
STATIC const mp_rom_map_elem_t ubluepy_constants_locals_dict_table[] = {
|
||||
// GAP events
|
||||
@@ -90,10 +92,12 @@ STATIC const mp_rom_map_elem_t ubluepy_constants_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_constants_locals_dict, ubluepy_constants_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_constants_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_constants,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_constants_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_constants_type,
|
||||
MP_QSTR_constants,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_constants_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY
|
||||
|
||||
@@ -77,12 +77,13 @@ STATIC const mp_rom_map_elem_t ubluepy_delegate_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_delegate_locals_dict, ubluepy_delegate_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_delegate_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_DefaultDelegate,
|
||||
.print = ubluepy_delegate_print,
|
||||
.make_new = ubluepy_delegate_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_delegate_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_delegate_type,
|
||||
MP_QSTR_DefaultDelegate,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
ubluepy_delegate_make_new,
|
||||
print, ubluepy_delegate_print,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_delegate_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY_PERIPHERAL || MICROPY_PY_UBLUEPY_CENTRAL
|
||||
|
||||
@@ -70,12 +70,13 @@ STATIC const mp_rom_map_elem_t ubluepy_descriptor_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_descriptor_locals_dict, ubluepy_descriptor_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_descriptor_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Descriptor,
|
||||
.print = ubluepy_descriptor_print,
|
||||
.make_new = ubluepy_descriptor_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_descriptor_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_descriptor_type,
|
||||
MP_QSTR_Descriptor,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
ubluepy_descriptor_make_new,
|
||||
print, ubluepy_descriptor_print,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_descriptor_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY
|
||||
|
||||
@@ -482,12 +482,13 @@ STATIC const mp_rom_map_elem_t ubluepy_peripheral_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_peripheral_locals_dict, ubluepy_peripheral_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_peripheral_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Peripheral,
|
||||
.print = ubluepy_peripheral_print,
|
||||
.make_new = ubluepy_peripheral_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_peripheral_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_peripheral_type,
|
||||
MP_QSTR_Peripheral,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
ubluepy_peripheral_make_new,
|
||||
print, ubluepy_peripheral_print,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_peripheral_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY
|
||||
|
||||
@@ -136,11 +136,13 @@ STATIC const mp_rom_map_elem_t ubluepy_scan_entry_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_scan_entry_locals_dict, ubluepy_scan_entry_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_scan_entry_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_ScanEntry,
|
||||
.print = ubluepy_scan_entry_print,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_scan_entry_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_scan_entry_type,
|
||||
MP_QSTR_ScanEntry,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
print, ubluepy_scan_entry_print,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_scan_entry_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY_CENTRAL
|
||||
|
||||
@@ -114,12 +114,13 @@ STATIC const mp_rom_map_elem_t ubluepy_scanner_locals_dict_table[] = {
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_scanner_locals_dict, ubluepy_scanner_locals_dict_table);
|
||||
|
||||
|
||||
const mp_obj_type_t ubluepy_scanner_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Scanner,
|
||||
.print = ubluepy_scanner_print,
|
||||
.make_new = ubluepy_scanner_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_scanner_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_scanner_type,
|
||||
MP_QSTR_Scanner,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
ubluepy_scanner_make_new,
|
||||
print, ubluepy_scanner_print,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_scanner_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY_CENTRAL
|
||||
|
||||
@@ -171,12 +171,13 @@ STATIC const mp_rom_map_elem_t ubluepy_service_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_service_locals_dict, ubluepy_service_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_service_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_Service,
|
||||
.print = ubluepy_service_print,
|
||||
.make_new = ubluepy_service_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_service_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_service_type,
|
||||
MP_QSTR_Service,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
ubluepy_service_make_new,
|
||||
print, ubluepy_service_print,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_service_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY_PERIPHERAL || MICROPY_PY_UBLUEPY_CENTRAL
|
||||
|
||||
@@ -160,12 +160,13 @@ STATIC const mp_rom_map_elem_t ubluepy_uuid_locals_dict_table[] = {
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(ubluepy_uuid_locals_dict, ubluepy_uuid_locals_dict_table);
|
||||
|
||||
const mp_obj_type_t ubluepy_uuid_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_UUID,
|
||||
.print = ubluepy_uuid_print,
|
||||
.make_new = ubluepy_uuid_make_new,
|
||||
.locals_dict = (mp_obj_dict_t*)&ubluepy_uuid_locals_dict
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
ubluepy_uuid_type,
|
||||
MP_QSTR_UUID,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
ubluepy_uuid_make_new,
|
||||
print, ubluepy_uuid_print,
|
||||
locals_dict, (mp_obj_dict_t*)&ubluepy_uuid_locals_dict
|
||||
);
|
||||
|
||||
#endif // MICROPY_PY_UBLUEPY
|
||||
|
||||
@@ -626,12 +626,14 @@ STATIC const mp_stream_p_t textio_stream_p = {
|
||||
.is_text = true,
|
||||
};
|
||||
|
||||
const mp_obj_type_t uos_mbfs_textio_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_TextIO,
|
||||
.protocol = &textio_stream_p,
|
||||
.locals_dict = (mp_obj_dict_t*)&uos_mbfs_file_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
uos_mbfs_textio_type,
|
||||
MP_QSTR_TextIO,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
protocol, &textio_stream_p,
|
||||
locals_dict, (mp_obj_dict_t*)&uos_mbfs_file_locals_dict
|
||||
);
|
||||
|
||||
|
||||
STATIC const mp_stream_p_t fileio_stream_p = {
|
||||
@@ -639,12 +641,14 @@ STATIC const mp_stream_p_t fileio_stream_p = {
|
||||
.write = microbit_file_write,
|
||||
};
|
||||
|
||||
const mp_obj_type_t uos_mbfs_fileio_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_FileIO,
|
||||
.protocol = &fileio_stream_p,
|
||||
.locals_dict = (mp_obj_dict_t*)&uos_mbfs_file_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
uos_mbfs_fileio_type,
|
||||
MP_QSTR_FileIO,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
protocol, &fileio_stream_p,
|
||||
locals_dict, (mp_obj_dict_t*)&uos_mbfs_file_locals_dict
|
||||
);
|
||||
|
||||
// From micro:bit fileobj.c
|
||||
mp_obj_t uos_mbfs_open(size_t n_args, const mp_obj_t *args) {
|
||||
|
||||
@@ -36,19 +36,23 @@ STATIC void pin_named_pins_obj_print(const mp_print_t *print, mp_obj_t self_in,
|
||||
mp_printf(print, "<Pin.%q>", self->name);
|
||||
}
|
||||
|
||||
const mp_obj_type_t pin_cpu_pins_obj_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_cpu,
|
||||
.print = pin_named_pins_obj_print,
|
||||
.locals_dict = (mp_obj_t)&pin_cpu_pins_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
pin_cpu_pins_obj_type,
|
||||
MP_QSTR_cpu,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
print, pin_named_pins_obj_print,
|
||||
locals_dict, (mp_obj_t)&pin_cpu_pins_locals_dict
|
||||
);
|
||||
|
||||
const mp_obj_type_t pin_board_pins_obj_type = {
|
||||
{ &mp_type_type },
|
||||
.name = MP_QSTR_board,
|
||||
.print = pin_named_pins_obj_print,
|
||||
.locals_dict = (mp_obj_t)&pin_board_pins_locals_dict,
|
||||
};
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
pin_board_pins_obj_type,
|
||||
MP_QSTR_board,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
print, pin_named_pins_obj_print,
|
||||
locals_dict, (mp_obj_t)&pin_board_pins_locals_dict
|
||||
);
|
||||
|
||||
const pin_obj_t *pin_find_named_pin(const mp_obj_dict_t *named_pins, mp_obj_t name) {
|
||||
mp_map_t *named_map = mp_obj_dict_get_map((mp_obj_t)named_pins);
|
||||
|
||||
Reference in New Issue
Block a user