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/objbool.c | |
parent | cbf7674025814797f5c537d6d1c195efe58ccaaf (diff) |
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/objbool.c')
-rw-r--r-- | py/objbool.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/py/objbool.c b/py/objbool.c index e0640b42a..622005657 100644 --- a/py/objbool.c +++ b/py/objbool.c @@ -36,7 +36,7 @@ typedef struct _mp_obj_bool_t { } mp_obj_bool_t; STATIC void bool_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) { - mp_obj_bool_t *self = self_in; + mp_obj_bool_t *self = MP_OBJ_TO_PTR(self_in); if (MICROPY_PY_UJSON && kind == PRINT_JSON) { if (self->value) { mp_print_str(print, "true"); @@ -66,7 +66,7 @@ STATIC mp_obj_t bool_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw } STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) { - mp_int_t value = ((mp_obj_bool_t*)o_in)->value; + mp_int_t value = ((mp_obj_bool_t*)MP_OBJ_TO_PTR(o_in))->value; switch (op) { case MP_UNARY_OP_BOOL: return o_in; // needs to hash to the same value as if converting to an integer @@ -88,7 +88,7 @@ STATIC mp_obj_t bool_unary_op(mp_uint_t op, mp_obj_t o_in) { } STATIC mp_obj_t bool_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { - mp_obj_bool_t *self = lhs_in; + mp_obj_bool_t *self = MP_OBJ_TO_PTR(lhs_in); return mp_binary_op(op, MP_OBJ_NEW_SMALL_INT(self->value), rhs_in); } |