Skip to content

Commit dbc28e3

Browse files
author
Joe Bakalor
authored
Merge pull request #2 from adafruit/master
Pull master
2 parents ba83a4a + 19ac8ae commit dbc28e3

File tree

218 files changed

+6285
-2474
lines changed

Some content is hidden

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

218 files changed

+6285
-2474
lines changed

.github/workflows/build.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ jobs:
137137
- "pyportal"
138138
- "pyportal_titano"
139139
- "pyruler"
140-
- "robohatmm1_m0"
141140
- "robohatmm1_m4"
142141
- "sam32"
143142
- "serpente"
143+
- "shirtty"
144144
- "snekboard"
145145
- "sparkfun_lumidrive"
146146
- "sparkfun_nrf52840_mini"
@@ -169,7 +169,8 @@ jobs:
169169
run: |
170170
sudo apt-get install -y gettext
171171
pip install requests sh click setuptools awscli
172-
wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~xenial1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb
172+
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
173+
sudo tar -C /usr --strip-components=1 -xaf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
173174
- name: Versions
174175
run: |
175176
gcc --version
@@ -190,7 +191,7 @@ jobs:
190191
name: ${{ matrix.board }}
191192
path: bin/${{ matrix.board }}
192193
- name: Upload to S3
193-
run: aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1
194+
run: "[ -z \"$AWS_ACCESS_KEY_ID\" ] || aws s3 cp bin/ s3://adafruit-circuit-python/bin/ --recursive --no-progress --region us-east-1"
194195
env:
195196
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
196197
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
@@ -199,7 +200,7 @@ jobs:
199200
run: |
200201
pip install uritemplate
201202
- name: Upload to Release
202-
run: python3 -u upload_release_files.py
203+
run: "[ -z \"$ADABOT_GITHUB_ACCESS_TOKEN\" ] || python3 -u upload_release_files.py"
203204
working-directory: tools
204205
env:
205206
UPLOAD_URL: ${{ github.event.release.upload_url }}

.gitmodules

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
[submodule "lib/tinyusb"]
7777
path = lib/tinyusb
7878
url = https://github.com/hathach/tinyusb.git
79-
branch = develop
79+
branch = master
80+
fetchRecurseSubmodules = false
8081
[submodule "tools/huffman"]
8182
path = tools/huffman
8283
url = https://github.com/tannewt/huffman.git

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ pseudoxml:
204204
all-source:
205205

206206
locale/circuitpython.pot: all-source
207-
find $(TRANSLATE_SOURCES) -iname "*.c" -print0 | (LC_ALL=C sort -z) | xargs -0 xgettext -L C -s --add-location=file --keyword=translate -o circuitpython.pot -p locale
207+
find $(TRANSLATE_SOURCES) -iname "*.c" -print | (LC_ALL=C sort) | xgettext -f- -L C -s --add-location=file --keyword=translate -o circuitpython.pot -p locale
208208

