objdict: Add __setitem__.
This commit is contained in:
parent
86a03044e3
commit
cd94b384a3
|
@ -37,6 +37,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_namedtuple_obj);
|
|||
|
||||
MP_DECLARE_CONST_FUN_OBJ(mp_op_contains_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ(mp_op_getitem_obj);
|
||||
MP_DECLARE_CONST_FUN_OBJ(mp_op_setitem_obj);
|
||||
|
||||
extern const mp_obj_module_t mp_module___main__;
|
||||
extern const mp_obj_module_t mp_module_array;
|
||||
|
|
|
@ -497,6 +497,7 @@ STATIC const mp_map_elem_t dict_locals_dict_table[] = {
|
|||
{ 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)&mp_op_getitem_obj },
|
||||
{ MP_OBJ_NEW_QSTR(MP_QSTR___setitem__), (mp_obj_t)&mp_op_setitem_obj },
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(dict_locals_dict, dict_locals_dict_table);
|
||||
|
|
|
@ -13,6 +13,12 @@ STATIC mp_obj_t op_getitem(mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
|||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_2(mp_op_getitem_obj, op_getitem);
|
||||
|
||||
STATIC mp_obj_t op_setitem(mp_obj_t self_in, mp_obj_t key_in, mp_obj_t value_in) {
|
||||
mp_store_subscr(self_in, key_in, value_in);
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_3(mp_op_setitem_obj, op_setitem);
|
||||
|
||||
STATIC mp_obj_t op_contains(mp_obj_t lhs_in, mp_obj_t rhs_in) {
|
||||
mp_obj_type_t *type = mp_obj_get_type(lhs_in);
|
||||
return type->binary_op(MP_BINARY_OP_IN, lhs_in, rhs_in);
|
||||
|
|
Loading…
Reference in New Issue