Index: TODO =================================================================== diff -u -N -r70dc2dc002db419eca126e8af372e0920ceb5a8a -r98b60429d7f10bf637fa2cfa2bb88d4069e2445f --- TODO (.../TODO) (revision 70dc2dc002db419eca126e8af372e0920ceb5a8a) +++ TODO (.../TODO) (revision 98b60429d7f10bf637fa2cfa2bb88d4069e2445f) @@ -4423,18 +4423,30 @@ - nx.tcl: handle "incremental" in slot reconfigure - nx.tcl: change defaultAccessor to "none" -- dropped "/obj/ info slot definition /obj/" in favor of - "/slotobj/ definition" +- dropped "/obj/ info slot definition /slotobj/" in favor of "/slotobj/ definition" + + +Method and configure parameter reform, Part 3: +- added + + /cls/ info lookup variables -> list of handles + /obj/ info lookup object variables -> list of handles + /obj/ info variable definition|name|parameter /handle/ + +- nx.tcl: added forward compatible scripted implementation of "lmap" + +- nsf.c: handle names for private slots in pattern provided to AddSlotObjects(), + used e.g. in "info lookup slots /pattern/" ======================================================================== TODO: - valuechangedcmd implemented via initcmd does - not work work with "configure" method -- consider "info properties" and "info variables" -- fix property inheritance in traits (nx-traits.tcl) + not work with "configure" method +- info AddSlotObjects(): handle full-qualified name for private slots - handling of slots/properties/variables - NsfParameterGetCmd should/could handle more than "list|name|syntax" - update documentation +- fix property inheritance in traits (nx-traits.tcl) - maybe remove unneeded values, align naming in enumeration of first arg of *::info::objectparameter and *::info::method - maybe change ::nsf::parametersyntax(..) to ::nsf::parameter::syntax(..) Index: generic/nsf.c =================================================================== diff -u -N -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 -r98b60429d7f10bf637fa2cfa2bb88d4069e2445f --- generic/nsf.c (.../nsf.c) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) +++ generic/nsf.c (.../nsf.c) (revision 98b60429d7f10bf637fa2cfa2bb88d4069e2445f) @@ -13773,7 +13773,7 @@ Tcl_Obj *listObj) { NsfObject *slotContainerObject; Tcl_DString ds, *dsPtr = &ds; - int fullQualPattern = (pattern && *pattern == ':'); + int fullQualPattern = (pattern && *pattern == ':' && *(pattern+1) == ':'); /*fprintf(stderr, "AddSlotObjects parent %s prefix %s type %p %s\n", ObjectName(parent), prefix, type, type ? ClassName(type) : "");*/ @@ -13828,10 +13828,26 @@ * If the pattern looks like fully qualified, we match against the * fully qualified name. */ - match = fullQualPattern ? - Tcl_StringMatch(ObjectName(childObject), pattern) : - Tcl_StringMatch(key, pattern); - + if (*key == '_' && *(key+1) == '_' && *(key+2) == '_' && *(key+3) == '_') { + Tcl_Obj *value = Nsf_ObjGetVar2((Nsf_Object *)childObject, interp, + NsfGlobalObjs[NSF_SETTERNAME], NULL, 0); + if (value) { + char *valueString = ObjStr(value); + + match = fullQualPattern ? + Tcl_StringMatch(valueString, pattern+2) : + Tcl_StringMatch(valueString, pattern); + } else { + match = 0; + } + /*fprintf(stderr, "pattern <%s> fullQualPattern %d child %s key %s %p <%s> match %d\n", + pattern, fullQualPattern, ObjectName(childObject), key, + value, value ? ObjStr(value) : "", match);*/ + } else { + match = fullQualPattern ? + Tcl_StringMatch(ObjectName(childObject), pattern) : + Tcl_StringMatch(key, pattern); + } if (!match) { continue; } Index: generic/nsfInt.h =================================================================== diff -u -N -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 -r98b60429d7f10bf637fa2cfa2bb88d4069e2445f --- generic/nsfInt.h (.../nsfInt.h) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) +++ generic/nsfInt.h (.../nsfInt.h) (revision 98b60429d7f10bf637fa2cfa2bb88d4069e2445f) @@ -632,7 +632,7 @@ NSF_METHOD_PARAMETER_SLOT_OBJ, /* constants */ NSF_ALIAS, NSF_ARGS, NSF_CMD, NSF_FILTER, NSF_FORWARD, - NSF_METHOD, NSF_OBJECT, NSF_SETTER, NSF_VALUECHECK, + NSF_METHOD, NSF_OBJECT, NSF_SETTER, NSF_SETTERNAME, NSF_VALUECHECK, NSF_GUARD_OPTION, NSF___UNKNOWN__, NSF_ARRAY, NSF_GET, NSF_SET, NSF_OBJECT_UNKNOWN_HANDLER, NSF_ARGUMENT_UNKNOWN_HANDLER, /* Partly redefined Tcl commands; leave them together at the end */ @@ -653,7 +653,7 @@ "::nx::methodParameterSlot", /* constants */ "alias", "args", "cmd", "filter", "forward", - "method", "object", "setter", "valuecheck", + "method", "object", "setter", "settername", "valuecheck", "-guard", "__unknown__", "::array", "get", "set", /* nsf tcl commands */ "::nsf::object::unknown", Index: library/lib/nx-test.tcl =================================================================== diff -u -N -rf858f142f5fab4f88996b3eb709c3afa55114be9 -r98b60429d7f10bf637fa2cfa2bb88d4069e2445f --- library/lib/nx-test.tcl (.../nx-test.tcl) (revision f858f142f5fab4f88996b3eb709c3afa55114be9) +++ library/lib/nx-test.tcl (.../nx-test.tcl) (revision 98b60429d7f10bf637fa2cfa2bb88d4069e2445f) @@ -155,7 +155,7 @@ ::nx::Test success } else { puts stderr "[set :name]:\tincorrect result for '${:msg}', expected:" - puts stderr "'${:expected}', got\n'$r'" + puts stderr "'${:expected}', got\n\"$r\"" puts stderr "\tin test file [info script]" if {[info exists :errorReport]} {eval [set :errorReport]} ::nx::Test failure Index: library/nx/nx.tcl =================================================================== diff -u -N -r70dc2dc002db419eca126e8af372e0920ceb5a8a -r98b60429d7f10bf637fa2cfa2bb88d4069e2445f --- library/nx/nx.tcl (.../nx.tcl) (revision 70dc2dc002db419eca126e8af372e0920ceb5a8a) +++ library/nx/nx.tcl (.../nx.tcl) (revision 98b60429d7f10bf637fa2cfa2bb88d4069e2445f) @@ -698,6 +698,9 @@ set syntax "/[self]/ configure [: ::nsf::methods::object::info::objectparameter syntax]" return [string trimright $syntax " "] } + :method "info lookup variables" {pattern:optional} { + return [: info lookup slots -type ::nx::VariableSlot {*}[current args]] + } :alias "info children" ::nsf::methods::object::info::children :alias "info class" ::nsf::methods::object::info::class :alias "info has mixin" ::nsf::methods::object::info::hasmixin @@ -711,8 +714,13 @@ :alias "info object mixin guard" ::nsf::methods::object::info::mixinguard :alias "info object mixin classes" ::nsf::methods::object::info::mixinclasses :method "info object slots" {{-type:class ::nx::Slot} pattern:optional} { - return [: ::nsf::methods::object::info::slotobjects -type $type {*}[current args]] + set method [list ::nsf::methods::object::info::slotobjects -type $type] + if {[info exists pattern]} {lappend method $pattern} + return [: {*}$method] } + :method "info object variables" {pattern:optional} { + return [: info object slots -type ::nx::VariableSlot {*}[current args]] + } # # Parameter extractors # @@ -724,6 +732,9 @@ # "info properties" is a short form of "info slot definition" #:alias "info properties" ::nx::Object::slot::__info::slot::definition :alias "info vars" ::nsf::methods::object::info::vars + :method "info variable definition" {slot} {return [$slot definition]} + :method "info variable name" {slot} {return [$slot name]} + :method "info variable parameter" {slot} {return [$slot getSpec]} } ###################################################################### @@ -766,15 +777,15 @@ if {[info exists pattern]} {return [::nsf::parameter::filter $defs $pattern]} return $defs } - set cmd {::nsf::methods::class::info::slotobjects -closure -type ::nx::Slot} - if {[info exists pattern]} {lappend cmd $pattern} - return [::nsf::parameter::specs -configure [: {*}$cmd]] + set slots [: ::nsf::methods::class::info::slotobjects -closure -type ::nx::Slot {*}[current args]] + return [::nsf::parameter::specs -configure $slots] + } :method "info configure syntax" {} { set defs [: ::nsf::methods::class::getCachedParameters] if {[llength $defs] == 0} { - set defs [::nsf::parameter::specs -configure \ - [: ::nsf::methods::class::info::slotobjects -closure -type ::nx::Slot]] + set slots [: ::nsf::methods::class::info::slotobjects -closure -type ::nx::Slot] + set defs [::nsf::parameter::specs -configure $slots] } set syntax "/[self]/ " foreach def $defs {append syntax [::nsf::parameter::get syntax $def] " "} @@ -802,6 +813,11 @@ #:alias "info properties" ::nx::Class::slot::__info::slot::definition :alias "info subclass" ::nsf::methods::class::info::subclass :alias "info superclass" ::nsf::methods::class::info::superclass + :method "info variables" {pattern:optional} { + set cmd {info slots -type ::nx::VariableSlot} + if {[info exists pattern]} {lappend cmd $pattern} + return [: {*}$cmd] + } } ###################################################################### @@ -832,6 +848,7 @@ :method "info method body" {name} {: ::nsf::methods::class::info::method body $name} :method "info method definition" {name} {: ::nsf::methods::class::info::method definition $name} :method "info method exists" {name} {: ::nsf::methods::class::info::method exists $name} + :method "info method handle" {name} {: ::nsf::methods::class::info::method definitionhandle $name} :method "info method registrationhandle" {name} {: ::nsf::methods::class::info::method registrationhandle $name} :method "info method definitionhandle" {name} {: ::nsf::methods::class::info::method definitionhandle $name} :method "info method origin" {name} {: ::nsf::methods::class::info::method origin $name} @@ -841,7 +858,7 @@ return $defs } :method "info method syntax" {name} { - return [string trimright "/[self]/ $name [: ::nsf::methods::class::info::method syntax $name]" { }] + return [string trimright "/[self]/ [namespace tail $name] [: ::nsf::methods::class::info::method syntax $name]" { }] } :method "info method type" {name} {: ::nsf::methods::class::info::method type $name} :method "info method precondition" {name} {: ::nsf::methods::class::info::method precondition $name} @@ -856,6 +873,7 @@ :method "info object method body" {name} {: ::nsf::methods::object::info::method body $name} :method "info object method definition" {name} {: ::nsf::methods::object::info::method definition $name} :method "info object method exists" {name} {: ::nsf::methods::object::info::method exists $name} + :method "info object method handle" {name} {: ::nsf::methods::object::info::method definitionhandle $name} :method "info object method registrationhandle" {name} {: ::nsf::methods::object::info::method registrationhandle $name} :method "info object method definitionhandle" {name} {: ::nsf::methods::object::info::method definitionhandle $name} :method "info object method origin" {name} {: ::nsf::methods::object::info::method origin $name} @@ -865,7 +883,7 @@ return $defs } :method "info object method syntax" {name} { - return [string trimright "/[self]/ $name [: ::nsf::methods::object::info::method syntax $name]" { }] + return [string trimright "/[self]/ [namespace tail $name] [: ::nsf::methods::object::info::method syntax $name]" { }] } :method "info object method type" {name} {: ::nsf::methods::object::info::method type $name} :method "info object method precondition" {name} {: ::nsf::methods::object::info::method precondition $name} @@ -2508,6 +2526,16 @@ unset ::nsf::bootstrap } +if {[info command ::lmap] eq ""} { + # provide a simple forward compatible version of Tcl 8.6's lmap + proc lmap {_var list body} { + upvar 1 $_var var + set res {} + foreach var $list {lappend res [uplevel 1 $body]} + return $res + } +} + # # When debug is not deactivated, tell the developer, what happened # Index: tests/info-method.test =================================================================== diff -u -N -r70dc2dc002db419eca126e8af372e0920ceb5a8a -r98b60429d7f10bf637fa2cfa2bb88d4069e2445f --- tests/info-method.test (.../info-method.test) (revision 70dc2dc002db419eca126e8af372e0920ceb5a8a) +++ tests/info-method.test (.../info-method.test) (revision 98b60429d7f10bf637fa2cfa2bb88d4069e2445f) @@ -727,9 +727,9 @@ ? {::nx::Object info methods "info"} "info" ? {::nx::Object info methods -path "info"} "" ? {lsort [::nx::Object info methods -path "info lookup *"]} \ - "{info lookup configure parameters} {info lookup configure syntax} {info lookup filter} {info lookup method} {info lookup methods} {info lookup slots}" + "{info lookup configure parameters} {info lookup configure syntax} {info lookup filter} {info lookup method} {info lookup methods} {info lookup slots} {info lookup variables}" ? {lsort [::nx::Object info methods -path "info *parameter*"]} \ - "{info lookup configure parameters} {info object method parameters} {info parameter name} {info parameter syntax}" + "{info lookup configure parameters} {info object method parameters} {info parameter name} {info parameter syntax} {info variable parameter}" ? {lsort [::nx::Object info methods "slots"]} "" ? {lsort [::nx::Object info methods "*slots*"]} "" ? {lsort [::nx::Object info methods -path "*slot*"]} \ @@ -785,8 +785,8 @@ # a forwarder to ::nsf::relation; definition comes via array ::nsf::parametersyntax ? {::nx::Class info method syntax mixin} "/::nx::Class/ mixin ?/class .../?|?add /class/?|?delete /class/?" - ? {::nx::Class info method syntax ::nx::next} "/::nx::Class/ ::nx::next ?/arguments/?" - ? {::nx::Class info method syntax ::nsf::xotclnext} "/::nx::Class/ ::nsf::xotclnext ?--noArgs? ?/arg .../?" + ? {::nx::Class info method syntax ::nx::next} "/::nx::Class/ next ?/arguments/?" + ? {::nx::Class info method syntax ::nsf::xotclnext} "/::nx::Class/ xotclnext ?--noArgs? ?/arg .../?" } # Index: tests/plain-object-method.test =================================================================== diff -u -N -r70dc2dc002db419eca126e8af372e0920ceb5a8a -r98b60429d7f10bf637fa2cfa2bb88d4069e2445f --- tests/plain-object-method.test (.../plain-object-method.test) (revision 70dc2dc002db419eca126e8af372e0920ceb5a8a) +++ tests/plain-object-method.test (.../plain-object-method.test) (revision 98b60429d7f10bf637fa2cfa2bb88d4069e2445f) @@ -11,7 +11,7 @@ ? {o filter f} "::o: unable to dispatch method 'filter'" ? {lsort [o info object methods]} "f" - ? {lsort [o info]} "valid submethods of ::o info: children class has info is lookup name object parameter parent precedence vars" + ? {lsort [o info]} "valid submethods of ::o info: children class has info is lookup name object parameter parent precedence variable vars" } package require nx::plain-object-method @@ -37,5 +37,5 @@ ? {o info filter methods} "" ? {lsort [o info object methods]} "f foo" - ? {lsort [o info]} "valid submethods of ::o info: children class filter has info is lookup method methods mixin name object parameter parent precedence vars" + ? {lsort [o info]} "valid submethods of ::o info: children class filter has info is lookup method methods mixin name object parameter parent precedence variable vars" } Index: tests/submethods.test =================================================================== diff -u -N -r70dc2dc002db419eca126e8af372e0920ceb5a8a -r98b60429d7f10bf637fa2cfa2bb88d4069e2445f --- tests/submethods.test (.../submethods.test) (revision 70dc2dc002db419eca126e8af372e0920ceb5a8a) +++ tests/submethods.test (.../submethods.test) (revision 98b60429d7f10bf637fa2cfa2bb88d4069e2445f) @@ -229,7 +229,7 @@ # defaultcmd has to return also subcmds of other shadowed ensembles ? {lsort [o1 info has]} "valid submethods of ::o1 info has: mixin namespace something type" - ? {lsort [o1 info]} "valid submethods of ::o1 info: children class has info is lookup name object parameter parent precedence vars" + ? {lsort [o1 info]} "valid submethods of ::o1 info: children class has info is lookup name object parameter parent precedence variable vars" # returning methodpath in ensemble ? {o1 info has something path} "info has something path"