Merge remote-tracking branch 'origin/main'

This commit is contained in:
Hosted Weblate 2021-10-08 18:52:45 +02:00
commit 202d55bd81
No known key found for this signature in database
GPG Key ID: A3FAAA06E6569B4C
22 changed files with 239 additions and 174 deletions

View File

@ -271,7 +271,7 @@ STATIC mp_obj_t bleio_adapter_start_advertising(mp_uint_t n_args, const mp_obj_t
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 2, bleio_adapter_start_advertising);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_start_advertising_obj, 1, bleio_adapter_start_advertising);
//| def stop_advertising(self) -> None:
//| """Stop sending advertising packets."""
@ -456,7 +456,7 @@ STATIC mp_obj_t bleio_adapter_connect(mp_uint_t n_args, const mp_obj_t *pos_args
return common_hal_bleio_adapter_connect(self, address, timeout);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 2, bleio_adapter_connect);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_adapter_connect_obj, 1, bleio_adapter_connect);
//| def erase_bonding(self) -> None:
//| """Erase all bonding information stored in flash memory."""

View File

@ -156,7 +156,7 @@ STATIC mp_obj_t bleio_characteristic_add_to_service(size_t n_args, const mp_obj_
return MP_OBJ_FROM_PTR(characteristic);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_add_to_service_fun_obj, 3, bleio_characteristic_add_to_service);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_characteristic_add_to_service_fun_obj, 1, bleio_characteristic_add_to_service);
STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_characteristic_add_to_service_obj, MP_ROM_PTR(&bleio_characteristic_add_to_service_fun_obj));

View File

@ -136,7 +136,7 @@ STATIC mp_obj_t bleio_descriptor_add_to_characteristic(size_t n_args, const mp_o
return MP_OBJ_FROM_PTR(descriptor);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_descriptor_add_to_characteristic_fun_obj, 3, bleio_descriptor_add_to_characteristic);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_descriptor_add_to_characteristic_fun_obj, 1, bleio_descriptor_add_to_characteristic);
STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(bleio_descriptor_add_to_characteristic_obj, MP_ROM_PTR(&bleio_descriptor_add_to_characteristic_fun_obj));
//| uuid: UUID

View File

@ -72,7 +72,7 @@ STATIC mp_obj_t bleio_scanentry_matches(mp_uint_t n_args, const mp_obj_t *pos_ar
mp_get_buffer_raise(args[ARG_prefixes].u_obj, &bufinfo, MP_BUFFER_READ);
return mp_obj_new_bool(common_hal_bleio_scanentry_matches(self, bufinfo.buf, bufinfo.len, match_all));
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 2, bleio_scanentry_matches);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_scanentry_matches_obj, 1, bleio_scanentry_matches);
//| address: Address
//| """The address of the device (read-only), of type `_bleio.Address`."""

View File

@ -214,7 +214,7 @@ STATIC mp_obj_t bleio_uuid_pack_into(mp_uint_t n_args, const mp_obj_t *pos_args,
common_hal_bleio_uuid_pack_into(self, bufinfo.buf + offset);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_uuid_pack_into_obj, 2, bleio_uuid_pack_into);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bleio_uuid_pack_into_obj, 1, bleio_uuid_pack_into);
STATIC const mp_rom_map_elem_t bleio_uuid_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_uuid16), MP_ROM_PTR(&bleio_uuid_uuid16_obj) },

View File

