Index: TODO =================================================================== diff -u -rf3c5823d0761ebed56a7af41151746119eb6bb84 -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- TODO (.../TODO) (revision f3c5823d0761ebed56a7af41151746119eb6bb84) +++ TODO (.../TODO) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -3423,9 +3423,10 @@ - fixed mem_count on xocomm.test (was 26 / 26) - nsf.c: small performance improvements +- nsf.c: experimental implementation of ::nsf::method::dispatch -TODO: +TODO: - private: * make sure nsf::dispatch works sufficiently similar to plain dispatch * document private in migration guide tutorial Index: generic/nsf.c =================================================================== diff -u -rf3c5823d0761ebed56a7af41151746119eb6bb84 -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- generic/nsf.c (.../nsf.c) (revision f3c5823d0761ebed56a7af41151746119eb6bb84) +++ generic/nsf.c (.../nsf.c) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -18163,7 +18163,107 @@ } +/* TODO: move me */ /* +cmd "method::dispatch" NsfMethodDispatchCmd { + {-argName "object" -required 1 -type object} + {-argName "-frame" -required 0 -nrargs 1 -type "method|object|default" -default "default"} + {-argName "command" -required 1 -type tclobj} + {-argName "args" -type args} +} +*/ +static int +NsfMethodDispatchCmd(Tcl_Interp *interp, NsfObject *object, int withFrame, + Tcl_Obj *command, int nobjc, Tcl_Obj *CONST nobjv[]) { + int result; + CONST char *methodName = ObjStr(command); + Tcl_Command cmd, importedCmd; + CallFrame frame, *framePtr = &frame; + Tcl_ObjCmdProc *proc; + int flags = 0; + int useCmdDispatch = 1; + + /*fprintf(stderr, "MethodDispatch obj=%s, cmd m='%s'\n", ObjectName(object), methodName);*/ + + if (*methodName != ':') { + return NsfPrintError(interp, "method name '%s' must be fully qualified", methodName); + } + + /* + * We have a fully qualified name of a Tcl command that will be dispatched. + */ + + cmd = Tcl_GetCommandFromObj(interp, command); + if (likely(cmd != NULL)) { + importedCmd = TclGetOriginalCommand(cmd); + if (unlikely(importedCmd != NULL)) { + cmd = importedCmd; + } + } + + if (unlikely(cmd == NULL)) { + return NsfPrintError(interp, "cannot lookup command '%s'", methodName); + } + + proc = Tcl_Command_objProc(cmd); + if (proc == TclObjInterpProc || + proc == NsfForwardMethod || + proc == NsfObjscopedMethod || + proc == NsfSetterMethod || + CmdIsNsfObject(cmd)) { + + if (withFrame && withFrame != FrameDefaultIdx) { + return NsfPrintError(interp, "cannot use -frame object|method in dispatch for command '%s'", + methodName); + } + useCmdDispatch = 0; + } else { + if (withFrame == FrameMethodIdx) { + useCmdDispatch = 0; + } else { + useCmdDispatch = 1; + } + } + + + if (withFrame == FrameObjectIdx) { + Nsf_PushFrameObj(interp, object, framePtr); + flags = NSF_CSC_IMMEDIATE; + } + /* + * Since we know, that we are always called with a full argument + * vector, we can include the cmd name in the objv by using + * nobjv-1; this way, we avoid a memcpy() + */ + if (useCmdDispatch) { + result = CmdMethodDispatch(object, interp, nobjc+1, nobjv-1, + Tcl_GetCommandName(interp, cmd), object, cmd, NULL); + } else { + + /* + * If "withFrame == instance" is specified, a callstack frame is pushed to + * make instvars accessible for the command. + */ + if (withFrame == FrameMethodIdx) { + flags = NSF_CSC_FORCE_FRAME|NSF_CSC_IMMEDIATE; + } + + result = MethodDispatch(object, interp, + nobjc+1, nobjv-1, cmd, object, + NULL /*NsfClass *cl*/, + Tcl_GetCommandName(interp, cmd), + NSF_CSC_TYPE_PLAIN, flags); + } + + if (withFrame == FrameObjectIdx) { + Nsf_PopFrameObj(interp, framePtr); + } + + return result; +} + + +/* cmd "object::dispatch" NsfObjectDispatchCmd { {-argName "object" -required 1 -type object} {-argName "-frame" -required 0 -nrargs 1 -type "method|object|default" -default "default"} @@ -18193,7 +18293,7 @@ * it. */ - if (*methodName == ':') { + if (0 && *methodName == ':') { Tcl_Command cmd, importedCmd; CallFrame frame, *framePtr = &frame; int flags = 0; Index: generic/nsfAPI.decls =================================================================== diff -u -r7d3bc964348a674a9d80ab8751f1f827dbd6b7b9 -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- generic/nsfAPI.decls (.../nsfAPI.decls) (revision 7d3bc964348a674a9d80ab8751f1f827dbd6b7b9) +++ generic/nsfAPI.decls (.../nsfAPI.decls) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -72,6 +72,12 @@ {-argName "-precondition" -type tclobj} {-argName "-postcondition" -type tclobj} } +cmd "method::dispatch" NsfMethodDispatchCmd { + {-argName "object" -required 1 -type object} + {-argName "-frame" -required 0 -type "method|object|default" -default "default"} + {-argName "command" -required 1 -type tclobj} + {-argName "args" -type args} +} cmd "method::delete" NsfMethodDeleteCmd { {-argName "object" -required 1 -type object} {-argName "-per-object" -nrargs 0} Index: generic/nsfAPI.h =================================================================== diff -u -r7d3bc964348a674a9d80ab8751f1f827dbd6b7b9 -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- generic/nsfAPI.h (.../nsfAPI.h) (revision 7d3bc964348a674a9d80ab8751f1f827dbd6b7b9) +++ generic/nsfAPI.h (.../nsfAPI.h) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -245,6 +245,7 @@ static int NsfMethodAssertionCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfMethodCreateCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfMethodDeleteCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); +static int NsfMethodDispatchCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfMethodForwardCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfMethodPropertyCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); static int NsfMethodRegisteredCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv []); @@ -341,6 +342,7 @@ static int NsfMethodAssertionCmd(Tcl_Interp *interp, NsfObject *object, int assertionsubcmd, Tcl_Obj *arg); static int NsfMethodCreateCmd(Tcl_Interp *interp, NsfObject *object, int withInner_namespace, int withPer_object, NsfObject *withReg_object, Tcl_Obj *methodName, Tcl_Obj *arguments, Tcl_Obj *body, Tcl_Obj *withPrecondition, Tcl_Obj *withPostcondition); static int NsfMethodDeleteCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, Tcl_Obj *methodName); +static int NsfMethodDispatchCmd(Tcl_Interp *interp, NsfObject *object, int withFrame, Tcl_Obj *command, int nobjc, Tcl_Obj *CONST nobjv[]); static int NsfMethodForwardCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, Tcl_Obj *method, Tcl_Obj *withDefault, int withEarlybinding, Tcl_Obj *withMethodprefix, int withObjframe, Tcl_Obj *withOnerror, int withVerbose, Tcl_Obj *target, int nobjc, Tcl_Obj *CONST nobjv[]); static int NsfMethodPropertyCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, Tcl_Obj *methodName, int methodproperty, Tcl_Obj *value); static int NsfMethodRegisteredCmd(Tcl_Interp *interp, Tcl_Obj *handle); @@ -438,6 +440,7 @@ NsfMethodAssertionCmdIdx, NsfMethodCreateCmdIdx, NsfMethodDeleteCmdIdx, + NsfMethodDispatchCmdIdx, NsfMethodForwardCmdIdx, NsfMethodPropertyCmdIdx, NsfMethodRegisteredCmdIdx, @@ -1238,6 +1241,27 @@ } static int +NsfMethodDispatchCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { + ParseContext pc; + (void)clientData; + + if (ArgumentParse(interp, objc, objv, NULL, objv[0], + method_definitions[NsfMethodDispatchCmdIdx].paramDefs, + method_definitions[NsfMethodDispatchCmdIdx].nrParameters, 1, + &pc) != TCL_OK) { + return TCL_ERROR; + } else { + NsfObject *object = (NsfObject *)pc.clientData[0]; + int withFrame = (int )PTR2INT(pc.clientData[1]); + Tcl_Obj *command = (Tcl_Obj *)pc.clientData[2]; + + assert(pc.status == 0); + return NsfMethodDispatchCmd(interp, object, withFrame, command, objc-pc.lastObjc, objv+pc.lastObjc); + + } +} + +static int NsfMethodForwardCmdStub(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { ParseContext pc; (void)clientData; @@ -2501,6 +2525,12 @@ {"-per-object", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, {"methodName", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} }, +{"::nsf::method::dispatch", NsfMethodDispatchCmdStub, 4, { + {"object", NSF_ARG_REQUIRED, 1, Nsf_ConvertToObject, NULL,NULL,"object",NULL,NULL,NULL,NULL,NULL}, + {"-frame", 0|NSF_ARG_IS_ENUMERATION, 1, ConvertToFrame, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {"command", NSF_ARG_REQUIRED, 1, Nsf_ConvertToTclobj, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, + {"args", 0, 1, ConvertToNothing, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}} +}, {"::nsf::method::forward", NsfMethodForwardCmdStub, 11, { {"object", NSF_ARG_REQUIRED, 1, Nsf_ConvertToObject, NULL,NULL,"object",NULL,NULL,NULL,NULL,NULL}, {"-per-object", 0, 0, Nsf_ConvertToString, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}, Index: library/nx/nx.tcl =================================================================== diff -u -rcb838e0d7ecf616891cc1f5089750208913d8503 -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- library/nx/nx.tcl (.../nx.tcl) (revision cb838e0d7ecf616891cc1f5089750208913d8503) +++ library/nx/nx.tcl (.../nx.tcl) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -122,7 +122,7 @@ #puts stderr ===nx118 set scope [expr {[::nsf::is class $object] && !${per-object} ? "class" : "object"}] #puts stderr ===nx119 - if {[::nsf::object::dispatch $object ::nsf::methods::${scope}::info::methods $w] eq ""} { + if {[::nsf::method::dispatch $object ::nsf::methods::${scope}::info::methods $w] eq ""} { # # Create dispatch/ensemble object and accessor method (if wanted) # @@ -143,8 +143,8 @@ # The accessor method exists already, check, if it is # appropriate for extending. # - set type [::nsf::object::dispatch $object ::nsf::methods::${scope}::info::method type $w] - set definition [::nsf::object::dispatch $object ::nsf::methods::${scope}::info::method definition $w] + set type [::nsf::method::dispatch $object ::nsf::methods::${scope}::info::method type $w] + set definition [::nsf::method::dispatch $object ::nsf::methods::${scope}::info::method definition $w] if {$scope eq "class"} { if {$type ne "alias"} {error "can't append to $type"} if {$definition eq ""} {error "definition must not be empty"} @@ -391,7 +391,7 @@ return [::nsf::method::require [::nsf::self] $methodName 0] } namespace { - ::nsf::object::dispatch [::nsf::self] ::nsf::methods::object::requirenamespace + ::nsf::method::dispatch [::nsf::self] ::nsf::methods::object::requirenamespace } } } @@ -625,17 +625,17 @@ # "package forget". We clear "info method" for ::nx::Object to avoid # confusions in the copy loop below, which uses method "method". # - if {[::nsf::object::dispatch ::nx::Object::slot::__info ::nsf::methods::object::info::methods "method"] ne ""} { + if {[::nsf::method::dispatch ::nx::Object::slot::__info ::nsf::methods::object::info::methods "method"] ne ""} { Object method "info method" {} {} } # # Copy all info methods except the subobjects to # ::nx::Class::slot::__info # - foreach m [::nsf::object::dispatch ::nx::Object::slot::__info ::nsf::methods::object::info::methods] { - if {[::nsf::object::dispatch ::nx::Object::slot::__info ::nsf::methods::object::info::method type $m] eq "object"} continue - set definition [::nsf::object::dispatch ::nx::Object::slot::__info ::nsf::methods::object::info::method definition $m] + foreach m [::nsf::method::dispatch ::nx::Object::slot::__info ::nsf::methods::object::info::methods] { + if {[::nsf::method::dispatch ::nx::Object::slot::__info ::nsf::methods::object::info::method type $m] eq "object"} continue + set definition [::nsf::method::dispatch ::nx::Object::slot::__info ::nsf::methods::object::info::method definition $m] ::nx::Class::slot::__info {*}[lrange $definition 1 end] unset definition } @@ -704,9 +704,9 @@ ###################################################################### proc ::nx::infoOptions {obj} { - #puts stderr "INFO INFO $obj -> '[::nsf::object::dispatch $obj ::nsf::methods::object::info::methods -methodtype all]'" + #puts stderr "INFO INFO $obj -> '[::nsf::method::dispatch $obj ::nsf::methods::object::info::methods -methodtype all]'" set methods [list] - foreach name [::nsf::object::dispatch $obj ::nsf::methods::object::info::methods] { + foreach name [::nsf::method::dispatch $obj ::nsf::methods::object::info::methods] { if {$name eq "unknown"} continue lappend methods $name } @@ -1041,7 +1041,7 @@ # Report just application specific methods not starting with "__" # set methods [list] - foreach m [::nsf::object::dispatch [::nsf::self] \ + foreach m [::nsf::method::dispatch [::nsf::self] \ ::nsf::methods::object::info::lookupmethods -source application] { if {[string match __* $m]} continue lappend methods $m @@ -1199,7 +1199,7 @@ # Collect the object parameter slots in per-position lists to # ensure partial ordering and avoid sorting. # - foreach slot [nsf::object::dispatch [self] ::nsf::methods::class::info::slotobjects -closure -type ::nx::Slot] { + foreach slot [nsf::method::dispatch [self] ::nsf::methods::class::info::slotobjects -closure -type ::nx::Slot] { lappend defs([$slot position]) [$slot getParameterSpec] } # @@ -1271,7 +1271,7 @@ if {![::nsf::object::exists $value]} { error "$value does not appear to be an object" } - set value [::nsf::object::dispatch $value -frame method ::nsf::self] + set value [::nsf::method::dispatch $value -frame method ::nsf::self] } } set p [lsearch -exact $old $value] @@ -1392,28 +1392,28 @@ # ${os}::Object::slot::filter method guard {obj prop filter guard:optional} { if {[info exists guard]} { - ::nsf::object::dispatch $obj ::nsf::methods::object::filterguard $filter $guard + ::nsf::method::dispatch $obj ::nsf::methods::object::filterguard $filter $guard } else { $obj info filter guard $filter } } ${os}::Class::slot::filter method guard {obj prop filter guard:optional} { if {[info exists guard]} { - ::nsf::object::dispatch $obj ::nsf::methods::class::filterguard $filter $guard + ::nsf::method::dispatch $obj ::nsf::methods::class::filterguard $filter $guard } else { $obj info filter guard $filter } } ${os}::Object::slot::mixin method guard {obj prop mixin guard:optional} { if {[info exists guard]} { - ::nsf::object::dispatch $obj ::nsf::methods::object::mixinguard $mixin $guard + ::nsf::method::dispatch $obj ::nsf::methods::object::mixinguard $mixin $guard } else { $obj info mixin guard $mixin } } ${os}::Class::slot::mixin method guard {obj prop filter guard:optional} { if {[info exists guard]} { - ::nsf::object::dispatch $obj ::nsf::methods::class::mixinguard $filter $guard + ::nsf::method::dispatch $obj ::nsf::methods::class::mixinguard $filter $guard } else { $obj info mixin guard $filter } @@ -1610,7 +1610,7 @@ ::nx::VariableSlot protected method handleTraces {} { # essentially like before set __initcmd "" - set trace {::nsf::object::dispatch [::nsf::self] -frame object ::trace} + set trace {::nsf::method::dispatch [::nsf::self] -frame object ::trace} # There might be already default values registered on the # class. If so, defaultcmd is ignored. if {[info exists :default]} { @@ -1641,7 +1641,7 @@ # ::nx::VariableSlot method __default_from_cmd {obj cmd var sub op} { #puts "GETVAR [::nsf::current method] obj=$obj cmd=$cmd, var=$var, op=$op" - ::nsf::object::dispatch $obj -frame object \ + ::nsf::method::dispatch $obj -frame object \ ::trace remove variable $var $op [list [::nsf::self] [::nsf::current method] $obj $cmd] ::nsf::var::set $obj $var [$obj eval $cmd] } @@ -1763,7 +1763,7 @@ if {$nocomplain} {$slot eval {set :nocomplain 1}} if {[info exists value]} {$slot setCheckedInstVar -nocomplain=$nocomplain $value} - return [::nsf::object::dispatch [self] ::nsf::methods::object::info::method handle [$slot name]] + return [::nsf::method::dispatch [self] ::nsf::methods::object::info::method handle [$slot name]] } Object method property { @@ -1795,7 +1795,7 @@ -defaultopts [list -accessor $accessor -config $config] \ $spec \ {*}[expr {[info exists default] ? [list $default] : ""}]] - return [::nsf::object::dispatch [self] ::nsf::methods::class::info::method handle [$slot name]] + return [::nsf::method::dispatch [self] ::nsf::methods::class::info::method handle [$slot name]] } nx::Class method property { @@ -1901,7 +1901,7 @@ if {![info exists object]} {set object [::nsf::self]} if {![::nsf::object::exists $object]} {$class create $object} # reused in XOTcl, no "require" there, so use nsf primitiva - ::nsf::object::dispatch $object ::nsf::methods::object::requirenamespace + ::nsf::method::dispatch $object ::nsf::methods::object::requirenamespace if {$withnew} { set m [ScopedNew new -container $object -withclass $class] $m volatile @@ -1936,7 +1936,7 @@ #puts stderr "COPY makeTargetList $t targetList '${:targetList}'" # if it is an object without namespace, it is a leaf if {[::nsf::object::exists $t]} { - if {[::nsf::object::dispatch $t ::nsf::methods::object::info::hasnamespace]} { + if {[::nsf::method::dispatch $t ::nsf::methods::object::info::hasnamespace]} { # make target list from all children set children [$t info children] } else { @@ -2001,8 +2001,8 @@ ::nsf::relation $obj object-filter [::nsf::relation $origin object-filter] ::nsf::relation $obj object-mixin [::nsf::relation $origin object-mixin] # reused in XOTcl, no "require" there, so use nsf primitiva - if {[::nsf::object::dispatch $origin ::nsf::methods::object::info::hasnamespace]} { - ::nsf::object::dispatch $obj ::nsf::methods::object::requirenamespace + if {[::nsf::method::dispatch $origin ::nsf::methods::object::info::hasnamespace]} { + ::nsf::method::dispatch $obj ::nsf::methods::object::requirenamespace } } else { namespace eval $dest {} @@ -2037,7 +2037,7 @@ # transfer the traces # foreach var [$origin info vars] { - set cmds [::nsf::object::dispatch $origin -frame object ::trace info variable $var] + set cmds [::nsf::method::dispatch $origin -frame object ::trace info variable $var] if {$cmds ne ""} { foreach cmd $cmds { foreach {op def} $cmd break Index: library/serialize/serializer.tcl =================================================================== diff -u -rfe1a8f6956a13ac6ce9f2df858b0c4d736840089 -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- library/serialize/serializer.tcl (.../serializer.tcl) (revision fe1a8f6956a13ac6ce9f2df858b0c4d736840089) +++ library/serialize/serializer.tcl (.../serializer.tcl) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -307,7 +307,7 @@ :public class method allChildren o { # return o and all its children fully qualified - set set [::nsf::object::dispatch $o -frame method ::nsf::current] + set set [::nsf::method::dispatch $o -frame method ::nsf::current] foreach c [$o info children] { lappend set {*}[:allChildren $c] } @@ -783,7 +783,7 @@ } :collect-var-traces $o $s - set objectName [::nsf::object::dispatch $o -frame method ::nsf::current object] + set objectName [::nsf::method::dispatch $o -frame method ::nsf::current object] set isSlotContainer [::nx::isSlotContainer $objectName] if {$isSlotContainer} { append cmd [list ::nx::slotObj [$o ::nsf::methods::object::info::parent]]\n @@ -922,7 +922,7 @@ :method Object-serialize {o s} { :collect-var-traces $o $s - append cmd [list [$o info class] create [::nsf::object::dispatch $o -frame method ::nsf::current object]] + append cmd [list [$o info class] create [::nsf::method::dispatch $o -frame method ::nsf::current object]] append cmd " -noinit\n" foreach i [$o ::nsf::methods::object::info::methods -methodtype scripted -callprotection all] { append cmd [:method-serialize $o $i ""] "\n" Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -rb2ab5886fc3278e549bb2772dfce921fbd06a9e9 -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision b2ab5886fc3278e549bb2772dfce921fbd06a9e9) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -369,7 +369,7 @@ # ::xotcl::Class instproc objectparameter {} { set parameterdefinitions [list] - foreach slot [nsf::object::dispatch [self] ::nsf::methods::class::info::slotobjects -closure -type ::nx::Slot] { + foreach slot [nsf::method::dispatch [self] ::nsf::methods::class::info::slotobjects -closure -type ::nx::Slot] { lappend parameterdefinitions [$slot getParameterSpec] } lappend parameterdefinitions args:alias,method=residualargs,args @@ -582,13 +582,13 @@ set guardsFlag [expr {$guards ? "-guards" : ""}] set patternArg [expr {[info exists pattern] ? [list $pattern] : ""}] if {$order && !$guards} { - set def [::nsf::object::dispatch [::nsf::current object] \ + set def [::nsf::method::dispatch [::nsf::current object] \ ::nsf::methods::object::info::filtermethods -order \ {*}$guardsFlag \ {*}$patternArg] set def [method_handles_to_xotcl $def] } else { - set def [::nsf::object::dispatch [::nsf::current object] \ + set def [::nsf::method::dispatch [::nsf::current object] \ ::nsf::methods::object::info::filtermethods \ {*}$guardsFlag \ {*}$patternArg] @@ -769,7 +769,7 @@ } Object instproc istype {class} { return [expr {[::nsf::is class $class] && - [::nsf::object::dispatch [self] ::nsf::methods::object::info::hastype $class]}] + [::nsf::method::dispatch [self] ::nsf::methods::object::info::hastype $class]}] } # definition of "xotcl::Object contains", based on nx @@ -864,16 +864,16 @@ # support for XOTcl specific convenience routines Object instproc hasclass cl { if {![::nsf::is class $cl]} {return 0} - if {[::nsf::object::dispatch [self] ::nsf::methods::object::info::hasmixin $cl]} {return 1} - ::nsf::object::dispatch [self] ::nsf::methods::object::info::hastype $cl + if {[::nsf::method::dispatch [self] ::nsf::methods::object::info::hasmixin $cl]} {return 1} + ::nsf::method::dispatch [self] ::nsf::methods::object::info::hastype $cl } Object instproc filtersearch {filter} { - set handle [::nsf::object::dispatch [::nsf::current object] \ + set handle [::nsf::method::dispatch [::nsf::current object] \ ::nsf::methods::object::info::lookupfilter $filter] return [method_handle_to_xotcl $handle] } Object instproc procsearch {name} { - set handle [::nsf::object::dispatch [::nsf::current object] \ + set handle [::nsf::method::dispatch [::nsf::current object] \ ::nsf::methods::object::info::lookupmethod $name] return [method_handle_to_xotcl $handle] } @@ -1045,7 +1045,7 @@ } namespace eval [::xotcl::self] {namespace import ::xotcl::*} #namespace eval [::xotcl::self] $script - #::nsf::object::dispatch [::xotcl::self] -frame method ::apply [list {} $script [::xotcl::self]] + #::nsf::method::dispatch [::xotcl::self] -frame method ::apply [list {} $script [::xotcl::self]] ::apply [list {} $script [::xotcl::self]] foreach e [set :export] { Index: tests/interceptor-slot.test =================================================================== diff -u -r7d3bc964348a674a9d80ab8751f1f827dbd6b7b9 -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- tests/interceptor-slot.test (.../interceptor-slot.test) (revision 7d3bc964348a674a9d80ab8751f1f827dbd6b7b9) +++ tests/interceptor-slot.test (.../interceptor-slot.test) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -224,11 +224,11 @@ ? {c1 [B info method origin foo]} "B A " ? {c1 [A info method origin foo]} "A " - # documententing unwanted behavior + # we expect same results via dispatch with fully qualified names ? {nsf::object::dispatch c1 foo} "C B A " - ? {nsf::object::dispatch c1 [C info method origin foo]} "C C B A " - ? {nsf::object::dispatch c1 [B info method origin foo]} "B C B A " - ? {nsf::object::dispatch c1 [A info method origin foo]} "A C B A " + ? {nsf::object::dispatch c1 [C info method origin foo]} "C B A " + ? {nsf::object::dispatch c1 [B info method origin foo]} "B A " + ? {nsf::object::dispatch c1 [A info method origin foo]} "A " # # check, whether the context of "my -local" is correct Index: tests/object-system.test =================================================================== diff -u -ra467cf37f204cc977b7af7519a0994c65f9ed10f -rf9dbc318044af9e7cc6114171f0f06120b249ab5 --- tests/object-system.test (.../object-system.test) (revision a467cf37f204cc977b7af7519a0994c65f9ed10f) +++ tests/object-system.test (.../object-system.test) (revision f9dbc318044af9e7cc6114171f0f06120b249ab5) @@ -170,7 +170,7 @@ Object create o {set :x 1} ::nsf::object::dispatch ::o ::incr x ? {o eval {set :x}} 1 "cmd dispatch without -frame object did not modify the instance variable" -::nsf::object::dispatch ::o -frame object ::incr x +::nsf::method::dispatch ::o -frame object ::incr x ? {o eval {set :x}} 2 "cmd dispatch -frame object modifies the instance variable" ? {catch {::nsf::object::dispatch ::o -frame object ::xxx x}} 1 "cmd dispatch with unknown command" o destroy @@ -183,9 +183,9 @@ return $results } } -::nsf::object::dispatch o ::eval {set x1 1; set :y1 1} -::nsf::object::dispatch o -frame method ::eval {set x2 1; set :y2 1} -::nsf::object::dispatch o -frame object ::eval {set x3 1; set :y3 1} +::nsf::method::dispatch o ::eval {set x1 1; set :y1 1} +::nsf::method::dispatch o -frame method ::eval {set x2 1; set :y2 1} +::nsf::method::dispatch o -frame object ::eval {set x3 1; set :y3 1} ? {o foo} "x1 0 y1 0 x2 0 y2 1 x3 1 y3 1" o destroy