8000 add, use a default exit object · adafruit/circuitpython@8aa1969 · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit 8aa1969

Browse files
committed
add, use a default exit object
This just delegates to .deinit(). Also, change default __enter__ to a macro that reuses the identically-beving "identity_obj", and harmonize a few sites so that the naming s consistent. Saves about 800 bytes on metro rp2350.
1 parent 95179be commit 8aa1969

File tree

47 files changed

+105
-320
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+105
-320
lines changed

ports/espressif/bindings/espcamera/Camera.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include "shared-bindings/displayio/Bitmap.h"
1919
#include "shared-bindings/microcontroller/Pin.h"
2020
#include "shared-bindings/util.h"
21+
#include "shared/runtime/context_manager_helpers.h"
2122
#include "esp_camera.h"
2223
#include "sensor.h"
2324

@@ -169,11 +170,7 @@ static void check_for_deinit(espcamera_camera_obj_t *self) {
169170
//| :ref:`lifetime-and-contextmanagers` for more info."""
170171
//| ...
171172
//|
172-
static mp_obj_t espcamera_camera_obj___exit__(size_t n_args, const mp_obj_t *args) {
173-
(void)n_args;
174-
return espcamera_camera_deinit(args[0]);
175-
}
176-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espcamera_camera___exit___obj, 4, 4, espcamera_camera_obj___exit__);
173+
// Provided by context manager helper.
177174

178175
//| frame_available: bool
179176
//| """True if a frame is available, False otherwise"""
@@ -947,8 +944,8 @@ static const mp_rom_map_elem_t espcamera_camera_locals_table[] = {
947944
{ MP_ROM_QSTR(MP_QSTR_denoise), MP_ROM_PTR(&espcamera_camera_denoise_obj) },
948945
{ MP_ROM_QSTR(MP_QSTR_framebuffer_count), MP_ROM_PTR(&espcamera_camera_framebuffer_count_obj) },
949946
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&espcamera_camera_deinit_obj) },
950-
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
951-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espcamera_camera___exit___obj) },
947+
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
948+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
952949
{ MP_ROM_QSTR(MP_QSTR_exposure_ctrl), MP_ROM_PTR(&espcamera_camera_exposure_ctrl_obj) },
953950
{ MP_ROM_QSTR(MP_QSTR_frame_available), MP_ROM_PTR(&espcamera_camera_frame_available_obj) },
954951
{ MP_ROM_QSTR(MP_QSTR_frame_size), MP_ROM_PTR(&espcamera_camera_frame_size_obj) },

ports/espressif/bindings/espnow/ESPNow.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "py/stream.h"
1313

1414
#include "shared-bindings/util.h"
15+
#include "shared/runtime/context_manager_helpers.h"
1516

1617
#include "bindings/espnow/ESPNow.h"
1718
#include "bindings/espnow/Peer.h"
@@ -92,11 +93,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(espnow_deinit_obj, espnow_deinit);
9293
//| :ref:`lifetime-and-contextmanagers` for more info."""
9394
//| ...
9495
//|
95-
static mp_obj_t espnow_obj___exit__(size_t n_args, const mp_obj_t *args) {
96-
(void)n_args;
97-
return espnow_deinit(args[0]);
98-
}
99-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espnow___exit___obj, 4, 4, espnow_obj___exit__);
96+
// Provided by context manager helper.
10097

10198
// --- Send and Read messages ---
10299

@@ -270,8 +267,8 @@ MP_PROPERTY_GETTER(espnow_peers_obj,
270267

271268
static const mp_rom_map_elem_t espnow_locals_dict_table[] = {
272269
// Context managers
273-
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
274-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espnow___exit___obj) },
270+
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
271+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
275272

276273
// Deinit the object
277274
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&espnow_deinit_obj) },

ports/espressif/bindings/espulp/ULP.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "shared-bindings/microcontroller/Pin.h"
88
#include "shared-bindings/util.h"
9+
#include "shared/runtime/context_manager_helpers.h"
910
#include "bindings/espulp/ULP.h"
1011