@ -63,7 +63,8 @@
//| device.readinto(bytes_read)
//| # A second transaction
//| with device:
//| device.write(bytes_read)"""
//| device.write(bytes_read)
//| """
//| ...
//|
STATIC mp_obj_t adafruit_bus_device_i2cdevice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@ -109,16 +110,18 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_obj___exit__(size_t n_args, const
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(adafruit_bus_device_i2cdevice___exit___obj, 4, 4, adafruit_bus_device_i2cdevice_obj___exit__);
//| def readinto(self, buf: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
//| """Read into ``buf`` from the device. The number of bytes read will be the
//| length of ``buf``.
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buf[start:end]``. This will not cause an allocation like
//| ``buf[start:end]`` will so it saves memory.
//| import sys
//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None:
//| """Read into ``buffer`` from the device.
//|
//| :param bytearray buf: buffer to write into
//| :param int start: Index to start writing at
//| :param int end: Index to write up to but not include; if None, use ``len(buf)``"""
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]`` were passed.
//| The number of bytes read will be the length of ``buffer[start:end]``.
//|
//| :param WriteableBuffer buffer: read bytes into this buffer
//| :param int start: beginning of buffer slice
//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``
//| """
//| ...
//|
STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@ -152,17 +155,19 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_o
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 2, adafruit_bus_device_i2cdevice_readinto);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_readinto_obj, 1, adafruit_bus_device_i2cdevice_readinto);
//| def write(self, buf: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
//| import sys
//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None:
//| """Write the bytes from ``buffer`` to the device, then transmit a stop bit.
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]``. This will not cause an allocation like
//| ``buffer[start:end]`` will so it saves memory.
//|
//| :param bytearray buf: buffer containing the bytes to write
//| :param int start: Index to start writing from
//| :param int end: Index to read up to but not include; if None, use ``len(buf)``
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``buffer[start:end]``.
//|
//| :param ReadableBuffer buffer: write out bytes from this buffer
//| :param int start: beginning of buffer slice
//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``
//| """
//| ...
//|
@ -196,28 +201,28 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write(size_t n_args, const mp_obj_
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 2, adafruit_bus_device_i2cdevice_write);
MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 1, adafruit_bus_device_i2cdevice_write);
//| def write_then_readinto(self, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None:
//| import sys
//| def write_then_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None:
//| """Write the bytes from ``out_buffer`` to the device, then immediately
//| reads into ``in_buffer`` from the device. The number of bytes read
//| will be the length of ``in_buffer``.
//| If ``out_start`` or ``out_end`` is provided, then the output buffer
//| will be sliced as if ``out_buffer[out_start:out_end]``. This will
//| not cause an allocation like ``buffer[out_start:out_end]`` will so
//| it saves memory.
//| If ``in_start`` or ``in_end`` is provided, then the input buffer
//| will be sliced as if ``in_buffer[in_start:in_end]``. This will not
//| cause an allocation like ``in_buffer[in_start:in_end]`` will so
//| it saves memory.
//| reads into ``in_buffer`` from the device.
//|
//| :param bytearray out_buffer: buffer containing the bytes to write
//| :param bytearray in_buffer: buffer containing the bytes to read into
//| :param int out_start: Index to start writing from
//| :param int out_end: Index to read up to but not include; if None, use ``len(out_buffer)``
//| :param int in_start: Index to start writing at
//| :param int in_end: Index to write up to but not include; if None, use ``len(in_buffer)``
//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced
//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``.
//|
//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced
//| as if ``in_buffer[in_start:in_end]`` were passed,
//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``.
//|
//| :param ReadableBuffer out_buffer: write out bytes from this buffer
//| :param WriteableBuffer in_buffer: read bytes into this buffer
//| :param int out_start: beginning of ``out_buffer`` slice
//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)``
//| :param int in_start: beginning of ``in_buffer`` slice
//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)``
//| """
//| ...
//|
@ -263,7 +268,7 @@ STATIC mp_obj_t adafruit_bus_device_i2cdevice_write_then_readinto(size_t n_args,
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 3, adafruit_bus_device_i2cdevice_write_then_readinto);
MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_then_readinto_obj, 1, adafruit_bus_device_i2cdevice_write_then_readinto);
STATIC const mp_rom_map_elem_t adafruit_bus_device_i2cdevice_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&adafruit_bus_device_i2cdevice___enter___obj) },

View File

@ -165,7 +165,8 @@ STATIC mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock);
//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
//| import sys
//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None:
//| """Read into ``buffer`` from the device selected by ``address``.
//| The number of bytes read will be the length of ``buffer``.
//| At least one byte must be read.
@ -175,7 +176,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock);
//| ``buf[start:end]`` will so it saves memory.
//|
//| :param int address: 7-bit device address
//| :param ~_typing.WriteableBuffer buffer: buffer to write into
//| :param WriteableBuffer buffer: buffer to write into
//| :param int start: Index to start writing at
//| :param int end: Index to write up to but not include"""
//| ...
@ -215,24 +216,26 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a
args[ARG_end].u_int);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_readfrom_into);
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 1, bitbangio_i2c_readfrom_into);
//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
//| import sys
//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None:
//| """Write the bytes from ``buffer`` to the device selected by ``address`` and then transmits a
//| stop bit. Use `writeto_then_readfrom` when needing a write, no stop and repeated start
//| before a read.
//|
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]``. This will not cause an allocation like
//| ``buffer[start:end]`` will so it saves memory.
//| as if ``buffer[start:end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``buffer[start:end]``.
//|
//| Writing a buffer or slice of length zero is permitted, as it can be used
//| to poll for the existence of a device.
//|
//| :param int address: 7-bit device address
//| :param ~_typing.ReadableBuffer buffer: buffer containing the bytes to write
//| :param int start: Index to start writing from
//| :param int end: Index to read up to but not include"""
//| :param ReadableBuffer buffer: buffer containing the bytes to write
//| :param int start: beginning of buffer slice
//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``
//| """
//| ...
//|
// Shared arg parsing for writeto and writeto_then_readfrom.
@ -274,22 +277,29 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_writeto);
//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None:
//| import sys
//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None:
//| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop
//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
//| ``in_buffer`` can be the same buffer because they are used sequentially.
//|
//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
//| will so it saves memory.
//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced
//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``out_buffer[start:end]``.
//|
//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced
//| as if ``in_buffer[in_start:in_end]`` were passed,
//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``.
//| :param int address: 7-bit device address
//| :param ~_typing.ReadableBuffer out_buffer: buffer containing the bytes to write
//| :param ~_typing.WriteableBuffer in_buffer: buffer to write into
//| :param int out_start: Index to start writing from
//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
//| :param int in_start: Index to start writing at
//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``"""
//| :param int out_start: beginning of ``out_buffer`` slice
//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)``
//| :param int in_start: beginning of ``in_buffer`` slice
//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)``
//| """
//| ...
//|
STATIC mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_address, ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
@ -315,7 +325,7 @@ STATIC mp_obj_t bitbangio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_then_readfrom_obj, 3, bitbangio_i2c_writeto_then_readfrom);
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_then_readfrom_obj, 1, bitbangio_i2c_writeto_then_readfrom);
STATIC const mp_rom_map_elem_t bitbangio_i2c_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bitbangio_i2c_deinit_obj) },

