File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727
2828// This file contains cumulative declarations for extmod/ .
2929
30+ #include <stddef.h>
3031#include "py/runtime.h"
3132
3233MP_DECLARE_CONST_FUN_OBJ (mp_uos_dupterm_obj );
34+
35+ #if MICROPY_PY_OS_DUPTERM
36+ void mp_uos_dupterm_tx_strn (const char * str , size_t len );
37+ #else
38+ #define mp_uos_dupterm_tx_strn (s , l )
39+ #endif
Original file line number Diff line number Diff line change 3434
3535#if MICROPY_PY_OS_DUPTERM
3636
37+ void mp_uos_dupterm_tx_strn (const char * str , size_t len ) {
38+ if (MP_STATE_PORT (term_obj ) != MP_OBJ_NULL ) {
39+ mp_obj_t write_m [3 ];
40+ mp_load_method (MP_STATE_PORT (term_obj ), MP_QSTR_write , write_m );
41+ write_m [2 ] = mp_obj_new_bytearray_by_ref (len , (char * )str );
42+ mp_call_method_n_kw (1 , 0 , write_m );
43+ }
44+ }
45+
3746STATIC mp_obj_t mp_uos_dupterm (mp_uint_t n_args , const mp_obj_t * args ) {
3847 if (n_args == 0 ) {
3948 if (MP_STATE_PORT (term_obj ) == MP_OBJ_NULL ) {
Original file line number Diff line number Diff line change 4545#include "py/gc.h"
4646#include "py/stackctrl.h"
4747#include "py/mphal.h"
48+ #include "extmod/misc.h"
4849#include "genhdr/mpversion.h"
4950#include "input.h"
5051
@@ -61,7 +62,7 @@ long heap_size = 1024*1024 * (sizeof(mp_uint_t) / 4);
6162STATIC void stderr_print_strn (void * env , const char * str , size_t len ) {
6263 (void )env ;
6364 ssize_t dummy = write (STDERR_FILENO , str , len );
64- mp_hal_dupterm_tx_strn (str , len );
65+ mp_uos_dupterm_tx_strn (str , len );
6566 (void )dummy ;
6667}
6768
Original file line number Diff line number Diff line change @@ -243,13 +243,6 @@ extern const struct _mp_obj_fun_builtin_t mp_builtin_open_obj;
243243
244244#define MP_STATE_PORT MP_STATE_VM
245245
246- #if MICROPY_PY_OS_DUPTERM
247- #include <stddef.h>
248- void mp_hal_dupterm_tx_strn (const char * str , size_t len );
249- #else
250- #define mp_hal_dupterm_tx_strn (s , l )
251- #endif
252-
253246#define MICROPY_PORT_ROOT_POINTERS \
254247 const char *readline_hist[50]; \
255248 mp_obj_t keyboard_interrupt_obj; \
Original file line number Diff line number Diff line change 3232#include "py/mpstate.h"
3333#include "py/mphal.h"
3434#include "py/runtime.h"
35+ #include "extmod/misc.h"
3536
3637#ifndef _WIN32
3738#include <signal.h>
@@ -107,17 +108,6 @@ void mp_hal_stdio_mode_orig(void) {
107108
108109#endif
109110
110- #if MICROPY_PY_OS_DUPTERM
111- void mp_hal_dupterm_tx_strn (const char * str , size_t len ) {
112- if (MP_STATE_PORT (term_obj ) != MP_OBJ_NULL ) {
113- mp_obj_t write_m [3 ];
114- mp_load_method (MP_STATE_PORT (term_obj ), MP_QSTR_write , write_m );
115- write_m [2 ] = mp_obj_new_bytearray_by_ref (len , (char * )str );
116- mp_call_method_n_kw (1 , 0 , write_m );
117- }
118- }
119- #endif
120-
121111int mp_hal_stdin_rx_chr (void ) {
122112 unsigned char c ;
123113 #if MICROPY_PY_OS_DUPTERM
@@ -152,7 +142,7 @@ int mp_hal_stdin_rx_chr(void) {
152142
153143void mp_hal_stdout_tx_strn (const char * str , size_t len ) {
154144 int ret = write (1 , str , len );
155- mp_hal_dupterm_tx_strn (str , len );
145+ mp_uos_dupterm_tx_strn (str , len );
156146 (void )ret ; // to suppress compiler warning
157147}
158148
You can’t perform that action at this time.
0 commit comments