diff options
| author | Glenn Ruben Bakke <glennbakke@gmail.com> | 2017-10-04 21:45:04 +0200 |
|---|---|---|
| committer | Glenn Ruben Bakke <glennbakke@gmail.com> | 2017-10-04 21:45:04 +0200 |
| commit | bcab2ba0a80297100919366add6bada140c6ed75 (patch) | |
| tree | 5133218f4fc010d5688f006dbdd1e2f346a843f7 /py/objdict.c | |
| parent | 4468731e3d039a3f72ac25aa43e936cf5ebb3f78 (diff) | |
| parent | f869d6b2e339c04469c6c9ea3fb2fabd7bbb2d8c (diff) | |
ports/nrf: Upmerging port with upstream master
Diffstat (limited to 'py/objdict.c')
| -rw-r--r-- | py/objdict.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/py/objdict.c b/py/objdict.c index a272ebdb6..1553a83b4 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -27,9 +27,6 @@ #include <string.h> #include <assert.h> -#include "py/nlr.h" -#include "py/obj.h" -#include "py/runtime0.h" #include "py/runtime.h" #include "py/builtin.h" #include "py/objtype.h" @@ -100,16 +97,22 @@ STATIC mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n return dict_out; } -STATIC mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) { +STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) { mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in); switch (op) { case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0); case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->map.used); + #if MICROPY_PY_SYS_GETSIZEOF + case MP_UNARY_OP_SIZEOF: { + size_t sz = sizeof(*self) + sizeof(*self->map.table) * self->map.alloc; + return MP_OBJ_NEW_SMALL_INT(sz); + } + #endif default: return MP_OBJ_NULL; // op not supported } } -STATIC mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { +STATIC mp_obj_t dict_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { mp_obj_dict_t *o = MP_OBJ_TO_PTR(lhs_in); switch (op) { case MP_BINARY_OP_IN: { @@ -476,7 +479,7 @@ STATIC void dict_view_print(const mp_print_t *print, mp_obj_t self_in, mp_print_ mp_print_str(print, "])"); } -STATIC mp_obj_t dict_view_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { +STATIC mp_obj_t dict_view_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) { // only supported for the 'keys' kind until sets and dicts are refactored mp_obj_dict_view_t *o = MP_OBJ_TO_PTR(lhs_in); if (o->kind != MP_DICT_VIEW_KEYS) { |