View File

@ -224,18 +224,23 @@ STATIC mp_obj_t bitbangio_spi_write(mp_obj_t self_in, mp_obj_t wr_buf) {
MP_DEFINE_CONST_FUN_OBJ_2(bitbangio_spi_write_obj, bitbangio_spi_write);
//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None, write_value: int = 0) -> None:
//| import sys
//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize, write_value: int = 0) -> None:
//| """Read into ``buffer`` while writing ``write_value`` for each byte read.
//| The SPI object must be locked.
//| If the number of bytes to read is 0, nothing happens.
//|
//| :param bytearray buffer: Read data into this buffer
//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]``
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``
//| :param int write_value: Value to write while reading."""
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]`` were passed.
//| The number of bytes read will be the length of ``buffer[start:end]``.
//|
//| :param WriteableBuffer buffer: read bytes into this buffer
//| :param int start: beginning of buffer slice
//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``
//| :param int write_value: value to write while reading
//| """
//| ...
//|
STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_buffer, ARG_start, ARG_end, ARG_write_value };
static const mp_arg_t allowed_args[] = {
@ -266,28 +271,39 @@ STATIC mp_obj_t bitbangio_spi_readinto(size_t n_args, const mp_obj_t *pos_args,
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 2, bitbangio_spi_readinto);
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 1, bitbangio_spi_readinto);
//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: ReadableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None:
//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``.
//| import sys
//| def write_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None:
//| """Write out the data in ``out_buffer`` while simultaneously reading data into ``in_buffer``.
//| The SPI object must be locked.
//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]``
//| must be equal.
//|
//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced
//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``.
//|
//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced
//| as if ``in_buffer[in_start:in_end]`` were passed,
//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``.
//|
//| The lengths of the slices defined by ``out_buffer[out_start:out_end]``
//| and ``in_buffer[in_start:in_end]`` must be equal.
//| If buffer slice lengths are both 0, nothing happens.
//|
//| :param ~_typing.ReadableBuffer buffer_out: Write out the data in this buffer
//| :param ~_typing.WriteableBuffer buffer_in: Read data into this buffer
//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]``
//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)``
//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]``
//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``"""
//| :param ReadableBuffer out_buffer: write out bytes from this buffer
//| :param WriteableBuffer in_buffer: read bytes into this buffer
//| :param int out_start: beginning of ``out_buffer`` slice
//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)``
//| :param int in_start: beginning of ``in_buffer`` slice
//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)``
//| """
//| ...
//|
STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_buffer_out, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_buffer_in, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
{ MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
@ -301,13 +317,13 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_buffer_info_t buf_out_info;
mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ);
mp_get_buffer_raise(args[ARG_out_buffer].u_obj, &buf_out_info, MP_BUFFER_READ);
int32_t out_start = args[ARG_out_start].u_int;
size_t out_length = buf_out_info.len;
normalize_buffer_bounds(&out_start, args[ARG_out_end].u_int, &out_length);
mp_buffer_info_t buf_in_info;
mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE);
mp_get_buffer_raise(args[ARG_in_buffer].u_obj, &buf_in_info, MP_BUFFER_WRITE);
int32_t in_start = args[ARG_in_start].u_int;
size_t in_length = buf_in_info.len;
normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length);
@ -329,7 +345,7 @@ STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_write_readinto_obj, 2, bitbangio_spi_write_readinto);
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_write_readinto_obj, 1, bitbangio_spi_write_readinto);
STATIC const mp_rom_map_elem_t bitbangio_spi_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&bitbangio_spi_deinit_obj) },