209209
translate: locale/circuitpython.pot
210210
for po in $(shell ls locale/*.po); do msgmerge -U $$po -s --no-fuzzy-matching --add-location=file locale/circuitpython.pot; done

drivers/wiznet5k/internet/dns/dns.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
#include <string.h>
5454
#include <stdlib.h>
55-
#include "tick.h"
55+
#include "supervisor/shared/tick.h"
5656

5757
//#include "Ethernet/socket.h"
5858
//#include "Internet/DNS/dns.h"
@@ -125,7 +125,7 @@ uint16_t DNS_MSGID; // DNS message ID
125125

126126

127127
uint32_t HAL_GetTick(void) {
128-
return ticks_ms;
128+
return supervisor_ticks_ms32();
129129
}
130130

131131
uint32_t hal_sys_tick;

extmod/machine_i2c.c

+11-10
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ MP_DEFINE_CONST_FUN_OBJ_KW(machine_i2c_init_obj, 1, machine_i2c_obj_init);
318318

319319
STATIC mp_obj_t machine_i2c_scan(mp_obj_t self_in) {
320320
mp_obj_base_t *self = MP_OBJ_TO_PTR(self_in);
321-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
321+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
322322
mp_obj_t list = mp_obj_new_list(0, NULL);
323323
// 7-bit addresses 0b0000xxx and 0b1111xxx are reserved
324324
for (int addr = 0x08; addr < 0x78; ++addr) {
@@ -333,7 +333,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_scan_obj, machine_i2c_scan);
333333

334334
STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) {
335335
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
336-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
336+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
337337
if (i2c_p->start == NULL) {
338338
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
339339
}
@@ -347,7 +347,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_start_obj, machine_i2c_start);
347347

348348
STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) {
349349
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
350-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
350+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
351351
if (i2c_p->stop == NULL) {
352352
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
353353
}
@@ -361,7 +361,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(machine_i2c_stop_obj, machine_i2c_stop);
361361

362362
STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) {
363363
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
364-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
364+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
365365
if (i2c_p->read == NULL) {
366366
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
367367
}
@@ -385,7 +385,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readinto_obj, 2, 3, machine_i2c_
385385

386386
STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) {
387387
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
388-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
388+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
389389
if (i2c_p->write == NULL) {
390390
mp_raise_msg(&mp_type_OSError, translate("I2C operation not supported"));
391391
}
@@ -407,7 +407,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(machine_i2c_write_obj, machine_i2c_write);
407407

408408
STATIC mp_obj_t machine_i2c_readfrom(size_t n_args, const mp_obj_t *args) {
409409
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
410-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
410+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
411411
mp_int_t addr = mp_obj_get_int(args[1]);
412412
vstr_t vstr;
413413
vstr_init_len(&vstr, mp_obj_get_int(args[2]));
@@ -422,7 +422,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_obj, 3, 4, machine_i2c_
422422

423423
STATIC mp_obj_t machine_i2c_readfrom_into(size_t n_args, const mp_obj_t *args) {
424424
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
425-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
425+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
426426
mp_int_t addr = mp_obj_get_int(args[1]);
427427
mp_buffer_info_t bufinfo;
428428
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_WRITE);
@@ -437,7 +437,7 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_readfrom_into_obj, 3, 4, machine
437437

438438
STATIC mp_obj_t machine_i2c_writeto(size_t n_args, const mp_obj_t *args) {
439439
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
440-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
440+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
441441
mp_int_t addr = mp_obj_get_int(args[1]);
442442
mp_buffer_info_t bufinfo;
443443
mp_get_buffer_raise(args[2], &bufinfo, MP_BUFFER_READ);
@@ -453,7 +453,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(machine_i2c_writeto_obj, 3, 4, machin
453453

454454
STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, uint8_t *buf, size_t len) {
455455
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
456-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
456+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
457457
uint8_t memaddr_buf[4];
458458
size_t memaddr_len = 0;
459459
for (int16_t i = addrsize - 8; i >= 0; i -= 8) {
@@ -473,7 +473,7 @@ STATIC int read_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t a
473473

474474
STATIC int write_mem(mp_obj_t self_in, uint16_t addr, uint32_t memaddr, uint8_t addrsize, const uint8_t *buf, size_t len) {
475475
mp_obj_base_t *self = (mp_obj_base_t*)MP_OBJ_TO_PTR(self_in);
476-
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)self->type->protocol;
476+
mp_machine_i2c_p_t *i2c_p = (mp_machine_i2c_p_t*)mp_proto_get(self, QSTR_protocol_i2c);
477477

478478
// need some memory to create the buffer to send; try to use stack if possible
479479
uint8_t buf2_stack[MAX_MEMADDR_SIZE + BUF_STACK_SIZE];
@@ -621,6 +621,7 @@ int mp_machine_soft_i2c_write(mp_obj_base_t *self_in, const uint8_t *src, size_t
621621
}
622622

623623
STATIC const mp_machine_i2c_p_t mp_machine_soft_i2c_p = {
624+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_i2c)
624625
.start = (int(*)(mp_obj_base_t*))mp_hal_i2c_start,
625626
.stop = (int(*)(mp_obj_base_t*))mp_hal_i2c_stop,
626627
.read = mp_machine_soft_i2c_read,

extmod/machine_i2c.h

+2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,12 @@
2727
#define MICROPY_INCLUDED_EXTMOD_MACHINE_I2C_H
2828

2929
#include "py/obj.h"
30+
#include "py/proto.h"
3031

3132
// I2C protocol
3233
// the first 4 methods can be NULL, meaning operation is not supported
3334
typedef struct _mp_machine_i2c_p_t {
35+
MP_PROTOCOL_HEAD
3436
int (*start)(mp_obj_base_t *obj);
3537
int (*stop)(mp_obj_base_t *obj);
3638
int (*read)(mp_obj_base_t *obj, uint8_t *dest, size_t len, bool nack);

extmod/machine_pinbase.c

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ mp_uint_t pinbase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *err
7474
}
7575

7676
STATIC const mp_pin_p_t pinbase_pin_p = {
77+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_pin)
7778
.ioctl = pinbase_ioctl,
7879
};
7980

extmod/machine_signal.c

+2-6
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,7 @@ STATIC mp_obj_t signal_make_new(const mp_obj_type_t *type, size_t n_args, const
4747
bool invert = false;
4848

4949
#if defined(MICROPY_PY_MACHINE_PIN_MAKE_NEW)
50-
mp_pin_p_t *pin_p = NULL;
51-
52-
if (MP_OBJ_IS_OBJ(pin)) {
53-
mp_obj_base_t *pin_base = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
54-
pin_p = (mp_pin_p_t*)pin_base->type->protocol;
55-
}
50+
mp_pin_p_t *pin_p = (mp_pin_t*)mp_proto_get(QSTR_pin_protocol, pin);
5651

5752
if (pin_p == NULL) {
5853
// If first argument isn't a Pin-like object, we filter out "invert"
@@ -170,6 +165,7 @@ STATIC const mp_rom_map_elem_t signal_locals_dict_table[] = {
170165
STATIC MP_DEFINE_CONST_DICT(signal_locals_dict, signal_locals_dict_table);
171166

172167
STATIC const mp_pin_p_t signal_pin_p = {
168+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_pin)
173169
.ioctl = signal_ioctl,
174170
};
175171

extmod/machine_spi.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ mp_obj_t mp_machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, const
6767

6868
STATIC mp_obj_t machine_spi_init(size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
6969
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(args[0]);
70-
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
70+
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
7171
spi_p->init(s, n_args - 1, args + 1, kw_args);
7272
return mp_const_none;
7373
}
7474
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(machine_spi_init_obj, 1, machine_spi_init);
7575

7676
STATIC mp_obj_t machine_spi_deinit(mp_obj_t self) {
7777
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self);
78-
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
78+
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
7979
if (spi_p->deinit != NULL) {
8080
spi_p->deinit(s);
8181
}
@@ -85,7 +85,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(machine_spi_deinit_obj, machine_spi_deinit);
8585

8686
STATIC void mp_machine_spi_transfer(mp_obj_t self, size_t len, const void *src, void *dest) {
8787
mp_obj_base_t *s = (mp_obj_base_t*)MP_OBJ_TO_PTR(self);
88-
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)s->type->protocol;
88+
mp_machine_spi_p_t *spi_p = (mp_machine_spi_p_t*)mp_proto_get(QSTR_protocol_spi, s);
8989
spi_p->transfer(s, len, src, dest);
9090
}
9191

@@ -268,6 +268,7 @@ STATIC void mp_machine_soft_spi_transfer(mp_obj_base_t *self_in, size_t len, con
268268
}
269269

270270
const mp_machine_spi_p_t mp_machine_soft_spi_p = {
271+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_spi)
271272
.init = mp_machine_soft_spi_init,
272273
.deinit = NULL,
273274
.transfer = mp_machine_soft_spi_transfer,

extmod/machine_spi.h

+2
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
#define MICROPY_INCLUDED_EXTMOD_MACHINE_SPI_H
2828

2929
#include "py/obj.h"
30+
#include "py/proto.h"
3031
#include "py/mphal.h"
3132
#include "drivers/bus/spi.h"
3233

3334
// SPI protocol
3435
typedef struct _mp_machine_spi_p_t {
36+
MP_PROTOCOL_HEAD
3537
void (*init)(mp_obj_base_t *obj, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args);
3638
void (*deinit)(mp_obj_base_t *obj); // can be NULL
3739
void (*transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest);

extmod/modframebuf.c

+9-7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <string.h>
2929

3030
#include "py/runtime.h"
31+
#include "py/proto.h"
3132

3233
#if MICROPY_PY_FRAMEBUF
3334

@@ -46,6 +47,7 @@ typedef uint32_t (*getpixel_t)(const mp_obj_framebuf_t*, int, int);
4647
typedef void (*fill_rect_t)(const mp_obj_framebuf_t *, int, int, int, int, uint32_t);
4748

4849
typedef struct _mp_framebuf_p_t {
50+
MP_PROTOCOL_HEAD
4951
setpixel_t setpixel;
5052
getpixel_t getpixel;
5153
fill_rect_t fill_rect;
@@ -227,13 +229,13 @@ STATIC void gs8_fill_rect(const mp_obj_framebuf_t *fb, int x, int y, int w, int
227229
}
228230

229231
STATIC mp_framebuf_p_t formats[] = {
230-
[FRAMEBUF_MVLSB] = {mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect},
231-
[FRAMEBUF_RGB565] = {rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect},
232-
[FRAMEBUF_GS2_HMSB] = {gs2_hmsb_setpixel, gs2_hmsb_getpixel, gs2_hmsb_fill_rect},
233-
[FRAMEBUF_GS4_HMSB] = {gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect},
234-
[FRAMEBUF_GS8] = {gs8_setpixel, gs8_getpixel, gs8_fill_rect},
235-
[FRAMEBUF_MHLSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
236-
[FRAMEBUF_MHMSB] = {mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
232+
[FRAMEBUF_MVLSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mvlsb_setpixel, mvlsb_getpixel, mvlsb_fill_rect},
233+
[FRAMEBUF_RGB565] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) rgb565_setpixel, rgb565_getpixel, rgb565_fill_rect},
234+
[FRAMEBUF_GS2_HMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs2_hmsb_setpixel, gs2_hmsb_getpixel, gs2_hmsb_fill_rect},
235+
[FRAMEBUF_GS4_HMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs4_hmsb_setpixel, gs4_hmsb_getpixel, gs4_hmsb_fill_rect},
236+
[FRAMEBUF_GS8] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) gs8_setpixel, gs8_getpixel, gs8_fill_rect},
237+
[FRAMEBUF_MHLSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
238+
[FRAMEBUF_MHMSB] = {MP_PROTO_IMPLEMENT(MP_QSTR_protocol_framebuf) mono_horiz_setpixel, mono_horiz_getpixel, mono_horiz_fill_rect},
237239
};
238240

239241
static inline void setpixel(const mp_obj_framebuf_t *fb, int x, int y, uint32_t col) {

extmod/modlwip.c

+1
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,7 @@ STATIC const mp_rom_map_elem_t lwip_socket_locals_dict_table[] = {
12611261
STATIC MP_DEFINE_CONST_DICT(lwip_socket_locals_dict, lwip_socket_locals_dict_table);
12621262

12631263
STATIC const mp_stream_p_t lwip_socket_stream_p = {
1264+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
12641265
.read = lwip_socket_read,
12651266
.write = lwip_socket_write,
12661267
.ioctl = lwip_socket_ioctl,

extmod/modussl_axtls.c

+1
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
221221
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
222222

223223
STATIC const mp_stream_p_t ussl_socket_stream_p = {
224+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
224225
.read = socket_read,
225226
.write = socket_write,
226227
.ioctl = socket_ioctl,

extmod/modussl_mbedtls.c

+1
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
305305
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
306306

307307
STATIC const mp_stream_p_t ussl_socket_stream_p = {
308+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
308309
.read = socket_read,
309310
.write = socket_write,
310311
.ioctl = socket_ioctl,

extmod/moduzlib.c

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ STATIC const mp_rom_map_elem_t decompio_locals_dict_table[] = {
134134
STATIC MP_DEFINE_CONST_DICT(decompio_locals_dict, decompio_locals_dict_table);
135135

136136
STATIC const mp_stream_p_t decompio_stream_p = {
137+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
137138
.read = decompio_read,
138139
};
139140

extmod/modwebrepl.c

+1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ STATIC const mp_rom_map_elem_t webrepl_locals_dict_table[] = {
331331
STATIC MP_DEFINE_CONST_DICT(webrepl_locals_dict, webrepl_locals_dict_table);
332332

333333
STATIC const mp_stream_p_t webrepl_stream_p = {
334+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
334335
.read = webrepl_read,
335336
.write = webrepl_write,
336337
.ioctl = webrepl_ioctl,

extmod/modwebsocket.c

+1
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ STATIC const mp_rom_map_elem_t websocket_locals_dict_table[] = {
286286
STATIC MP_DEFINE_CONST_DICT(websocket_locals_dict, websocket_locals_dict_table);
287287

288288
STATIC const mp_stream_p_t websocket_stream_p = {
289+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_stream)
289290
.read = websocket_read,
290291
.write = websocket_write,
291292
.ioctl = websocket_ioctl,

extmod/vfs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ mp_import_stat_t mp_vfs_import_stat(const char *path) {
126126
}
127127

128128
// If the mounted object has the VFS protocol, call its import_stat helper
129-
const mp_vfs_proto_t *proto = mp_obj_get_type(vfs->obj)->protocol;
129+
const mp_vfs_proto_t *proto = (mp_vfs_proto_t*)mp_proto_get(MP_QSTR_protocol_vfs, vfs->obj);
130130
if (proto != NULL) {
131131
return proto->import_stat(MP_OBJ_TO_PTR(vfs->obj), path_out);
132132
}

extmod/vfs.h

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
#include "py/lexer.h"
3030
#include "py/obj.h"
31+
#include "py/proto.h"
3132

3233
// return values of mp_vfs_lookup_path
3334
// ROOT is 0 so that the default current directory is the root directory
@@ -47,6 +48,7 @@
4748

4849
// At the moment the VFS protocol just has import_stat, but could be extended to other methods
4950
typedef struct _mp_vfs_proto_t {
51+
MP_PROTOCOL_HEAD
5052
mp_import_stat_t (*import_stat)(void *self, const char *path);
5153
} mp_vfs_proto_t;
5254

extmod/vfs_fat.c

+1
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ STATIC const mp_rom_map_elem_t fat_vfs_locals_dict_table[] = {
488488
STATIC MP_DEFINE_CONST_DICT(fat_vfs_locals_dict, fat_vfs_locals_dict_table);
489489

490490
STATIC const mp_vfs_proto_t fat_vfs_proto = {
491+
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_vfs)
491492
.import_stat = fat_vfs_import_stat,
492493
};
493494

0 commit comments

Comments
 (0)