diff options
author | John R. Lenton <jlenton@gmail.com> | 2014-01-07 23:18:25 +0000 |
---|---|---|
committer | John R. Lenton <jlenton@gmail.com> | 2014-01-07 23:18:25 +0000 |
commit | baa665406fef58cfb0be0df8d2798ed0961506da (patch) | |
tree | 4f67d80921cf3e8c669ae38014510ad17c9fda24 | |
parent | 689c16ae73b9118f39187d157664763b35e4d40f (diff) | |
download | micropython-baa665406fef58cfb0be0df8d2798ed0961506da.tar.gz micropython-baa665406fef58cfb0be0df8d2798ed0961506da.zip |
Moved dict methods out to a mp_method_t.
-rw-r--r-- | py/objdict.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/py/objdict.c b/py/objdict.c index 7cfd597ed4..c36d4ccb03 100644 --- a/py/objdict.c +++ b/py/objdict.c @@ -102,7 +102,6 @@ static const mp_obj_type_t dict_it_type = { { &mp_const_type }, "dict_iterator", .iternext = dict_it_iternext, - .methods = { { NULL, NULL }, }, }; static mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur) { @@ -250,6 +249,17 @@ static MP_DEFINE_CONST_FUN_OBJ_2(dict_update_obj, dict_update); /******************************************************************************/ /* dict constructors & etc */ +static const mp_method_t dict_type_methods[] = { + { "clear", &dict_clear_obj }, + { "copy", &dict_copy_obj }, + { "get", &dict_get_obj }, + { "pop", &dict_pop_obj }, + { "popitem", &dict_popitem_obj }, + { "setdefault", &dict_setdefault_obj }, + { "update", &dict_update_obj }, + { NULL, NULL }, // end-of-list sentinel +}; + const mp_obj_type_t dict_type = { { &mp_const_type }, "dict", @@ -257,16 +267,7 @@ const mp_obj_type_t dict_type = { .make_new = dict_make_new, .binary_op = dict_binary_op, .getiter = dict_getiter, - .methods = { - { "clear", &dict_clear_obj }, - { "copy", &dict_copy_obj }, - { "get", &dict_get_obj }, - { "pop", &dict_pop_obj }, - { "popitem", &dict_popitem_obj }, - { "setdefault", &dict_setdefault_obj }, - { "update", &dict_update_obj }, - { NULL, NULL }, // end-of-list sentinel - }, + .methods = dict_type_methods, }; mp_obj_t mp_obj_new_dict(int n_args) { |