View File

@ -86,7 +86,7 @@ STATIC mp_obj_t bit_transpose(size_t n_args, const mp_obj_t *pos_args, mp_map_t
common_hal_bitops_bit_transpose(output_bufinfo.buf, input_bufinfo.buf, inlen, width);
return args[ARG_output].u_obj;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitops_bit_transpose_obj, 1, bit_transpose);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitops_bit_transpose_obj, 0, bit_transpose);
STATIC const mp_rom_map_elem_t bitops_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_bitops) },

View File

@ -176,19 +176,19 @@ STATIC mp_obj_t busio_i2c_obj_unlock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_i2c_unlock_obj, busio_i2c_obj_unlock);
//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
//| import sys
//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None:
//| """Read into ``buffer`` from the device selected by ``address``.
//| The number of bytes read will be the length of ``buffer``.
//| At least one byte must be read.
//|
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]``. This will not cause an allocation like
//| ``buf[start:end]`` will so it saves memory.
//| as if ``buffer[start:end]`` were passed, but without copying the data.
//| The number of bytes read will be the length of ``buffer[start:end]``.
//|
//| :param int address: 7-bit device address
//| :param ~_typing.WriteableBuffer buffer: buffer to write into
//| :param int start: Index to start writing at
//| :param int end: Index to write up to but not include. Defaults to ``len(buffer)``"""
//| :param WriteableBuffer buffer: buffer to write into
//| :param int start: beginning of buffer slice
//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``"""
//| ...
//|
// Shared arg parsing for readfrom_into and writeto_then_readfrom.
@ -226,23 +226,25 @@ STATIC mp_obj_t busio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_args,
args[ARG_end].u_int);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 3, busio_i2c_readfrom_into);
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_readfrom_into_obj, 1, busio_i2c_readfrom_into);
//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
//| import sys
//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None:
//| """Write the bytes from ``buffer`` to the device selected by ``address`` and
//| then transmit a stop bit.
//|
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]``. This will not cause an allocation like
//| ``buffer[start:end]`` will so it saves memory.
//| as if ``buffer[start:end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``buffer[start:end]``.
//|
//| Writing a buffer or slice of length zero is permitted, as it can be used
//| to poll for the existence of a device.
//|
//| :param int address: 7-bit device address
//| :param ~_typing.ReadableBuffer buffer: buffer containing the bytes to write
//| :param int start: Index to start writing from
//| :param int end: Index to read up to but not include. Defaults to ``len(buffer)``"""
//| :param ReadableBuffer buffer: buffer containing the bytes to write
//| :param int start: beginning of buffer slice
//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``
//| """
//| ...
//|
// Shared arg parsing for writeto and writeto_then_readfrom.
@ -282,22 +284,28 @@ STATIC mp_obj_t busio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, mp_ma
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_obj, 1, busio_i2c_writeto);
//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None:
//| import sys
//| def writeto_then_readfrom(self, address: int, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None:
//| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop
//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
//| ``in_buffer`` can be the same buffer because they are used sequentially.
//|
//| If ``start`` or ``end`` is provided, then the corresponding buffer will be sliced
//| as if ``buffer[start:end]``. This will not cause an allocation like ``buf[start:end]``
//| will so it saves memory.
//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced
//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``out_buffer[start:end]``.
//|
//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced
//| as if ``in_buffer[in_start:in_end]`` were passed,
//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``.
//| :param int address: 7-bit device address
//| :param ~_typing.ReadableBuffer out_buffer: buffer containing the bytes to write
//| :param ~_typing.WriteableBuffer in_buffer: buffer to write into
//| :param int out_start: Index to start writing from
//| :param int out_end: Index to read up to but not include. Defaults to ``len(buffer)``
//| :param int in_start: Index to start writing at
//| :param int in_end: Index to write up to but not include. Defaults to ``len(buffer)``"""
//| :param int out_start: beginning of ``out_buffer`` slice
//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)``
//| :param int in_start: beginning of ``in_buffer`` slice
//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)``
//| """
//| ...
//|
STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
@ -324,7 +332,7 @@ STATIC mp_obj_t busio_i2c_writeto_then_readfrom(size_t n_args, const mp_obj_t *p
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_then_readfrom_obj, 3, busio_i2c_writeto_then_readfrom);
MP_DEFINE_CONST_FUN_OBJ_KW(busio_i2c_writeto_then_readfrom_obj, 1, busio_i2c_writeto_then_readfrom);
STATIC const mp_rom_map_elem_t busio_i2c_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&busio_i2c_deinit_obj) },

