aboutsummaryrefslogtreecommitdiff
path: root/py/obj.h
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2020-06-21 17:10:20 +1000
committerDamien George <damien@micropython.org>2020-06-24 12:05:00 +1000
commit456a3abe8dbcd8ee822d81d6780db72d55e89d61 (patch)
tree9e87a9e6dd5f8d1c271d40056ff18ef74c09af96 /py/obj.h
parentb4dc4c5b9a1e6df620a14d85f18721a0bcb17d83 (diff)
py/obj.h: Add public mp_obj_is_dict_or_ordereddict() helper macro.
And use it in py/objdict.c instead of mp_obj_is_dict_type. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'py/obj.h')
-rw-r--r--py/obj.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/py/obj.h b/py/obj.h
index f80f00031..590b9c4b6 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -708,6 +708,7 @@ extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj;
#define mp_obj_is_int(o) (mp_obj_is_small_int(o) || mp_obj_is_type(o, &mp_type_int))
#define mp_obj_is_str(o) (mp_obj_is_qstr(o) || mp_obj_is_type(o, &mp_type_str))
#define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && ((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->binary_op == mp_obj_str_binary_op))
+#define mp_obj_is_dict_or_ordereddict(o) (mp_obj_is_obj(o) && ((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->make_new == mp_obj_dict_make_new)
#define mp_obj_is_fun(o) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function))
mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict);
@@ -890,6 +891,7 @@ typedef struct _mp_obj_dict_t {
mp_obj_base_t base;
mp_map_t map;
} mp_obj_dict_t;
+mp_obj_t mp_obj_dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args);
void mp_obj_dict_init(mp_obj_dict_t *dict, size_t n_args);
size_t mp_obj_dict_len(mp_obj_t self_in);
mp_obj_t mp_obj_dict_get(mp_obj_t self_in, mp_obj_t index);