From 4ebdb1f2b217410cdc1cee0e0c0da8fceb7627f2 Mon Sep 17 00:00:00 2001 From: Damien George Date: Tue, 18 Oct 2016 11:06:20 +1100 Subject: py: Be more specific with MP_DECLARE_CONST_FUN_OBJ macros. In order to have more fine-grained control over how builtin functions are constructed, the MP_DECLARE_CONST_FUN_OBJ macros are made more specific, with suffix of _0, _1, _2, _3, _VAR, _VAR_BETEEN or _KW. These names now match the MP_DEFINE_CONST_FUN_OBJ macros. --- lib/utils/pyexec.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/utils') diff --git a/lib/utils/pyexec.h b/lib/utils/pyexec.h index ae69a195e..0c7567e27 100644 --- a/lib/utils/pyexec.h +++ b/lib/utils/pyexec.h @@ -49,6 +49,6 @@ void pyexec_event_repl_init(void); int pyexec_event_repl_process_char(int c); extern uint8_t pyexec_repl_active; -MP_DECLARE_CONST_FUN_OBJ(pyb_set_repl_info_obj); +MP_DECLARE_CONST_FUN_OBJ_1(pyb_set_repl_info_obj); #endif // __MICROPY_INCLUDED_LIB_UTILS_PYEXEC_H__ -- cgit v1.2.3 From f64e806f50606902323c62cf7b479922724022b6 Mon Sep 17 00:00:00 2001 From: Erik Moqvist Date: Sun, 16 Oct 2016 16:40:56 +0200 Subject: lib/utils/pyhelp.c: Use mp_printf() instead of printf() This patch introduces MP_PYTHON_PRINTER for general use. --- lib/utils/pyhelp.c | 10 +++++----- py/mpprint.h | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) (limited to 'lib/utils') diff --git a/lib/utils/pyhelp.c b/lib/utils/pyhelp.c index 5c0b2c57b..30ff391c4 100644 --- a/lib/utils/pyhelp.c +++ b/lib/utils/pyhelp.c @@ -29,11 +29,11 @@ #include "lib/utils/pyhelp.h" STATIC void pyhelp_print_info_about_object(mp_obj_t name_o, mp_obj_t value) { - printf(" "); + mp_printf(MP_PYTHON_PRINTER, " "); mp_obj_print(name_o, PRINT_STR); - printf(" -- "); + mp_printf(MP_PYTHON_PRINTER, " -- "); mp_obj_print(value, PRINT_STR); - printf("\n"); + mp_printf(MP_PYTHON_PRINTER, "\n"); } // Helper for 1-argument form of builtin help @@ -57,9 +57,9 @@ STATIC void pyhelp_print_info_about_object(mp_obj_t name_o, mp_obj_t value) { // void pyhelp_print_obj(const mp_obj_t obj) { // try to print something sensible about the given object - printf("object "); + mp_printf(MP_PYTHON_PRINTER, "object "); mp_obj_print(obj, PRINT_STR); - printf(" is of type %s\n", mp_obj_get_type_str(obj)); + mp_printf(MP_PYTHON_PRINTER, " is of type %s\n", mp_obj_get_type_str(obj)); mp_map_t *map = NULL; if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) { diff --git a/py/mpprint.h b/py/mpprint.h index 6e47409ec..f9204e322 100644 --- a/py/mpprint.h +++ b/py/mpprint.h @@ -39,6 +39,12 @@ #define PF_FLAG_ADD_PERCENT (0x100) #define PF_FLAG_SHOW_OCTAL_LETTER (0x200) +#if MICROPY_PY_IO +# define MP_PYTHON_PRINTER &mp_sys_stdout_print +#else +# define MP_PYTHON_PRINTER &mp_plat_print +#endif + typedef void (*mp_print_strn_t)(void *data, const char *str, size_t len); typedef struct _mp_print_t { -- cgit v1.2.3 From c38ea32810f2b8b55c1585a3022902c359f84d6e Mon Sep 17 00:00:00 2001 From: Vincenzo Frascino Date: Wed, 26 Oct 2016 10:33:26 +0100 Subject: lib/utils/pyexec: Add mp_hal_set_interrupt_char() prototype. This patch removes a compilation warning in pyexec. Signed-off-by: Vincenzo Frascino --- lib/utils/pyexec.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/utils') diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index d7c257024..ed424a2f9 100644 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -53,6 +53,8 @@ STATIC bool repl_display_debugging_info = 0; #define EXEC_FLAG_IS_REPL (4) #define EXEC_FLAG_SOURCE_IS_RAW_CODE (8) +extern void mp_hal_set_interrupt_char (int c); + // parses, compiles and executes the code in the lexer // frees the lexer before returning // EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output -- cgit v1.2.3 From 6832cbd69d04db1703b8b17939d8cd894aea4c68 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 26 Oct 2016 13:45:03 +0300 Subject: lib/utils/pyexec: Fix compilation warning of type vs format mismatch. This happens with some compilers on some architectures, which don't define size_t as unsigned int. MicroPython's printf() dooesn't support obscure format specifiers for size_t, so the obvious choice is to explicitly cast to unsigned, to match %u used in printf(). --- lib/utils/pyexec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/utils') diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index ed424a2f9..b398d7266 100644 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -120,7 +120,9 @@ STATIC int parse_compile_execute(void *source, mp_parse_input_kind_t input_kind, { size_t n_pool, n_qstr, n_str_data_bytes, n_total_bytes; qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); - printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes); + printf("qstr:\n n_pool=" UINT_FMT "\n n_qstr=" UINT_FMT "\n " + "n_str_data_bytes=" UINT_FMT "\n n_total_bytes=" UINT_FMT "\n", + (unsigned)n_pool, (unsigned)n_qstr, (unsigned)n_str_data_bytes, (unsigned)n_total_bytes); } #if MICROPY_ENABLE_GC -- cgit v1.2.3 From 3cdccb9b1429bc3afd04ec3f9171b373fe939375 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Wed, 26 Oct 2016 17:53:28 +0300 Subject: zephyr: Fix mp_hal_set_interrupt_char() declaration to be compatible. With other ports. Other ports declare it in mphalport.h, it can be inline or macro. --- lib/utils/pyexec.c | 2 -- zephyr/mphalport.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/utils') diff --git a/lib/utils/pyexec.c b/lib/utils/pyexec.c index b398d7266..61cd5a98c 100644 --- a/lib/utils/pyexec.c +++ b/lib/utils/pyexec.c @@ -53,8 +53,6 @@ STATIC bool repl_display_debugging_info = 0; #define EXEC_FLAG_IS_REPL (4) #define EXEC_FLAG_SOURCE_IS_RAW_CODE (8) -extern void mp_hal_set_interrupt_char (int c); - // parses, compiles and executes the code in the lexer // frees the lexer before returning // EXEC_FLAG_PRINT_EOF prints 2 EOF chars: 1 after normal output, 1 after exception output diff --git a/zephyr/mphalport.h b/zephyr/mphalport.h index 594bdd6d0..a634455a8 100644 --- a/zephyr/mphalport.h +++ b/zephyr/mphalport.h @@ -1,4 +1,5 @@ #include +#include "lib/utils/interrupt_char.h" static inline mp_uint_t mp_hal_ticks_us(void) { return sys_tick_get() * sys_clock_us_per_tick; -- cgit v1.2.3