View File

@ -237,13 +237,19 @@ STATIC mp_obj_t busio_spi_obj_unlock(mp_obj_t self_in) {
}
MP_DEFINE_CONST_FUN_OBJ_1(busio_spi_unlock_obj, busio_spi_obj_unlock);
//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: Optional[int] = None) -> None:
//| import sys
//| def write(self, buffer: ReadableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None:
//| """Write the data contained in ``buffer``. The SPI object must be locked.
//| If the buffer is empty, nothing happens.
//|
//| :param ~_typing.ReadableBuffer buffer: Write out the data in this buffer
//| :param int start: Start of the slice of ``buffer`` to write out: ``buffer[start:end]``
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``"""
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``buffer[start:end]``.
//|
//| :param ReadableBuffer buffer: write out bytes from this buffer
//| :param int start: beginning of buffer slice
//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``
//| """
//| ...
//|
@ -276,18 +282,24 @@ STATIC mp_obj_t busio_spi_write(size_t n_args, const mp_obj_t *pos_args, mp_map_
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 2, busio_spi_write);
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_obj, 1, busio_spi_write);
//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: Optional[int] = None, write_value: int = 0) -> None:
//| import sys
//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize, write_value: int = 0) -> None:
//| """Read into ``buffer`` while writing ``write_value`` for each byte read.
//| The SPI object must be locked.
//| If the number of bytes to read is 0, nothing happens.
//|
//| :param ~_typing.WriteableBuffer buffer: Read data into this buffer
//| :param int start: Start of the slice of ``buffer`` to read into: ``buffer[start:end]``
//| :param int end: End of the slice; this index is not included. Defaults to ``len(buffer)``
//| :param int write_value: Value to write while reading. (Usually ignored.)"""
//| If ``start`` or ``end`` is provided, then the buffer will be sliced
//| as if ``buffer[start:end]`` were passed.
//| The number of bytes read will be the length of ``buffer[start:end]``.
//|
//| :param WriteableBuffer buffer: read bytes into this buffer
//| :param int start: beginning of buffer slice
//| :param int end: end of buffer slice; if not specified, use ``len(buffer)``
//| :param int write_value: value to write while reading
//| """
//| ...
//|
@ -321,29 +333,40 @@ STATIC mp_obj_t busio_spi_readinto(size_t n_args, const mp_obj_t *pos_args, mp_m
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 2, busio_spi_readinto);
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_readinto_obj, 1, busio_spi_readinto);
//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: WriteableBuffer, *, out_start: int = 0, out_end: Optional[int] = None, in_start: int = 0, in_end: Optional[int] = None) -> None:
//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``.
//| import sys
//| def write_readinto(self, out_buffer: ReadableBuffer, in_buffer: WriteableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None:
//| """Write out the data in ``out_buffer`` while simultaneously reading data into ``in_buffer``.
//| The SPI object must be locked.
//| The lengths of the slices defined by ``buffer_out[out_start:out_end]`` and ``buffer_in[in_start:in_end]``
//| must be equal.
//|
//| If ``out_start`` or ``out_end`` is provided, then the buffer will be sliced
//| as if ``out_buffer[out_start:out_end]`` were passed, but without copying the data.
//| The number of bytes written will be the length of ``out_buffer[out_start:out_end]``.
//|
//| If ``in_start`` or ``in_end`` is provided, then the input buffer will be sliced
//| as if ``in_buffer[in_start:in_end]`` were passed,
//| The number of bytes read will be the length of ``out_buffer[in_start:in_end]``.
//|
//| The lengths of the slices defined by ``out_buffer[out_start:out_end]``
//| and ``in_buffer[in_start:in_end]`` must be equal.
//| If buffer slice lengths are both 0, nothing happens.
//|
//| :param ~_typing.ReadableBuffer buffer_out: Write out the data in this buffer
//| :param ~_typing.WriteableBuffer buffer_in: Read data into this buffer
//| :param int out_start: Start of the slice of buffer_out to write out: ``buffer_out[out_start:out_end]``
//| :param int out_end: End of the slice; this index is not included. Defaults to ``len(buffer_out)``
//| :param int in_start: Start of the slice of ``buffer_in`` to read into: ``buffer_in[in_start:in_end]``
//| :param int in_end: End of the slice; this index is not included. Defaults to ``len(buffer_in)``"""
//| :param ReadableBuffer out_buffer: write out bytes from this buffer
//| :param WriteableBuffer in_buffer: read bytes into this buffer
//| :param int out_start: beginning of ``out_buffer`` slice
//| :param int out_end: end of ``out_buffer`` slice; if not specified, use ``len(out_buffer)``
//| :param int in_start: beginning of ``in_buffer`` slice
//| :param int in_end: end of ``in_buffer slice``; if not specified, use ``len(in_buffer)``
//| """
//| ...
//|
STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_buffer_out, ARG_buffer_in, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
enum { ARG_out_buffer, ARG_in_buffer, ARG_out_start, ARG_out_end, ARG_in_start, ARG_in_end };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_buffer_out, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_buffer_in, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_out_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_in_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
{ MP_QSTR_out_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
{ MP_QSTR_out_end, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = INT_MAX} },
{ MP_QSTR_in_start, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = 0} },
@ -356,13 +379,13 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_buffer_info_t buf_out_info;
mp_get_buffer_raise(args[ARG_buffer_out].u_obj, &buf_out_info, MP_BUFFER_READ);
mp_get_buffer_raise(args[ARG_out_buffer].u_obj, &buf_out_info, MP_BUFFER_READ);
int32_t out_start = args[ARG_out_start].u_int;
size_t out_length = buf_out_info.len;
normalize_buffer_bounds(&out_start, args[ARG_out_end].u_int, &out_length);
mp_buffer_info_t buf_in_info;
mp_get_buffer_raise(args[ARG_buffer_in].u_obj, &buf_in_info, MP_BUFFER_WRITE);
mp_get_buffer_raise(args[ARG_in_buffer].u_obj, &buf_in_info, MP_BUFFER_WRITE);
int32_t in_start = args[ARG_in_start].u_int;
size_t in_length = buf_in_info.len;
normalize_buffer_bounds(&in_start, args[ARG_in_end].u_int, &in_length);
@ -384,7 +407,7 @@ STATIC mp_obj_t busio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args
}
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 2, busio_spi_write_readinto);
MP_DEFINE_CONST_FUN_OBJ_KW(busio_spi_write_readinto_obj, 1, busio_spi_write_readinto);
//| frequency: int
//| """The actual SPI bus frequency. This may not match the frequency requested

