Index: TODO =================================================================== diff -u -rd12e042ad1ee6135bedf22dc9ad7b0f27208b654 -r1a67ad0bf0b5c2092e1558d13659bad489f5bb75 --- TODO (.../TODO) (revision d12e042ad1ee6135bedf22dc9ad7b0f27208b654) +++ TODO (.../TODO) (revision 1a67ad0bf0b5c2092e1558d13659bad489f5bb75) @@ -1169,6 +1169,12 @@ - reanimated 5 tests in tests/destroytest.tcl - changed resolve_method_path to __resolve_method_path and made it protected +- fix requiredness of last argument in parametercheck +- return "object" for "info method type ...." when method is an object. +- return valid creation command in "info method definition ...." + when method is an object. +- extend regression test + TODO: - check "my" vs. "nsf::dispatch" in xotcl2.tcl - overthink decision about not showing "child objects" per default in "info methods" Index: generic/tclAPI.h =================================================================== diff -u -r4b8cf86fbf103e2d7a014a4942a6486fb77ebd39 -r1a67ad0bf0b5c2092e1558d13659bad489f5bb75 --- generic/tclAPI.h (.../tclAPI.h) (revision 4b8cf86fbf103e2d7a014a4942a6486fb77ebd39) +++ generic/tclAPI.h (.../tclAPI.h) (revision 1a67ad0bf0b5c2092e1558d13659bad489f5bb75) @@ -2212,7 +2212,7 @@ {"::nsf::parametercheck", XOTclParametercheckCmdStub, 3, { {"-nocomplain", 0, 0, convertToString}, {"param", 0, 0, convertToTclobj}, - {"value", 0, 0, convertToTclobj}} + {"value", 1, 0, convertToTclobj}} }, {"::nsf::__qualify", XOTclQualifyObjCmdStub, 1, { {"name", 1, 0, convertToTclobj}} Index: generic/xotcl.c =================================================================== diff -u -r02ec0d2caa6701949f29171520a462564299a611 -r1a67ad0bf0b5c2092e1558d13659bad489f5bb75 --- generic/xotcl.c (.../xotcl.c) (revision 02ec0d2caa6701949f29171520a462564299a611) +++ generic/xotcl.c (.../xotcl.c) (revision 1a67ad0bf0b5c2092e1558d13659bad489f5bb75) @@ -10382,17 +10382,27 @@ } #endif } else { - /* must be an alias */ - switch (subcmd) { - case InfomethodsubcmdTypeIdx: - Tcl_SetObjResult(interp, XOTclGlobalObjs[XOTE_ALIAS]); - break; - case InfomethodsubcmdDefinitionIdx: - { - Tcl_Obj *entryObj = AliasGet(interp, object->cmdName, methodName, withPer_object); - /*fprintf(stderr, "aliasGet %s -> %s (%d) returned %p\n", - objectName(object), methodName, withPer_object, entryObj);*/ - if (entryObj) { + /* + * The cmd must be an alias or object. + * + * Note that some aliases come with procPtr == XOTclObjDispatch. + * In order to dinstinguish between "object" and alias, we have + * to do the lookup for the entryObj to determine wether it is + * really an alias. + */ + + Tcl_Obj *entryObj = AliasGet(interp, object->cmdName, methodName, withPer_object); + /*fprintf(stderr, "aliasGet %s -> %s (%d) returned %p\n", + objectName(object), methodName, withPer_object, entryObj);*/ + + if (entryObj) { + /* is an alias */ + switch (subcmd) { + case InfomethodsubcmdTypeIdx: + Tcl_SetObjResult(interp, XOTclGlobalObjs[XOTE_ALIAS]); + break; + case InfomethodsubcmdDefinitionIdx: + { int nrElements; Tcl_Obj **listElements; resultObj = Tcl_NewListObj(0, NULL); @@ -10405,6 +10415,43 @@ break; } } + } else { + /* check, to be on the safe side */ + if (procPtr == XOTclObjDispatch) { + /* is an object */ + switch (subcmd) { + case InfomethodsubcmdTypeIdx: + Tcl_SetObjResult(interp, Tcl_NewStringObj("object", -1)); + break; + case InfomethodsubcmdDefinitionIdx: + { + /* yyyy */ + XOTclObject *subObject = XOTclGetObjectFromCmdPtr(cmd); + assert(subObject); + resultObj = Tcl_NewListObj(0, NULL); + /* we can make + create + or something similar to the other definition cmds + createChild + */ + AppendMethodRegistration(interp, resultObj, "create", + &(subObject->cl)->object, + ObjStr(subObject->cmdName), cmd, 0, 0); + /* + AppendMethodRegistration(interp, resultObj, "subobject", + object, methodName, cmd, 0, 0); + Tcl_ListObjAppendElement(interp, resultObj, subObject->cmdName);*/ + + Tcl_SetObjResult(interp, resultObj); + break; + } + } + } else { + /* should never happen */ + fprintf(stderr, "should never happen, maybe someone deleted the alias %s for object %s\n", + methodName, objectName(object)); + Tcl_ResetResult(interp); + } } } } Index: library/nx/nx.tcl =================================================================== diff -u -r5afef6111e8c64d8035a90aa683ff077a5cf1d91 -r1a67ad0bf0b5c2092e1558d13659bad489f5bb75 --- library/nx/nx.tcl (.../nx.tcl) (revision 5afef6111e8c64d8035a90aa683ff077a5cf1d91) +++ library/nx/nx.tcl (.../nx.tcl) (revision 1a67ad0bf0b5c2092e1558d13659bad489f5bb75) @@ -379,8 +379,8 @@ if {$definition eq ""} {error "definition must not be empty"} set object [lindex $definition end] } else { - if {$type ne "alias"} {error "can't append to $type"} - if {$definition ne ""} {error "unexpected definition '$definition'"} + if {$type ne "object"} {error "can't append to $type"} + if {[llength $definition] != 3} {error "unexpected definition '$definition'"} append object ::$w } } @@ -751,6 +751,7 @@ # copy all methods except the subobjects to ::nx::Class::slot::__info # foreach m [::nx::Object::slot::__info ::nsf::cmd::ObjectInfo2::methods] { + if {[::nx::Object::slot::__info ::nsf::cmd::ObjectInfo2::method type $m] eq "object"} continue set definition [::nx::Object::slot::__info ::nsf::cmd::ObjectInfo2::method definition $m] ::nx::Class::slot::__info {*}[lrange $definition 1 end] } Index: tests/destroytest.tcl =================================================================== diff -u -rc00e6abc0c78284c5aef12eb2ca80e3d852b079c -r1a67ad0bf0b5c2092e1558d13659bad489f5bb75 --- tests/destroytest.tcl (.../destroytest.tcl) (revision c00e6abc0c78284c5aef12eb2ca80e3d852b079c) +++ tests/destroytest.tcl (.../destroytest.tcl) (revision 1a67ad0bf0b5c2092e1558d13659bad489f5bb75) @@ -437,6 +437,7 @@ Object create o2 ::nsf::alias o x o2 ? {o x} ::o2 "call object via alias" + ? {o info method type x} alias ## the forwarded object needs a per-object methods o2 method info args next o2 method set args next Index: tests/info-method.tcl =================================================================== diff -u -r451c0d385a7b952b55d12fd02895dfc5ba342293 -r1a67ad0bf0b5c2092e1558d13659bad489f5bb75 --- tests/info-method.tcl (.../info-method.tcl) (revision 451c0d385a7b952b55d12fd02895dfc5ba342293) +++ tests/info-method.tcl (.../info-method.tcl) (revision 1a67ad0bf0b5c2092e1558d13659bad489f5bb75) @@ -69,6 +69,19 @@ ? {lsort [c1 info callable methods -application]} "a addOne foo m m-with-assertions s" } +Test case subobj { + ::nx::Object create o { + ::nx::Object create [::nx::self]::sub { + :method foo {} {;} + } + :alias subal ::o::sub + } + ? {o info methods} "sub subal" + ? {o info method type sub} "object" + ? {o info method definition sub} "::nx::Object create ::o::sub" + ? {o info method type subal} "alias" +} + Test case callable { # define the same method for Object and Class ::nx::Object method bar {} {return Object.bar}