Index: library/nx/nx.tcl =================================================================== diff -u -ra615b76dd389290567bc8506fec6fa0a3b2c14d2 -rd4bf05d3f89dd055bb5c86cb7f3f82ca2321473c --- library/nx/nx.tcl (.../nx.tcl) (revision a615b76dd389290567bc8506fec6fa0a3b2c14d2) +++ library/nx/nx.tcl (.../nx.tcl) (revision d4bf05d3f89dd055bb5c86cb7f3f82ca2321473c) @@ -1235,7 +1235,7 @@ {per-object false} {methodname} {forwardername} - {defaultmethods {get assign}} + {defaultmethods {}} {accessor public} {incremental:boolean false} {configurable true} @@ -1316,17 +1316,27 @@ } # - # good old default: TODO question in case of nx-relation slot + # Define a forwarder directing accessor calls to the slot # ObjectParameterSlot protected method createForwarder {name domain} { + set dm [${:manager} cget -defaultmethods] ::nsf::method::forward $domain \ -per-object=${:per-object} \ $name \ + -onerror [list ${:manager} onError] \ ${:manager} \ - [list %1 [${:manager} cget -defaultmethods]] %self \ + [expr {$dm ne "" ? [list %1 $dm] : "%1"}] %self \ ${:forwardername} } + ObjectParameterSlot 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 + } + ObjectParameterSlot protected method makeForwarder {} { # # Build forwarder from the source object class ($domain) to the slot @@ -1613,7 +1623,7 @@ if {1} { ::nx::RelationSlot create ::nx::Object::slot::object-mixin \ -multiplicity 0..n \ - -defaultmethods get \ + -defaultmethods {} \ -disposition slotassign \ -settername "object mixin" -forwardername object-mixin -elementtype mixinreg } @@ -1626,7 +1636,7 @@ if {1} { ::nx::RelationSlot create ::nx::Object::slot::object-filter \ -multiplicity 0..n \ - -defaultmethods get \ + -defaultmethods {} \ -disposition slotassign \ -settername "object filter" -forwardername object-filter -elementtype filterreg } @@ -1650,7 +1660,7 @@ if {1} { ::nx::RelationSlot create ::nx::Class::slot::mixin \ -multiplicity 0..n \ - -defaultmethods get \ + -defaultmethods {} \ -disposition slotassign \ -forwardername "class-mixin" -elementtype mixinreg } @@ -1663,7 +1673,7 @@ if {1} { ::nx::RelationSlot create ::nx::Class::slot::filter \ -multiplicity 0..n \ - -defaultmethods get \ + -defaultmethods {} \ -disposition slotassign \ -forwardername class-filter -elementtype filterreg } @@ -1858,29 +1868,9 @@ return 1 } - if {1} { - # - # TODO: remove if - # - ::nx::VariableSlot protected method needsForwarder {} { - return 1 - } - ::nx::VariableSlot protected method createForwarder {name domain} { - ::nsf::method::forward $domain \ - -per-object=${:per-object} \ - $name \ - -onerror [list ${:manager} onError] \ - ${:manager} \ - %1 %self \ - ${:forwardername} - } - ::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 - } + # TODO: check detailed xotcl2 implications + ::nx::VariableSlot protected method needsForwarder {} { + return 1 } ::nx::VariableSlot protected method makeAccessor {} { Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -r91007cd5fdd2f8f125fdd433ef7701574e8167d2 -rd4bf05d3f89dd055bb5c86cb7f3f82ca2321473c --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 91007cd5fdd2f8f125fdd433ef7701574e8167d2) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision d4bf05d3f89dd055bb5c86cb7f3f82ca2321473c) @@ -426,7 +426,7 @@ ::xotcl::Class instproc parameter {arglist} { set slotContainer [::nx::slotObj [::nsf::self]] foreach arg $arglist { - puts stderr "[self] ::nsf::classes::nx::Class::property -accessor public $arg" + puts stderr "PARAMETER: [self] ::nsf::classes::nx::Class::property -accessor public $arg" #[self] ::nsf::classes::nx::Class::property -accessor public $arg if {[llength $arg] > 1} { ::nx::MetaSlot createFromParameterSpec [::nsf::self] [lindex $arg 0] [lindex $arg 1] @@ -457,18 +457,24 @@ set cSlotContainer [::nx::slotObj ::xotcl::Class] set oSlotContainer [::nx::slotObj ::xotcl::Object] - ::nx::RelationSlot create ${cSlotContainer}::superclass + ::nx::RelationSlot create ${cSlotContainer}::superclass \ + -defaultmethods {get assign} #::nsf::method::alias ${cSlotContainer}::superclass assign ::nsf::relation - ::nx::RelationSlot create ${oSlotContainer}::class -elementtype class -multiplicity 1..1 + ::nx::RelationSlot create ${oSlotContainer}::class -elementtype class -multiplicity 1..1 \ + -defaultmethods {get assign} #::nsf::method::alias ${oSlotContainer}::class assign ::nsf::relation ::nx::RelationSlot create ${oSlotContainer}::mixin -forwardername object-mixin \ + -defaultmethods {get assign} \ -elementtype mixinreg -multiplicity 0..n ::nx::RelationSlot create ${oSlotContainer}::filter -forwardername object-filter \ + -defaultmethods {get assign} \ -elementtype filterreg -multiplicity 0..n ::nx::RelationSlot create ${cSlotContainer}::instmixin -forwardername class-mixin \ + -defaultmethods {get assign} \ -elementtype mixinreg -multiplicity 0..n ::nx::RelationSlot create ${cSlotContainer}::instfilter -forwardername class-filter \ - -elementtype filterreg -multiplicity 0..n + -defaultmethods {get assign} \ + -elementtype filterreg -multiplicity 0..n ######################## # Info definition @@ -1011,6 +1017,8 @@ # ::xotcl::MetaSlot create ::xotcl::Attribute -superclass ::nx::VariableSlot { + #:property defaultmethods {get assign} + :property -accessor public multivalued { :public object method assign {object property value} { set mClass [expr {$value ? "0..n" : "1..1"}] @@ -1042,7 +1050,7 @@ -per-object=${:per-object} \ $name \ ${:manager} \ - [list %1 [${:manager} cget -defaultmethods]] %self \ + "%1 {get assign}" %self \ ${:forwardername} } Index: tests/interceptor-slot.test =================================================================== diff -u -ra615b76dd389290567bc8506fec6fa0a3b2c14d2 -rd4bf05d3f89dd055bb5c86cb7f3f82ca2321473c --- tests/interceptor-slot.test (.../interceptor-slot.test) (revision a615b76dd389290567bc8506fec6fa0a3b2c14d2) +++ tests/interceptor-slot.test (.../interceptor-slot.test) (revision d4bf05d3f89dd055bb5c86cb7f3f82ca2321473c) @@ -16,7 +16,7 @@ ? {C info lookup method mixin} "::nsf::classes::nx::Class::mixin" ? {C mixin set M} ::M ? {C info precedence} "::nx::Class ::nx::Object" - ? {C mixin} "::M" + ? {C mixin get} "::M" ? {C info mixin classes} "::M" ? {c1 info precedence} "::M ::C ::nx::Object" ? {C mixin add M2} "::M2 ::M" @@ -118,8 +118,8 @@ ? {C object mixin set M} ::M ? {C info precedence} "::M ::nx::Class ::nx::Object" - # forwarder with 0 arguments + flag - ? {C object mixin} "::M" + # forwarder with get + ? {C object mixin get} "::M" } Index: tests/methods.test =================================================================== diff -u -rc90b4fbe1aca2a6bcff6205d001f6ed83db51a90 -rd4bf05d3f89dd055bb5c86cb7f3f82ca2321473c --- tests/methods.test (.../methods.test) (revision c90b4fbe1aca2a6bcff6205d001f6ed83db51a90) +++ tests/methods.test (.../methods.test) (revision d4bf05d3f89dd055bb5c86cb7f3f82ca2321473c) @@ -235,8 +235,8 @@ ? {lsort [C object mixin get]} "::M2 ::M4" ? {lsort [C mixin get]} "::M1 ::M3" - ? {lsort [C object mixin]} "::M2 ::M4" - ? {lsort [C mixin]} "::M1 ::M3" + ? {lsort [C object mixin]} {wrong # args: use "::C mixin assign|get"} ;# TODO: should be "C object mixin ..." + ? {lsort [C mixin]} {wrong # args: use "::C mixin assign|get"} ? {catch {C mixin M5} errorMsg} 1 ? {lsort [C info mixin classes]} "::M1 ::M3" Index: tests/mixinof.test =================================================================== diff -u -r12319faaf20df7116346558bd948b0edda9124eb -rd4bf05d3f89dd055bb5c86cb7f3f82ca2321473c --- tests/mixinof.test (.../mixinof.test) (revision 12319faaf20df7116346558bd948b0edda9124eb) +++ tests/mixinof.test (.../mixinof.test) (revision d4bf05d3f89dd055bb5c86cb7f3f82ca2321473c) @@ -10,7 +10,7 @@ ########################################### nx::Class create A nx::Object create o -object-mixin A -? {o object mixin} ::A +? {o object mixin get} ::A ? {o info object mixin classes} ::A ? {A info mixinof} ::o @@ -77,7 +77,7 @@ nx::Class create C -superclass B C create c1 -? {B mixin} ::A +? {B mixin get} ::A ? {B info mixin classes} ::A ? {A info mixinof} ::B ? {c1 info precedence} "::A ::C ::B ::nx::Object" @@ -129,7 +129,7 @@ B create b1 C create c1 -? {B mixin} ::A +? {B mixin get} ::A ? {B info mixin classes} ::A ? {A info mixinof -scope class} ::B ? {a1 info precedence} "::M ::A ::nx::Object" @@ -224,7 +224,7 @@ B create b1 C create c1 -? {B mixin} ::A +? {B mixin get} ::A ? {B info mixin classes} ::A ? {A info mixinof -scope class} ::B ? {a1 info precedence} "::M ::A ::nx::Object" @@ -258,7 +258,7 @@ B create b1 C create c1 -? {B mixin} ::A +? {B mixin get} ::A ? {B info mixin classes} ::A ? {A info mixinof -scope class} ::B ? {a1 info precedence} "::M ::A ::nx::Object" @@ -287,7 +287,7 @@ nx::Class create C -superclass B C create c1 - ? {B mixin} ::A + ? {B mixin get} ::A ? {B info mixin classes} ::A ? {A info mixinof -scope class} ::B ? {c1 info precedence} "::A ::C ::B ::nx::Object" @@ -302,7 +302,7 @@ ? {C info superclass -closure} "::nx::Object" ? {B info heritage} "::A ::nx::Object" ? {C info heritage} "::nx::Object" - ? {B mixin} ::A + ? {B mixin get} ::A ? {B info mixin classes} ::A ? {A info mixinof} ::B ? {c1 info precedence} "::C ::nx::Object" @@ -324,7 +324,7 @@ nx::Class create C -superclass B C create c1 - ? {B mixin} ::A + ? {B mixin get} ::A ? {B info mixin classes} ::A ? {A info mixinof -scope class} ::B ? {c1 info precedence} "::A ::C ::B ::nx::Object" @@ -490,7 +490,7 @@ nx::Class create C2 -mixin A C2 create c22 - ? {c1 object mixin} ::A + ? {c1 object mixin get} ::A ? {c1 info object mixin classes} ::A ? {lsort [A info mixinof]} "::C2 ::c1" ? {M info mixinof} ""