View File

@ -116,7 +116,7 @@ STATIC mp_obj_t camera_obj_take_picture(size_t n_args, const mp_obj_t *pos_args,
return MP_OBJ_NEW_SMALL_INT(common_hal_camera_take_picture(self, (uint8_t *)bufinfo.buf, bufinfo.len, args[ARG_width].u_int, args[ARG_height].u_int, format));
}
MP_DEFINE_CONST_FUN_OBJ_KW(camera_take_picture_obj, 2, camera_obj_take_picture);
MP_DEFINE_CONST_FUN_OBJ_KW(camera_take_picture_obj, 1, camera_obj_take_picture);
STATIC const mp_rom_map_elem_t camera_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&camera_deinit_obj) },

View File

@ -285,8 +285,7 @@ STATIC mp_obj_t displayio_bitmap_obj_blit(size_t n_args, const mp_obj_t *pos_arg
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 4, displayio_bitmap_obj_blit);
// `displayio_bitmap_obj_blit` requires at least 4 arguments
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_bitmap_blit_obj, 1, displayio_bitmap_obj_blit);
//| def fill(self, value: int) -> None:
//| """Fills the bitmap with the supplied palette index value."""

View File

@ -240,7 +240,7 @@ STATIC mp_obj_t displayio_epaperdisplay_update_refresh_mode(size_t n_args, const
displayio_epaperdisplay_change_refresh_mode_parameters(self, &start_sequence, seconds_per_frame);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_epaperdisplay_update_refresh_mode_obj, 3, displayio_epaperdisplay_update_refresh_mode);
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_epaperdisplay_update_refresh_mode_obj, 1, displayio_epaperdisplay_update_refresh_mode);
//| def refresh(self) -> None:
//| """Refreshes the display immediately or raises an exception if too soon. Use

View File

@ -149,7 +149,7 @@ STATIC mp_obj_t displayio_fourwire_obj_send(size_t n_args, const mp_obj_t *pos_a
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 3, displayio_fourwire_obj_send);
MP_DEFINE_CONST_FUN_OBJ_KW(displayio_fourwire_send_obj, 1, displayio_fourwire_obj_send);
STATIC const mp_rom_map_elem_t displayio_fourwire_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_reset), MP_ROM_PTR(&displayio_fourwire_reset_obj) },

View File

