shared/runtime/sys_stdio_mphal: Make func static and remove some TODOs.

stdio_obj_print is private to this file so can be made static.  The __del__
method does nothing so can be removed (it's only called by the GC if it
exists, so if it doesn't exist it won't be called).  And FileIO doesn't
support a constructor in MicroPython at this stage.

Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
Damien George 2022-08-23 13:02:40 +10:00
parent af54d2ce9f
commit 7c8ec85fa3
1 changed files with 1 additions and 5 deletions

View File

@ -52,7 +52,7 @@ typedef struct _sys_stdio_obj_t {
STATIC const sys_stdio_obj_t stdio_buffer_obj;
#endif
void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void stdio_obj_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
sys_stdio_obj_t *self = MP_OBJ_TO_PTR(self_in);
mp_printf(print, "<io.FileIO %d>", self->fd);
}
@ -100,8 +100,6 @@ STATIC mp_obj_t stdio_obj___exit__(size_t n_args, const mp_obj_t *args) {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stdio_obj___exit___obj, 4, 4, stdio_obj___exit__);
// TODO gc hook to close the file if not already closed
STATIC const mp_rom_map_elem_t stdio_locals_dict_table[] = {
#if MICROPY_PY_SYS_STDIO_BUFFER
{ MP_ROM_QSTR(MP_QSTR_buffer), MP_ROM_PTR(&stdio_buffer_obj) },
@ -112,7 +110,6 @@ STATIC const mp_rom_map_elem_t stdio_locals_dict_table[] = {
{ MP_ROM_QSTR(MP_QSTR_readlines), MP_ROM_PTR(&mp_stream_unbuffered_readlines_obj)},
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&mp_stream_write_obj) },
{ MP_ROM_QSTR(MP_QSTR_close), MP_ROM_PTR(&mp_identity_obj) },
{ MP_ROM_QSTR(MP_QSTR___del__), MP_ROM_PTR(&mp_identity_obj) },
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&mp_identity_obj) },
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&stdio_obj___exit___obj) },
};
@ -129,7 +126,6 @@ STATIC const mp_stream_p_t stdio_obj_stream_p = {
STATIC const mp_obj_type_t stdio_obj_type = {
{ &mp_type_type },
.name = MP_QSTR_FileIO,
// TODO .make_new?
.print = stdio_obj_print,
.getiter = mp_identity_getiter,
.iternext = mp_stream_unbuffered_iter,