summaryrefslogtreecommitdiffstatshomepage
path: root/py/objdict.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/objdict.c')
-rw-r--r--py/objdict.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/py/objdict.c b/py/objdict.c
index 50ce279040..3737f5eab0 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -6,6 +6,7 @@
#include "nlr.h"
#include "misc.h"
#include "mpconfig.h"
+#include "mpqstr.h"
#include "obj.h"
#include "runtime0.h"
#include "runtime.h"
@@ -16,7 +17,7 @@ typedef struct _mp_obj_dict_t {
mp_map_t map;
} mp_obj_dict_t;
-void dict_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
+static void dict_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in) {
mp_obj_dict_t *self = self_in;
bool first = true;
print(env, "{");
@@ -34,7 +35,13 @@ void dict_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_ob
print(env, "}");
}
-mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
+// args are reverse in the array
+static mp_obj_t dict_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args) {
+ // TODO create from an iterable!
+ return rt_build_map(0);
+}
+
+static mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_dict_t *o = lhs_in;
switch (op) {
case RT_BINARY_OP_SUBSCR:
@@ -42,7 +49,7 @@ mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
// dict load
mp_map_elem_t *elem = mp_map_lookup_helper(&o->map, rhs_in, false);
if (elem == NULL) {
- nlr_jump(mp_obj_new_exception_msg(rt_q_KeyError, "<value>"));
+ nlr_jump(mp_obj_new_exception_msg(MP_QSTR_KeyError, "<value>"));
} else {
return elem->value;
}
@@ -57,6 +64,7 @@ const mp_obj_type_t dict_type = {
{ &mp_const_type },
"dict",
dict_print, // print
+ dict_make_new, // make_new
NULL, // call_n
NULL, // unary_op
dict_binary_op, // binary_op