@ -112,7 +112,7 @@ STATIC mp_obj_t mod_msgpack_pack(size_t n_args, const mp_obj_t *pos_args, mp_map
common_hal_msgpack_pack(args[ARG_obj].u_obj, args[ARG_buffer].u_obj, handler);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 1, mod_msgpack_pack);
MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_pack_obj, 0, mod_msgpack_pack);
//| def unpack(buffer: ReadableBuffer, *, ext_hook: Union[Callable[[int, bytes], object], None] = None, use_list: bool=True) -> object:
@ -144,7 +144,7 @@ STATIC mp_obj_t mod_msgpack_unpack(size_t n_args, const mp_obj_t *pos_args, mp_m
return common_hal_msgpack_unpack(args[ARG_buffer].u_obj, hook, args[ARG_use_list].u_bool);
}
MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_unpack_obj, 1, mod_msgpack_unpack);
MP_DEFINE_CONST_FUN_OBJ_KW(mod_msgpack_unpack_obj, 0, mod_msgpack_unpack);
STATIC const mp_rom_map_elem_t msgpack_module_globals_table[] = {

View File

@ -88,7 +88,7 @@ STATIC mp_obj_t qrio_qrdecoder_decode(size_t n_args, const mp_obj_t *pos_args, m
return shared_module_qrio_qrdecoder_decode(self, &bufinfo, policy);
}
MP_DEFINE_CONST_FUN_OBJ_KW(qrio_qrdecoder_decode_obj, 2, qrio_qrdecoder_decode);
MP_DEFINE_CONST_FUN_OBJ_KW(qrio_qrdecoder_decode_obj, 1, qrio_qrdecoder_decode);
//| width: int
//| """The width of image the decoder expects"""

View File

@ -69,19 +69,20 @@ STATIC mp_obj_t socketpool_socketpool_make_new(const mp_obj_type_t *type, size_t
//| :param ~int type: SOCK_STREAM, SOCK_DGRAM or SOCK_RAW"""
//| ...
//|
STATIC mp_obj_t socketpool_socketpool_socket(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 0, 5, false);
enum { ARG_family, ARG_type };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_family, MP_ARG_INT, {.u_int = SOCKETPOOL_AF_INET} },
{ MP_QSTR_type, MP_ARG_INT, {.u_int = SOCKETPOOL_SOCK_STREAM} },
};
socketpool_socketpool_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]);
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);
socketpool_socketpool_addressfamily_t family = args[ARG_family].u_int;
socketpool_socketpool_sock_t type = args[ARG_type].u_int;
socketpool_socketpool_obj_t *self = pos_args[0];
socketpool_socketpool_addressfamily_t family = SOCKETPOOL_AF_INET;
socketpool_socketpool_sock_t type = SOCKETPOOL_SOCK_STREAM;
if (n_args >= 2) {
family = mp_obj_get_int(pos_args[1]);
if (n_args >= 3) {
type = mp_obj_get_int(pos_args[2]);
}
}
return common_hal_socketpool_socket(self, family, type);
}
MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socketpool_socket);
@ -94,7 +95,6 @@ MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_socket_obj, 1, socketpool_socke
//| as a tuple."""
//| ...
//|
STATIC mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_host, ARG_port, ARG_family, ARG_type, ARG_proto, ARG_flags };
static const mp_arg_t allowed_args[] = {
@ -137,7 +137,7 @@ STATIC mp_obj_t socketpool_socketpool_getaddrinfo(size_t n_args, const mp_obj_t
tuple->items[4] = MP_OBJ_FROM_PTR(sockaddr);
return mp_obj_new_list(1, (mp_obj_t *)&tuple);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_getaddrinfo_obj, 3, socketpool_socketpool_getaddrinfo);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(socketpool_socketpool_getaddrinfo_obj, 1, socketpool_socketpool_getaddrinfo);
STATIC const mp_rom_map_elem_t socketpool_socketpool_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_socket), MP_ROM_PTR(&socketpool_socketpool_socket_obj) },

View File

@ -79,7 +79,7 @@ STATIC mp_obj_t ssl_sslcontext_wrap_socket(size_t n_args, const mp_obj_t *pos_ar
return common_hal_ssl_sslcontext_wrap_socket(self, sock, server_side, server_hostname);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_wrap_socket_obj, 2, ssl_sslcontext_wrap_socket);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(ssl_sslcontext_wrap_socket_obj, 1, ssl_sslcontext_wrap_socket);
STATIC const mp_rom_map_elem_t ssl_sslcontext_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_wrap_socket), MP_ROM_PTR(&ssl_sslcontext_wrap_socket_obj) },

View File