1112
#include "py/enum.h"
@@ -69,11 +70,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(espulp_ulp_deinit_obj, espulp_ulp_deinit);
6970
//| :ref:`lifetime-and-contextmanagers` for more info."""
7071
//| ...
7172
//|
72-
static mp_obj_t espulp_ulp_obj___exit__(size_t n_args, const mp_obj_t *args) {
73-
(void)n_args;
74-
return espulp_ulp_deinit(args[0]);
75-
}
76-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(espulp_ulp___exit___obj, 4, 4, espulp_ulp_obj___exit__);
73+
// Provided by context manager helper.
7774

7875
//| def set_wakeup_period(self, period_index: int, period_us: int) -> None:
7976
//| """Sets the wakeup period for the ULP.
@@ -188,8 +185,8 @@ MP_PROPERTY_GETTER(espulp_ulp_arch_obj,
188185

189186
static const mp_rom_map_elem_t espulp_ulp_locals_table[] = {
190187
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&espulp_ulp_deinit_obj) },
191-
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
192-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&espulp_ulp___exit___obj) },
188+
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
189+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
193190
{ MP_ROM_QSTR(MP_QSTR_set_wakeup_period), MP_ROM_PTR(&espulp_ulp_set_wakeup_period_obj) },
194191
{ MP_ROM_QSTR(MP_QSTR_run), MP_ROM_PTR(&espulp_ulp_run_obj) },
195192
{ MP_ROM_QSTR(MP_QSTR_halt), MP_ROM_PTR(&espulp_ulp_halt_obj) },

ports/raspberrypi/bindings/rp2pio/StateMachine.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,6 @@ MP_DEFINE_CONST_FUN_OBJ_1(rp2pio_statemachine_deinit_obj, rp2pio_statemachine_ob
378378
//| :ref:`lifetime-and-contextmanagers` for more info."""
379379
//| ...
380380
//|
381-
static mp_obj_t rp2pio_statemachine_obj___exit__(size_t n_args, const mp_obj_t *args) {
382-
(void)n_args;
383-
common_hal_rp2pio_statemachine_deinit(args[0]);
384-
return mp_const_none;
385-
}
386-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(rp2pio_statemachine_obj___exit___obj, 4, 4, rp2pio_statemachine_obj___exit__);
387381

388382

389383
static void check_for_deinit(rp2pio_statemachine_obj_t *self) {
@@ -1126,7 +1120,7 @@ MP_PROPERTY_GETTER(rp2pio_statemachine_last_write_obj,
11261120
static const mp_rom_map_elem_t rp2pio_statemachine_locals_dict_table[] = {
11271121
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&rp2pio_statemachine_deinit_obj) },
11281122
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
1129-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&rp2pio_statemachine_obj___exit___obj) },
1123+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
11301124

11311125
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&rp2pio_statemachine_stop_obj) },
11321126
{ MP_ROM_QSTR(MP_QSTR_restart), MP_ROM_PTR(&rp2pio_statemachine_restart_obj) },

ports/zephyr-cp/bindings/zephyr_serial/UART.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ static const mp_rom_map_elem_t _zephyr_serial_uart_locals_dict_table[] = {
259259
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&_zephyr_serial_uart_deinit_obj) },
260260
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&_zephyr_serial_uart_deinit_obj) },
261261
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
262-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&_zephyr_serial_uart___exit___obj) },
262+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
263263

264264
// Standard stream methods.
265265
{ MP_OBJ_NEW_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },

shared-bindings/analogbufio/BufferedIn.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,7 @@ static void check_for_deinit(analogbufio_bufferedin_obj_t *self) {
9191
//| :ref:`lifetime-and-contextmanagers` for more info."""
9292
//| ...
9393
//|
94-
static mp_obj_t analogbufio_bufferedin___exit__(size_t n_args, const mp_obj_t *args) {
95-
(void)n_args;
96-
common_hal_analogbufio_bufferedin_deinit(args[0]);
97-
return mp_const_none;
98-
}
99-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogbufio_bufferedin___exit___obj, 4, 4, analogbufio_bufferedin___exit__);
94+
// Provided by context manager helper.
10095

