Skip to content

Commit 9b4ffc0

Browse files
committed
Changed unions to ReadableBuffer and WriteableBuffer
1 parent dd27fdf commit 9b4ffc0

14 files changed

Lines changed: 24 additions & 24 deletions

File tree

shared-bindings/_bleio/Address.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
//| """Encapsulates the address of a BLE device."""
3939
//|
4040

41-
//| def __init__(self, address: Union[bytes, bytearray, memoryview], address_type: int):
41+
//| def __init__(self, address: ReadableBuffer, address_type: int):
4242
//| """Create a new Address object encapsulating the address value.
4343
//| The value itself can be one of:
4444
//|

shared-bindings/_bleio/CharacteristicBuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ STATIC void check_for_deinit(bleio_characteristic_buffer_obj_t *self) {
110110
//| :rtype: bytes or None"""
111111
//| ...
112112
//|
113-
//| def readinto(self, buf: Union[bytearray, memoryview]) -> Optional[int]:
113+
//| def readinto(self, buf: WriteableBuffer) -> Optional[int]:
114114
//| """Read bytes into the ``buf``. Read at most ``len(buf)`` bytes.
115115
//|
116116
//| :return: number of bytes read and stored into ``buf``

shared-bindings/_bleio/Descriptor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ const mp_obj_property_t bleio_descriptor_characteristic_obj = {
167167
(mp_obj_t)&mp_const_none_obj },
168168
};
169169

170-
//| value: Union[bytearray, memoryview] = ...
170+
//| value: WriteableBuffer = ...
171171
//| """The value of this descriptor."""
172172
//|
173173
STATIC mp_obj_t bleio_descriptor_get_value(mp_obj_t self_in) {

shared-bindings/_bleio/PacketBuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ STATIC void check_for_deinit(bleio_packet_buffer_obj_t *self) {
9393
}
9494
}
9595

96-
//| def readinto(self, buf: Union[bytearray, memoryview]) -> int:
96+
//| def readinto(self, buf: WriteableBuffer) -> int:
9797
//| """Reads a single BLE packet into the ``buf``. Raises an exception if the next packet is longer
9898
//| than the given buffer. Use `packet_size` to read the maximum length of a single packet.
9999
//|

shared-bindings/_bleio/UUID.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ const mp_obj_property_t bleio_uuid_size_obj = {
186186
};
187187

188188

189-
//| def pack_into(self, buffer: Union[bytearray, memoryview], offset: int = 0) -> None:
189+
//| def pack_into(self, buffer: WriteableBuffer, offset: int = 0) -> None:
190190
//| """Packs the UUID into the given buffer at the given offset."""
191191
//| ...
192192
//|

shared-bindings/aesio/aes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
//| class AES:
1313
//| """Encrypt and decrypt AES streams"""
1414
//|
15-
//| def __init__(self, key: Union[bytes, bytearray, memoryview], mode: int=0, iv: Union[bytes, bytearray, memoryview]=None, segment_size: int=8) -> AES:
15+
//| def __init__(self, key: ReadableBuffer, mode: int=0, iv: ReadableBuffer=None, segment_size: int=8) -> AES:
1616
//| """Create a new AES state with the given key.
1717
//|
1818
//| :param bytearray key: A 16-, 24-, or 32-byte key
@@ -152,7 +152,7 @@ STATIC void validate_length(aesio_aes_obj_t *self, size_t src_length,
152152
}
153153
}
154154

155-
//| def encrypt_into(src: Union[bytearray, memoryview], dest: Union[bytearray, memoryview]) -> None:
155+
//| def encrypt_into(src: WriteableBuffer, dest: WriteableBuffer) -> None:
156156
//| """Encrypt the buffer from ``src`` into ``dest``.
157157
//|
158158
//| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the
@@ -183,7 +183,7 @@ STATIC mp_obj_t aesio_aes_encrypt_into(mp_obj_t aesio_obj, mp_obj_t src,
183183
STATIC MP_DEFINE_CONST_FUN_OBJ_3(aesio_aes_encrypt_into_obj,
184184
aesio_aes_encrypt_into);
185185

186-
//| def decrypt_into(src: Union[bytearray, memoryview], dest: Union[bytearray, memoryview]) -> None:
186+
//| def decrypt_into(src: WriteableBuffer, dest: WriteableBuffer) -> None:
187187
//|
188188
//| """Decrypt the buffer from ``src`` into ``dest``.
189189
//| For ECB mode, the buffers must be 16 bytes long. For CBC mode, the

shared-bindings/audiobusio/PDMIn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ STATIC mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *arg
168168
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, audiobusio_pdmin_obj___exit__);
169169