@ -48,26 +48,30 @@
//|
//| This is the CircuitPython analog to the UNIX ``mount`` command.
//|
//| :param bool readonly: True when the filesystem should be readonly to CircuitPython."""
//| :param VfsFat filesystem: The filesystem to mount.
//| :param str mount_path: Where to mount the filesystem.
//| :param bool readonly: True when the filesystem should be readonly to CircuitPython.
//| """
//| ...
//|
mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_readonly };
enum { ARG_filesystem, ARG_mount_path, ARG_readonly };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_filesystem, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_mount_path, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_readonly, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
};
// parse args
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args - 2, pos_args + 2, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
// get the mount point
const char *mnt_str = mp_obj_str_get_str(pos_args[1]);
const char *mnt_str = mp_obj_str_get_str(args[ARG_mount_path].u_obj);
// Make sure we're given an object we can mount.
// TODO(tannewt): Make sure we have all the methods we need to operating it
// as a file system.
mp_obj_t vfs_obj = pos_args[0];
mp_obj_t vfs_obj = args[ARG_filesystem].u_obj;
mp_obj_t dest[2];
mp_load_method_maybe(vfs_obj, MP_QSTR_mount, dest);
if (dest[0] == MP_OBJ_NULL) {
@ -78,7 +82,7 @@ mp_obj_t storage_mount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_arg
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 2, storage_mount);
MP_DEFINE_CONST_FUN_OBJ_KW(storage_mount_obj, 0, storage_mount);
//| def umount(mount: Union[str, VfsFat]) -> None:
//| """Unmounts the given filesystem object or if *mount* is a path, then unmount
@ -101,6 +105,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount);
//| def remount(mount_path: str, readonly: bool = False, *, disable_concurrent_write_protection: bool = False) -> None:
//| """Remounts the given path with new parameters.
//|
//| :param str mount_path: The path to remount.
//| :param bool readonly: True when the filesystem should be readonly to CircuitPython.
//| :param bool disable_concurrent_write_protection: When True, the check that makes sure the
//| underlying filesystem data is written by one computer is disabled. Disabling the protection
@ -109,24 +114,23 @@ MP_DEFINE_CONST_FUN_OBJ_1(storage_umount_obj, storage_umount);
//| ...
//|
mp_obj_t storage_remount(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_readonly, ARG_disable_concurrent_write_protection };
enum { ARG_mount_path, ARG_readonly, ARG_disable_concurrent_write_protection };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_mount_path, MP_ARG_OBJ | MP_ARG_REQUIRED },
{ MP_QSTR_readonly, MP_ARG_BOOL, {.u_bool = false} },
{ MP_QSTR_disable_concurrent_write_protection, MP_ARG_KW_ONLY | MP_ARG_BOOL, {.u_bool = false} },
};
// get the mount point
const char *mnt_str = mp_obj_str_get_str(pos_args[0]);
// parse 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);
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
const char *mnt_str = mp_obj_str_get_str(args[ARG_mount_path].u_obj);
common_hal_storage_remount(mnt_str, args[ARG_readonly].u_bool, args[ARG_disable_concurrent_write_protection].u_bool);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 1, storage_remount);
MP_DEFINE_CONST_FUN_OBJ_KW(storage_remount_obj, 0, storage_remount);
//| def getmount(mount_path: str) -> VfsFat:
//| """Retrieves the mount object associated with the mount path"""

View File

@ -105,7 +105,7 @@ STATIC mp_obj_t traceback_format_exception(size_t n_args, const mp_obj_t *pos_ar
return mp_obj_new_str_from_vstr(&mp_type_str, &vstr);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 3, traceback_format_exception);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_format_exception_obj, 0, traceback_format_exception);
//| def print_exception(etype: Type[BaseException], value: BaseException, tb: TracebackType,
//| limit: Optional[int] = None, file: Optional[io.FileIO] = None, chain: Optional[bool] = True) -> None:
@ -155,7 +155,7 @@ STATIC mp_obj_t traceback_print_exception(size_t n_args, const mp_obj_t *pos_arg
traceback_exception_common(&print, args[ARG_value].u_obj, args[ARG_tb].u_obj, args[ARG_limit].u_obj);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_print_exception_obj, 3, traceback_print_exception);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(traceback_print_exception_obj, 0, traceback_print_exception);
STATIC const mp_rom_map_elem_t traceback_module_globals_table[] = {
// module name

View File

@ -189,7 +189,7 @@ STATIC mp_obj_t usb_hid_device_send_report(size_t n_args, const mp_obj_t *pos_ar
common_hal_usb_hid_device_send_report(self, ((uint8_t *)bufinfo.buf), bufinfo.len, report_id);
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_device_send_report_obj, 2, usb_hid_device_send_report);
MP_DEFINE_CONST_FUN_OBJ_KW(usb_hid_device_send_report_obj, 1, usb_hid_device_send_report);
//| def get_last_received_report(self, report_id: Optional[int] = None) -> bytes:
//| """Get the last received HID OUT report for the given report ID.