10196
//| def readinto(self, buffer: WriteableBuffer, loop: bool = False) -> int:
10297
//| """Fills the provided buffer with ADC voltage values.
@@ -144,7 +139,7 @@ static const mp_rom_map_elem_t analogbufio_bufferedin_locals_dict_table[] = {
144139
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&analogbufio_bufferedin_deinit_obj) },
145140
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&analogbufio_bufferedin_deinit_obj) },
146141
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
147-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&analogbufio_bufferedin___exit___obj) },
142+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
148143
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&analogbufio_bufferedin_readinto_obj)},
149144
};
150145

shared-bindings/analogio/AnalogIn.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,7 @@ static void check_for_deinit(analogio_analogin_obj_t *self) {
8787
//| :ref:`lifetime-and-contextmanagers` for more info."""
8888
//| ...
8989
//|
90-
static mp_obj_t analogio_analogin___exit__(size_t n_args, const mp_obj_t *args) {
91-
(void)n_args;
92-
common_hal_analogio_analogin_deinit(args[0]);
93-
return mp_const_none;
94-
}
95-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogin___exit___obj, 4, 4, analogio_analogin___exit__);
90+
// Provided by context manager helper.
9691

9792
//| value: int
9893
//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (read-only)
@@ -135,7 +130,7 @@ MP_PROPERTY_GETTER(analogio_analogin_reference_voltage_obj,
135130
static const mp_rom_map_elem_t analogio_analogin_locals_dict_table[] = {
136131
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&analogio_analogin_deinit_obj) },
137132
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
138-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&analogio_analogin___exit___obj) },
133+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
139134
{ MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&analogio_analogin_value_obj)},
140135
{ MP_ROM_QSTR(MP_QSTR_reference_voltage), MP_ROM_PTR(&analogio_analogin_reference_voltage_obj)},
141136
};

shared-bindings/analogio/AnalogOut.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(analogio_analogout_deinit_obj, analogio_analogo
7373
//| :ref:`lifetime-and-contextmanagers` for more info."""
7474
//| ...
7575
//|
76-
static mp_obj_t analogio_analogout___exit__(size_t n_args, const mp_obj_t *args) {
77-
(void)n_args;
78-
common_hal_analogio_analogout_deinit(args[0]);
79-
return mp_const_none;
80-
}
81-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(analogio_analogout___exit___obj, 4, 4, analogio_analogout___exit__);
76+
// Provided by context manager helper.
8277

8378
//| value: int
8479
//| """The value on the analog pin between 0 and 65535 inclusive (16-bit). (write-only)
@@ -107,7 +102,7 @@ static const mp_rom_map_elem_t analogio_analogout_locals_dict_table[] = {
107102
// instance methods
108103
{ MP_OBJ_NEW_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&analogio_analogout_deinit_obj) },
109104
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
110-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&analogio_analogout___exit___obj) },
105+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
111106

112107
// Properties
113108
{ MP_OBJ_NEW_QSTR(MP_QSTR_value), (mp_obj_t)&analogio_analogout_value_obj },

shared-bindings/audiobusio/I2SOut.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,7 @@ static void check_for_deinit(audiobusio_i2sout_obj_t *self) {
135135
//| :ref:`lifetime-and-contextmanagers` for more info."""
136136
//| ...
137137
//|
138-
static mp_obj_t audiobusio_i2sout_obj___exit__(size_t n_args, const mp_obj_t *args) {
139-
(void)n_args;
140-
common_hal_audiobusio_i2sout_deinit(args[0]);
141-
return mp_const_none;
142-
}
143-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, audiobusio_i2sout_obj___exit__);
138+
// Provided by context manager helper.
144139

145140

146141
//| def play(self, sample: circuitpython_typing.AudioSample, *, loop: bool = False) -> None:
@@ -248,7 +243,7 @@ static const mp_rom_map_elem_t audiobusio_i2sout_locals_dict_table[] = {
248243
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&audiobusio_i2sout_deinit_obj) },
249244
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiobusio_i2sout_deinit_obj) },
250245
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
251-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiobusio_i2sout___exit___obj) },
246+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
252247
{ MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiobusio_i2sout_play_obj) },
253248
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiobusio_i2sout_stop_obj) },
254249
{ MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&audiobusio_i2sout_pause_obj) },

