From 7a16fadbf843ca5d49fb20b5f5785ffccfd9019f Mon Sep 17 00:00:00 2001 From: ian-v Date: Mon, 6 Jan 2014 09:52:29 -0800 Subject: Co-exist with C++ (issue #85) --- py/objstr.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'py/objstr.c') diff --git a/py/objstr.c b/py/objstr.c index db3e0beca0..08e3793916 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -184,17 +184,18 @@ mp_obj_t str_format(int n_args, const mp_obj_t *args) { static MP_DEFINE_CONST_FUN_OBJ_2(str_join_obj, str_join); static MP_DEFINE_CONST_FUN_OBJ_VAR(str_format_obj, 1, str_format); +const mp_method_t str_type_methods[] = { + { "join", &str_join_obj }, + { "format", &str_format_obj }, + { NULL, NULL }, // end-of-list sentinel +}; const mp_obj_type_t str_type = { { &mp_const_type }, "str", .print = str_print, .binary_op = str_binary_op, .getiter = str_getiter, - .methods = { - { "join", &str_join_obj }, - { "format", &str_format_obj }, - { NULL, NULL }, // end-of-list sentinel - }, + .methods = str_type_methods, }; mp_obj_t mp_obj_new_str(qstr qstr) { @@ -235,7 +236,7 @@ static const mp_obj_type_t str_it_type = { { &mp_const_type }, "str_iterator", .iternext = str_it_iternext, - .methods = { { NULL, NULL }, }, + .methods = NULL, }; mp_obj_t mp_obj_new_str_iterator(mp_obj_str_t *str, int cur) { -- cgit v1.2.3 From a5a01df81d01705b9f04264cc46fbb1bc32641b3 Mon Sep 17 00:00:00 2001 From: ian-v Date: Mon, 6 Jan 2014 14:14:11 -0800 Subject: Make list and str method tables static --- py/objlist.c | 2 +- py/objstr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'py/objstr.c') diff --git a/py/objlist.c b/py/objlist.c index 52eb488379..b642b7015a 100644 --- a/py/objlist.c +++ b/py/objlist.c @@ -261,7 +261,7 @@ 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_2(list_sort_obj, list_sort); -const mp_method_t list_type_methods[] = { +static const mp_method_t list_type_methods[] = { { "append", &list_append_obj }, { "clear", &list_clear_obj }, { "copy", &list_copy_obj }, diff --git a/py/objstr.c b/py/objstr.c index 08e3793916..66041c587f 100644 --- a/py/objstr.c +++ b/py/objstr.c @@ -184,7 +184,7 @@ mp_obj_t str_format(int n_args, const mp_obj_t *args) { static MP_DEFINE_CONST_FUN_OBJ_2(str_join_obj, str_join); static MP_DEFINE_CONST_FUN_OBJ_VAR(str_format_obj, 1, str_format); -const mp_method_t str_type_methods[] = { +static const mp_method_t str_type_methods[] = { { "join", &str_join_obj }, { "format", &str_format_obj }, { NULL, NULL }, // end-of-list sentinel -- cgit v1.2.3