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/objattrtuple.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/objattrtuple.c')
-rw-r--r-- | py/objattrtuple.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/py/objattrtuple.c b/py/objattrtuple.c index 04c17a2c64..c6dd3aeacf 100644 --- a/py/objattrtuple.c +++ b/py/objattrtuple.c @@ -50,17 +50,17 @@ void mp_obj_attrtuple_print_helper(const mp_print_t *print, const qstr *fields, STATIC void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) { (void)kind; - mp_obj_tuple_t *o = o_in; - const qstr *fields = (const qstr*)o->items[o->len]; + mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in); + const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(o->items[o->len]); mp_obj_attrtuple_print_helper(print, fields, o); } STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { if (dest[0] == MP_OBJ_NULL) { // load attribute - mp_obj_tuple_t *self = self_in; + mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in); mp_uint_t len = self->len; - const qstr *fields = (const qstr*)self->items[len]; + const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(self->items[len]); for (mp_uint_t i = 0; i < len; i++) { if (fields[i] == attr) { dest[0] = self->items[i]; @@ -77,8 +77,8 @@ mp_obj_t mp_obj_new_attrtuple(const qstr *fields, mp_uint_t n, const mp_obj_t *i for (mp_uint_t i = 0; i < n; i++) { o->items[i] = items[i]; } - o->items[n] = (void*)fields; - return o; + o->items[n] = MP_OBJ_FROM_PTR(fields); + return MP_OBJ_FROM_PTR(o); } const mp_obj_type_t mp_type_attrtuple = { |