shared-bindings/audiobusio/PDMIn.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,7 @@ static void check_for_deinit(audiobusio_pdmin_obj_t *self) {
152152
//| """Automatically deinitializes the hardware when exiting a context."""
153153
//| ...
154154
//|
155-
static mp_obj_t audiobusio_pdmin_obj___exit__(size_t n_args, const mp_obj_t *args) {
156-
(void)n_args;
157-
common_hal_audiobusio_pdmin_deinit(args[0]);
158-
return mp_const_none;
159-
}
160-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_pdmin___exit___obj, 4, 4, audiobusio_pdmin_obj___exit__);
155+
// Provided by context manager helper.
161156

162157

163158
//| def record(self, destination: WriteableBuffer, destination_length: int) -> None:
@@ -220,7 +215,7 @@ static const mp_rom_map_elem_t audiobusio_pdmin_locals_dict_table[] = {
220215
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&audiobusio_pdmin_deinit_obj) },
221216
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiobusio_pdmin_deinit_obj) },
222217
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
223-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiobusio_pdmin___exit___obj) },
218+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
224219
{ MP_ROM_QSTR(MP_QSTR_record), MP_ROM_PTR(&audiobusio_pdmin_record_obj) },
225220
{ MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&audiobusio_pdmin_sample_rate_obj) }
226221
};

shared-bindings/audiocore/RawSample.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(audioio_rawsample_deinit_obj, audioio_rawsample
132132
//| :ref:`lifetime-and-contextmanagers` for more info."""
133133
//| ...
134134
//|
135-
static mp_obj_t audioio_rawsample_obj___exit__(size_t n_args, const mp_obj_t *args) {
136-
(void)n_args;
137-
common_hal_audioio_rawsample_deinit(args[0]);
138-
return mp_const_none;
139-
}
140-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_rawsample___exit___obj, 4, 4, audioio_rawsample_obj___exit__);
135+
// Provided by context manager helper.
141136

142137
//| sample_rate: Optional[int]
143138
//| """32 bit value that dictates how quickly samples are played in Hertz (cycles per second).
@@ -151,7 +146,7 @@ static const mp_rom_map_elem_t audioio_rawsample_locals_dict_table[] = {
151146
// Methods
152147
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audioio_rawsample_deinit_obj) },
153148
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
154-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audioio_rawsample___exit___obj) },
149+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
155150

156151
// Properties
157152
AUDIOSAMPLE_FIELDS,

shared-bindings/audiocore/WaveFile.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,7 @@ static MP_DEFINE_CONST_FUN_OBJ_1(audioio_wavefile_deinit_obj, audioio_wavefile_d
100100
//| :ref:`lifetime-and-contextmanagers` for more info."""
101101
//| ...
102102
//|
103-
static mp_obj_t audioio_wavefile_obj___exit__(size_t n_args, const mp_obj_t *args) {
104-
(void)n_args;
105-
common_hal_audioio_wavefile_deinit(args[0]);
106-
return mp_const_none;
107-
}
108-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_wavefile___exit___obj, 4, 4, audioio_wavefile_obj___exit__);
103+
// Provided by context manager helper.
109104

110105
//| sample_rate: int
111106
//| """32 bit value that dictates how quickly samples are loaded into the DAC
@@ -124,7 +119,7 @@ static const mp_rom_map_elem_t audioio_wavefile_locals_dict_table[] = {
124119
// Methods
125120
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audioio_wavefile_deinit_obj) },
126121
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
127-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audioio_wavefile___exit___obj) },
122+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
128123

129124
// Properties
130125
AUDIOSAMPLE_FIELDS,

shared-bindings/audiodelays/Echo.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,12 +137,7 @@ static void check_for_deinit(audiodelays_echo_obj_t *self) {
137137
//| :ref:`lifetime-and-contextmanagers` for more info."""
138138
//| ...
139139
//|
140-
static mp_obj_t audiodelays_echo_obj___exit__(size_t n_args, const mp_obj_t *args) {
141-
(void)n_args;
142-
common_hal_audiodelays_echo_deinit(args[0]);
143-
return mp_const_none;
144-
}
145-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiodelays_echo___exit___obj, 4, 4, audiodelays_echo_obj___exit__);
140+
// Provided by context manager helper.
146141

