Index: library/nx/nx.tcl =================================================================== diff -u -r12319faaf20df7116346558bd948b0edda9124eb -r91007cd5fdd2f8f125fdd433ef7701574e8167d2 --- library/nx/nx.tcl (.../nx.tcl) (revision 12319faaf20df7116346558bd948b0edda9124eb) +++ library/nx/nx.tcl (.../nx.tcl) (revision 91007cd5fdd2f8f125fdd433ef7701574e8167d2) @@ -762,7 +762,7 @@ :alias "info precedence" ::nsf::methods::object::info::precedence :alias "info vars" ::nsf::methods::object::info::vars :method "info variable definition" {handle} {return [$handle definition]} - :method "info variable name" {handle} {return [$handle name]} + :method "info variable name" {handle} {return [$handle cget -name]} :method "info variable parameter" {handle} {return [$handle parameter]} } @@ -1130,8 +1130,15 @@ # # register the standard setter # - ::nsf::method::setter $class $att + #::nsf::method::setter $class $att + # + # make setter protected + # + #regexp {^([^:]+):} $att . att + #::nsf::method::property $class $att call-protected true + + # # set for every bootstrap property slot the position 0 # ::nsf::var::set $slotObj position 0 @@ -1142,7 +1149,7 @@ ::nsf::parameter:invalidate::classcache $class } - ObjectParameterSlot public method namedParameterSpec {-map-private:switch prefix name options} { + ObjectParameterSlot protected method namedParameterSpec {-map-private:switch prefix name options} { # # Build a pos/nonpos parameter specification from name and option list # @@ -1206,15 +1213,16 @@ # Define method "value" as a slot forwarder to allow for calling # value-less slot methods like e.g. "get" dispite of the arity-based # forward dispatcher. - ::nx::Slot public method value {obj method prop value:optional pos:optional} { - if {[info exists pos]} { - ${:manager} $prop $obj ${:name} $value $pos - } elseif {[info exists value]} { - ${:manager} $prop $obj ${:name} $value - } else { - ${:manager} $prop $obj ${:name} - } - } + # ::nx::Slot public method value {obj method prop value:optional pos:optional} { + # if {[info exists pos]} { + # ${:manager} $prop $obj ${:name} $value $pos + # } elseif {[info exists value]} { + # ${:manager} $prop $obj ${:name} $value + # } else { + # ${:manager} $prop $obj ${:name} + # } + # } + # TODO REMOVEME ###################################################################### # configure nx::ObjectParameterSlot @@ -1315,7 +1323,7 @@ -per-object=${:per-object} \ $name \ ${:manager} \ - [list %1 [${:manager} defaultmethods]] %self \ + [list %1 [${:manager} cget -defaultmethods]] %self \ ${:forwardername} } @@ -1850,13 +1858,14 @@ } ::nx::VariableSlot public method onError {cmd msg} { if {[string match "%1 requires argument*" $msg]} { + #return -code error "wrong # args: use \"$cmd assign|get\" [lsort [:info lookup methods -callprotection public -source application]]" return -code error "wrong # args: use \"$cmd assign|get\"" } return -code error $msg } } - ::nx::VariableSlot public method makeAccessor {} { + ::nx::VariableSlot protected method makeAccessor {} { if {${:accessor} eq "none"} { #puts stderr "*** Do not register forwarder ${:domain} ${:name}" @@ -1895,7 +1904,6 @@ } :makeAccessor if {${:per-object} && [info exists :default]} { - puts stderr "reconfigure calls setCheckedInstVar" :setCheckedInstVar -nocomplain=[info exists :nocomplain] ${:domain} ${:default} } if {[::nsf::is class ${:domain}]} { @@ -1905,7 +1913,7 @@ ::nx::VariableSlot public method parameter {} { # This is a shortend "lightweight" version of "getParameterSpec" - # returning less (implicit) details. + # returning less (implicit) details. used e.g. by "info variable parameter" set options [:getParameterOptions -withMultiplicity true] set spec [:namedParameterSpec -map-private "" ${:name} $options] if {[info exists :default]} {lappend spec ${:default}} @@ -2178,9 +2186,9 @@ } if {[$slot eval {info exists :settername}]} { - set name [$slot settername] + set name [$slot cget -settername] } else { - set name [$slot name] + set name [$slot cget -name] } return [::nsf::directdispatch [self] ::nsf::methods::object::info::method registrationhandle $name] @@ -2230,9 +2238,9 @@ $spec \ {*}[expr {[info exists defaultValue] ? [list $defaultValue] : ""}]] if {[$slot eval {info exists :settername}]} { - set name [$slot settername] + set name [$slot cget -settername] } else { - set name [$slot name] + set name [$slot cget -name] } #puts stderr handle=[::nsf::directdispatch [self] ::nsf::methods::class::info::method registrationhandle $name] return [::nsf::directdispatch [self] ::nsf::methods::class::info::method registrationhandle $name] @@ -2280,8 +2288,8 @@ # content and not to produce a warning when it might look like a # non-positional parameter. ###################################################################### - ::nx::Slot method type=any {name value} { - } + ::nx::Slot method type=any {name value} { } + ::nsf::method::property ::nx::Slot type=any call-protected true ###################################################################### # Now the slots are defined; now we can defines the Objects or @@ -2585,10 +2593,10 @@ #puts stderr "replacing domain and manager from <$origin> to <$dest> in slots <$slots>" foreach oldslot $slots { - set container [expr {[$oldslot per-object] ? "per-object-slot" : "slot"}] + set container [expr {[$oldslot cget -per-object] ? "per-object-slot" : "slot"}] set newslot [::nx::slotObj -container $container $dest [namespace tail $oldslot]] - if {[$oldslot domain] eq $origin} {$newslot domain $dest} - if {[$oldslot manager] eq $oldslot} {$newslot manager $newslot} + if {[$oldslot cget -domain] eq $origin} {$newslot configure -domain $dest} + if {[$oldslot cget -manager] eq $oldslot} {$newslot configure -manager $newslot} $newslot eval :init } } Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -r85ee1fdb043ed3f82fd272cc004c476c40861fdb -r91007cd5fdd2f8f125fdd433ef7701574e8167d2 --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 85ee1fdb043ed3f82fd272cc004c476c40861fdb) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 91007cd5fdd2f8f125fdd433ef7701574e8167d2) @@ -1014,8 +1014,7 @@ :property -accessor public multivalued { :public object method assign {object property value} { set mClass [expr {$value ? "0..n" : "1..1"}] - $object incremental $value - $object multiplicity $mClass + $object configure -incremental $value -multiplicity $mClass } :public object method get {object property} { return [$object eval [list :isMultivalued]] @@ -1043,7 +1042,7 @@ -per-object=${:per-object} \ $name \ ${:manager} \ - [list %1 [${:manager} defaultmethods]] %self \ + [list %1 [${:manager} cget -defaultmethods]] %self \ ${:forwardername} } Index: library/xotcl/tests/slottest.xotcl =================================================================== diff -u -racc540eae81024718461724ce69e7971fa9ddfa9 -r91007cd5fdd2f8f125fdd433ef7701574e8167d2 --- library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision acc540eae81024718461724ce69e7971fa9ddfa9) +++ library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 91007cd5fdd2f8f125fdd433ef7701574e8167d2) @@ -132,7 +132,8 @@ } ? {O superclass slot self} "::xotcl::Class::slot::superclass" -? {O superclass slot domain} "::xotcl::Class" +#? {O superclass slot domain} "::xotcl::Class" +? {::xotcl::Class::slot::superclass cget -domain} "::xotcl::Class" ? {O2 superclass} "::O" O2 superclass add M @@ -210,8 +211,8 @@ } puts [Person serialize] -Person::slot::name default "gustaf" -? {Person::slot::name default} gustaf +Person::slot::name configure -default "gustaf" +? {Person::slot::name cget -default} gustaf Person p1 -name neophytos ? {p1 name} neophytos ? {p1 age} 0 Index: tests/parameters.test =================================================================== diff -u -r12319faaf20df7116346558bd948b0edda9124eb -r91007cd5fdd2f8f125fdd433ef7701574e8167d2 --- tests/parameters.test (.../parameters.test) (revision 12319faaf20df7116346558bd948b0edda9124eb) +++ tests/parameters.test (.../parameters.test) (revision 91007cd5fdd2f8f125fdd433ef7701574e8167d2) @@ -1057,10 +1057,12 @@ # slot object # ParamTest eval { - :property -accessor public os { - :type object - :multiplicity 1..n - } + #:property -accessor public os { + # :type object + # :multiplicity 1..n + #} + :property -accessor public os:object,1..n + } ? {ParamTest info method definition os} "::ParamTest public forward os ::ParamTest::slot::os %1 %self os" @@ -1170,9 +1172,19 @@ nx::test case slot-specfic-converter { nx::Class create Person { - :property -accessor public sex { - :type "sex" - :convert true + # :property -accessor public sex { + # :type "sex" + # :convert true + # :object method type=sex {name value} { + # #puts stderr "[self] slot specific converter" + # switch -glob $value { + # m* {return m} + # f* {return f} + # default {error "expected sex but got $value"} + # } + # } + # } + :property -accessor public sex:sex,convert { :object method type=sex {name value} { #puts stderr "[self] slot specific converter" switch -glob $value { @@ -1182,6 +1194,7 @@ } } } + } Person create p1 -sex male @@ -1193,7 +1206,7 @@ } ####################################################### -# test for setters with parameters +# test for setters with parameters os ####################################################### nx::test case setters { nx::Object create o @@ -2141,7 +2154,7 @@ ? {o cget -a} newvalue o eval {unset :a} ? {o eval {info exists :a}} 0 - [o info object slots a] default anothervalue + [o info object slots a] configure -default anothervalue ? {o eval {info exists :a}} 0 # # re-assignment must be requested by a reconfigure call Index: tests/properties.test =================================================================== diff -u -r85ee1fdb043ed3f82fd272cc004c476c40861fdb -r91007cd5fdd2f8f125fdd433ef7701574e8167d2 --- tests/properties.test (.../properties.test) (revision 85ee1fdb043ed3f82fd272cc004c476c40861fdb) +++ tests/properties.test (.../properties.test) (revision 91007cd5fdd2f8f125fdd433ef7701574e8167d2) @@ -160,9 +160,12 @@ # cases) # + set unknowns "valid are: {assign definition destroy get getParameterSpec getPropertyDefinitionOptions onError parameter reconfigure setCheckedInstVar}" ? {c1 b add x} {property b of ::C ist not multivalued} + #? {c1 b add x} "method 'add' unknown for slot ::C::slot::b; $unknowns" ? {c1 c add x} {::c1: unable to dispatch method 'c'} ? {c1 eval {:c add x}} {property c of ::C ist not multivalued} + #? {c1 eval {:c add x}} "method 'add' unknown for slot ::C::slot::c; $unknowns" ? {c1 d add x} {::c1: unable to dispatch method 'd'} ? {c1 eval {:d add x}} {::c1: unable to dispatch method 'd'} ? {c1 e add x} {::c1: unable to dispatch method 'e'} @@ -174,8 +177,10 @@ ? {c1 va add x} {::c1: unable to dispatch method 'va'} ? {c1 vb add x} {property vb of ::C ist not multivalued} + #? {c1 vb add x} "method 'add' unknown for slot ::C::slot::vb; $unknowns" ? {c1 vc add x} {::c1: unable to dispatch method 'vc'} ? {c1 eval {:vc add x}} {property vc of ::C ist not multivalued} + #? {c1 eval {:vc add x}} "method 'add' unknown for slot ::C::slot::vc; $unknowns" ? {c1 vd add x} {::c1: unable to dispatch method 'vd'} ? {c1 eval {:vd add x}} {::c1: unable to dispatch method 'vd'} ? {c1 ve add x} {::c1: unable to dispatch method 've'} @@ -678,22 +683,22 @@ # Tests for experimental "value add", "value assign" ... # -nx::test case property-value-incremental { +# nx::test case property-value-incremental { - nx::Object create o1 { - :object property -incremental {a a1} - } +# nx::Object create o1 { +# :object property -incremental {a a1} +# } - ? {o1 a add x} {x a1} - ? {o1 a assign {a1}} {a1} +# ? {o1 a add x} {x a1} +# ? {o1 a assign {a1}} {a1} - nsf::configure debug 2 - ? {o1 a value add x } {x a1} - ? {o1 a value assign {a b c}} {a b c} - ? {o1 a value get } {a b c} - ? {o1 a value add x } {x a b c} - ? {o1 a value add z end} {x a b c z} -} +# nsf::configure debug 2 +# ? {o1 a value add x } {x a1} +# ? {o1 a value assign {a b c}} {a b c} +# ? {o1 a value get } {a b c} +# ? {o1 a value add x } {x a b c} +# ? {o1 a value add z end} {x a b c z} +# } # # Test interactions between multiplicity and incremental Index: tests/serialize.test =================================================================== diff -u -racc540eae81024718461724ce69e7971fa9ddfa9 -r91007cd5fdd2f8f125fdd433ef7701574e8167d2 --- tests/serialize.test (.../serialize.test) (revision acc540eae81024718461724ce69e7971fa9ddfa9) +++ tests/serialize.test (.../serialize.test) (revision 91007cd5fdd2f8f125fdd433ef7701574e8167d2) @@ -78,11 +78,10 @@ set c1(One) [list [::Serializer deepSerialize -ignoreVarsRE "a" c1] "b"] set c1(One2) [list [::Serializer deepSerialize -ignoreVarsRE {::a$} c1] "b"] set c1(IgnoreAll) [list [::Serializer deepSerialize -ignoreVarsRE "." c1] ""] - set names {}; foreach s [C info slots] {lappend names [$s name]} + set names {}; foreach s [C info slots] {lappend names [$s cget -name]} set c1(None2) [list [::Serializer deepSerialize -ignoreVarsRE [join $names |] c1] ""] c1 destroy -puts stderr ====1 foreach t [array names c1] { ? {nsf::object::exists c1} 0 lassign $c1($t) script res @@ -98,7 +97,7 @@ #set C(One) [list [::Serializer deepSerialize -ignoreVarsRE "x" C] "y"] set C(One2) [list [::Serializer deepSerialize -ignoreVarsRE {::x$} C] "y"] #set C(IgnoreAll) [list [::Serializer deepSerialize -ignoreVarsRE "." C] ""] - set names {}; foreach s [C info object slots] {lappend names [$s name]} + set names {}; foreach s [C info object slots] {lappend names [$s cget -name]} #set C(None2) [list [::Serializer deepSerialize -ignoreVarsRE [join $names |] C] ""] C destroy