Index: TODO =================================================================== diff -u -ra467cf37f204cc977b7af7519a0994c65f9ed10f -r1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0 --- TODO (.../TODO) (revision a467cf37f204cc977b7af7519a0994c65f9ed10f) +++ TODO (.../TODO) (revision 1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0) @@ -3291,30 +3291,41 @@ * additional public method ObjectParameterSlot.getPropertyDefinition * updated and extended regression test +- nx.tcl: + * added "/obj/ info slot definition" + * added "/obj/ info slot name" + * added "/obj/ info properties" (alias to "/obj/ info slot definition") + * extended regression test + TODO: - nx: * maybe provide a replacement for -attributes, but without the magic variable. - * introspection of properties - * before we had ? {C info attributes} {{x 1} {y 2}} - * now we have - Object method "info slots" {{-type ::nx::Slot} pattern:optional} {..} - Class method "info slots" {{-type ::nx::Slot} -closure:switch -source pattern:optional} {..} - returning slot objects, but no nice way. - e.g. Class method "info parameter list" {name:optional} {...} - gets the value from the object parameters, but has no way to filter e.g. for -source, -type etc. - * do we need an "info property"? - * rename "info parameter spec" into "info parameter definition"? - - - add "property" and "attribute" into migration guide - - incremental: flag -incremental {set :incremental 1} => parameter option? + - naming of slot classes + * should we switch from "-class" to "-slotclass"? + + o1 property ?-class value? ?-incremental? ?-nocomplain? spec ?initblock? + o1 variable ?-accessor? ?-class value? ?-incremental? ?-initblock value? ?-nocomplain? spec ?value? + + * the introspection interface uses "-type", meaning "class or subclass" + + o1 info lookup slots ?-type value? ?-source value? ?pattern? + o1 info properties ?-type value? ?-closure? ?-source value? ?pattern? + o1 info slot definition ?-type value? ?-closure? ?-source value? ?pattern? + o1 info slot name ?-type value? ?-closure? ?-source value? ?pattern? + o1 info slot objects ?-type value? ?pattern? + + o1 info children ?-type class? ?pattern? + + - add "property" and "attribute" and "info property" and "info slot ..." to migration guide + - doc/langRef2.xotcl vs library/xotcl/doc/langRef.xotcl - strange refcounting bug in 8.6b2 bug-is-86.tcl @@ -3359,23 +3370,7 @@ - interface of "variable" and "attribute": * add switch -array for "variable"? (Just setting is trivial, handling setters and incremental setter is more work) - * should we switch from "-class" to "-slotclass"? - * should we change interface for default value in attribute? - probably not, same interface is used in methodparameters as well - - Should we leave "variable" and "attribute" as it ist? - options: - (a) leave it as it is - (b) use "property" instead of "attribute" - ("a property is a variable with accessors"), - some tribute to beans terminology - (c) use "parameter" instead of "attribute", - since providing accessors means make the - variable an object parameter - (d) use "attribute" instead of "variable" - Variable is the tcl term, attribute is the UML term - (e) others? - - call user defined setter in object parameters? - NsfObjWrongArgs() & friends is not aware of submethods. Error Index: library/nx/nx.tcl =================================================================== diff -u -ra467cf37f204cc977b7af7519a0994c65f9ed10f -r1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0 --- library/nx/nx.tcl (.../nx.tcl) (revision a467cf37f204cc977b7af7519a0994c65f9ed10f) +++ library/nx/nx.tcl (.../nx.tcl) (revision 1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0) @@ -604,11 +604,25 @@ :alias "info mixin classes" ::nsf::methods::object::info::mixinclasses :alias "info parent" ::nsf::methods::object::info::parent :alias "info precedence" ::nsf::methods::object::info::precedence + :method "info slot definition" {{-type ::nx::Slot} -closure:switch -source:optional pattern:optional} { + set result {} + foreach slot [::nsf::my ::nsf::methods::object::info::slotobjects {*}[current args]] { + lappend result [$slot getPropertyDefinition] + } + return $result + } + :method "info slot name" {{-type ::nx::Slot} -closure:switch -source:optional pattern:optional} { + set result {} + foreach slot [::nsf::my ::nsf::methods::object::info::slotobjects {*}[current args]] { + lappend result [$slot name] + } + return $result + } :method "info slot objects" {{-type ::nx::Slot} pattern:optional} { - set cmd [list ::nsf::methods::object::info::slotobjects -type $type] - if {[info exists pattern]} {lappend cmd $pattern} - return [::nsf::my {*}$cmd] + return [::nsf::my ::nsf::methods::object::info::slotobjects {*}[current args]] } + # "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 } @@ -685,15 +699,13 @@ :method "info slot definition" {{-type ::nx::Slot} -closure:switch -source:optional pattern:optional} { set result {} foreach slot [::nsf::my ::nsf::methods::class::info::slotobjects {*}[current args]] { - # ssss lappend result [$slot getPropertyDefinition] } return $result } :method "info slot name" {{-type ::nx::Slot} -closure:switch -source:optional pattern:optional} { set result {} foreach slot [::nsf::my ::nsf::methods::class::info::slotobjects {*}[current args]] { - # ssss lappend result [$slot name] } return $result @@ -803,8 +815,8 @@ lappend opts -$property 1 } elseif {$property eq "noaccessor"} { set opt(-accessor) 0 - } elseif {[string match config=* $property]} { - set opt(-config) [string range $property 7 end] + } elseif {$property eq "noconfig"} { + set opt(-config) 0 } elseif {[string match type=* $property]} { set class [:requireClass ::nx::VariableSlot $class] set type [string range $property 5 end] @@ -1133,7 +1145,6 @@ ObjectParameterSlot public method getPropertyDefinition {} { set options [:getParameterOptions -withMultiplicity true] if {[info exists :positional]} {lappend options positional} - # sssss if {!${:accessor}} {lappend options noaccessor} if {!${:config}} {lappend options noconfig} if {[info exists :default]} { @@ -1702,6 +1713,11 @@ if {$parameterOptions ne ""} { #puts stderr "*** ::nsf::is $parameterOptions $value // opts=$opts" # we rely here that the nsf::is error message expresses the implementation limits + if {[string match *nonconfig* $parameterOptions]} { + set options {} + foreach o [split $parameterOptions ,] {if {$o ne "noconfig"} {lappend options $o}} + set parameterOptions [join $options ,] + } ::nsf::is -complain $parameterOptions $value } else { set name $spec Index: tests/info-method.test =================================================================== diff -u -ra467cf37f204cc977b7af7519a0994c65f9ed10f -r1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0 --- tests/info-method.test (.../info-method.test) (revision a467cf37f204cc977b7af7519a0994c65f9ed10f) +++ tests/info-method.test (.../info-method.test) (revision 1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0) @@ -553,7 +553,7 @@ ? {lsort [::nx::Object info methods "slots"]} "" ? {lsort [::nx::Object info methods "*slots*"]} "" ? {lsort [::nx::Object info methods -path "*slot*"]} \ - "{info lookup slots} {info slot objects}" + "{info lookup slots} {info slot definition} {info slot name} {info slot objects}" ? {lsort [::nx::Object info methods -path "*filter*"]} \ "filter {info filter guard} {info filter methods} {info lookup filter}" Index: tests/parameters.test =================================================================== diff -u -rbda7fdde3da654972629af7da59c7da24969cb92 -r1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0 --- tests/parameters.test (.../parameters.test) (revision bda7fdde3da654972629af7da59c7da24969cb92) +++ tests/parameters.test (.../parameters.test) (revision 1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0) @@ -2171,29 +2171,76 @@ # Test slots with configparameter true/false, accessor true/false # against "info slot definition" and "info parameter" # -Test case info-slots-types { +Test case class-info-slots-types { + # + # "/cls/ info slot ..." shows all slots, including variables + # "/cls/ info parameter ..." shows the parameter available for object parameterization + # Class create C { # variable has no config parameter and no accessor :variable v 100 } - # "v" does not show up in "info parameter" + # "v" does NOT show up in "info parameter" ? {C info parameter list} "-volatile -noinit -mixin -class -filter __initcmd" ? {C info parameter names} "volatile noinit mixin class filter __initcmd" - # "v" does show up in "info slot" + # "v" does show up in "info slot ..." ? {C info slot objects} "::C::slot::v" ? {C info slot definition} "{v:noaccessor,noconfig 100}" Class create D { - :property {p:noaccessor 200} + :property {p0 200} + :property {p1:noaccessor 201} + :property {p2:noaccessor,noconfig 202} + :property {p3:noconfig 203} } - # "p" does show up in "info parameter" - ? {D info parameter list} "-p -volatile -noinit -mixin -class -filter __initcmd" - ? {D info parameter names} "p volatile noinit mixin class filter __initcmd" + # "p2" and "p3" do NOT show up in "info parameter" + ? {D info parameter list} "-p0 -p1 -volatile -noinit -mixin -class -filter __initcmd" + ? {D info parameter names} "p0 p1 volatile noinit mixin class filter __initcmd" - # "p" does show up in "info slot" - ? {D info slot objects} "::D::slot::p" - ? {D info slot definition} "{p:noaccessor 200}" + # "p1" and "p2" do NOT show up in "info methods" + ? {D info methods} "p0 p3" + + # all properties show up in "info slot" + ? {D info slot objects} "::D::slot::p0 ::D::slot::p1 ::D::slot::p2 ::D::slot::p3" + ? {D info slot definition} "{p0 200} {p1:noaccessor 201} {p2:noaccessor,noconfig 202} {p3:noconfig 203}" + ? {D info properties} "{p0 200} {p1:noaccessor 201} {p2:noaccessor,noconfig 202} {p3:noconfig 203}" + +} + + +Test case object-info-slots-types { + # + # "/obj/ info slot ..." shows all slots, including variables + # + Object create o1 { + # plain object variable has no slot object + :variable v0 100 + # In case we require an accessor or e.g. incremental, slot objects + # are created; incremental implies accessor + :variable -accessor v1 100 + :variable -incremental v2 100 + } + + # only the variables with slots show up in "info slot ..." + ? {o1 info slot objects} "::o1::per-object-slot::v2 ::o1::per-object-slot::v1" + ? {o1 info slot definition} "{v2:noconfig 100} {v1:noconfig 100}" + + Object create o2 { + :property {p0 200} + :property {p1:noaccessor 201} + :property {p2:noaccessor,noconfig 202} + :property {p3:noconfig 203} + } + + # "p1" and "p2" do NOT show up in "info methods" + ? {o2 info methods} "p0 p3" + + # all properties show up in "info slot" + ? {o2 info slot objects} "::o2::per-object-slot::p0 ::o2::per-object-slot::p1 ::o2::per-object-slot::p2 ::o2::per-object-slot::p3" + ? {o2 info slot definition} "{p0:noconfig 200} {p1:noaccessor,noconfig 201} {p2:noaccessor,noconfig 202} {p3:noconfig 203}" + ? {o2 info properties} "{p0:noconfig 200} {p1:noaccessor,noconfig 201} {p2:noaccessor,noconfig 202} {p3:noconfig 203}" + } \ No newline at end of file Index: tests/submethods.test =================================================================== diff -u -ra467cf37f204cc977b7af7519a0994c65f9ed10f -r1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0 --- tests/submethods.test (.../submethods.test) (revision a467cf37f204cc977b7af7519a0994c65f9ed10f) +++ tests/submethods.test (.../submethods.test) (revision 1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0) @@ -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 filter has info is lookup method methods mixin parent precedence slot vars" + ? {lsort [o1 info]} "Valid submethods of ::o1 info: children class filter has info is lookup method methods mixin parent precedence properties slot vars" # returning methodpath in ensemble ? {o1 info has something path} "info has something path"