diff options
author | Damien George <damien.p.george@gmail.com> | 2015-11-27 17:01:44 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-11-29 14:25:35 +0000 |
commit | 999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (patch) | |
tree | 897eb07b82f1893cfd413b9ef7f625cd996f859d /py/emitglue.c | |
parent | cbf7674025814797f5c537d6d1c195efe58ccaaf (diff) | |
download | micropython-999cedb90ff0827cdb9dfe0e4faa6ebc1739d271.tar.gz micropython-999cedb90ff0827cdb9dfe0e4faa6ebc1739d271.zip |
py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a
pointer-sized primitive type.
This patch also includes additional changes to allow the code to compile
when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of
mp_uint_t, and various casts.
Diffstat (limited to 'py/emitglue.c')
-rw-r--r-- | py/emitglue.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/py/emitglue.c b/py/emitglue.c index 26fe3dec91..7ebd9c3518 100644 --- a/py/emitglue.c +++ b/py/emitglue.c @@ -263,7 +263,7 @@ STATIC qstr load_qstr(mp_reader_t *reader) { STATIC mp_obj_t load_obj(mp_reader_t *reader) { byte obj_type = read_byte(reader); if (obj_type == 'e') { - return (mp_obj_t)&mp_const_ellipsis_obj; + return MP_OBJ_FROM_PTR(&mp_const_ellipsis_obj); } else { size_t len = read_uint(reader); vstr_t vstr; @@ -324,7 +324,7 @@ STATIC mp_raw_code_t *load_raw_code(mp_reader_t *reader) { *ct++ = (mp_uint_t)load_obj(reader); } for (mp_uint_t i = 0; i < n_raw_code; ++i) { - *ct++ = (mp_uint_t)load_raw_code(reader); + *ct++ = (mp_uint_t)(uintptr_t)load_raw_code(reader); } // create raw_code and return it @@ -511,7 +511,7 @@ STATIC void save_obj(mp_print_t *print, mp_obj_t o) { mp_print_bytes(print, &obj_type, 1); mp_print_uint(print, len); mp_print_bytes(print, (const byte*)str, len); - } else if (o == &mp_const_ellipsis_obj) { + } else if (MP_OBJ_TO_PTR(o) == &mp_const_ellipsis_obj) { byte obj_type = 'e'; mp_print_bytes(print, &obj_type, 1); } else { @@ -582,7 +582,7 @@ STATIC void save_raw_code(mp_print_t *print, mp_raw_code_t *rc) { save_obj(print, (mp_obj_t)*const_table++); } for (uint i = 0; i < rc->data.u_byte.n_raw_code; ++i) { - save_raw_code(print, (mp_raw_code_t*)*const_table++); + save_raw_code(print, (mp_raw_code_t*)(uintptr_t)*const_table++); } } @@ -614,7 +614,7 @@ STATIC void fd_print_strn(void *env, const char *str, size_t len) { void mp_raw_code_save_file(mp_raw_code_t *rc, const char *filename) { int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); - mp_print_t fd_print = {(void*)(mp_int_t)fd, fd_print_strn}; + mp_print_t fd_print = {(void*)(intptr_t)fd, fd_print_strn}; mp_raw_code_save(rc, &fd_print); close(fd); } |