diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-18 13:10:51 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-01-18 13:11:59 +0200 |
commit | 6d8edf6acfc5b7be3e6d053e044d718b4fc2cf00 (patch) | |
tree | 2c8330193b827ee84b353e788d07892dc1ad2ddd /py/obj.h | |
parent | 166bb40fb22b9c43209ce9792b6a8d48276ef7fa (diff) | |
download | micropython-6d8edf6acfc5b7be3e6d053e044d718b4fc2cf00.tar.gz micropython-6d8edf6acfc5b7be3e6d053e044d718b4fc2cf00.zip |
Add store_item() virtual method to type to implement container[index] = val.
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -97,6 +97,7 @@ typedef mp_obj_t (*mp_unary_op_fun_t)(int op, mp_obj_t); typedef mp_obj_t (*mp_binary_op_fun_t)(int op, mp_obj_t, mp_obj_t); typedef void (*mp_load_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t *dest); // for fail, do nothing; for attr, dest[1] = value; for method, dest[0] = self, dest[1] = method typedef bool (*mp_store_attr_fun_t)(mp_obj_t self_in, qstr attr, mp_obj_t value); // return true if store succeeded +typedef bool (*mp_store_item_fun_t)(mp_obj_t self_in, mp_obj_t index, mp_obj_t value); // return true if store succeeded typedef struct _mp_method_t { const char *name; @@ -162,6 +163,9 @@ struct _mp_obj_type_t { mp_load_attr_fun_t load_attr; mp_store_attr_fun_t store_attr; + // Implements container[index] = val; note that load_item is implemented + // by binary_op(RT_BINARY_OP_SUBSCR) + mp_store_item_fun_t store_item; // these are for dynamically created types (classes) mp_obj_t bases_tuple; |