Skip to content
Snippets Groups Projects
Commit f64e806f authored by Erik Moqvist's avatar Erik Moqvist Committed by Damien George
Browse files

lib/utils/pyhelp.c: Use mp_printf() instead of printf()

This patch introduces MP_PYTHON_PRINTER for general use.
parent 571e6f26
No related branches found
No related tags found
No related merge requests found
...@@ -29,11 +29,11 @@ ...@@ -29,11 +29,11 @@
#include "lib/utils/pyhelp.h" #include "lib/utils/pyhelp.h"
STATIC void pyhelp_print_info_about_object(mp_obj_t name_o, mp_obj_t value) { 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); mp_obj_print(name_o, PRINT_STR);
printf(" -- "); mp_printf(MP_PYTHON_PRINTER, " -- ");
mp_obj_print(value, PRINT_STR); mp_obj_print(value, PRINT_STR);
printf("\n"); mp_printf(MP_PYTHON_PRINTER, "\n");
} }
// Helper for 1-argument form of builtin help // 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) { ...@@ -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) { void pyhelp_print_obj(const mp_obj_t obj) {
// try to print something sensible about the given object // try to print something sensible about the given object
printf("object "); mp_printf(MP_PYTHON_PRINTER, "object ");
mp_obj_print(obj, PRINT_STR); 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; mp_map_t *map = NULL;
if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) { if (MP_OBJ_IS_TYPE(obj, &mp_type_module)) {
......
...@@ -39,6 +39,12 @@ ...@@ -39,6 +39,12 @@
#define PF_FLAG_ADD_PERCENT (0x100) #define PF_FLAG_ADD_PERCENT (0x100)
#define PF_FLAG_SHOW_OCTAL_LETTER (0x200) #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 void (*mp_print_strn_t)(void *data, const char *str, size_t len);
typedef struct _mp_print_t { typedef struct _mp_print_t {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment