From 48c65b3363a421724f35de75679744e8575c2ec3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 25 Mar 2020 00:41:14 +0900 Subject: [PATCH] [qwaq] Move builtin printf to main.c and add traceon/traceoff defs (that don't need PF_Cmds). This lets gcd.dat load in the second progs thread. --- ruamoko/qwaq/main.c | 46 ++++++++++++++++++++++++++++++++++---- ruamoko/qwaq/qwaq-curses.c | 16 ------------- 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/ruamoko/qwaq/main.c b/ruamoko/qwaq/main.c index 3972acbc3..79a4e6f96 100644 --- a/ruamoko/qwaq/main.c +++ b/ruamoko/qwaq/main.c @@ -203,9 +203,6 @@ spawn_progs (qwaq_thread_t *thread, progsinit_f *funcs) Sys_Error ("couldn't load %s", name); } - //pr->pr_trace = 1; - //pr->pr_trace_depth = -1; - PR_PushFrame (pr); if (thread->args.size > 2) { pr_argc = thread->args.size - 1; @@ -323,16 +320,57 @@ done: return qargs_ind; } +static void +bi_printf (progs_t *pr) +{ + const char *fmt = P_GSTRING (pr, 0); + int count = pr->pr_argc - 1; + pr_type_t **args = pr->pr_params + 1; + dstring_t *dstr = dstring_new (); + + PR_Sprintf (pr, dstr, "bi_printf", fmt, count, args); + if (dstr->str) + Sys_Printf (dstr->str, stdout); + dstring_delete (dstr); +} + +static void +bi_traceon (progs_t *pr) +{ + pr->pr_trace = true; + pr->pr_trace_depth = pr->pr_depth; +} + +static void +bi_traceoff (progs_t *pr) +{ + pr->pr_trace = false; +} + +static builtin_t common_builtins[] = { + {"printf", bi_printf, -1}, + {"traceon", bi_traceon, -1}, + {"traceoff", bi_traceoff, -1}, + {}, +}; + +static void +common_builtins_init (progs_t *pr) +{ + PR_RegisterBuiltins (pr, common_builtins); +} + static progsinit_f main_app[] = { Key_Progs_Init, - PR_Cmds_Init, BI_Init, + common_builtins_init, QWAQ_EditBuffer_Init, QWAQ_Debug_Init, 0 }; static progsinit_f target_app[] = { + common_builtins_init, QWAQ_DebugTarget_Init, 0 }; diff --git a/ruamoko/qwaq/qwaq-curses.c b/ruamoko/qwaq/qwaq-curses.c index 360c68bec..b8f8670b5 100644 --- a/ruamoko/qwaq/qwaq-curses.c +++ b/ruamoko/qwaq/qwaq-curses.c @@ -1544,20 +1544,6 @@ bi_initialize (progs_t *pr) create_thread (qwaq_curses_thread, res); } -static void -bi_printf (progs_t *pr) -{ - const char *fmt = P_GSTRING (pr, 0); - int count = pr->pr_argc - 1; - pr_type_t **args = pr->pr_params + 1; - dstring_t *dstr = dstring_new (); - - PR_Sprintf (pr, dstr, "bi_printf", fmt, count, args); - if (dstr->str) - Sys_Printf (dstr->str, stdout); - dstring_delete (dstr); -} - static void bi_c_TextContext__is_initialized (progs_t *pr) { @@ -1824,8 +1810,6 @@ static builtin_t builtins[] = { {"wresize", bi_wresize, -1}, {"resizeterm", bi_resizeterm, -1}, - {"printf", bi_printf, -1}, - {"_c_TextContext__is_initialized", bi_c_TextContext__is_initialized, -1}, {"_c_TextContext__max_colors", bi_c_TextContext__max_colors, -1}, {"_c_TextContext__max_color_pairs", bi_c_TextContext__max_color_pairs, -1},