Update MicroPython from 1.12 to 1.17

This commit is contained in:
Yaya.Cout
2021-12-14 18:16:49 +01:00
parent 5cbce3c116
commit 38faecda29
162 changed files with 8326 additions and 3888 deletions

View File

@@ -59,12 +59,17 @@ STATIC mp_uint_t iobase_read_write(mp_obj_t obj, void *buf, mp_uint_t size, int
mp_load_method(obj, qst, dest);
mp_obj_array_t ar = {{&mp_type_bytearray}, BYTEARRAY_TYPECODE, 0, size, buf};
dest[2] = MP_OBJ_FROM_PTR(&ar);
mp_obj_t ret = mp_call_method_n_kw(1, 0, dest);
if (ret == mp_const_none) {
mp_obj_t ret_obj = mp_call_method_n_kw(1, 0, dest);
if (ret_obj == mp_const_none) {
*errcode = MP_EAGAIN;
return MP_STREAM_ERROR;
}
mp_int_t ret = mp_obj_get_int(ret_obj);
if (ret >= 0) {
return ret;
} else {
return mp_obj_get_int(ret);
*errcode = -ret;
return MP_STREAM_ERROR;
}
}
STATIC mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode) {
@@ -72,7 +77,7 @@ STATIC mp_uint_t iobase_read(mp_obj_t obj, void *buf, mp_uint_t size, int *errco
}
STATIC mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode) {
return iobase_read_write(obj, (void*)buf, size, errcode, MP_QSTR_write);
return iobase_read_write(obj, (void *)buf, size, errcode, MP_QSTR_write);
}
STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
@@ -144,7 +149,7 @@ STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t si
// is word-aligned, to guard against obscure cases when it matters, e.g.
// https://github.com/micropython/micropython/issues/1863
memcpy(self->buf + self->len, buf, rem);
buf = (byte*)buf + rem;
buf = (byte *)buf + rem;
size -= rem;
mp_uint_t out_sz = mp_stream_write_exactly(self->stream, self->buf, self->alloc, errcode);
(void)out_sz;
@@ -190,12 +195,12 @@ STATIC const mp_stream_p_t bufwriter_stream_p = {
.write = bufwriter_write,
};
STATIC const mp_obj_type_t bufwriter_type = {
STATIC const mp_obj_type_t mp_type_bufwriter = {
{ &mp_type_type },
.name = MP_QSTR_BufferedWriter,
.make_new = bufwriter_make_new,
.protocol = &bufwriter_stream_p,
.locals_dict = (mp_obj_dict_t*)&bufwriter_locals_dict,
.locals_dict = (mp_obj_dict_t *)&bufwriter_locals_dict,
};
#endif // MICROPY_PY_IO_BUFFEREDWRITER
@@ -231,14 +236,14 @@ STATIC mp_obj_t resource_stream(mp_obj_t package_in, mp_obj_t path_in) {
mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t);
o->base.type = &mp_type_bytesio;
o->vstr = m_new_obj(vstr_t);
vstr_init_fixed_buf(o->vstr, len + 1, (char*)data);
vstr_init_fixed_buf(o->vstr, len + 1, (char *)data);
o->vstr->len = len;
o->pos = 0;
return MP_OBJ_FROM_PTR(o);
}
mp_obj_t path_out = mp_obj_new_str(path_buf.buf, path_buf.len);
return mp_builtin_open(1, &path_out, (mp_map_t*)&mp_const_empty_map);
return mp_builtin_open(1, &path_out, (mp_map_t *)&mp_const_empty_map);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_2(resource_stream_obj, resource_stream);
#endif
@@ -265,7 +270,7 @@ STATIC const mp_rom_map_elem_t mp_module_io_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_BytesIO), MP_ROM_PTR(&mp_type_bytesio) },
#endif
#if MICROPY_PY_IO_BUFFEREDWRITER
{ MP_ROM_QSTR(MP_QSTR_BufferedWriter), MP_ROM_PTR(&bufwriter_type) },
{ MP_ROM_QSTR(MP_QSTR_BufferedWriter), MP_ROM_PTR(&mp_type_bufwriter) },
#endif
};
@@ -273,7 +278,7 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_io_globals, mp_module_io_globals_table);
const mp_obj_module_t mp_module_io = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&mp_module_io_globals,
.globals = (mp_obj_dict_t *)&mp_module_io_globals,
};
#endif