Index: TODO =================================================================== diff -u -r7d3bc964348a674a9d80ab8751f1f827dbd6b7b9 -rcb838e0d7ecf616891cc1f5089750208913d8503 --- TODO (.../TODO) (revision 7d3bc964348a674a9d80ab8751f1f827dbd6b7b9) +++ TODO (.../TODO) (revision cb838e0d7ecf616891cc1f5089750208913d8503) @@ -3399,7 +3399,9 @@ * removed "-local", "-system" and "-intrinsic" from plain dispatch (like e.g. "o1 -system method") * removed flag "-local" from nsf::object::dispatch + * made nsf::my and nsf::object::dispatch available in the nx namespace + TODO: - fix interp.test for tcl 8.6 - fix xocomm.test for tcl 8.6 @@ -3408,7 +3410,6 @@ * needed fails since method %s.%s is private ? * maybe let private imply protected * make sure nsf::dispatch works sufficiently similar to plain dispatch - * make nsf::my and nsf::object::dispatch available in the nx namespace * document private in migration guide tutorial - nx: Index: generic/nsf.tcl =================================================================== diff -u -r40c99702db40bd86761bfea1f1209cc761e61e62 -rcb838e0d7ecf616891cc1f5089750208913d8503 --- generic/nsf.tcl (.../nsf.tcl) (revision 40c99702db40bd86761bfea1f1209cc761e61e62) +++ generic/nsf.tcl (.../nsf.tcl) (revision cb838e0d7ecf616891cc1f5089750208913d8503) @@ -4,14 +4,11 @@ # # Symbols reused in the next scripting language - - namespace export next current self - - # Symbols reused in XOTcl - namespace eval ::nsf::method::create { - namespace export alias - } - namespace export configure finalize interp is my relation + namespace export \ + next current self configure finalize interp is my relation + + namespace eval ::nsf::object {namespace export dispatch} + namespace eval ::nsf::method::create {namespace export alias} # # support for method provide and method require Index: generic/predefined.h =================================================================== diff -u -rc6057c18970d5bc19fe0f1f760ef0d29898ecfdd -rcb838e0d7ecf616891cc1f5089750208913d8503 --- generic/predefined.h (.../predefined.h) (revision c6057c18970d5bc19fe0f1f760ef0d29898ecfdd) +++ generic/predefined.h (.../predefined.h) (revision cb838e0d7ecf616891cc1f5089750208913d8503) @@ -1,9 +1,9 @@ static char cmd[] = "namespace eval ::nsf {\n" -"namespace export next current self\n" -"namespace eval ::nsf::method::create {\n" -"namespace export alias}\n" -"namespace export configure finalize interp is my relation\n" +"namespace export \\\n" +"next current self configure finalize interp is my relation\n" +"namespace eval ::nsf::object {namespace export dispatch}\n" +"namespace eval ::nsf::method::create {namespace export alias}\n" "proc ::nsf::method::provide {require_name definition {script \"\"}} {\n" "set ::nsf::methodIndex($require_name) [list definition $definition script $script]}\n" "proc ::nsf::method::require {object name {per_object 0}} {\n" Index: library/nx/nx.tcl =================================================================== diff -u -r3e0565bde9f6f02b2145aecc8c1756c28d8ae507 -rcb838e0d7ecf616891cc1f5089750208913d8503 --- library/nx/nx.tcl (.../nx.tcl) (revision 3e0565bde9f6f02b2145aecc8c1756c28d8ae507) +++ library/nx/nx.tcl (.../nx.tcl) (revision cb838e0d7ecf616891cc1f5089750208913d8503) @@ -3,6 +3,8 @@ namespace eval ::nx { namespace eval ::nsf {}; # make pkg indexer happy + namespace eval ::nsf::object {}; # make pkg indexer happy + # # By setting the variable bootstrap, we can check later, whether we # are in bootstrapping mode @@ -33,7 +35,8 @@ # # get frequenly used primitiva from the next scripting framework # - namespace import ::nsf::next ::nsf::current ::nsf::self + namespace export next current self configure finalize interp is my relation + namespace import ::nsf::next ::nsf::current ::nsf::self ::nsf::my ::nsf::object::dispatch # # provide the standard command set for ::nx::Object Index: tests/protected.test =================================================================== diff -u -r7d3bc964348a674a9d80ab8751f1f827dbd6b7b9 -rcb838e0d7ecf616891cc1f5089750208913d8503 --- tests/protected.test (.../protected.test) (revision 7d3bc964348a674a9d80ab8751f1f827dbd6b7b9) +++ tests/protected.test (.../protected.test) (revision cb838e0d7ecf616891cc1f5089750208913d8503) @@ -27,7 +27,7 @@ ::nsf::method::property C SET call-protected true ? {c1 SET x 1} {::c1: unable to dispatch method 'SET'} - ? {::nsf::object::dispatch c1 SET x 2} {2} "dispatch of protected methods works" + ? {nx::dispatch c1 SET x 2} {2} "dispatch of protected methods works" ? {c1 foo} {foo} ? {c1 bar} {bar} ? {c1 bar-SET} {1} @@ -37,7 +37,7 @@ ::nsf::method::property C foo call-protected true ? {c1 SET x 1} {::c1: unable to dispatch method 'SET'} - ? {::nsf::object::dispatch c1 SET x 2} {2} "dispatch of protected methods works" + ? {nx::dispatch c1 SET x 2} {2} "dispatch of protected methods works" ? {c1 bar} {bar} "other method work" ? {c1 foo} {::c1: unable to dispatch method 'foo'} ? {c1 bar-SET} {1} "internal call of protected C implementend method" @@ -54,7 +54,7 @@ ? {::nsf::method::property C foo call-protected} 0 ? {c1 SET x 3} 3 - ? {::nsf::object::dispatch c1 SET x 2} {2} + ? {nx::dispatch c1 SET x 2} {2} ? {c1 foo} {foo} ? {c1 bar} {bar} ? {c1 bar-SET} {1} @@ -67,7 +67,7 @@ ? {::nsf::method::property C SET call-protected} 0 ? {c1 SET x 3} 3 - ? {::nsf::object::dispatch c1 SET x 4} {4} + ? {nx::dispatch c1 SET x 4} {4} ? {c1 foo} {::c1: unable to dispatch method 'foo'} ? {c1 bar} {bar} ? {c1 bar-SET} {1} @@ -183,8 +183,8 @@ # methods are defined as private to avoid interference. # nx::Class create M { - :public method foo {} {nsf::my -local bar} - :private method bar {} {nsf::my -local baz} + :public method foo {} {my -local bar} + :private method bar {} {my -local baz} :private method baz {} {return "M.baz"} } @@ -214,17 +214,17 @@ :public method bar {} {return "B.bar [next]"} :public method baz {} {return "B.baz [next]"} :create b1 { - :public method foo {} {nsf::my -local bar} - :private method bar {} {nsf::my -local baz} + :public method foo {} {my -local bar} + :private method bar {} {my -local baz} :private method baz {} {return "b1.baz"} } } nx::Class create C -superclass B { :public method bar {} {return "C.bar [next]"} :public method baz {} {return "C.baz [next]"} :create c1 { - :public method foo {} {nsf::my -local bar} - :private method bar {} {nsf::my -local baz} + :public method foo {} {my -local bar} + :private method bar {} {my -local baz} :private method baz {} {return "c1.baz"} } } @@ -265,7 +265,7 @@ nx::Test case local+filter { nx::Class create C { :method f1 args { return "f1 [next]" } - :public method foo {} { return "C.foo [nsf::my -local bar]"} + :public method foo {} { return "C.foo [my -local bar]"} :private method bar {} { return "bar"} :public method baz {} { return "C.baz [next]"} } @@ -354,8 +354,8 @@ # add on B calls to local C eval { - :public method q1 {} {nsf::my -local p1} - :public method q3 {} {nsf::my -local p3} + :public method q1 {} {my -local p1} + :public method q3 {} {my -local p3} } # all chains start with C, since local resolve works ? {c1 q1} "C.p1 " @@ -368,35 +368,32 @@ # calls via method handles allows us to dispatch private methods, # results like "-local" resolves above - ? {nsf::object::dispatch c1 [C info method handle p1]} "C.p1 " - ? {nsf::object::dispatch c1 [C info method handle p3]} "C.p3 B.p3" + ? {nx::dispatch c1 [C info method handle p1]} "C.p1 " + ? {nx::dispatch c1 [C info method handle p3]} "C.p3 B.p3" # we can't call the private method via dispatch, since the private # methods are removed from the search for methods - ? {nsf::object::dispatch c1 p1} "::c1: unable to dispatch method 'p1'" - ? {nsf::object::dispatch c1 p3} "B.p3" + ? {nx::dispatch c1 p1} "::c1: unable to dispatch method 'p1'" + ? {nx::dispatch c1 p3} "B.p3" # via dispatch, the local flag uses (as always) the context of the # currently execting class, which is not provided below - ? {nsf::object::dispatch c1 -local p1} "::c1: unable to dispatch method 'p1'" - + ? {nx::dispatch c1 -local p1} "::c1: unable to dispatch method 'p1'" } - - # -# test "nsf::my -local" on classes +# test "my -local" on classes # nx::Test case class-my-local { nx::Class create Base { :private method baz {a b} { expr {$a + $b} } - :public method foo {a b} { nsf::my -local baz $a $b } + :public method foo {a b} { my -local baz $a $b } } nx::Class create Sub -superclass Base { - :public method bar {a b} { nsf::my -local baz $a $b } + :public method bar {a b} { my -local baz $a $b } :private method baz {a b} { expr {$a * $b} } :create s1 @@ -408,7 +405,7 @@ } # -# test "nsf::my -local" on objects +# test "my -local" on objects # nx::Test case object-my-local { nx::Class create M { @@ -418,7 +415,7 @@ nx::Object create o1 { :protected method foo {} {return o1} :public method foo2 {} {:foo} - :public method bar {} {nsf::my -local foo} + :public method bar {} {my -local foo} } ? {o1 foo} {::o1: unable to dispatch method 'foo'} @@ -434,17 +431,17 @@ } # -# test nsf::my + path instead of "nsf::my -local" on classes +# test "my" + path instead of "my -local" on classes # nx::Test case my+handle-instead-of-my-local { nx::Class create Base { :private method privateMethod {a b} { expr {$a + $b} } - :public method foo {a b} { nsf::my [Base info method handle privateMethod] $a $b } + :public method foo {a b} { my [Base info method handle privateMethod] $a $b } } nx::Class create Sub -superclass Base { - :public method bar {a b} { nsf::my [Sub info method handle privateMethod] $a $b } + :public method bar {a b} { my [Sub info method handle privateMethod] $a $b } :private method privateMethod {a b} { expr {$a * $b} } :create s1 @@ -455,17 +452,17 @@ } # -# test object::dispatch instead of "nsf::my -local" on classes +# test object::dispatch instead of "my -local" on classes # nx::Test case dispatch-instead-of-my-local { nx::Class create Base { :private method privateMethod {a b} { expr {$a + $b} } - :public method foo {a b} { nsf::object::dispatch [self] [Base info method handle privateMethod] $a $b } + :public method foo {a b} { dispatch [self] [Base info method handle privateMethod] $a $b } } nx::Class create Sub -superclass Base { - :public method bar {a b} { nsf::object::dispatch [self] [Sub info method handle privateMethod] $a $b } + :public method bar {a b} { dispatch [self] [Sub info method handle privateMethod] $a $b } :private method privateMethod {a b} { expr {$a * $b} } :create s1 @@ -494,16 +491,16 @@ ? {o1 ::nx::Object::slot::__info::vars} "v" ? {o1 [nx::Object info method origin "info vars"]} "v" #? {o1 -system info vars} "v" - ? {nsf::object::dispatch o1 -system info vars} "v" + ? {nx::dispatch o1 -system info vars} "v" #? {o1 -system} "no method name specified" ? {o1 method foo {} {return foo}} "overloads method method" - ? {nsf::object::dispatch o1 -system public method foo {} {return foo}} "::o1::foo" + ? {nx::dispatch o1 -system public method foo {} {return foo}} "::o1::foo" ? {o1 destroy} "overloads system destroy" ? {nsf::object::exists o1} 1 - ? {nsf::object::dispatch o1 -system destroy} "" + ? {nx::dispatch o1 -system destroy} "" ? {nsf::object::exists o1} 0 # @@ -520,12 +517,12 @@ ? {c1 ::nx::Object::slot::__info::vars} "v" ? {c1 [nx::Object info method origin "info vars"]} "v" #? {c1 -system info vars} "v" - ? {nsf::object::dispatch c1 -system info vars} "v" + ? {nx::dispatch c1 -system info vars} "v" ? {c1 destroy} "overloads system destroy" ? {nsf::object::exists c1} 1 #? {c1 -system destroy} "" - ? {nsf::object::dispatch c1 -system destroy} "" + ? {nx::dispatch c1 -system destroy} "" ? {nsf::object::exists c1} 0 } @@ -541,7 +538,7 @@ nx::Class create Base { :private method baz {a b} { expr {$a + $b} } :protected method baz2 {a b} { expr {$a + $b} } - :public method foo {a b} { nsf::my -local baz $a $b } + :public method foo {a b} { my -local baz $a $b } :create b1 } # we can call Base.baz only through Base.foo @@ -552,7 +549,7 @@ # private method via "my -local" nx::Class create Mix { :private method baz {a b} { expr {$a ** $b} } - :public method foo {a b} { nsf::my -local baz $a $b } + :public method foo {a b} { my -local baz $a $b } } b1 mixin add Mix @@ -567,8 +564,8 @@ nx::Class create Intermediate -superclass Base { :private method baz {a b} { next } :private method baz2 {a b} { next } - :public method foo {a b} { nsf::my -local baz $a $b } - :public method foo2 {a b} { nsf::my -local baz2 $a $b } + :public method foo {a b} { my -local baz $a $b } + :public method foo2 {a b} { my -local baz2 $a $b } :create i1 } @@ -579,7 +576,7 @@ ? {i1 foo2 4 5} 9 nx::Class create Sub -superclass Intermediate { - :public method bar {a b} { nsf::my -local baz $a $b } + :public method bar {a b} { my -local baz $a $b } :private method baz {a b} { expr {$a * $b} } :create s1