extmod: Give vars/funcs unique names so STATIC can be set to nothing.
Fixes issue #5018.
This commit is contained in:
parent
3327dfc16e
commit
0cc8910bc5
@ -31,14 +31,14 @@
|
|||||||
|
|
||||||
// the algorithm here is modelled on CPython's heapq.py
|
// the algorithm here is modelled on CPython's heapq.py
|
||||||
|
|
||||||
STATIC mp_obj_list_t *get_heap(mp_obj_t heap_in) {
|
STATIC mp_obj_list_t *uheapq_get_heap(mp_obj_t heap_in) {
|
||||||
if (!mp_obj_is_type(heap_in, &mp_type_list)) {
|
if (!mp_obj_is_type(heap_in, &mp_type_list)) {
|
||||||
mp_raise_TypeError("heap must be a list");
|
mp_raise_TypeError("heap must be a list");
|
||||||
}
|
}
|
||||||
return MP_OBJ_TO_PTR(heap_in);
|
return MP_OBJ_TO_PTR(heap_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
|
STATIC void uheapq_heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
|
||||||
mp_obj_t item = heap->items[pos];
|
mp_obj_t item = heap->items[pos];
|
||||||
while (pos > start_pos) {
|
while (pos > start_pos) {
|
||||||
mp_uint_t parent_pos = (pos - 1) >> 1;
|
mp_uint_t parent_pos = (pos - 1) >> 1;
|
||||||
@ -53,7 +53,7 @@ STATIC void heap_siftdown(mp_obj_list_t *heap, mp_uint_t start_pos, mp_uint_t po
|
|||||||
heap->items[pos] = item;
|
heap->items[pos] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) {
|
STATIC void uheapq_heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) {
|
||||||
mp_uint_t start_pos = pos;
|
mp_uint_t start_pos = pos;
|
||||||
mp_uint_t end_pos = heap->len;
|
mp_uint_t end_pos = heap->len;
|
||||||
mp_obj_t item = heap->items[pos];
|
mp_obj_t item = heap->items[pos];
|
||||||
@ -67,19 +67,19 @@ STATIC void heap_siftup(mp_obj_list_t *heap, mp_uint_t pos) {
|
|||||||
pos = child_pos;
|
pos = child_pos;
|
||||||
}
|
}
|
||||||
heap->items[pos] = item;
|
heap->items[pos] = item;
|
||||||
heap_siftdown(heap, start_pos, pos);
|
uheapq_heap_siftdown(heap, start_pos, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t mod_uheapq_heappush(mp_obj_t heap_in, mp_obj_t item) {
|
STATIC mp_obj_t mod_uheapq_heappush(mp_obj_t heap_in, mp_obj_t item) {
|
||||||
mp_obj_list_t *heap = get_heap(heap_in);
|
mp_obj_list_t *heap = uheapq_get_heap(heap_in);
|
||||||
mp_obj_list_append(heap_in, item);
|
mp_obj_list_append(heap_in, item);
|
||||||
heap_siftdown(heap, 0, heap->len - 1);
|
uheapq_heap_siftdown(heap, 0, heap->len - 1);
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_uheapq_heappush_obj, mod_uheapq_heappush);
|
||||||
|
|
||||||
STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
|
STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
|
||||||
mp_obj_list_t *heap = get_heap(heap_in);
|
mp_obj_list_t *heap = uheapq_get_heap(heap_in);
|
||||||
if (heap->len == 0) {
|
if (heap->len == 0) {
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
|
||||||
}
|
}
|
||||||
@ -88,16 +88,16 @@ STATIC mp_obj_t mod_uheapq_heappop(mp_obj_t heap_in) {
|
|||||||
heap->items[0] = heap->items[heap->len];
|
heap->items[0] = heap->items[heap->len];
|
||||||
heap->items[heap->len] = MP_OBJ_NULL; // so we don't retain a pointer
|
heap->items[heap->len] = MP_OBJ_NULL; // so we don't retain a pointer
|
||||||
if (heap->len) {
|
if (heap->len) {
|
||||||
heap_siftup(heap, 0);
|
uheapq_heap_siftup(heap, 0);
|
||||||
}
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heappop_obj, mod_uheapq_heappop);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_uheapq_heappop_obj, mod_uheapq_heappop);
|
||||||
|
|
||||||
STATIC mp_obj_t mod_uheapq_heapify(mp_obj_t heap_in) {
|
STATIC mp_obj_t mod_uheapq_heapify(mp_obj_t heap_in) {
|
||||||
mp_obj_list_t *heap = get_heap(heap_in);
|
mp_obj_list_t *heap = uheapq_get_heap(heap_in);
|
||||||
for (mp_uint_t i = heap->len / 2; i > 0;) {
|
for (mp_uint_t i = heap->len / 2; i > 0;) {
|
||||||
heap_siftup(heap, --i);
|
uheapq_heap_siftup(heap, --i);
|
||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ struct ssl_args {
|
|||||||
|
|
||||||
STATIC const mp_obj_type_t ussl_socket_type;
|
STATIC const mp_obj_type_t ussl_socket_type;
|
||||||
|
|
||||||
STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
|
STATIC mp_obj_ssl_socket_t *ussl_socket_new(mp_obj_t sock, struct ssl_args *args) {
|
||||||
#if MICROPY_PY_USSL_FINALISER
|
#if MICROPY_PY_USSL_FINALISER
|
||||||
mp_obj_ssl_socket_t *o = m_new_obj_with_finaliser(mp_obj_ssl_socket_t);
|
mp_obj_ssl_socket_t *o = m_new_obj_with_finaliser(mp_obj_ssl_socket_t);
|
||||||
#else
|
#else
|
||||||
@ -118,13 +118,13 @@ STATIC mp_obj_ssl_socket_t *socket_new(mp_obj_t sock, struct ssl_args *args) {
|
|||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
STATIC void ussl_socket_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||||
(void)kind;
|
(void)kind;
|
||||||
mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in);
|
mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(self_in);
|
||||||
mp_printf(print, "<_SSLSocket %p>", self->ssl_sock);
|
mp_printf(print, "<_SSLSocket %p>", self->ssl_sock);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_uint_t socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
|
STATIC mp_uint_t ussl_socket_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
|
||||||
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in);
|
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in);
|
||||||
|
|
||||||
if (o->ssl_sock == NULL) {
|
if (o->ssl_sock == NULL) {
|
||||||
@ -173,7 +173,7 @@ eagain:
|
|||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
|
STATIC mp_uint_t ussl_socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
|
||||||
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in);
|
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(o_in);
|
||||||
|
|
||||||
if (o->ssl_sock == NULL) {
|
if (o->ssl_sock == NULL) {
|
||||||
@ -189,7 +189,7 @@ STATIC mp_uint_t socket_write(mp_obj_t o_in, const void *buf, mp_uint_t size, in
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
|
STATIC mp_uint_t ussl_socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, int *errcode) {
|
||||||
mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(o_in);
|
mp_obj_ssl_socket_t *self = MP_OBJ_TO_PTR(o_in);
|
||||||
if (request == MP_STREAM_CLOSE && self->ssl_sock != NULL) {
|
if (request == MP_STREAM_CLOSE && self->ssl_sock != NULL) {
|
||||||
ssl_free(self->ssl_sock);
|
ssl_free(self->ssl_sock);
|
||||||
@ -200,7 +200,7 @@ STATIC mp_uint_t socket_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_t arg, i
|
|||||||
return mp_get_stream(self->sock)->ioctl(self->sock, request, arg, errcode);
|
return mp_get_stream(self->sock)->ioctl(self->sock, request, arg, errcode);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {
|
STATIC mp_obj_t ussl_socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {
|
||||||
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(self_in);
|
mp_obj_ssl_socket_t *o = MP_OBJ_TO_PTR(self_in);
|
||||||
mp_obj_t sock = o->sock;
|
mp_obj_t sock = o->sock;
|
||||||
mp_obj_t dest[3];
|
mp_obj_t dest[3];
|
||||||
@ -210,14 +210,14 @@ STATIC mp_obj_t socket_setblocking(mp_obj_t self_in, mp_obj_t flag_in) {
|
|||||||
o->blocking = mp_obj_is_true(flag_in);
|
o->blocking = mp_obj_is_true(flag_in);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_setblocking_obj, socket_setblocking);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(ussl_socket_setblocking_obj, ussl_socket_setblocking);
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
|
STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&socket_setblocking_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_setblocking), MP_ROM_PTR(&ussl_socket_setblocking_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_stream_close_obj) },
|
||||||
#if MICROPY_PY_USSL_FINALISER
|
#if MICROPY_PY_USSL_FINALISER
|
||||||
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) },
|
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_stream_close_obj) },
|
||||||
@ -227,16 +227,16 @@ STATIC const mp_rom_map_elem_t ussl_socket_locals_dict_table[] = {
|
|||||||
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
|
STATIC MP_DEFINE_CONST_DICT(ussl_socket_locals_dict, ussl_socket_locals_dict_table);
|
||||||
|
|
||||||
STATIC const mp_stream_p_t ussl_socket_stream_p = {
|
STATIC const mp_stream_p_t ussl_socket_stream_p = {
|
||||||
.read = socket_read,
|
.read = ussl_socket_read,
|
||||||
.write = socket_write,
|
.write = ussl_socket_write,
|
||||||
.ioctl = socket_ioctl,
|
.ioctl = ussl_socket_ioctl,
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC const mp_obj_type_t ussl_socket_type = {
|
STATIC const mp_obj_type_t ussl_socket_type = {
|
||||||
{ &mp_type_type },
|
{ &mp_type_type },
|
||||||
// Save on qstr's, reuse same as for module
|
// Save on qstr's, reuse same as for module
|
||||||
.name = MP_QSTR_ussl,
|
.name = MP_QSTR_ussl,
|
||||||
.print = socket_print,
|
.print = ussl_socket_print,
|
||||||
.getiter = NULL,
|
.getiter = NULL,
|
||||||
.iternext = NULL,
|
.iternext = NULL,
|
||||||
.protocol = &ussl_socket_stream_p,
|
.protocol = &ussl_socket_stream_p,
|
||||||
@ -260,7 +260,7 @@ STATIC mp_obj_t mod_ssl_wrap_socket(size_t n_args, const mp_obj_t *pos_args, mp_
|
|||||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args,
|
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args,
|
||||||
MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args);
|
MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args);
|
||||||
|
|
||||||
return MP_OBJ_FROM_PTR(socket_new(sock, &args));
|
return MP_OBJ_FROM_PTR(ussl_socket_new(sock, &args));
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(mod_ssl_wrap_socket_obj, 1, mod_ssl_wrap_socket);
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ typedef struct _mp_obj_utimeq_t {
|
|||||||
|
|
||||||
STATIC mp_uint_t utimeq_id;
|
STATIC mp_uint_t utimeq_id;
|
||||||
|
|
||||||
STATIC mp_obj_utimeq_t *get_heap(mp_obj_t heap_in) {
|
STATIC mp_obj_utimeq_t *utimeq_get_heap(mp_obj_t heap_in) {
|
||||||
return MP_OBJ_TO_PTR(heap_in);
|
return MP_OBJ_TO_PTR(heap_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ STATIC mp_obj_t utimeq_make_new(const mp_obj_type_t *type, size_t n_args, size_t
|
|||||||
return MP_OBJ_FROM_PTR(o);
|
return MP_OBJ_FROM_PTR(o);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
|
STATIC void utimeq_heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t pos) {
|
||||||
struct qentry item = heap->items[pos];
|
struct qentry item = heap->items[pos];
|
||||||
while (pos > start_pos) {
|
while (pos > start_pos) {
|
||||||
mp_uint_t parent_pos = (pos - 1) >> 1;
|
mp_uint_t parent_pos = (pos - 1) >> 1;
|
||||||
@ -101,7 +101,7 @@ STATIC void heap_siftdown(mp_obj_utimeq_t *heap, mp_uint_t start_pos, mp_uint_t
|
|||||||
heap->items[pos] = item;
|
heap->items[pos] = item;
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC void heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) {
|
STATIC void utimeq_heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) {
|
||||||
mp_uint_t start_pos = pos;
|
mp_uint_t start_pos = pos;
|
||||||
mp_uint_t end_pos = heap->len;
|
mp_uint_t end_pos = heap->len;
|
||||||
struct qentry item = heap->items[pos];
|
struct qentry item = heap->items[pos];
|
||||||
@ -118,13 +118,13 @@ STATIC void heap_siftup(mp_obj_utimeq_t *heap, mp_uint_t pos) {
|
|||||||
pos = child_pos;
|
pos = child_pos;
|
||||||
}
|
}
|
||||||
heap->items[pos] = item;
|
heap->items[pos] = item;
|
||||||
heap_siftdown(heap, start_pos, pos);
|
utimeq_heap_siftdown(heap, start_pos, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
|
STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
|
||||||
(void)n_args;
|
(void)n_args;
|
||||||
mp_obj_t heap_in = args[0];
|
mp_obj_t heap_in = args[0];
|
||||||
mp_obj_utimeq_t *heap = get_heap(heap_in);
|
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
|
||||||
if (heap->len == heap->alloc) {
|
if (heap->len == heap->alloc) {
|
||||||
mp_raise_msg(&mp_type_IndexError, "queue overflow");
|
mp_raise_msg(&mp_type_IndexError, "queue overflow");
|
||||||
}
|
}
|
||||||
@ -133,14 +133,14 @@ STATIC mp_obj_t mod_utimeq_heappush(size_t n_args, const mp_obj_t *args) {
|
|||||||
heap->items[l].id = utimeq_id++;
|
heap->items[l].id = utimeq_id++;
|
||||||
heap->items[l].callback = args[2];
|
heap->items[l].callback = args[2];
|
||||||
heap->items[l].args = args[3];
|
heap->items[l].args = args[3];
|
||||||
heap_siftdown(heap, 0, heap->len);
|
utimeq_heap_siftdown(heap, 0, heap->len);
|
||||||
heap->len++;
|
heap->len++;
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_utimeq_heappush);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_utimeq_heappush_obj, 4, 4, mod_utimeq_heappush);
|
||||||
|
|
||||||
STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
|
STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
|
||||||
mp_obj_utimeq_t *heap = get_heap(heap_in);
|
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
|
||||||
if (heap->len == 0) {
|
if (heap->len == 0) {
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
|
||||||
}
|
}
|
||||||
@ -158,14 +158,14 @@ STATIC mp_obj_t mod_utimeq_heappop(mp_obj_t heap_in, mp_obj_t list_ref) {
|
|||||||
heap->items[heap->len].callback = MP_OBJ_NULL; // so we don't retain a pointer
|
heap->items[heap->len].callback = MP_OBJ_NULL; // so we don't retain a pointer
|
||||||
heap->items[heap->len].args = MP_OBJ_NULL;
|
heap->items[heap->len].args = MP_OBJ_NULL;
|
||||||
if (heap->len) {
|
if (heap->len) {
|
||||||
heap_siftup(heap, 0);
|
utimeq_heap_siftup(heap, 0);
|
||||||
}
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mod_utimeq_heappop_obj, mod_utimeq_heappop);
|
||||||
|
|
||||||
STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) {
|
STATIC mp_obj_t mod_utimeq_peektime(mp_obj_t heap_in) {
|
||||||
mp_obj_utimeq_t *heap = get_heap(heap_in);
|
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
|
||||||
if (heap->len == 0) {
|
if (heap->len == 0) {
|
||||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
|
nlr_raise(mp_obj_new_exception_msg(&mp_type_IndexError, "empty heap"));
|
||||||
}
|
}
|
||||||
@ -177,7 +177,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(mod_utimeq_peektime_obj, mod_utimeq_peektime);
|
|||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) {
|
STATIC mp_obj_t mod_utimeq_dump(mp_obj_t heap_in) {
|
||||||
mp_obj_utimeq_t *heap = get_heap(heap_in);
|
mp_obj_utimeq_t *heap = utimeq_get_heap(heap_in);
|
||||||
for (int i = 0; i < heap->len; i++) {
|
for (int i = 0; i < heap->len; i++) {
|
||||||
printf(UINT_FMT "\t%p\t%p\n", heap->items[i].time,
|
printf(UINT_FMT "\t%p\t%p\n", heap->items[i].time,
|
||||||
MP_OBJ_TO_PTR(heap->items[i].callback), MP_OBJ_TO_PTR(heap->items[i].args));
|
MP_OBJ_TO_PTR(heap->items[i].callback), MP_OBJ_TO_PTR(heap->items[i].args));
|
||||||
|
@ -219,7 +219,7 @@ STATIC mp_obj_t file_obj_make_new(const mp_obj_type_t *type, size_t n_args, size
|
|||||||
|
|
||||||
// TODO gc hook to close the file if not already closed
|
// TODO gc hook to close the file if not already closed
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = {
|
STATIC const mp_rom_map_elem_t vfs_fat_rawfile_locals_dict_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_readline), MP_ROM_PTR(&mp_stream_unbuffered_readline_obj) },
|
||||||
@ -234,10 +234,10 @@ STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = {
|
|||||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&file_obj___exit___obj) },
|
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&file_obj___exit___obj) },
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
|
STATIC MP_DEFINE_CONST_DICT(vfs_fat_rawfile_locals_dict, vfs_fat_rawfile_locals_dict_table);
|
||||||
|
|
||||||
#if MICROPY_PY_IO_FILEIO
|
#if MICROPY_PY_IO_FILEIO
|
||||||
STATIC const mp_stream_p_t fileio_stream_p = {
|
STATIC const mp_stream_p_t vfs_fat_fileio_stream_p = {
|
||||||
.read = file_obj_read,
|
.read = file_obj_read,
|
||||||
.write = file_obj_write,
|
.write = file_obj_write,
|
||||||
.ioctl = file_obj_ioctl,
|
.ioctl = file_obj_ioctl,
|
||||||
@ -250,12 +250,12 @@ const mp_obj_type_t mp_type_vfs_fat_fileio = {
|
|||||||
.make_new = file_obj_make_new,
|
.make_new = file_obj_make_new,
|
||||||
.getiter = mp_identity_getiter,
|
.getiter = mp_identity_getiter,
|
||||||
.iternext = mp_stream_unbuffered_iter,
|
.iternext = mp_stream_unbuffered_iter,
|
||||||
.protocol = &fileio_stream_p,
|
.protocol = &vfs_fat_fileio_stream_p,
|
||||||
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
|
.locals_dict = (mp_obj_dict_t*)&vfs_fat_rawfile_locals_dict,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC const mp_stream_p_t textio_stream_p = {
|
STATIC const mp_stream_p_t vfs_fat_textio_stream_p = {
|
||||||
.read = file_obj_read,
|
.read = file_obj_read,
|
||||||
.write = file_obj_write,
|
.write = file_obj_write,
|
||||||
.ioctl = file_obj_ioctl,
|
.ioctl = file_obj_ioctl,
|
||||||
@ -269,8 +269,8 @@ const mp_obj_type_t mp_type_vfs_fat_textio = {
|
|||||||
.make_new = file_obj_make_new,
|
.make_new = file_obj_make_new,
|
||||||
.getiter = mp_identity_getiter,
|
.getiter = mp_identity_getiter,
|
||||||
.iternext = mp_stream_unbuffered_iter,
|
.iternext = mp_stream_unbuffered_iter,
|
||||||
.protocol = &textio_stream_p,
|
.protocol = &vfs_fat_textio_stream_p,
|
||||||
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
|
.locals_dict = (mp_obj_dict_t*)&vfs_fat_rawfile_locals_dict,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Factory function for I/O stream classes
|
// Factory function for I/O stream classes
|
||||||
|
@ -200,7 +200,7 @@ STATIC mp_uint_t vfs_posix_file_ioctl(mp_obj_t o_in, mp_uint_t request, uintptr_
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = {
|
STATIC const mp_rom_map_elem_t vfs_posix_rawfile_locals_dict_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_fileno), MP_ROM_PTR(&vfs_posix_file_fileno_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_fileno), MP_ROM_PTR(&vfs_posix_file_fileno_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_read), MP_ROM_PTR(&mp_stream_read_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_readinto), MP_ROM_PTR(&mp_stream_readinto_obj) },
|
||||||
@ -215,10 +215,10 @@ STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = {
|
|||||||
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&vfs_posix_file___exit___obj) },
|
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&vfs_posix_file___exit___obj) },
|
||||||
};
|
};
|
||||||
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(rawfile_locals_dict, rawfile_locals_dict_table);
|
STATIC MP_DEFINE_CONST_DICT(vfs_posix_rawfile_locals_dict, vfs_posix_rawfile_locals_dict_table);
|
||||||
|
|
||||||
#if MICROPY_PY_IO_FILEIO
|
#if MICROPY_PY_IO_FILEIO
|
||||||
STATIC const mp_stream_p_t fileio_stream_p = {
|
STATIC const mp_stream_p_t vfs_posix_fileio_stream_p = {
|
||||||
.read = vfs_posix_file_read,
|
.read = vfs_posix_file_read,
|
||||||
.write = vfs_posix_file_write,
|
.write = vfs_posix_file_write,
|
||||||
.ioctl = vfs_posix_file_ioctl,
|
.ioctl = vfs_posix_file_ioctl,
|
||||||
@ -231,12 +231,12 @@ const mp_obj_type_t mp_type_vfs_posix_fileio = {
|
|||||||
.make_new = vfs_posix_file_make_new,
|
.make_new = vfs_posix_file_make_new,
|
||||||
.getiter = mp_identity_getiter,
|
.getiter = mp_identity_getiter,
|
||||||
.iternext = mp_stream_unbuffered_iter,
|
.iternext = mp_stream_unbuffered_iter,
|
||||||
.protocol = &fileio_stream_p,
|
.protocol = &vfs_posix_fileio_stream_p,
|
||||||
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
|
.locals_dict = (mp_obj_dict_t*)&vfs_posix_rawfile_locals_dict,
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
STATIC const mp_stream_p_t textio_stream_p = {
|
STATIC const mp_stream_p_t vfs_posix_textio_stream_p = {
|
||||||
.read = vfs_posix_file_read,
|
.read = vfs_posix_file_read,
|
||||||
.write = vfs_posix_file_write,
|
.write = vfs_posix_file_write,
|
||||||
.ioctl = vfs_posix_file_ioctl,
|
.ioctl = vfs_posix_file_ioctl,
|
||||||
@ -250,8 +250,8 @@ const mp_obj_type_t mp_type_vfs_posix_textio = {
|
|||||||
.make_new = vfs_posix_file_make_new,
|
.make_new = vfs_posix_file_make_new,
|
||||||
.getiter = mp_identity_getiter,
|
.getiter = mp_identity_getiter,
|
||||||
.iternext = mp_stream_unbuffered_iter,
|
.iternext = mp_stream_unbuffered_iter,
|
||||||
.protocol = &textio_stream_p,
|
.protocol = &vfs_posix_textio_stream_p,
|
||||||
.locals_dict = (mp_obj_dict_t*)&rawfile_locals_dict,
|
.locals_dict = (mp_obj_dict_t*)&vfs_posix_rawfile_locals_dict,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mp_obj_vfs_posix_file_t mp_sys_stdin_obj = {{&mp_type_textio}, STDIN_FILENO};
|
const mp_obj_vfs_posix_file_t mp_sys_stdin_obj = {{&mp_type_textio}, STDIN_FILENO};
|
||||||
|
Loading…
Reference in New Issue
Block a user