From f61cd2bb370bc99b4275bab89cf670b72e3970a9 Mon Sep 17 00:00:00 2001 From: apnadkarni Date: Mon, 17 Jun 2024 16:47:44 +0000 Subject: Remove tcl::unsupported::inject --- generic/tclBasic.c | 58 ---------------------------------------------------- tests/coroutine.test | 43 ++------------------------------------ 2 files changed, 2 insertions(+), 99 deletions(-) diff --git a/generic/tclBasic.c b/generic/tclBasic.c index dfed030..98a0579 100644 --- a/generic/tclBasic.c +++ b/generic/tclBasic.c @@ -237,7 +237,6 @@ static Tcl_NRPostProc TEOV_RunLeaveTraces; static Tcl_NRPostProc EvalObjvCore; static Tcl_NRPostProc Dispatch; -static Tcl_ObjCmdProc NRInjectObjCmd; static Tcl_NRPostProc NRPostInvoke; static Tcl_ObjCmdProc CoroTypeObjCmd; static Tcl_ObjCmdProc TclNRCoroInjectObjCmd; @@ -1196,8 +1195,6 @@ Tcl_CreateInterp(void) cmdPtr->compileProc = &TclCompileAssembleCmd; /* Coroutine monkeybusiness */ - Tcl_NRCreateCommand(interp, "::tcl::unsupported::inject", NULL, - NRInjectObjCmd, NULL, NULL); Tcl_CreateObjCommand(interp, "::tcl::unsupported::corotype", CoroTypeObjCmd, NULL, NULL); @@ -9658,61 +9655,6 @@ InjectHandlerPostCall( return result; } -/* - *---------------------------------------------------------------------- - * - * NRInjectObjCmd -- - * - * Implementation of [::tcl::unsupported::inject] command. - * - *---------------------------------------------------------------------- - */ - -static int -NRInjectObjCmd( - TCL_UNUSED(void *), - Tcl_Interp *interp, - int objc, - Tcl_Obj *const objv[]) -{ - CoroutineData *corPtr; - ExecEnv *savedEEPtr = iPtr->execEnvPtr; - - /* - * Usage more or less like tailcall: - * inject coroName cmd ?arg1 arg2 ...? - */ - - if (objc < 3) { - Tcl_WrongNumArgs(interp, 1, objv, "coroName cmd ?arg1 arg2 ...?"); - return TCL_ERROR; - } - - corPtr = GetCoroutineFromObj(interp, objv[1], - "can only inject a command into a coroutine"); - if (!corPtr) { - return TCL_ERROR; - } - if (!COR_IS_SUSPENDED(corPtr)) { - Tcl_SetObjResult(interp, Tcl_NewStringObj( - "can only inject a command into a suspended coroutine", TCL_INDEX_NONE)); - Tcl_SetErrorCode(interp, "TCL", "COROUTINE", "ACTIVE", (char *)NULL); - return TCL_ERROR; - } - - /* - * Add the callback to the coro's execEnv, so that it is the first thing - * to happen when the coro is resumed. - */ - - iPtr->execEnvPtr = corPtr->eePtr; - TclNRAddCallback(interp, TclNREvalList, Tcl_NewListObj(objc - 2, objv + 2), - NULL, NULL, NULL); - iPtr->execEnvPtr = savedEEPtr; - - return TCL_OK; -} - int TclNRInterpCoroutine( void *clientData, diff --git a/tests/coroutine.test b/tests/coroutine.test index c3023f7..e51d655 100644 --- a/tests/coroutine.test +++ b/tests/coroutine.test @@ -825,45 +825,6 @@ test coroutine-7.14 { return [list $done0 $done1] } -result {failure failure} - -test coroutine-8.0.0 {coro inject executed} -body { - coroutine demo apply {{} { foreach i {1 2} yield }} - demo - set ::result none - tcl::unsupported::inject demo set ::result inject-executed - demo - set ::result -} -result {inject-executed} -test coroutine-8.0.1 {coro inject after error} -body { - coroutine demo apply {{} { foreach i {1 2} yield; error test }} - demo - set ::result none - tcl::unsupported::inject demo set ::result inject-executed - lappend ::result [catch {demo} err] $err -} -result {inject-executed 1 test} -test coroutine-8.1.1 {coro inject, ticket 42202ba1e5ff566e} -body { - interp create child - child eval { - coroutine demo apply {{} { while {1} yield }} - demo - tcl::unsupported::inject demo set ::result inject-executed - } - interp delete child -} -result {} -test coroutine-8.1.2 {coro inject with result, ticket 42202ba1e5ff566e} -body { - interp create child - child eval { - coroutine demo apply {{} { while {1} yield }} - demo - tcl::unsupported::inject demo set ::result inject-executed - } - child eval demo - set result [child eval {set ::result}] - - interp delete child - set result -} -result {inject-executed} - test coroutine-9.1 {coroprobe with yield} -body { coroutine demo apply {{} { foreach i {1 2} yield }} list [coroprobe demo set i] [demo] [coroprobe demo set i] [demo] @@ -1037,7 +998,7 @@ test coroutine-12.1 {coroutine general introspection} -setup { $i eval { # Make the introspection code namespace path tcl::unsupported - proc probe {type var} { + proc probe {var type args} { upvar 1 $var v set f [info frame] incr f -1 @@ -1049,7 +1010,7 @@ test coroutine-12.1 {coroutine general introspection} -setup { } } proc pokecoro {c var} { - inject $c probe [corotype $c] $var + coroinject $c probe $var $c } -- cgit v0.12