use mp_arg_validate_type
for keyword args
This commit is contained in:
parent
f13db0d0e2
commit
1977011cfd
@ -103,10 +103,6 @@ msgstr ""
|
||||
msgid "%q length must be >= 1"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/vectorio/Polygon.c
|
||||
msgid "%q list must be a list"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c
|
||||
msgid "%q must <= %d"
|
||||
msgstr ""
|
||||
@ -144,12 +140,12 @@ msgstr ""
|
||||
msgid "%q must be between %d and %d"
|
||||
msgstr ""
|
||||
|
||||
#: ports/atmel-samd/common-hal/busio/UART.c
|
||||
msgid "%q must be power of 2"
|
||||
#: py/argcheck.c
|
||||
msgid "%q must be of type %q"
|
||||
msgstr ""
|
||||
|
||||
#: py/argcheck.c
|
||||
msgid "%q must of type %q"
|
||||
#: ports/atmel-samd/common-hal/busio/UART.c
|
||||
msgid "%q must be power of 2"
|
||||
msgstr ""
|
||||
|
||||
#: ports/raspberrypi/common-hal/rp2pio/StateMachine.c
|
||||
@ -783,10 +779,6 @@ msgstr ""
|
||||
msgid "Clock unit in use"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_pew/PewPew.c
|
||||
msgid "Column entry must be digitalio.DigitalInOut"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/displayio/FourWire.c shared-bindings/displayio/I2CDisplay.c
|
||||
#: shared-bindings/paralleldisplay/ParallelBus.c
|
||||
msgid "Command must be an int between 0 and 255"
|
||||
@ -962,36 +954,9 @@ msgstr ""
|
||||
#: shared-bindings/_bleio/__init__.c shared-bindings/aesio/aes.c
|
||||
#: shared-bindings/busio/SPI.c shared-bindings/microcontroller/Pin.c
|
||||
#: shared-bindings/neopixel_write/__init__.c
|
||||
#: shared-bindings/terminalio/Terminal.c
|
||||
msgid "Expected a %q"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/CharacteristicBuffer.c
|
||||
#: shared-bindings/_bleio/Descriptor.c shared-bindings/_bleio/PacketBuffer.c
|
||||
msgid "Expected a Characteristic"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Expected a DigitalInOut"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Characteristic.c
|
||||
msgid "Expected a Service"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Expected a UART"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Characteristic.c shared-bindings/_bleio/Descriptor.c
|
||||
#: shared-bindings/_bleio/Service.c
|
||||
msgid "Expected a UUID"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_bleio/Adapter.c
|
||||
msgid "Expected an Address"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/alarm/__init__.c
|
||||
msgid "Expected an alarm"
|
||||
msgstr ""
|
||||
@ -2032,10 +1997,6 @@ msgstr ""
|
||||
msgid "Right channel unsupported"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_pew/PewPew.c
|
||||
msgid "Row entry must be digitalio.DigitalInOut"
|
||||
msgstr ""
|
||||
|
||||
#: main.c
|
||||
msgid "Running in safe mode! Not running saved code.\n"
|
||||
msgstr ""
|
||||
@ -2671,10 +2632,6 @@ msgstr ""
|
||||
msgid "buffer too small for requested bytes"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/_pew/PewPew.c
|
||||
msgid "buttons must be digitalio.DigitalInOut"
|
||||
msgstr ""
|
||||
|
||||
#: shared-bindings/adafruit_pixelbuf/PixelBuf.c
|
||||
msgid "byteorder is not a string"
|
||||
msgstr ""
|
||||
@ -3461,7 +3418,7 @@ msgstr ""
|
||||
msgid "invalid syntax for number"
|
||||
msgstr ""
|
||||
|
||||
#: py/objexcept.c shared-bindings/traceback/__init__.c
|
||||
#: py/objexcept.c
|
||||
msgid "invalid traceback"
|
||||
msgstr ""
|
||||
|
||||
|
@ -204,7 +204,7 @@ mp_uint_t mp_arg_validate_length_range(mp_uint_t length, mp_uint_t min, mp_uint_
|
||||
|
||||
mp_obj_t mp_arg_validate_type(mp_obj_t obj, const mp_obj_type_t *type, qstr arg_name) {
|
||||
if (!mp_obj_is_type(obj, type)) {
|
||||
mp_raise_TypeError_varg(translate("%q must of type %q"), arg_name, type->name);
|
||||
mp_raise_TypeError_varg(translate("%q must be of type %q"), arg_name, type->name);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
@ -95,17 +95,10 @@ STATIC mp_obj_t bleio_adapter_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
busio_uart_obj_t *uart = args[ARG_uart].u_obj;
|
||||
if (!mp_obj_is_type(uart, &busio_uart_type)) {
|
||||
mp_raise_ValueError(translate("Expected a UART"));
|
||||
}
|
||||
busio_uart_obj_t *uart = mp_arg_validate_type(args[ARG_uart].u_obj, &busio_uart_type, MP_QSTR_uart);
|
||||
|
||||
digitalio_digitalinout_obj_t *rts = args[ARG_rts].u_obj;
|
||||
digitalio_digitalinout_obj_t *cts = args[ARG_cts].u_obj;
|
||||
if (!mp_obj_is_type(rts, &digitalio_digitalinout_type) ||
|
||||
!mp_obj_is_type(cts, &digitalio_digitalinout_type)) {
|
||||
mp_raise_ValueError(translate("Expected a DigitalInOut"));
|
||||
}
|
||||
digitalio_digitalinout_obj_t *rts = mp_arg_validate_type(args[ARG_rts].u_obj, &digitalio_digitalinout_type, MP_QSTR_rts);
|
||||
digitalio_digitalinout_obj_t *cts = mp_arg_validate_type(args[ARG_cts].u_obj, &digitalio_digitalinout_type, MP_QSTR_cts);
|
||||
|
||||
// Will enable the adapter.
|
||||
common_hal_bleio_adapter_construct_hci_uart(self, uart, rts, cts);
|
||||
@ -257,15 +250,11 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t
|
||||
mp_raise_bleio_BluetoothError(translate("Cannot have scan responses for extended, connectable advertisements."));
|
||||
}
|
||||
|
||||
bleio_address_obj_t *address = MP_OBJ_TO_PTR(args[ARG_directed_to].u_obj);
|
||||
const bleio_address_obj_t *address = mp_arg_validate_type(args[ARG_directed_to].u_obj, &bleio_address_type, MP_QSTR_directed_to);
|
||||
if (address != NULL && !connectable) {
|
||||
mp_raise_bleio_BluetoothError(translate("Only connectable advertisements can be directed"));
|
||||
}
|
||||
|
||||
if (address != NULL && !mp_obj_is_type(address, &bleio_address_type)) {
|
||||
mp_raise_TypeError(translate("Expected an Address"));
|
||||
}
|
||||
|
||||
common_hal_bleio_adapter_start_advertising(self, connectable, anonymous, timeout, interval,
|
||||
&data_bufinfo, &scan_response_bufinfo, args[ARG_tx_power].u_int, address);
|
||||
|
||||
@ -447,11 +436,7 @@ STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
if (!mp_obj_is_type(args[ARG_address].u_obj, &bleio_address_type)) {
|
||||
mp_raise_TypeError(translate("Expected an Address"));
|
||||
}
|
||||
|
||||
bleio_address_obj_t *address = MP_OBJ_TO_PTR(args[ARG_address].u_obj);
|
||||
bleio_address_obj_t *address = mp_arg_validate_type(args[ARG_address].u_obj, &bleio_address_type, MP_QSTR_address);
|
||||
mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj);
|
||||
|
||||
return common_hal_bleio_adapter_connect(self, address, timeout);
|
||||
|
@ -94,15 +94,9 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
const mp_obj_t service_obj = args[ARG_service].u_obj;
|
||||
if (!mp_obj_is_type(service_obj, &bleio_service_type)) {
|
||||
mp_raise_TypeError(translate("Expected a Service"));
|
||||
}
|
||||
bleio_service_obj_t *service = mp_arg_validate_type(args[ARG_service].u_obj, &bleio_service_type, MP_QSTR_service);
|
||||
|
||||
const mp_obj_t uuid_obj = args[ARG_uuid].u_obj;
|
||||
if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) {
|
||||
mp_raise_TypeError(translate("Expected a UUID"));
|
||||
}
|
||||
bleio_uuid_obj_t *uuid = mp_arg_validate_type(args[ARG_uuid].u_obj, &bleio_uuid_type, MP_QSTR_uuid);
|
||||
|
||||
const bleio_characteristic_properties_t properties = args[ARG_properties].u_int;
|
||||
if (properties & ~CHAR_PROP_ALL) {
|
||||
@ -149,7 +143,7 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_
|
||||
// Range checking on max_length arg is done by the common_hal layer, because
|
||||
// it may vary depending on underlying BLE implementation.
|
||||
common_hal_bleio_characteristic_construct(
|
||||
characteristic, MP_OBJ_TO_PTR(service_obj), 0, MP_OBJ_TO_PTR(uuid_obj),
|
||||
characteristic, service, 0, uuid,
|
||||
properties, read_perm, write_perm,
|
||||
max_length, fixed_length, &initial_value_bufinfo,
|
||||
user_description);
|
||||
|
@ -68,7 +68,7 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type,
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
const mp_obj_t characteristic = args[ARG_characteristic].u_obj;
|
||||
bleio_characteristic_obj_t *characteristic = mp_arg_validate_type(args[ARG_characteristic].u_obj, &bleio_characteristic_type, MP_QSTR_characteristic);
|
||||
|
||||
mp_float_t timeout = mp_obj_get_float(args[ARG_timeout].u_obj);
|
||||
if (timeout < 0.0f) {
|
||||
@ -80,14 +80,10 @@ STATIC mp_obj_t bleio_characteristic_buffer_make_new(const mp_obj_type_t *type,
|
||||
mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_buffer_size);
|
||||
}
|
||||
|
||||
if (!mp_obj_is_type(characteristic, &bleio_characteristic_type)) {
|
||||
mp_raise_TypeError(translate("Expected a Characteristic"));
|
||||
}
|
||||
|
||||
bleio_characteristic_buffer_obj_t *self = m_new_obj(bleio_characteristic_buffer_obj_t);
|
||||
self->base.type = &bleio_characteristic_buffer_type;
|
||||
|
||||
common_hal_bleio_characteristic_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), timeout, buffer_size);
|
||||
common_hal_bleio_characteristic_buffer_construct(self, characteristic, timeout, buffer_size);
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
@ -84,15 +84,9 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
const mp_obj_t characteristic_obj = args[ARG_characteristic].u_obj;
|
||||
if (!mp_obj_is_type(characteristic_obj, &bleio_characteristic_type)) {
|
||||
mp_raise_TypeError(translate("Expected a Characteristic"));
|
||||
}
|
||||
bleio_characteristic_obj_t *characteristic = mp_arg_validate_type(args[ARG_characteristic].u_obj, &bleio_characteristic_type, MP_QSTR_characteristic);
|
||||
|
||||
const mp_obj_t uuid_obj = args[ARG_uuid].u_obj;
|
||||
if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) {
|
||||
mp_raise_TypeError(translate("Expected a UUID"));
|
||||
}
|
||||
bleio_uuid_obj_t *uuid = mp_arg_validate_type(args[ARG_uuid].u_obj, &bleio_uuid_type, MP_QSTR_uuid);
|
||||
|
||||
const bleio_attribute_security_mode_t read_perm = args[ARG_read_perm].u_int;
|
||||
common_hal_bleio_attribute_security_mode_check_valid(read_perm);
|
||||
@ -128,11 +122,11 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o
|
||||
// Range checking on max_length arg is done by the common_hal layer, because
|
||||
// it may vary depending on underlying BLE implementation.
|
||||
common_hal_bleio_descriptor_construct(
|
||||
descriptor, MP_OBJ_TO_PTR(characteristic_obj), MP_OBJ_TO_PTR(uuid_obj),
|
||||
descriptor, characteristic, uuid,
|
||||
read_perm, write_perm,
|
||||
max_length, fixed_length, &initial_value_bufinfo);
|
||||
|
||||
common_hal_bleio_characteristic_add_descriptor(characteristic_obj, descriptor);
|
||||
common_hal_bleio_characteristic_add_descriptor(characteristic, descriptor);
|
||||
|
||||
return MP_OBJ_FROM_PTR(descriptor);
|
||||
}
|
||||
|
@ -71,17 +71,13 @@ STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
const mp_obj_t characteristic = args[ARG_characteristic].u_obj;
|
||||
bleio_characteristic_obj_t *characteristic = mp_arg_validate_type(args[ARG_characteristic].u_obj, &bleio_characteristic_type, MP_QSTR_characteristic);
|
||||
|
||||
const mp_int_t buffer_size = args[ARG_buffer_size].u_int;
|
||||
if (buffer_size < 1) {
|
||||
mp_raise_ValueError_varg(translate("%q must be >= 1"), MP_QSTR_buffer_size);
|
||||
}
|
||||
|
||||
if (!mp_obj_is_type(characteristic, &bleio_characteristic_type)) {
|
||||
mp_raise_TypeError(translate("Expected a Characteristic"));
|
||||
}
|
||||
|
||||
size_t max_packet_size = common_hal_bleio_characteristic_get_max_length(characteristic);
|
||||
if (args[ARG_max_packet_size].u_obj != mp_const_none) {
|
||||
max_packet_size = mp_obj_get_int(args[ARG_max_packet_size].u_obj);
|
||||
@ -90,7 +86,7 @@ STATIC mp_obj_t bleio_packet_buffer_make_new(const mp_obj_type_t *type, size_t n
|
||||
bleio_packet_buffer_obj_t *self = m_new_obj(bleio_packet_buffer_obj_t);
|
||||
self->base.type = &bleio_packet_buffer_type;
|
||||
|
||||
common_hal_bleio_packet_buffer_construct(self, MP_OBJ_TO_PTR(characteristic), buffer_size, max_packet_size);
|
||||
common_hal_bleio_packet_buffer_construct(self, characteristic, buffer_size, max_packet_size);
|
||||
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
@ -58,17 +58,14 @@ STATIC mp_obj_t bleio_service_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
const mp_obj_t uuid_obj = args[ARG_uuid].u_obj;
|
||||
if (!mp_obj_is_type(uuid_obj, &bleio_uuid_type)) {
|
||||
mp_raise_TypeError(translate("Expected a UUID"));
|
||||
}
|
||||
bleio_uuid_obj_t *uuid = mp_arg_validate_type(args[ARG_uuid].u_obj, &bleio_uuid_type, MP_QSTR_uuid);
|
||||
|
||||
const bool is_secondary = args[ARG_secondary].u_bool;
|
||||
|
||||
bleio_service_obj_t *service = m_new_obj(bleio_service_obj_t);
|
||||
service->base.type = &bleio_service_type;
|
||||
|
||||
common_hal_bleio_service_construct(service, MP_OBJ_TO_PTR(uuid_obj), is_secondary);
|
||||
common_hal_bleio_service_construct(service, uuid, is_secondary);
|
||||
|
||||
return MP_OBJ_FROM_PTR(service);
|
||||
}
|
||||
|
@ -92,31 +92,20 @@ STATIC mp_obj_t pewpew_make_new(const mp_obj_type_t *type, size_t n_args,
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < rows_size; ++i) {
|
||||
if (!mp_obj_is_type(rows[i], &digitalio_digitalinout_type)) {
|
||||
mp_raise_TypeError(translate("Row entry must be digitalio.DigitalInOut"));
|
||||
}
|
||||
digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(rows[i]);
|
||||
digitalio_digitalinout_obj_t *pin = mp_arg_validate_type(rows[i], &digitalio_digitalinout_type, MP_QSTR_rows);
|
||||
if (common_hal_digitalio_digitalinout_deinited(pin)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < cols_size; ++i) {
|
||||
if (!mp_obj_is_type(cols[i], &digitalio_digitalinout_type)) {
|
||||
mp_raise_TypeError(translate("Column entry must be digitalio.DigitalInOut"));
|
||||
}
|
||||
digitalio_digitalinout_obj_t *pin = MP_OBJ_TO_PTR(cols[i]);
|
||||
digitalio_digitalinout_obj_t *pin = mp_arg_validate_type(cols[i], &digitalio_digitalinout_type, MP_QSTR_cols);
|
||||
if (common_hal_digitalio_digitalinout_deinited(pin)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
}
|
||||
|
||||
if (!mp_obj_is_type(args[ARG_buttons].u_obj,
|
||||
&digitalio_digitalinout_type)) {
|
||||
mp_raise_TypeError(translate("buttons must be digitalio.DigitalInOut"));
|
||||
}
|
||||
digitalio_digitalinout_obj_t *buttons = MP_OBJ_TO_PTR(
|
||||
args[ARG_buttons].u_obj);
|
||||
digitalio_digitalinout_obj_t *buttons = mp_arg_validate_type(args[ARG_buttons].u_obj, &digitalio_digitalinout_type, MP_QSTR_buttons);
|
||||
if (common_hal_digitalio_digitalinout_deinited(buttons)) {
|
||||
raise_deinited_error();
|
||||
}
|
||||
|
@ -463,10 +463,7 @@ STATIC mp_obj_t bitmaptools_arrayblit(size_t n_args, const mp_obj_t *pos_args, m
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
if (!mp_obj_is_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type)) {
|
||||
mp_raise_TypeError(NULL);
|
||||
}
|
||||
displayio_bitmap_t *bitmap = MP_OBJ_TO_PTR(args[ARG_bitmap].u_obj);
|
||||
displayio_bitmap_t *bitmap = mp_arg_validate_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_bitmap);
|
||||
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(args[ARG_data].u_obj, &bufinfo, MP_BUFFER_READ);
|
||||
@ -533,15 +530,9 @@ STATIC mp_obj_t bitmaptools_readinto(size_t n_args, const mp_obj_t *pos_args, mp
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
if (!mp_obj_is_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type)) {
|
||||
mp_raise_TypeError(NULL);
|
||||
}
|
||||
displayio_bitmap_t *bitmap = MP_OBJ_TO_PTR(args[ARG_bitmap].u_obj);
|
||||
displayio_bitmap_t *bitmap = mp_arg_validate_type(args[ARG_bitmap].u_obj, &displayio_bitmap_type, MP_QSTR_bitmap);
|
||||
|
||||
if (!mp_obj_is_type(args[ARG_file].u_obj, &mp_type_fileio)) {
|
||||
mp_raise_TypeError(NULL);
|
||||
}
|
||||
pyb_file_obj_t *file = MP_OBJ_TO_PTR(args[ARG_file].u_obj);
|
||||
pyb_file_obj_t *file = mp_arg_validate_type(args[ARG_file].u_obj, &mp_type_fileio, MP_QSTR_file);
|
||||
|
||||
int element_size = args[ARG_element_size].u_int;
|
||||
if (element_size != 1 && element_size != 2 && element_size != 4) {
|
||||
|
@ -55,18 +55,14 @@ STATIC mp_obj_t terminalio_terminal_make_new(const mp_obj_type_t *type, size_t n
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
mp_obj_t tilegrid = args[ARG_tilegrid].u_obj;
|
||||
if (!mp_obj_is_type(tilegrid, &displayio_tilegrid_type)) {
|
||||
mp_raise_TypeError_varg(translate("Expected a %q"), displayio_tilegrid_type.name);
|
||||
}
|
||||
displayio_tilegrid_t *tilegrid = mp_arg_validate_type(args[ARG_tilegrid].u_obj, &displayio_tilegrid_type, MP_QSTR_tilegrid);
|
||||
|
||||
fontio_builtinfont_t *font = mp_arg_validate_type(args[ARG_font].u_obj, &fontio_builtinfont_type, MP_QSTR_font);
|
||||
|
||||
mp_obj_t font = args[ARG_font].u_obj;
|
||||
if (!mp_obj_is_type(font, &fontio_builtinfont_type)) {
|
||||
mp_raise_TypeError_varg(translate("Expected a %q"), fontio_builtinfont_type.name);
|
||||
}
|
||||
terminalio_terminal_obj_t *self = m_new_obj(terminalio_terminal_obj_t);
|
||||
self->base.type = &terminalio_terminal_type;
|
||||
common_hal_terminalio_terminal_construct(self, MP_OBJ_TO_PTR(tilegrid), MP_OBJ_TO_PTR(font));
|
||||
|
||||
common_hal_terminalio_terminal_construct(self, tilegrid, font);
|
||||
return MP_OBJ_FROM_PTR(self);
|
||||
}
|
||||
|
||||
|
@ -52,10 +52,7 @@ STATIC void traceback_exception_common(mp_print_t *print, mp_obj_t value, mp_obj
|
||||
}
|
||||
|
||||
if (tb_obj != mp_const_none && print_tb) {
|
||||
if (!mp_obj_is_type(tb_obj, &mp_type_traceback)) {
|
||||
mp_raise_TypeError(translate("invalid traceback"));
|
||||
}
|
||||
exc.traceback = MP_OBJ_TO_PTR(tb_obj);
|
||||
exc.traceback = mp_arg_validate_type(tb_obj, &mp_type_traceback, MP_QSTR_tb);
|
||||
} else {
|
||||
exc.traceback = (mp_obj_traceback_t *)&mp_const_empty_traceback_obj;
|
||||
}
|
||||
|
@ -38,14 +38,12 @@ static mp_obj_t vectorio_polygon_make_new(const mp_obj_type_t *type, size_t n_ar
|
||||
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
|
||||
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
|
||||
|
||||
if (!mp_obj_is_type(args[ARG_points_list].u_obj, &mp_type_list)) {
|
||||
mp_raise_TypeError_varg(translate("%q list must be a list"), MP_QSTR_point);
|
||||
}
|
||||
mp_obj_t points_list = mp_arg_validate_type(args[ARG_points_list].u_obj, &mp_type_list, MP_QSTR_points);
|
||||
|
||||
vectorio_polygon_t *self = m_new_obj(vectorio_polygon_t);
|
||||
self->base.type = &vectorio_polygon_type;
|
||||
|
||||
common_hal_vectorio_polygon_construct(self, args[ARG_points_list].u_obj);
|
||||
common_hal_vectorio_polygon_construct(self, points_list);
|
||||
|
||||
// VectorShape parts
|
||||
mp_obj_t pixel_shader = args[ARG_pixel_shader].u_obj;
|
||||
|
Loading…
Reference in New Issue
Block a user