147142

148143
//| delay_ms: synthio.BlockInput
@@ -281,7 +276,7 @@ static const mp_rom_map_elem_t audiodelays_echo_locals_dict_table[] = {
281276
// Methods
282277
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiodelays_echo_deinit_obj) },
283278
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
284-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiodelays_echo___exit___obj) },
279+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
285280
{ MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiodelays_echo_play_obj) },
286281
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiodelays_echo_stop_obj) },
287282

shared-bindings/audiofilters/Distortion.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,7 @@ static void check_for_deinit(audiofilters_distortion_obj_t *self) {
176176
//| :ref:`lifetime-and-contextmanagers` for more info."""
177177
//| ...
178178
//|
179-
static mp_obj_t audiofilters_distortion_obj___exit__(size_t n_args, const mp_obj_t *args) {
180-
(void)n_args;
181-
common_hal_audiofilters_distortion_deinit(args[0]);
182-
return mp_const_none;
183-
}
184-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiofilters_distortion___exit___obj, 4, 4, audiofilters_distortion_obj___exit__);
179+
// Provided by context manager helper.
185180

186181

187182
//| drive: synthio.BlockInput
@@ -357,7 +352,7 @@ static const mp_rom_map_elem_t audiofilters_distortion_locals_dict_table[] = {
357352
// Methods
358353
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiofilters_distortion_deinit_obj) },
359354
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
360-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiofilters_distortion___exit___obj) },
355+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
361356
{ MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiofilters_distortion_play_obj) },
362357
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiofilters_distortion_stop_obj) },
363358

shared-bindings/audiofilters/Filter.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,7 @@ static void check_for_deinit(audiofilters_filter_obj_t *self) {
124124
//| :ref:`lifetime-and-contextmanagers` for more info."""
125125
//| ...
126126
//|
127-
static mp_obj_t audiofilters_filter_obj___exit__(size_t n_args, const mp_obj_t *args) {
128-
(void)n_args;
129-
common_hal_audiofilters_filter_deinit(args[0]);
130-
return mp_const_none;
131-
}
132-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiofilters_filter___exit___obj, 4, 4, audiofilters_filter_obj___exit__);
127+
// Provided by context manager helper.
133128

134129

135130
//| filter: synthio.Biquad | Tuple[synthio.Biquad] | None
@@ -229,7 +224,7 @@ static const mp_rom_map_elem_t audiofilters_filter_locals_dict_table[] = {
229224
// Methods
230225
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiofilters_filter_deinit_obj) },
231226
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
232-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiofilters_filter___exit___obj) },
227+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
233228
{ MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiofilters_filter_play_obj) },
234229
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiofilters_filter_stop_obj) },
235230

shared-bindings/audioio/AudioOut.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -124,13 +124,7 @@ static void check_for_deinit(audioio_audioout_obj_t *self) {
124124
//| :ref:`lifetime-and-contextmanagers` for more info."""
125125
//| ...
126126
//|
127-
static mp_obj_t audioio_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) {
128-
(void)n_args;
129-
common_hal_audioio_audioout_deinit(args[0]);
130-
return mp_const_none;
131-
}
132-
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, audioio_audioout_obj___exit__);
133-
127+
// Provided by context manager helper.
134128

135129
//| def play(self, sample: circuitpython_typing.AudioSample, *, loop: bool = False) -> None:
136130
//| """Plays the sample once when loop=False and continuously when loop=True.
@@ -237,7 +231,7 @@ static const mp_rom_map_elem_t audioio_audioout_locals_dict_table[] = {
237231
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&audioio_audioout_deinit_obj) },
238232
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audioio_audioout_deinit_obj) },
239233
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
240-
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audioio_audioout___exit___obj) },
234+
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
241235
{ MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audioio_audioout_play_obj) },
242236
{ MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audioio_audioout_stop_obj) },
243237
{ MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&audioio_audioout_pause_obj) },

0 commit comments

Comments
 (0)
0