summaryrefslogtreecommitdiff
path: root/py/objdict.c
diff options
context:
space:
mode:
authorScott Shawcroft <scott@tannewt.org>2019-01-14 15:14:40 -0800
committerScott Shawcroft <scott@tannewt.org>2019-01-14 17:29:19 -0800
commit72d993d60c5e5238942491df00776ca31f9758a1 (patch)
tree7dc8ff9548dc5c5fe4286414eb361c61b0774306 /py/objdict.c
parent619bc4caae15ceb7b6de547a5264c9eca9086fe9 (diff)
py changes for supporting superclass constructors that take kwargs
Diffstat (limited to 'py/objdict.c')
-rw-r--r--py/objdict.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/py/objdict.c b/py/objdict.c
index cd110f1c1..f672ac039 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -81,7 +81,7 @@ STATIC void dict_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_
}
}
-STATIC mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
+STATIC mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_obj_t dict_out = mp_obj_new_dict(0);
mp_obj_dict_t *dict = MP_OBJ_TO_PTR(dict_out);
dict->base.type = type;
@@ -90,11 +90,9 @@ STATIC mp_obj_t dict_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
dict->map.is_ordered = 1;
}
#endif
- if (n_args > 0 || n_kw > 0) {
+ if (n_args > 0 || kw_args != NULL) {
mp_obj_t args2[2] = {dict_out, args[0]}; // args[0] is always valid, even if it's not a positional arg
- mp_map_t kwargs;
- mp_map_init_fixed_table(&kwargs, n_kw, args + n_args);
- dict_update(n_args + 1, args2, &kwargs); // dict_update will check that n_args + 1 == 1 or 2
+ dict_update(n_args + 1, args2, kw_args); // dict_update will check that n_args + 1 == 1 or 2
}
return dict_out;
}
@@ -328,7 +326,7 @@ STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwarg
mp_obj_dict_t *self = MP_OBJ_TO_PTR(args[0]);
mp_ensure_not_fixed(self);
- mp_arg_check_num(n_args, kwargs->used, 1, 2, true);
+ mp_arg_check_num(n_args, kwargs, 1, 2, true);
if (n_args == 2) {
// given a positional argument