Index: TODO =================================================================== diff -u -ra08065ac227c3b26514f29392a961f11db121369 -r9c636251d106b1728258076165dd19e8af36b2c1 --- TODO (.../TODO) (revision a08065ac227c3b26514f29392a961f11db121369) +++ TODO (.../TODO) (revision 9c636251d106b1728258076165dd19e8af36b2c1) @@ -3067,8 +3067,23 @@ - library/mongodb: * updated to current interface in git HEAD +- nx.tcl: added switch "incremental" to "variable" and "attribute" +- added regression test + + TODO: - - variable and incremental + - more regression tests for incremental + variable/attribute + + - placement of switched and parameters: + currently we have: + /obj/ attribute ?-incremental? ?-nocomplain? spec ?-class value? ?initblock? + /obj/ variable ?-class value? ?-initblock value? ?-accessor boolean? ?-array? ?-incremental? ?-nocomplain? spec ?value? + + /cls/ attribute ?-incremental? spec ?-class value? ?initblock? + /cls/ variable ?-class value? ?-incremental? ?-initblock value? ?-objectparameter value? ?-accessor value? spec ?default? + + 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? Index: library/nx/nx.tcl =================================================================== diff -u -rf3127511bec503add89e7a691f33213b1999274d -r9c636251d106b1728258076165dd19e8af36b2c1 --- library/nx/nx.tcl (.../nx.tcl) (revision f3127511bec503add89e7a691f33213b1999274d) +++ library/nx/nx.tcl (.../nx.tcl) (revision 9c636251d106b1728258076165dd19e8af36b2c1) @@ -1613,8 +1613,9 @@ nx::Object method variable { {-class ""} {-initblock ""} - {-array:switch} {-accessor:boolean false} + {-array:switch} + {-incremental:switch} {-nocomplain:switch} spec value:optional @@ -1630,6 +1631,13 @@ #puts stderr "Object variable $spec accessor $accessor nocomplain $nocomplain" + if {$incremental} { + # incremental implies accessor + set accessor true + append initblock { + set :incremental 1 + } + } if {$initblock eq "" && !$accessor} { # get name an list of parameter options lassign [::nx::MetaSlot parseParameterSpec -class $class $spec] \ @@ -1664,9 +1672,16 @@ return [::nsf::object::dispatch [self] ::nsf::methods::object::info::method handle [$slot name]] } - Object method attribute {-nocomplain:switch spec {-class ""} {initblock ""}} { + Object method attribute { + -incremental:switch + -nocomplain:switch + spec + {-class ""} + {initblock ""} + } { set r [[self] ::nsf::classes::nx::Object::variable \ -class $class \ + -incremental=$incremental \ -nocomplain=$nocomplain \ -initblock $initblock \ -accessor true \ @@ -1675,13 +1690,21 @@ } nx::Class method variable { - {-class ""} + {-class ""} + -incremental:switch {-initblock ""} {-objectparameter false} {-accessor false} spec default:optional } { + if {$incremental} { + # incremental implies accessor + set accessor true + append initblock { + set :incremental 1 + } + } #puts stderr "Class variable $spec" set slot [::nx::MetaSlot createFromParameterSpec [::nsf::self] \ -class $class \ @@ -1692,9 +1715,10 @@ return [::nsf::object::dispatch [self] ::nsf::methods::class::info::method handle [$slot name]] } - Class method attribute {spec {-class ""} {initblock ""}} { + Class method attribute {-incremental:switch spec {-class ""} {initblock ""}} { set r [[self] ::nsf::classes::nx::Class::variable \ -class $class \ + -incremental=$incremental \ -initblock $initblock \ -accessor true \ -objectparameter true \ Index: tests/parameters.test =================================================================== diff -u -red9fb67f4304d4e03ce35df1e9cbe10eb5e0e183 -r9c636251d106b1728258076165dd19e8af36b2c1 --- tests/parameters.test (.../parameters.test) (revision ed9fb67f4304d4e03ce35df1e9cbe10eb5e0e183) +++ tests/parameters.test (.../parameters.test) (revision 9c636251d106b1728258076165dd19e8af36b2c1) @@ -1888,8 +1888,14 @@ ? [list [self] variable -nocomplain r1:range,arg=1-10 5] "" ? [list [self] attribute -nocomplain [list r2:range,arg=1-10 5]] \ {::enterprise::r2} - - # more tests, e.g. incremental + + # testing incremental + ? [list [self] variable -incremental -nocomplain i:int,0..* {}] "::enterprise::i" + :i add 1 + ? [list [self] i] "1" + :i add 2 + ? [list [self] i] "2 1" + ? [list [self] i add a] {expected integer but got "a" for parameter "value"} } nx::Class create C {