Index: TODO =================================================================== diff -u -rd2f17f8dd98fcfa82a8473ed5e299c7c2026a80f -r67ad561b71e208451454fc1d71e591e75e4f3a71 --- TODO (.../TODO) (revision d2f17f8dd98fcfa82a8473ed5e299c7c2026a80f) +++ TODO (.../TODO) (revision 67ad561b71e208451454fc1d71e591e75e4f3a71) @@ -1191,8 +1191,13 @@ - scripted "info slotobjects" to return only objects of class ::nx::Slot - fixed test with UnknownClass in xotcl/tests/testx.xotcl +- fixed silent (scripted) unknown handler. +- reavtivated corresponding regression test +- extended regression tests (call unknown method + with filter with and without unknown handlers) + TODO: -- fix test "ob bar" (filter test) in tests/interceptor-slot.tcl (currently commented out) + - check "my" vs. "nsf::dispatch" in xotcl2.tcl - overthink decision about not showing "child objects" per default in "info methods" Index: generic/xotcl.c =================================================================== diff -u -rd2f17f8dd98fcfa82a8473ed5e299c7c2026a80f -r67ad561b71e208451454fc1d71e591e75e4f3a71 --- generic/xotcl.c (.../xotcl.c) (revision d2f17f8dd98fcfa82a8473ed5e299c7c2026a80f) +++ generic/xotcl.c (.../xotcl.c) (revision 67ad561b71e208451454fc1d71e591e75e4f3a71) @@ -5881,11 +5881,12 @@ result = ObjectDispatch(clientData, interp, objc+2, tov, flags | XOTCL_CM_NO_UNKNOWN); FREE_ON_STACK(Tcl_Obj*, tov); - } else { /* no unknown called */ - fprintf(stderr, "--- No unknown method Name %s objv[%d] %s\n", - ObjStr(methodObj), 1, ObjStr(objv[1])); + } else { /* no unknown called, builtin unknown handler */ + + /*fprintf(stderr, "--- No unknown method Name %s objv[%d] %s\n", + ObjStr(methodObj), 1, ObjStr(objv[1]));*/ result = XOTclVarErrMsg(interp, objectName(object), - ": xxx unable to dispatch method '", + ": unable to dispatch method '", ObjStr(objv[1]), "'", (char *) NULL); } return result; @@ -6249,6 +6250,10 @@ result = MethodDispatch(clientData, interp, objc-shift, objv+shift, cmd, object, cl, methodName, frameType); } + + /*fprintf(stderr, "MethodDispatch %s returns %d unknown %d\n", + methodName, result, rst->unknown);*/ + if (result == TCL_ERROR) { /*fprintf(stderr, "Call ErrInProc cl = %p, cmd %p, flags %.6x\n", cl, cl ? cl->object.id : 0, cl ? cl->object.flags : 0);*/ @@ -6280,8 +6285,10 @@ } } /* be sure to reset unknown flag */ - if (unknown) + if (unknown && (frameType & XOTCL_CSC_TYPE_ACTIVE_FILTER) == 0) { + /*fprintf(stderr, "**** rst->unknown set to 0 flags %.6x frameType %.6x\n",flags,frameType);*/ rst->unknown = 0; + } exit_dispatch: #ifdef DISPATCH_TRACE @@ -7567,6 +7574,7 @@ } cscPtr->callType |= XOTCL_CSC_CALL_IS_NEXT; RUNTIME_STATE(interp)->unknown = 0; + /*fprintf(stderr, "setting unknown to 0\n");*/ result = MethodDispatch((ClientData)object, interp, nobjc, nobjv, cmd, object, *cl, *methodName, frameType); cscPtr->callType &= ~XOTCL_CSC_CALL_IS_NEXT; Index: library/nx/nx.tcl =================================================================== diff -u -r851e2c38fe3ae9d84f531605d55defe2e1308a02 -r67ad561b71e208451454fc1d71e591e75e4f3a71 --- library/nx/nx.tcl (.../nx.tcl) (revision 851e2c38fe3ae9d84f531605d55defe2e1308a02) +++ library/nx/nx.tcl (.../nx.tcl) (revision 67ad561b71e208451454fc1d71e591e75e4f3a71) @@ -528,12 +528,14 @@ return $r } - # unknown handler for Object - :protected method unknown {m args} { - if {![::nsf::current isnext]} { - error "[::nsf::current object]: unable to dispatch method '$m'" - } - } + # Default unknown-handler for Object + # + # Actually, we do not need thios unknwon handler, but we could + # define it as follows: + # + # :protected method unknown {m args} { + # error "[::nsf::current object]: unable to dispatch method '$m'" + # } # "init" must exist on Object. per default it is empty. :protected method init args {} Index: tests/interceptor-slot.tcl =================================================================== diff -u -rfc6166907f061a71b8a5766441c32080b5cf34f1 -r67ad561b71e208451454fc1d71e591e75e4f3a71 --- tests/interceptor-slot.tcl (.../interceptor-slot.tcl) (revision fc6166907f061a71b8a5766441c32080b5cf34f1) +++ tests/interceptor-slot.tcl (.../interceptor-slot.tcl) (revision 67ad561b71e208451454fc1d71e591e75e4f3a71) @@ -97,6 +97,33 @@ # forwarder with 0 arguments + flag ? {C object mixin} "::M" + + +Test case mixin-add { + + Class create M1 { + :method mfoo {} {puts [current method]} + } + Class create M11 + Class create C1 + + ? {C1 info callable method mixin} "::nsf::classes::nx::Class::mixin" + C1 object mixin M1 + ? {C1 info precedence} "::M1 ::nx::Class ::nx::Object" + C1 create c11 + ? {c11 info precedence} "::C1 ::nx::Object" + C1 object mixin add M11 + ? {C1 info precedence} "::M11 ::M1 ::nx::Class ::nx::Object" + Object create o -mixin M1 + ? {o info precedence} "::M1 ::nx::Object" + + Class create O + O object mixin M1 + ? {O info precedence} "::M1 ::nx::Class ::nx::Object" + Class create O -object-mixin M1 + ? {O info precedence} "::M1 ::nx::Class ::nx::Object" +} + Test parameter count 3 Test case "filter-and-creation" { Class create Foo { @@ -117,36 +144,29 @@ # uplevel [list [self] create {*}$args] #} } + + # define nx unknown handler in case it does not exist + ::nx::Object protected method unknown {m args} { + error "[::nsf::current object]: unable to dispatch method '$m'" + } + ? {Foo create ob} ::ob ? {ob bar} {::ob: unable to dispatch method 'bar'} Foo filter myfilter + # create through filter ? {Foo create ob} ::ob - # TODO: the following test does not work yet. - #? {ob bar} {::ob: unable to dispatch method 'bar'} -} + # unknown through filter + ? {ob bar1} {::ob: unable to dispatch method 'bar1'} + # deactivate nx unknown handler in case it exists + ::nx::Object method unknown {} {} -puts stderr "==================== XOTcl" -package require XOTcl -namespace import -force ::xotcl::* + # create through filter + ? {Foo create ob2} ::ob2 + # unknown through filter + ? {ob2 bar2} {::ob2: unable to dispatch method 'bar2'} +} -Class create M1 -Class create M11 -M1 instproc mfoo {} {puts [self proc]} -Class create C1 -? {C1 procsearch mixin} "::xotcl::Object instforward mixin" -C1 mixin M1 -? {C1 info precedence} "::M1 ::xotcl::Class ::xotcl::Object" -C1 create c11 -? {c11 info precedence} "::C1 ::xotcl::Object" -C1 mixin add M11 -? {C1 info precedence} "::M11 ::M1 ::xotcl::Class ::xotcl::Object" -Object o -mixin M1 -? {o info precedence} "::M1 ::xotcl::Object" -Class O -O mixin M1 -? {O info precedence} "::M1 ::xotcl::Class ::xotcl::Object" -Class O -mixin M1 -? {O info precedence} "::M1 ::xotcl::Class ::xotcl::Object" +