Index: TODO =================================================================== diff -u -r0054815a6f649a06f4e3a9f5516df56c05e99098 -rb5b08b9cc2fea92762787311da318d49d77d2a7b --- TODO (.../TODO) (revision 0054815a6f649a06f4e3a9f5516df56c05e99098) +++ TODO (.../TODO) (revision b5b08b9cc2fea92762787311da318d49d77d2a7b) @@ -1336,9 +1336,10 @@ - fixed handles with subcommands used on objects without namespaces - new functions: GetRegObject() +- fixed handles with subcommands for class methods when called on classes or objects +- extended regression test TODO: -- /* TODO: what, if we call on a class "info method" with a methodhandle of an object? */ - check potential crashes with invalid input - check equivalence of the following two commands Index: generic/nsf.c =================================================================== diff -u -r0054815a6f649a06f4e3a9f5516df56c05e99098 -rb5b08b9cc2fea92762787311da318d49d77d2a7b --- generic/nsf.c (.../nsf.c) (revision 0054815a6f649a06f4e3a9f5516df56c05e99098) +++ generic/nsf.c (.../nsf.c) (revision b5b08b9cc2fea92762787311da318d49d77d2a7b) @@ -14523,7 +14523,8 @@ Tcl_DStringInit(dsPtr); cmd = ResolveMethodName(interp, object->nsPtr, methodNameObj, dsPtr, ®Object, &defObject, &methodName1, &fromClassNS); - /*fprintf(stderr, "object %p regObject %p defObject %p\n",object,regObject,defObject);*/ + /*fprintf(stderr, "object %p regObject %p defObject %p fromClass %d\n", + object,regObject,defObject,fromClassNS);*/ result = ListMethod(interp, regObject ? regObject : object, defObject ? defObject : object, @@ -14761,19 +14762,20 @@ int subcmd, Tcl_Obj *methodNameObj) { NsfObject *regObject, *defObject; CONST char *methodName1 = NULL; - int fromClassNs = 0, result; + int fromClassNS = 1, result; Tcl_DString ds, *dsPtr = &ds; Tcl_Command cmd; Tcl_DStringInit(dsPtr); cmd = ResolveMethodName(interp, class->nsPtr, methodNameObj, - dsPtr, ®Object, &defObject, &methodName1, &fromClassNs); - /* TODO: what, if we call on a class "info method" with a methodhandle of an object? */ + dsPtr, ®Object, &defObject, &methodName1, &fromClassNS); + /*fprintf(stderr, "object %p regObject %p defObject %p fromClass %d\n", + &class->object,regObject,defObject,fromClassNS);*/ result = ListMethod(interp, regObject ? regObject : &class->object, defObject ? defObject : &class->object, methodName1, - cmd, subcmd, 0); + cmd, subcmd, fromClassNS ? 0 : 1); Tcl_DStringFree(dsPtr); return result; Index: tests/info-method.tcl =================================================================== diff -u -r0054815a6f649a06f4e3a9f5516df56c05e99098 -rb5b08b9cc2fea92762787311da318d49d77d2a7b --- tests/info-method.tcl (.../info-method.tcl) (revision 0054815a6f649a06f4e3a9f5516df56c05e99098) +++ tests/info-method.tcl (.../info-method.tcl) (revision b5b08b9cc2fea92762787311da318d49d77d2a7b) @@ -210,6 +210,8 @@ :method "bar b" {x:int y:upper} {return b} :method "bar baz x" {x:int y:upper} {return x} :method "bar baz y" {x:int y:upper} {return y} + :object method "foo x" {z:int} {return z} + :object method "foo y" {z:int} {return z} } # query definition on subcommand @@ -221,12 +223,18 @@ # query definition on subcommand with handle ? {o info method definition "::o::foo b"} {::o method {foo b} {x:int y:upper} {return b}} - # query definition on subcommand with handle called on different object + # query definition on subcommand with handle called on different object ? {o2 info method definition "::o::foo b"} {::o method {foo b} {x:int y:upper} {return b}} # query definition on handle of ensemble object called on different object ? {o2 info method definition "::o::foo::b"} {::o::foo method b {x:int y:upper} {return b}} + # query definition on subcommand with handle called on class + ? {o2 info method definition "::o::foo b"} {::o method {foo b} {x:int y:upper} {return b}} + + # query definition on handle of ensemble object called on class + ? {o2 info method definition "::o::foo::b"} {::o::foo method b {x:int y:upper} {return b}} + # query definition on subcommand of class ? {::nx::Object info method definition "info lookup methods"} \ {::nx::Object alias {info lookup methods} ::nsf::cmd::ObjectInfo::lookupmethods} @@ -239,11 +247,21 @@ ? {o info method definition "::nx::Object::slot::__info::lookup::methods"} \ {::nx::Object::slot::__info::lookup alias methods ::nsf::cmd::ObjectInfo::lookupmethods} - ? {C info method handle "bar"} {::nsf::classes::C::bar} ? {C info method handle "bar a"} {::nsf::classes::C::bar a} ? {C info method handle "bar baz y"} {::nsf::classes::C::bar baz y} + ? {C info method definition "bar b"} {::C method {bar b} {x:int y:upper} {return b}} + ? {C info method definition "::nsf::classes::C::bar b"} {::C method {bar b} {x:int y:upper} {return b}} + ? {o2 info method definition "::nsf::classes::C::bar b"} {::C method {bar b} {x:int y:upper} {return b}} + + ? {C object info method handle "foo"} {::C::foo} + ? {C object info method handle "foo x"} {::C::foo x} + + ? {C object info method definition "::C::foo x"} {::C object method {foo x} z:int {return z}} + ? {C info method definition "::C::foo x"} {::C object method {foo x} z:int {return z}} + ? {o2 info method definition "::C::foo x"} {::C object method {foo x} z:int {return z}} + ? {C info method definition "bar baz y"} \ {::C method {bar baz y} {x:int y:upper} {return y}} ? {C info method definition "::nsf::classes::C::bar baz y"} \