Moved dict methods out to a mp_method_t.
This commit is contained in:
parent
689c16ae73
commit
baa665406f
23
py/objdict.c
23
py/objdict.c
@ -102,7 +102,6 @@ static const mp_obj_type_t dict_it_type = {
|
|||||||
{ &mp_const_type },
|
{ &mp_const_type },
|
||||||
"dict_iterator",
|
"dict_iterator",
|
||||||
.iternext = dict_it_iternext,
|
.iternext = dict_it_iternext,
|
||||||
.methods = { { NULL, NULL }, },
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur) {
|
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 */
|
/* 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 = {
|
const mp_obj_type_t dict_type = {
|
||||||
{ &mp_const_type },
|
{ &mp_const_type },
|
||||||
"dict",
|
"dict",
|
||||||
@ -257,16 +267,7 @@ const mp_obj_type_t dict_type = {
|
|||||||
.make_new = dict_make_new,
|
.make_new = dict_make_new,
|
||||||
.binary_op = dict_binary_op,
|
.binary_op = dict_binary_op,
|
||||||
.getiter = dict_getiter,
|
.getiter = dict_getiter,
|
||||||
.methods = {
|
.methods = 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
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
mp_obj_t mp_obj_new_dict(int n_args) {
|
mp_obj_t mp_obj_new_dict(int n_args) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user