170170

171-
//| def record(self, destination: Union[bytearray, memoryview], destination_length: int) -> None:
171+
//| def record(self, destination: WriteableBuffer, destination_length: int) -> None:
172172
//| """Records destination_length bytes of samples to destination. This is
173173
//| blocking.
174174
//|

shared-bindings/audiocore/WaveFile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
4141
//| an internal buffer."""
4242
//|
43-
//| def __init__(self, file: typing.BinaryIO, buffer: Union[bytes, bytearray, memoryview]):
43+
//| def __init__(self, file: typing.BinaryIO, buffer: ReadableBuffer):
4444
//| """Load a .wav file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
4545
//|
4646
//| :param typing.BinaryIO file: Already opened wave file

shared-bindings/audiomp3/MP3Decoder.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
//| class MP3:
3838
//| """Load a mp3 file for audio playback"""
3939
//|
40-
//| def __init__(self, file: typing.BinaryIO, buffer: Union[bytearray, memoryview]):
40+
//| def __init__(self, file: typing.BinaryIO, buffer: WriteableBuffer):
4141
//|
4242
//| """Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
4343
//|

shared-bindings/bitbangio/I2C.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ STATIC mp_obj_t bitbangio_i2c_obj_unlock(mp_obj_t self_in) {
165165
}
166166
MP_DEFINE_CONST_FUN_OBJ_1(bitbangio_i2c_unlock_obj, bitbangio_i2c_obj_unlock);
167167

168-
//| def readfrom_into(self, address: int, buffer: Union[bytearray, memoryview], *, start: int = 0, end: int = None) -> None:
168+
//| def readfrom_into(self, address: int, buffer: WriteableBuffer, *, start: int = 0, end: int = None) -> None:
169169
//| """Read into ``buffer`` from the device selected by ``address``.
170170
//| The number of bytes read will be the length of ``buffer``.
171171
//| At least one byte must be read.
@@ -217,7 +217,7 @@ STATIC mp_obj_t bitbangio_i2c_readfrom_into(size_t n_args, const mp_obj_t *pos_a
217217
}
218218
MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_readfrom_into_obj, 3, bitbangio_i2c_readfrom_into);
219219

220-
//| def writeto(self, address: int, buffer: Union[bytes, bytearray, memoryview], *, start: int = 0, end: int = None, stop: bool = True) -> None:
220+
//| def writeto(self, address: int, buffer: ReadableBuffer, *, start: int = 0, end: int = None, stop: bool = True) -> None:
221221
//| """Write the bytes from ``buffer`` to the device selected by ``address`` and then transmits a
222222
//| stop bit. Use `writeto_then_readfrom` when needing a write, no stop and repeated start
223223
//| before a read.
@@ -277,7 +277,7 @@ STATIC mp_obj_t bitbangio_i2c_writeto(size_t n_args, const mp_obj_t *pos_args, m
277277
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(bitbangio_i2c_writeto_obj, 1, bitbangio_i2c_writeto);
278278

279279

280-
//| def writeto_then_readfrom(self, address: int, out_buffer: Union[bytearray, memoryview], in_buffer: Union[bytes, bytearray, memoryview], *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> None:
280+
//| def writeto_then_readfrom(self, address: int, out_buffer: WriteableBuffer, in_buffer: ReadableBuffer, *, out_start: int = 0, out_end: int = None, in_start: int = 0, in_end: int = None) -> None:
281281
//| """Write the bytes from ``out_buffer`` to the device selected by ``address``, generate no stop
282282
//| bit, generate a repeated start and read into ``in_buffer``. ``out_buffer`` and
283283
//| ``in_buffer`` can be the same buffer because they are used sequentially.

0 commit comments

Comments
 (0)