Index: generic/nsf.c =================================================================== diff -u -rd007a8d7283d2861e0de5cfe567d540b8bd801de -r5b91151679ab9da9dae7e2480f9d7152637f72b6 --- generic/nsf.c (.../nsf.c) (revision d007a8d7283d2861e0de5cfe567d540b8bd801de) +++ generic/nsf.c (.../nsf.c) (revision 5b91151679ab9da9dae7e2480f9d7152637f72b6) @@ -18634,8 +18634,8 @@ NsfProcStubDeleteProc(ClientData clientData) { NsfProcClientData *tcd = clientData; - fprintf(stderr, "NsfProcStubDeleteProc received %p\n", clientData); - /*fprintf(stderr, "... procName %s paramDefs %p\n", ObjStr(tcd->procName), tcd->paramDefs);*/ + /* fprintf(stderr, "NsfProcStubDeleteProc received %p\n", clientData); + fprintf(stderr, "... procName %s paramDefs %p\n", ObjStr(tcd->procName), tcd->paramDefs);*/ DECR_REF_COUNT2("procNameObj", tcd->procName); if (tcd->cmd != NULL) { @@ -18690,7 +18690,7 @@ fullMethodName = ObjStr(procNameObj); CheckCStack(interp, "nsfProc", fullMethodName); - /*fprintf(stderr, "=== InvokeShadowedProc %s objc %d\n", fullMethodName, objc);*/ + /* fprintf(stderr, "=== InvokeShadowedProc %s objc %d\n", fullMethodName, objc); */ /* * The code below is derived from the scripted method dispatch and just @@ -18735,8 +18735,8 @@ } #if defined(NRE) - /*fprintf(stderr, "CALL TclNRInterpProcCore proc '%s' %s nameObj %p %s\n", - ObjStr(objv[0]), fullMethodName, procNameObj, ObjStr(procNameObj));*/ + /* fprintf(stderr, "CALL TclNRInterpProcCore proc '%s' %s nameObj %p %s\n", + ObjStr(objv[0]), fullMethodName, procNameObj, ObjStr(procNameObj)); */ Tcl_NRAddCallback(interp, ProcDispatchFinalize, (ClientData)fullMethodName, pcPtr, @@ -18861,13 +18861,19 @@ Tcl_Command newCmdPtr = Tcl_GetCommandFromObj(interp, tcd->procName); if (unlikely(newCmdPtr == NULL)) { - return NsfPrintError(interp, "cannot lookup command '%s'", - ObjStr(tcd->procName)); + result = NsfPrintError(interp, "cannot lookup command '%s'", + ObjStr(tcd->procName)); + ParseContextRelease(pcPtr); + NsfTclStackFree(interp, pcPtr, "release parse context"); + return result; } if (unlikely(!CmdIsProc(newCmdPtr))) { - return NsfPrintError(interp, "command '%s' is not a proc", - ObjStr(tcd->procName)); + result = NsfPrintError(interp, "command '%s' is not a proc", + ObjStr(tcd->procName)); + ParseContextRelease(pcPtr); + NsfTclStackFree(interp, pcPtr, "release parse context"); + return result; } /* Index: tests/nsf-cmd.test =================================================================== diff -u -rd007a8d7283d2861e0de5cfe567d540b8bd801de -r5b91151679ab9da9dae7e2480f9d7152637f72b6 --- tests/nsf-cmd.test (.../nsf-cmd.test) (revision d007a8d7283d2861e0de5cfe567d540b8bd801de) +++ tests/nsf-cmd.test (.../nsf-cmd.test) (revision 5b91151679ab9da9dae7e2480f9d7152637f72b6) @@ -617,7 +617,7 @@ namespace delete ::ns1 } -nx::test case nsf-proc-rename-delete { +nx::test case nsf-proc-backstage-rename { namespace eval ::ns1 {} ? {info commands ::ns1::foo} "" ? {info commands ::nsf::procs::ns1::foo} "" @@ -636,22 +636,72 @@ ? {::ns1::foo -x ok} "1-ok" - rename [set x ::nsf::procs::ns1::foo] "" + rename ::nsf::procs::ns1::foo "" ? {info commands ::ns1::foo} "::ns1::foo" ? {info commands ::nsf::procs::ns1::foo} "" ? {info procs ::ns1::foo} "" ? {info procs ::nsf::procs::ns1::foo} "" - ? {::ns1::foo -x ok} {invalid command name "::ns1::foo"} + ? {::ns1::foo -x ok} {cannot lookup command '::nsf::procs::ns1::foo'} + rename ::ns1::foo "" + + ? {info commands ::ns1::foo} "" + ? {info commands ::nsf::procs::ns1::foo} "" + ? {info procs ::ns1::foo} "" + ? {info procs ::nsf::procs::ns1::foo} "" + + ? {::ns1::foo -x ok} {invalid command name "::ns1::foo"} + namespace eval ::ns1 {} } +nx::test case nsf-proc-backstage-rename-2 { + namespace eval ::ns1 {} + ? {info commands ::ns1::foo} "" + ? {info commands ::nsf::procs::ns1::foo} "" + ? {info procs ::ns1::foo} "" + ? {info procs ::nsf::procs::ns1::foo} "" -# - to-do interp hide/expose + ? {::ns1::foo -x ok} {invalid command name "::ns1::foo"} + + nsf::proc ::ns1::foo { + {-x:required} + } { return 1-$x } + ? {info commands ::ns1::foo} "::ns1::foo" + ? {info commands ::nsf::procs::ns1::foo} "::nsf::procs::ns1::foo" + ? {info procs ::ns1::foo} "" + ? {info procs ::nsf::procs::ns1::foo} "::nsf::procs::ns1::foo" + ? {::ns1::foo -x ok} "1-ok" + rename ::nsf::procs::ns1::foo "" + nx::Object create ::nsf::procs::ns1::foo + + ? {info commands ::ns1::foo} "::ns1::foo" + ? {info commands ::nsf::procs::ns1::foo} "::nsf::procs::ns1::foo" + ? {info procs ::ns1::foo} "" + ? {info procs ::nsf::procs::ns1::foo} "" + + ? {::ns1::foo -x ok} {command '::nsf::procs::ns1::foo' is not a proc} + + rename ::ns1::foo "" + + ? {info commands ::ns1::foo} "" + ? {info commands ::nsf::procs::ns1::foo} "::nsf::procs::ns1::foo" + ? {info procs ::ns1::foo} "" + ? {info procs ::nsf::procs::ns1::foo} "" + + ? {::ns1::foo -x ok} {invalid command name "::ns1::foo"} + + namespace eval ::ns1 {} + rename ::nsf::procs::ns1::foo "" +} + +# - TO-DO: interp hide/expose + + # # Local variables: # mode: tcl