Index: TODO =================================================================== diff -u -r66a02c8089dd0c695c626c0f0bad064e7b5ae8a1 -r156a002c09a06c6602f12d6f2f73038fa100b66e --- TODO (.../TODO) (revision 66a02c8089dd0c695c626c0f0bad064e7b5ae8a1) +++ TODO (.../TODO) (revision 156a002c09a06c6602f12d6f2f73038fa100b66e) @@ -4995,6 +4995,8 @@ - deactivated "-onerror", since its semantics are expressible via try/catch, and there are no regression tests for xotcl and nx, and we could not find any script that uses this +- renamed "-methodprefix" to "-prefix" in nx, since the prefix + can be applied as well applied to a cmd. nsf.c: - de-spaghetti precedence computations for multiple inheritance and @@ -5005,13 +5007,6 @@ ======================================================================== TODO: -- forwarder: I find the naming "-methodprefix" misleading, the 2nd arg - can also denote a subcommand, ensemble command or simply an argument - to a resulting command call. methodprefix is biased towards NX, - though its use is not. Just -prefix? (to maintain XOTcl compat, just - rename it in the NX forwarder API ... the malus would be that - -methodprefix pops up in info introspection etc. :/) - - check deactivated tests in tests/serialize.test C(One), C(IgnoreAll), C(None2) and xlloc fix Index: generic/nsf.c =================================================================== diff -u -r416e73c14f19c308cd7cf9f8769a72d0244f665b -r156a002c09a06c6602f12d6f2f73038fa100b66e --- generic/nsf.c (.../nsf.c) (revision 416e73c14f19c308cd7cf9f8769a72d0244f665b) +++ generic/nsf.c (.../nsf.c) (revision 156a002c09a06c6602f12d6f2f73038fa100b66e) @@ -18417,7 +18417,7 @@ static void AppendForwardDefinition(Tcl_Interp *interp, Tcl_Obj *listObj, ForwardCmdClientData *tcd) { if (tcd->prefix) { - Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("-methodprefix", -1)); + Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("-prefix", -1)); Tcl_ListObjAppendElement(interp, listObj, tcd->prefix); } if (tcd->subcommands) { Index: library/nx/nx.tcl =================================================================== diff -u -ra35803ea84148ebadd79d8527830dcbdebd8873e -r156a002c09a06c6602f12d6f2f73038fa100b66e --- library/nx/nx.tcl (.../nx.tcl) (revision a35803ea84148ebadd79d8527830dcbdebd8873e) +++ library/nx/nx.tcl (.../nx.tcl) (revision 156a002c09a06c6602f12d6f2f73038fa100b66e) @@ -339,13 +339,18 @@ Class public method forward { methodName - -default -methodprefix -frame -onerror -returns -verbose:switch + -default -prefix -frame -onerror -returns -verbose:switch target:optional args } { array set "" [:__resolve_method_path $methodName] set arguments [lrange [::nsf::current args] 1 end] set nrPreArgs [expr {[llength $arguments]-[llength $args]}] + if {[info exists prefix]} { + set p [lsearch -exact [lrange $arguments 0 $nrPreArgs] -prefix] + # search for "-prefix" in the arguments before $args and replace it + if {$p > -1} {set arguments [lreplace $arguments $p $p -methodprefix]} + } if {[info exists frame]} { if {$frame ne "object"} { error "value of parameter -frame must be 'object'" } set p [lsearch -exact [lrange $arguments 0 $nrPreArgs] -frame] @@ -537,12 +542,17 @@ :public method "object forward" { methodName - -default -methodprefix -frame -onerror -returns -verbose:switch + -default -prefix -frame -onerror -returns -verbose:switch target:optional args } { array set "" [:__resolve_method_path -per-object $methodName] set arguments [lrange [::nsf::current args] 1 end] set nrPreArgs [expr {[llength $arguments]-[llength $args]}] + if {[info exists prefix]} { + set p [lsearch -exact [lrange $arguments 0 $nrPreArgs] -prefix] + # search for "-prefix" in the arguments before $args and replace it + if {$p > -1} {set arguments [lreplace $arguments $p $p -methodprefix]} + } if {[info exists frame]} { if {$frame ne "object"} { error "value of parameter -frame must be 'object'" } set p [lsearch -exact [lrange $arguments 0 $nrPreArgs] -frame] Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -ra35803ea84148ebadd79d8527830dcbdebd8873e -r156a002c09a06c6602f12d6f2f73038fa100b66e --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision a35803ea84148ebadd79d8527830dcbdebd8873e) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 156a002c09a06c6602f12d6f2f73038fa100b66e) @@ -578,6 +578,11 @@ lappend result -objscope incr i } + -prefix { + lappend result -methodprefix + incr i + lappend result [lindex $list $i] + } -* {lappend result [lindex $list $i]} default { lappend result {*}[lrange $list $i end] Index: tests/forward.test =================================================================== diff -u -r8c16e18f186d305671e9543bf3c5d23fa65dc684 -r156a002c09a06c6602f12d6f2f73038fa100b66e --- tests/forward.test (.../forward.test) (revision 8c16e18f186d305671e9543bf3c5d23fa65dc684) +++ tests/forward.test (.../forward.test) (revision 156a002c09a06c6602f12d6f2f73038fa100b66e) @@ -101,7 +101,7 @@ return $result } } - nx::Object public forward Info -methodprefix @ Info %1 %self + nx::Object public forward Info -prefix @ Info %1 %self nx::Class create X { :create x1 @@ -127,7 +127,7 @@ ########################################### nx::test case introspection { nx::Class create C { - :public forward Info -methodprefix @ Info %1 %self + :public forward Info -prefix @ Info %1 %self } ? {C info methods -type forwarder} Info @@ -142,7 +142,7 @@ ? {C info methods -type forwarder} [list Info] # get the definition of a instforwarder - ? {C info method definition Info} [list ::C public forward Info -methodprefix @ Info %1 %self] + ? {C info method definition Info} [list ::C public forward Info -prefix @ Info %1 %self] # check introspection for objects nx::Object create obj { @@ -311,22 +311,22 @@ ? {obj foo X} "OOF-B X" ## - ## -methodprefix; requires a 2nd arg! + ## -prefix; requires a 2nd arg! ## ## obj public object method _FOO args {return [current method]-$args} ## 1) 2nd arg is missing! Prefix is silently neglected ... - obj public object forward FOO -methodprefix _ %self + obj public object forward FOO -prefix _ %self ? {obj FOO} {::obj} # 2) There is a 2nd arg, a method argument - ? {obj FOO FOO X} "_FOO-X" + ? {obj FOO FOO X} "_FOO-X" "prefix, 2nd arg is method argument" # 3) There is a 2nd arg, a forwarder argument - obj public object forward FOO -methodprefix _ %self %1 - ? {obj FOO FOO X} "_FOO-X" + obj public object forward FOO -prefix _ %self %1 + ? {obj FOO FOO X} "_FOO-X" "prefix, 2nd arg is forwarder argument" # 4) There is a 2nd arg, a forwarder argument provided through %1 - obj public object forward FOO -methodprefix _ %self {%1 {FOO FOO}} - ? {obj FOO X} "_FOO-X" + obj public object forward FOO -prefix _ %self {%1 {FOO FOO}} + ? {obj FOO X} "_FOO-X" "prefix, 2nd arg is forwarder argument provided through %1" }