diff options
author | Damien George <damien.p.george@gmail.com> | 2016-01-03 15:55:55 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2016-01-11 00:49:27 +0000 |
commit | 5b3f0b7f39bd67cc9182993c288f09f67a0890df (patch) | |
tree | d26730229745746b47e536a789a54f989d4ecffd /unix | |
parent | 4b72b3a133ea87a1ef8b964508dc25c551ccf093 (diff) | |
download | micropython-5b3f0b7f39bd67cc9182993c288f09f67a0890df.tar.gz micropython-5b3f0b7f39bd67cc9182993c288f09f67a0890df.zip |
py: Change first arg of type.make_new from mp_obj_t to mp_obj_type_t*.
The first argument to the type.make_new method is naturally a uPy type,
and all uses of this argument cast it directly to a pointer to a type
structure. So it makes sense to just have it a pointer to a type from
the very beginning (and a const pointer at that). This patch makes
such a change, and removes all unnecessary casting to/from mp_obj_t.
Diffstat (limited to 'unix')
-rw-r--r-- | unix/file.c | 4 | ||||
-rw-r--r-- | unix/modffi.c | 6 | ||||
-rw-r--r-- | unix/modsocket.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/unix/file.c b/unix/file.c index 2d3eb7b5a2..9ce5b69784 100644 --- a/unix/file.c +++ b/unix/file.c @@ -202,10 +202,10 @@ STATIC mp_obj_t fdfile_open(const mp_obj_type_t *type, mp_arg_val_t *args) { return MP_OBJ_FROM_PTR(o); } -STATIC mp_obj_t fdfile_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t fdfile_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { mp_arg_val_t arg_vals[FILE_OPEN_NUM_ARGS]; mp_arg_parse_all_kw_array(n_args, n_kw, args, FILE_OPEN_NUM_ARGS, file_open_args, arg_vals); - return fdfile_open(MP_OBJ_TO_PTR(type_in), arg_vals); + return fdfile_open(type, arg_vals); } STATIC const mp_rom_map_elem_t rawfile_locals_dict_table[] = { diff --git a/unix/modffi.c b/unix/modffi.c index 337f7a7b7c..86a0b4483f 100644 --- a/unix/modffi.c +++ b/unix/modffi.c @@ -301,7 +301,7 @@ STATIC mp_obj_t ffimod_addr(mp_obj_t self_in, mp_obj_t symname_in) { } MP_DEFINE_CONST_FUN_OBJ_2(ffimod_addr_obj, ffimod_addr); -STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t ffimod_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)n_args; (void)n_kw; @@ -315,7 +315,7 @@ STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, co nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(errno))); } mp_obj_ffimod_t *o = m_new_obj(mp_obj_ffimod_t); - o->base.type = MP_OBJ_TO_PTR(type_in); + o->base.type = type; o->handle = mod; return MP_OBJ_FROM_PTR(o); } @@ -478,7 +478,7 @@ STATIC const mp_obj_type_t opaque_type = { */ STATIC mp_obj_t mod_ffi_open(size_t n_args, const mp_obj_t *args) { - return ffimod_make_new((mp_obj_t)&ffimod_type, n_args, 0, args); + return ffimod_make_new(&ffimod_type, n_args, 0, args); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_ffi_open_obj, 1, 2, mod_ffi_open); diff --git a/unix/modsocket.c b/unix/modsocket.c index a9bb2e09ce..8af229cde4 100644 --- a/unix/modsocket.c +++ b/unix/modsocket.c @@ -313,7 +313,7 @@ STATIC mp_obj_t socket_makefile(size_t n_args, const mp_obj_t *args) { } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_makefile_obj, 1, 3, socket_makefile); -STATIC mp_obj_t socket_make_new(mp_obj_t type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { +STATIC mp_obj_t socket_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) { (void)type_in; (void)n_kw; |