Index: library/nx/nx.tcl =================================================================== diff -u -rb0d97485503d32672dd3691131ce51bdf3923881 -rb8b81d5258a35f294599bb755a0cc15cf363972b --- library/nx/nx.tcl (.../nx.tcl) (revision b0d97485503d32672dd3691131ce51bdf3923881) +++ library/nx/nx.tcl (.../nx.tcl) (revision b8b81d5258a35f294599bb755a0cc15cf363972b) @@ -186,7 +186,7 @@ # method-modifier for object specific methos :method class-object {what args} { - if {$what in [list "alias" "attribute" "forward" "method" "setter"]} { + if {$what in [list "alias" "attribute" "forward" "method"]} { return [::nsf::dispatch [::nsf::self] ::nsf::classes::nx::Object::$what {*}$args] } if {$what in [list "info"]} { @@ -230,7 +230,7 @@ # method modifier "public" :method public {args} { - set p [lsearch -regexp $args {^(method|alias|attribute|forward|setter)$}] + set p [lsearch -regexp $args {^(method|alias|attribute|forward)$}] if {$p == -1} {error "$args is not a method defining method"} set r [::nsf::dispatch [::nsf::current object] {*}$args] if {$r ne ""} {::nsf::methodproperty [::nsf::self] $r call-protected false} @@ -239,7 +239,7 @@ # method modifier "protected" :method protected {args} { - set p [lsearch -regexp $args {^(method|alias|attribute|forward|setter)$}] + set p [lsearch -regexp $args {^(method|alias|attribute|forward)$}] if {$p == -1} {error "$args is not a method defining command"} set r [{*}:$args] if {$r ne ""} {::nsf::methodproperty [::nsf::self] $r call-protected true} @@ -355,23 +355,6 @@ return $r } - # Add setter methods. - # - Object public method setter {parameter} { - set o [::nsf::self] - set r [::nsf::setter $o -per-object $parameter] - ::nsf::methodproperty $o -per-object $r call-protected \ - [::nsf::dispatch $o __default_attribute_call_protection] - return $r - } - Class public method setter {parameter} { - set o [::nsf::self] - set r [::nsf::setter $o $parameter] - ::nsf::methodproperty $o $r call-protected \ - [::nsf::dispatch $o __default_attribute_call_protection] - return $r - } - # Add method "require" # Object method require {what args} { @@ -808,8 +791,10 @@ #puts stderr "Do not register forwarder ${:domain} ${:name}" return } - #puts stderr "Slot [::nsf::self] init, forwarder on ${:domain}" - ::nsf::forward ${:domain} ${:name} \ + #puts stderr "ObjectParameterSlot [::nsf::self] init, forwarder on ${:domain} <$args> ${:per-object}" + ::nsf::forward ${:domain} \ + {*}[expr {${:per-object} ? "-per-object" : ""}] \ + ${:name} \ ${:manager} \ [list %1 [${:manager} defaultmethods]] %self \ ${:methodname} @@ -1248,8 +1233,8 @@ ############################################ # Define method "attribute" for convenience ############################################ - Class method attribute {spec {-slotclass ::nx::Attribute} {initblock ""}} { - set r [$slotclass createFromParameterSyntax [::nsf::self] -initblock $initblock {*}$spec] + Class method attribute {spec {-class ::nx::Attribute} {initblock ""}} { + set r [$class createFromParameterSyntax [::nsf::self] -initblock $initblock {*}$spec] if {$r ne ""} { set o [::nsf::self] ::nsf::methodproperty $o $r call-protected \ @@ -1258,8 +1243,8 @@ } } - Object method attribute {spec {-slotclass ::nx::Attribute} {initblock ""}} { - set r [$slotclass createFromParameterSyntax [::nsf::self] -per-object -initblock $initblock {*}$spec] + Object method attribute {spec {-class ::nx::Attribute} {initblock ""}} { + set r [$class createFromParameterSyntax [::nsf::self] -per-object -initblock $initblock {*}$spec] if {$r ne ""} { set o [::nsf::self] ::nsf::methodproperty $o -per-object $r call-protected \ Index: tests/info-method.test =================================================================== diff -u -rb0d97485503d32672dd3691131ce51bdf3923881 -rb8b81d5258a35f294599bb755a0cc15cf363972b --- tests/info-method.test (.../info-method.test) (revision b0d97485503d32672dd3691131ce51bdf3923881) +++ tests/info-method.test (.../info-method.test) (revision b8b81d5258a35f294599bb755a0cc15cf363972b) @@ -17,8 +17,8 @@ :class-object forward add1 expr 1 + :class-object forward fpo ::o - :setter s - :class-object setter spo + :attribute s + :class-object attribute spo :alias a ::set :class-object alias apo ::puts @@ -68,8 +68,8 @@ ? {::nx::Object info lookup methods -source application} "" ? {::nx::Class info lookup methods -source application} "" - set object_methods "alias attribute class configure contains copy destroy eval filter forward info method mixin move protected public require setter volatile vwait" - set class_methods "alias alloc attribute attributes class class-object configure contains copy create dealloc destroy eval filter forward info method mixin move new protected public require setter superclass volatile vwait" + set object_methods "alias attribute class configure contains copy destroy eval filter forward info method mixin move protected public require volatile vwait" + set class_methods "alias alloc attribute attributes class class-object configure contains copy create dealloc destroy eval filter forward info method mixin move new protected public require superclass volatile vwait" ? {lsort [::nx::Object info lookup methods -source baseclasses]} $class_methods ? {lsort [::nx::Class info lookup methods -source baseclasses]} $class_methods @@ -141,7 +141,7 @@ ? {o method foo {} {return o.foo}} "::o::foo" ? {o alias is ::nsf::is} "::o::is" - ? {o setter x} "::o::x" + ? {o attribute x} "::o::x" ? {lsort [o info methods]} "foo is x" ? {o attribute A} ::o::A Index: tests/method-modifiers.test =================================================================== diff -u -rfc4e3f5f6a94ef7324baffab90d58cd7eb513907 -rb8b81d5258a35f294599bb755a0cc15cf363972b --- tests/method-modifiers.test (.../method-modifiers.test) (revision fc4e3f5f6a94ef7324baffab90d58cd7eb513907) +++ tests/method-modifiers.test (.../method-modifiers.test) (revision b8b81d5258a35f294599bb755a0cc15cf363972b) @@ -17,25 +17,25 @@ :protected forward protected_forward %self protected_method # setter - :setter plain_setter - :public setter public_setter - :protected setter protected_setter + :attribute plain_setter + :public attribute public_setter + :protected attribute protected_setter # alias :alias plain_alias [C info method handle plain_method] :public alias public_alias [C info method handle public_method] :protected alias protected_alias [C info method handle protected_method] - # object + # class-object :class-object method plain_object_method {} {return [current method]} :public class-object method public_object_method {} {return [current method]} :protected class-object method protected_object_method {} {return [current method]} :class-object forward plain_object_forward %self plain_object_method :public class-object forward public_object_forward %self public_object_method :protected class-object forward protected_object_forward %self protected_object_method - :class-object setter plain_object_setter - :public class-object setter public_object_setter - :protected class-object setter protected_object_setter + :class-object attribute plain_object_setter + :public class-object attribute public_object_setter + :protected class-object attribute protected_object_setter :class-object alias plain_object_alias [:class-object info method handle plain_object_method] :public class-object alias public_object_alias [:class-object info method handle public_object_method] :protected class-object alias protected_object_alias [:class-object info method handle protected_object_method] @@ -52,20 +52,20 @@ :protected forward protected_object_forward %self protected_object_method # setter - :setter plain_object_setter - :public setter public_object_setter - :protected setter protected_object_setter + :attribute plain_object_setter + :public attribute public_object_setter + :protected attribute protected_object_setter # alias :alias plain_object_alias [:info method handle plain_object_method] :public alias public_object_alias [:info method handle public_object_method] :protected alias protected_object_alias [:info method handle protected_object_method] } -C public setter s0 -C protected setter s1 +C public attribute s0 +C protected attribute s1 ? {c1 s0 0} 0 ? {::nsf::dispatch c1 s1 1} 1 -C class-object setter s3 +C class-object attribute s3 ? {C s3 3} 3 # create a fresh object (different from c1) @@ -155,11 +155,12 @@ } # object level setter -Test case object-level-setter -? {c1 plain_object_setter 1} "1" -? {c1 public_object_setter 2} "2" -? {catch {c1 protected_object_setter 3}} 1 -? {::nsf::dispatch c1 protected_object_setter 4} "4" +Test case object-level-setter { + ? {c1 plain_object_setter 1} "1" + ? {c1 public_object_setter 2} "2" + ? {catch {c1 protected_object_setter 3}} 1 + ? {::nsf::dispatch c1 protected_object_setter 4} "4" +} # object level alias ....TODO: wanted behavior of [current method]? not "plain_alias"? Test case object-level-alias { @@ -313,3 +314,12 @@ ? {f1 list length} "::f1-length" ? {f1 list reverse} "::f1-reverse" } + +Test case class-object-attribute { + Class create C {:class-object attribute x} + ? {C x 1} 1 + ? {C x} 1 + ? {C info methods} "" + ? {C class-object info methods} x +} + Index: tests/protected.test =================================================================== diff -u -rfc4e3f5f6a94ef7324baffab90d58cd7eb513907 -rb8b81d5258a35f294599bb755a0cc15cf363972b --- tests/protected.test (.../protected.test) (revision fc4e3f5f6a94ef7324baffab90d58cd7eb513907) +++ tests/protected.test (.../protected.test) (revision b8b81d5258a35f294599bb755a0cc15cf363972b) @@ -90,7 +90,7 @@ ? {catch {C forward SET ::set} errorMsg; set errorMsg} \ {Method 'SET' of ::C cannot be overwritten. Derive e.g. a sub-class!} # try to redefine via setter -? {catch {C setter SET} errorMsg; set errorMsg} \ +? {catch {C attribute SET} errorMsg; set errorMsg} \ {Method 'SET' of ::C cannot be overwritten. Derive e.g. a sub-class!} # overwrite-protect object specific method