Index: TODO =================================================================== diff -u -r1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0 -rca508a05de8e3783d432b8de2db2ae3e61ae271e --- TODO (.../TODO) (revision 1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0) +++ TODO (.../TODO) (revision ca508a05de8e3783d432b8de2db2ae3e61ae271e) @@ -3297,17 +3297,16 @@ * added "/obj/ info properties" (alias to "/obj/ info slot definition") * extended regression test +- nx.tcl: + * added parameter option incremental for "property" and "variable" + * removed the nonpos argument "-incremental" from "property" and "variable" + * adapted regression test for these cases TODO: - nx: * maybe provide a replacement for -attributes, but without the magic variable. - - incremental: - flag -incremental - {set :incremental 1} - => parameter option? - - naming of slot classes * should we switch from "-class" to "-slotclass"? Index: library/nx/nx.tcl =================================================================== diff -u -r1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0 -rca508a05de8e3783d432b8de2db2ae3e61ae271e --- library/nx/nx.tcl (.../nx.tcl) (revision 1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0) +++ library/nx/nx.tcl (.../nx.tcl) (revision ca508a05de8e3783d432b8de2db2ae3e61ae271e) @@ -817,6 +817,9 @@ set opt(-accessor) 0 } elseif {$property eq "noconfig"} { set opt(-config) 0 + } elseif {$property eq "incremental"} { + set opt(-accessor) 1 + lappend opts -incremental 1 } elseif {[string match type=* $property]} { set class [:requireClass ::nx::VariableSlot $class] set type [string range $property 5 end] @@ -845,6 +848,7 @@ lappend opts -type $type } lappend opts {*}[array get opt] + #puts stderr "[self] *** parseParameterSpec [list $name $parameterOptions $class $opts]" return [list $name $parameterOptions $class $opts] } @@ -1671,7 +1675,6 @@ nx::Object method variable { {-accessor:switch} {-class ""} - {-incremental:switch} {-initblock ""} {-nocomplain:switch} spec:parameter @@ -1683,41 +1686,38 @@ # situations: # - when accessors are needed # (serializer uses slot object to create accessors) - # in general: # - when initblock is non empty # #puts stderr "Object variable $spec accessor $accessor nocomplain $nocomplain" - if {$incremental} { + # get name and list of parameter options + lassign [::nx::MetaSlot parseParameterSpec -class $class $spec] \ + name parameterOptions class options + array set opts $options + + if {[info exists opts(-incremental)]} { # the usage of "-incremental" implies "-accessor" set accessor true - append initblock { - set :incremental 1 - } } if {$initblock eq "" && !$accessor} { # - # build a slot-less variable + # we can build a slot-less variable # - # get name an list of parameter options - lassign [::nx::MetaSlot parseParameterSpec -class $class $spec] \ - name parameterOptions class opts - set isSwitch [regsub {\mswitch\M} $parameterOptions boolean parameterOptions] if {[info exists value]} { if {[info exists :$name] && !$nocomplain} { error "Object [self] has already an instance variable named '$name'" } if {$parameterOptions ne ""} { - #puts stderr "*** ::nsf::is $parameterOptions $value // opts=$opts" + #puts stderr "*** ::nsf::is $parameterOptions $value // opts=$options" # 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 ,] + set noptions {} + foreach o [split $parameterOptions ,] { + if {$o ne "noconfig"} {lappend noptions $o} } + set parameterOptions [join $noptions ,] ::nsf::is -complain $parameterOptions $value } else { set name $spec @@ -1748,15 +1748,13 @@ Object method property { {-class ""} - -incremental:switch -nocomplain:switch spec:parameter {initblock ""} } { set r [[self] ::nsf::classes::nx::Object::variable \ -accessor=true \ -class $class \ - -incremental=$incremental \ -initblock $initblock \ -nocomplain=$nocomplain \ {*}$spec] @@ -1767,18 +1765,10 @@ {-accessor:switch} {-class ""} {-config:switch} - -incremental:switch {-initblock ""} spec:parameter default:optional } { - if {$incremental} { - # the usage of "-incremental" implies "-accessor" - set accessor true - append initblock { - set :incremental 1 - } - } set slot [::nx::MetaSlot createFromParameterSpec [::nsf::self] \ -class $class \ -initblock $initblock \ @@ -1790,15 +1780,13 @@ nx::Class method property { {-class ""} - -incremental:switch spec:parameter {initblock ""} } { set r [[self] ::nsf::classes::nx::Class::variable \ -accessor=true \ -class $class \ -config=true \ - -incremental=$incremental \ -initblock $initblock \ {*}$spec] return $r Index: tests/parameters.test =================================================================== diff -u -r1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0 -rca508a05de8e3783d432b8de2db2ae3e61ae271e --- tests/parameters.test (.../parameters.test) (revision 1d1a1be1636a5b6f9ad6e3b5df2a6aa7170b62f0) +++ tests/parameters.test (.../parameters.test) (revision ca508a05de8e3783d432b8de2db2ae3e61ae271e) @@ -27,7 +27,7 @@ ? {::nsf::method::alias C foo ::set 1} \ {Invalid argument '1', maybe too many arguments; should be "::nsf::method::alias object ?-per-object? methodName ?-frame method|object|default? cmdName"} - ? {C eval {:property x -class D}} {Invalid argument 'D', maybe too many arguments; should be "::C property ?-class value? ?-incremental? spec ?initblock?"} "Test whether the colon prefix is suppressed" + ? {C eval {:property x -class D}} {Invalid argument 'D', maybe too many arguments; should be "::C property ?-class value? spec ?initblock?"} "Test whether the colon prefix is suppressed" } ####################################################### @@ -879,10 +879,7 @@ :property {s2:substdefault,substdefault "[current]"} # substdefault with incremental - :property {s3:substdefault "[current]"} { - # Bypassing the Optimizer helps after applying the patch (solving step 1) - set :incremental 1 - } + :property {s3:substdefault,incremental "[current]"} } Bar create ::b @@ -1946,8 +1943,8 @@ {::enterprise::r2} # testing incremental - ? [list [self] variable -incremental -nocomplain i:int,0..* {}] "::enterprise::i" - ? [list [self] property -incremental -nocomplain j:int,0..* {}] "::enterprise::j" + ? [list [self] variable -nocomplain i:int,0..*,incremental {}] "::enterprise::i" + ? [list [self] property -nocomplain j:int,0..*,incremental {}] "::enterprise::j" :i add 1 :j add 1 ? [list [self] i] "1" @@ -2221,7 +2218,7 @@ # 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 + :variable v2:incremental 100 } # only the variables with slots show up in "info slot ..."