diff options
author | John R. Lenton <jlenton@gmail.com> | 2014-01-07 18:01:08 +0000 |
---|---|---|
committer | John R. Lenton <jlenton@gmail.com> | 2014-01-07 18:01:08 +0000 |
commit | 270112f7312f724e46ae34649dfce3ec43b697e0 (patch) | |
tree | d7438ae877350aede062d8ac7e62e52ab35cb018 /py/objlist.c | |
parent | c06763a0207dde7f2060f7b1670a0b99298a01f8 (diff) | |
parent | fd04bb3bacf5dbc4d79c04a49520e3e81abb7352 (diff) | |
download | micropython-270112f7312f724e46ae34649dfce3ec43b697e0.tar.gz micropython-270112f7312f724e46ae34649dfce3ec43b697e0.zip |
Merge remote-tracking branch 'upstream/master' into listsort. Lots of conflict fun.
Conflicts:
py/obj.h
py/objbool.c
py/objboundmeth.c
py/objcell.c
py/objclass.c
py/objclosure.c
py/objcomplex.c
py/objdict.c
py/objexcept.c
py/objfun.c
py/objgenerator.c
py/objinstance.c
py/objmodule.c
py/objrange.c
py/objset.c
py/objslice.c
Diffstat (limited to 'py/objlist.c')
-rw-r--r-- | py/objlist.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/py/objlist.c b/py/objlist.c index a39586a4cd..0446412e83 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -58,6 +58,7 @@ static mp_obj_t list_make_new(mp_obj_t type_in, int n_args, const mp_obj_t *args default: nlr_jump(mp_obj_new_exception_msg_1_arg(MP_QSTR_TypeError, "list takes at most 1 argument, %d given", (void*)(machine_int_t)n_args)); } + return NULL; } static mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { @@ -277,27 +278,28 @@ static MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, list_remove); static MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse); static MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, list_sort); +static const mp_method_t list_type_methods[] = { + { "append", &list_append_obj }, + { "clear", &list_clear_obj }, + { "copy", &list_copy_obj }, + { "count", &list_count_obj }, + { "index", &list_index_obj }, + { "insert", &list_insert_obj }, + { "pop", &list_pop_obj }, + { "remove", &list_remove_obj }, + { "reverse", &list_reverse_obj }, + { "sort", &list_sort_obj }, + { NULL, NULL }, // end-of-list sentinel +}; + const mp_obj_type_t list_type = { .base = { &mp_const_type }, .name = "list", .print = list_print, .make_new = list_make_new, - .unary_op = NULL, .binary_op = list_binary_op, .getiter = list_getiter, - .methods = { - { "append", &list_append_obj }, - { "clear", &list_clear_obj }, - { "copy", &list_copy_obj }, - { "count", &list_count_obj }, - { "index", &list_index_obj }, - { "insert", &list_insert_obj }, - { "pop", &list_pop_obj }, - { "remove", &list_remove_obj }, - { "reverse", &list_reverse_obj }, - { "sort", &list_sort_obj }, - { NULL, NULL }, // end-of-list sentinel - }, + .methods = list_type_methods, }; static mp_obj_list_t *list_new(uint n) { @@ -361,7 +363,6 @@ static const mp_obj_type_t list_it_type = { .base = { &mp_const_type }, .name = "list_iterator", .iternext = list_it_iternext, - .methods = { { NULL, NULL }, }, }; mp_obj_t mp_obj_new_list_iterator(mp_obj_list_t *list, int cur) { |