1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
|
# -*- Tcl -*-
package prefer latest
package req nx::test
package req msgcat
::msgcat::mcset [::msgcat::mclocale] m1 [set ::msg1 "[namespace current] message1"]
namespace eval ::foo {
::msgcat::mcset [::msgcat::mclocale] m1 [set ::msg2 "[namespace current] message2"]
}
namespace eval ::foo::bar {
::msgcat::mcset [::msgcat::mclocale] m1 [set ::msg3 "[namespace current] message3"]
}
namespace import ::msgcat::mc
nx::Class create C {
:require namespace
? [list set _ [mc m1]] $::msg1
:public method foo {} {
return [mc m1]
}
:public object method bar {} {
return [mc m1]
}
:property baz {
:public object method value=get {args} {
return [namespace current]-[mc m1]
}
}
}
? {[::C new] foo} $::msg1
? {::C bar} $::msg1
? {[::C new] cget -baz} "::C::slot-$::msg1"
namespace eval ::foo {
nx::Class create C {
:require namespace
? [list set _ [mc m1]] $::msg2
:public method foo {} {
return [mc m1]
}
:public object method bar {} {
return [mc m1]
}
:property baz {
:public object method value=get {args} {
return [namespace current]-[mc m1]
}
}
}
? {[::foo::C new] foo} $::msg2
? {::foo::C bar} $::msg2
? {[::foo::C new] cget -baz} "::foo::C::slot-$::msg2"
}
namespace eval ::foo::bar {
nx::Class create C {
:require namespace
? [list set _ [mc m1]] $::msg3
:public method foo {} {
return [mc m1]
}
:public object method bar {} {
return [mc m1]
}
:property baz {
:public object method value=get {args} {
return [namespace current]-[mc m1]
}
}
:property -accessor public baf {
:public object method value=set {obj prop value} {
::msgcat::mcset [::msgcat::mclocale] $value [set ::msg4 "[namespace current] message4"]
next
}
:public object method value=get {args} {
mc [next]
}
}
:create ::c
}
? {[::foo::bar::C new] foo} $::msg3
? {::foo::bar::C bar} $::msg3
? {[::foo::bar::C new] cget -baz} "::foo::bar::C::slot-$::msg3"
::c baf set m1
? {::c baf get} $::msg4
}
#
# Local variables:
# mode: tcl
# tcl-indent-level: 2
# indent-tabs-mode: nil
# End:
#
|