py: Make mp_obj_get_type() return a const ptr to mp_obj_type_t.

Most types are in rodata/ROM, and mp_obj_base_t.type is a constant pointer,
so enforce this const-ness throughout the code base.  If a type ever needs
to be modified (eg a user type) then a simple cast can be used.
This commit is contained in:
Damien George
2020-01-09 11:01:14 +11:00
parent e3187b052f
commit bfbd94401d
16 changed files with 42 additions and 42 deletions

View File

@@ -85,7 +85,7 @@ mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf_, mp_uint_t size, int *errcode
}
const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags) {
mp_obj_type_t *type = mp_obj_get_type(self_in);
const mp_obj_type_t *type = mp_obj_get_type(self_in);
const mp_stream_p_t *stream_p = type->protocol;
if (stream_p == NULL
|| ((flags & MP_STREAM_OP_READ) && stream_p->read == NULL)