Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fix n_args_min on many MP_DEFINE_CONST_FUN_OBJ_KW() #5439

Merged
merged 3 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions locale/circuitpython.pot
Original file line number Diff line number Diff line change
Expand Up @@ -3943,6 +3943,7 @@ msgstr ""
#: ports/espressif/boards/adafruit_funhouse/mpconfigboard.h
#: ports/espressif/boards/adafruit_magtag_2.9_grayscale/mpconfigboard.h
#: ports/espressif/boards/adafruit_metro_esp32s2/mpconfigboard.h
#: ports/espressif/boards/ai_thinker_esp32-c3s/mpconfigboard.h
#: ports/espressif/boards/ai_thinker_esp_12k_nodemcu/mpconfigboard.h
#: ports/espressif/boards/artisense_rd00/mpconfigboard.h
#: ports/espressif/boards/atmegazero_esp32s2/mpconfigboard.h
Expand All @@ -3961,6 +3962,7 @@ msgstr ""
#: ports/espressif/boards/gravitech_cucumber_rs/mpconfigboard.h
#: ports/espressif/boards/lilygo_ttgo_t8_s2_st7789/mpconfigboard.h
#: ports/espressif/boards/lolin_s2_mini/mpconfigboard.h
#: ports/espressif/boards/microdev_micro_c3/mpconfigboard.h
#: ports/espressif/boards/microdev_micro_s2/mpconfigboard.h
#: ports/espressif/boards/morpheans_morphesp-240/mpconfigboard.h
#: ports/espressif/boards/muselab_nanoesp32_s2_wroom/mpconfigboard.h
Expand Down
4 changes: 2 additions & 2 deletions shared-bindings/_bleio/Adapter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/_bleio/Characteristic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));


Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/_bleio/Descriptor.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/_bleio/ScanEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -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`."""
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/_bleio/UUID.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down
35 changes: 19 additions & 16 deletions shared-bindings/adafruit_bus_device/I2CDevice.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,16 +109,17 @@ 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``.
//| import sys
//| def readinto(self, buffer: WriteableBuffer, *, start: int = 0, end: int = sys.maxsize) -> None:
//| """Read into ``buffer`` from the device. The number of bytes read will be the
//| length of ``buffer``.
//| 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.
//| as if ``buffer[start:end]``. This will not cause an allocation like
//| ``buffer[start:end]`` will so it saves memory.
//|
//| :param bytearray buf: buffer to write into
//| :param bytearray buffer: 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)``"""
//| :param int end: Index to write up to but not include; if None, use ``len(buffer)``"""
dhalbert marked this conversation as resolved.
Show resolved Hide resolved
//| ...
//|
STATIC mp_obj_t adafruit_bus_device_i2cdevice_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
Expand Down Expand Up @@ -152,17 +153,18 @@ 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 bytearray 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; if None, use ``len(buf)``
//| :param int end: Index to read up to but not include; if None, use ``len(buffer)``
//| """
//| ...
//|
Expand Down Expand Up @@ -196,10 +198,11 @@ 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: WriteableBuffer, 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, then immediately
//| reads into ``in_buffer`` from the device. The number of bytes read
//| will be the length of ``in_buffer``.
Expand All @@ -215,9 +218,9 @@ MP_DEFINE_CONST_FUN_OBJ_KW(adafruit_bus_device_i2cdevice_write_obj, 2, adafruit_
//| :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 out_end: Index to read up to but not include; if not specified, 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)``
//| :param int in_end: Index to write up to but not include; if not specified, use ``len(in_buffer)``
//| """
//| ...
//|
Expand Down Expand Up @@ -263,7 +266,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) },
Expand Down
19 changes: 11 additions & 8 deletions shared-bindings/bitbangio/I2C.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -215,9 +216,10 @@ 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.
Expand All @@ -232,7 +234,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_rea
//| :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 int end: Index to read up to but not include. If not specified, use ``len(buffer)``"""
//| ...
//|
// Shared arg parsing for writeto and writeto_then_readfrom.
Expand Down Expand Up @@ -274,7 +276,8 @@ 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.
Expand All @@ -287,9 +290,9 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_wr
//| :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 out_end: Index to read up to but not include. If not specified, use ``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 in_end: Index to write up to but not include. If not specified, use ``len(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 };
Expand All @@ -315,7 +318,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) },
Expand Down
16 changes: 9 additions & 7 deletions shared-bindings/bitbangio/SPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,15 @@ 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 end: End of the slice; this index is not included. If not specified, use ``len(buffer)``
//| :param int write_value: Value to write while reading."""
//| ...
//|
Expand Down Expand Up @@ -266,9 +267,10 @@ 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:
//| import sys
//| def write_readinto(self, buffer_out: ReadableBuffer, buffer_in: ReadableBuffer, *, out_start: int = 0, out_end: int = sys.maxsize, in_start: int = 0, in_end: int = sys.maxsize) -> None:
//| """Write out the data in ``buffer_out`` while simultaneously reading data into ``buffer_in``.
//| 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]``
Expand All @@ -278,9 +280,9 @@ MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_spi_readinto_obj, 2, bitbangio_spi_readinto
//| :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 out_end: End of the slice; this index is not included. If not specified, use ``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 int in_end: End of the slice; this index is not included. If not specified, use ``len(buffer_in)``"""
//| ...
//|
STATIC mp_obj_t bitbangio_spi_write_readinto(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
Expand Down Expand Up @@ -329,7 +331,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) },
Expand Down
2 changes: 1 addition & 1 deletion shared-bindings/bitops/__init__.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down
Loading