From 12a04392b9f3d6a7321f505309f4c7bcf1a6ee2f Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 11 Apr 2014 05:24:44 +0300 Subject: objdict: Implement __getitem__ method. --- py/objdict.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'py') diff --git a/py/objdict.c b/py/objdict.c index 85986448c..170724de1 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -123,6 +123,12 @@ STATIC bool dict_store_item(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) { return true; } +STATIC mp_obj_t dict_getitem(mp_obj_t lhs_in, mp_obj_t rhs_in) { + return dict_binary_op(MP_BINARY_OP_SUBSCR, lhs_in, rhs_in); +} + +STATIC MP_DEFINE_CONST_FUN_OBJ_2(dict_getitem_obj, dict_getitem); + /******************************************************************************/ /* dict iterator */ @@ -481,6 +487,7 @@ STATIC const mp_map_elem_t dict_locals_dict_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR_setdefault), (mp_obj_t)&dict_setdefault_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_update), (mp_obj_t)&dict_update_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_values), (mp_obj_t)&dict_values_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR___getitem__), (mp_obj_t)&dict_getitem_obj }, }; STATIC MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table); -- cgit v1.2.3