Index: TODO =================================================================== diff -u -r31404a50d429bd67e904a70797c4f67674fab09f -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- TODO (.../TODO) (revision 31404a50d429bd67e904a70797c4f67674fab09f) +++ TODO (.../TODO) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -4421,10 +4421,13 @@ /obj/ info slot definition /obj/ /obj/ info lookup slots ?-type /type/? ?-source all|application|baseclasses? ?/pattern/? +- nx.tcl: handle "incremental" in slot reconfigure +- nx.tcl: change defaultAccessor to "none" - ======================================================================== TODO: +- valuechangedcmd implemented via initcmd does + not work work with "configure" method - consider "info properties" and "info variables" - fix property inheritance in traits (nx-traits.tcl) - handling of slots/properties/variables Index: doc/example-scripts/bagel.tcl =================================================================== diff -u -r5693145107c55b5f64bf0fb487aa43e0f2238f1a -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- doc/example-scripts/bagel.tcl (.../bagel.tcl) (revision 5693145107c55b5f64bf0fb487aa43e0f2238f1a) +++ doc/example-scripts/bagel.tcl (.../bagel.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -27,7 +27,7 @@ # they've been toasted. We can create and access an instance variable # by defining an property for the class. All instance variables are # per default public in the sense of C++. -? {Bagel property {toasted 0}} "::nsf::classes::Bagel::toasted" +? {Bagel property -accessor public {toasted 0}} "::nsf::classes::Bagel::toasted" # Since abagel was created before the definition of the property we # have to set the default value for it using the setter method. Again, @@ -95,7 +95,7 @@ # toppings are empty. ? {nx::Class create SpreadableBagel -superclass Bagel { - :property {toppings:0..n ""} + :property -accessor public {toppings:0..n ""} }} ::SpreadableBagel ? {SpreadableBagel info superclass} ::Bagel Index: doc/example-scripts/rosetta-constraint-genericity.tcl =================================================================== diff -u -re884c2b0d63fa1b5a691e866ccff8d4094a2a8e4 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- doc/example-scripts/rosetta-constraint-genericity.tcl (.../rosetta-constraint-genericity.tcl) (revision e884c2b0d63fa1b5a691e866ccff8d4094a2a8e4) +++ doc/example-scripts/rosetta-constraint-genericity.tcl (.../rosetta-constraint-genericity.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -26,7 +26,7 @@ :property -incremental item:object,type=::Eatable :public method print {} { set string "Foodbox contains:\n" - foreach i ${:item} {append string " [$i name]\n"} + foreach i ${:item} {append string " [$i cget -name]\n"} return $string } } Index: doc/example-scripts/rosetta-delegates.tcl =================================================================== diff -u -r5693145107c55b5f64bf0fb487aa43e0f2238f1a -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- doc/example-scripts/rosetta-delegates.tcl (.../rosetta-delegates.tcl) (revision 5693145107c55b5f64bf0fb487aa43e0f2238f1a) +++ doc/example-scripts/rosetta-delegates.tcl (.../rosetta-delegates.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -46,5 +46,5 @@ # Now, we set the +delegatee+; therefore, the delegatee will perform # the action. # -? {$a delegatee [Delegatee new]} "::nsf::__#1" +? {$a configure -delegatee [Delegatee new]} "" ? {$a operation} "delegatee implementatiton" \ No newline at end of file Index: doc/example-scripts/rosetta-polymorphism.tcl =================================================================== diff -u -rf71f786b01f7ad3d6749bc43c14c5f5d39658480 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- doc/example-scripts/rosetta-polymorphism.tcl (.../rosetta-polymorphism.tcl) (revision f71f786b01f7ad3d6749bc43c14c5f5d39658480) +++ doc/example-scripts/rosetta-polymorphism.tcl (.../rosetta-polymorphism.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -31,15 +31,15 @@ ? {$p print} "Point(1.0,2.0)" # Get the x coordinate of this point: -? {$p x} "1.0" +? {$p cget -x} "1.0" # Create a circle: ? {set c [Circle new -x 3.0 -y 4.0 -radius 5.0]} "::nsf::__#1" # Copy the circle ? {set d [$c copy]} "::nsf::__#3" # Change the radius of the copied circle: -? {$d radius 1.5} 1.5 +? {$d configure -radius 1.5} "" # Print the two circles: ? {$c print} "Circle(3.0,4.0,5.0)" Index: doc/example-scripts/traits-composite.tcl =================================================================== diff -u -rf858f142f5fab4f88996b3eb709c3afa55114be9 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- doc/example-scripts/traits-composite.tcl (.../traits-composite.tcl) (revision f858f142f5fab4f88996b3eb709c3afa55114be9) +++ doc/example-scripts/traits-composite.tcl (.../traits-composite.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -85,7 +85,7 @@ # +collection+ that uses the composite trait +tReadStream+: nx::Class create ReadStream { :property {collection ""} - :property {position 0} + :property -accessor public {position 0} :require trait tReadStream } Index: doc/example-scripts/traits-simple.tcl =================================================================== diff -u -rf858f142f5fab4f88996b3eb709c3afa55114be9 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- doc/example-scripts/traits-simple.tcl (.../traits-simple.tcl) (revision f858f142f5fab4f88996b3eb709c3afa55114be9) +++ doc/example-scripts/traits-simple.tcl (.../traits-simple.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -50,7 +50,7 @@ nx::Class create ReadStream { :property {collection ""} - :property {position 0} + :property -accessor public {position 0} :require trait tReadStream } Index: generic/nsf.c =================================================================== diff -u -rfc77eaadabdd690239694a6f1cf155a7d16b5cd4 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- generic/nsf.c (.../nsf.c) (revision fc77eaadabdd690239694a6f1cf155a7d16b5cd4) +++ generic/nsf.c (.../nsf.c) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -12579,7 +12579,7 @@ */ forwardSpec = paramPtr->method ? paramPtr->method : NULL; /* different default? */ if (forwardSpec == NULL) { - return NsfPrintError(interp, "no forward spec available\n"); + return NsfPrintError(interp, "forward: no spec available\n"); } result = Tcl_ListObjGetElements(interp, forwardSpec, &nobjc, &nobjv); @@ -16629,8 +16629,8 @@ int result; Tcl_Obj *methodObj = Tcl_NewStringObj(methodName, -1); - /* fprintf(stderr, "CallConfigureMethod method %s->'%s' level %d, argc %d\n", - ObjectName(object), methodName, level, argc);*/ + /*fprintf(stderr, "CallConfigureMethod method %s->'%s' argc %d\n", + ObjectName(object), methodName, argc);*/ /* * When configure gets "-init" passed, we call "init" and notice the fact it @@ -16648,7 +16648,7 @@ DECR_REF_COUNT(methodObj); /*fprintf(stderr, "method '%s' called args: %d o=%p, result=%d %d\n", - methodName, argc+1, obj, result, TCL_ERROR);*/ + methodName, argc+1, object, result, TCL_ERROR);*/ if (result != TCL_OK) { Tcl_Obj *res = Tcl_DuplicateObj(Tcl_GetObjResult(interp)); /* save the result */ @@ -22360,7 +22360,9 @@ * Special setter methods for invoking methods calls; handles types * "initcmd", "alias" and "forward". */ - if (paramPtr->flags & NSF_ARG_METHOD_INVOCATION) { + if ((paramPtr->flags & NSF_ARG_METHOD_INVOCATION) + //&& (paramPtr->flags & NSF_ARG_METHOD_CALL || object->flags & NSF_INIT_CALLED) + ) { int consuming = (*paramPtr->name == '-' || paramPtr->nrArgs > 0); if (consuming && newValue == NsfGlobalObjs[NSF___UNKNOWN__]) { @@ -22504,7 +22506,7 @@ } if (!found) { - result = NsfPrintError(interp, "cannot lookup parameter value for %s", nameString); + result = NsfPrintError(interp, "cget: cannot lookup parameter value for %s", nameString); goto cget_exit; } @@ -22533,7 +22535,7 @@ /* * We do NOT have a slot */ - if (found && paramPtr->flags & NSF_ARG_METHOD_INVOCATION) { + if (found && paramPtr->flags & NSF_ARG_METHOD_CALL) { if (paramPtr->flags & NSF_ARG_ALIAS) { /* * It is a parameter associated with an aliased method. Invoke the Index: generic/nsfInt.h =================================================================== diff -u -r9149131f82853343544588c8667969e03a296397 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- generic/nsfInt.h (.../nsfInt.h) (revision 9149131f82853343544588c8667969e03a296397) +++ generic/nsfInt.h (.../nsfInt.h) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -436,6 +436,7 @@ /* method invocations */ #define NSF_ARG_METHOD_INVOCATION (NSF_ARG_ALIAS|NSF_ARG_FORWARD|NSF_ARG_INITCMD) +#define NSF_ARG_METHOD_CALL (NSF_ARG_ALIAS|NSF_ARG_FORWARD) /* Disallowed parameter options */ #define NSF_DISALLOWED_ARG_METHOD_PARAMETER (NSF_ARG_METHOD_INVOCATION|NSF_ARG_NOCONFIG|NSF_ARG_SLOTASSIGN|NSF_ARG_SLOTINITIALIZE) Index: library/nx/nx.tcl =================================================================== diff -u -r31404a50d429bd67e904a70797c4f67674fab09f -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- library/nx/nx.tcl (.../nx.tcl) (revision 31404a50d429bd67e904a70797c4f67674fab09f) +++ library/nx/nx.tcl (.../nx.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -1777,6 +1777,10 @@ ::nx::VariableSlot public method reconfigure {} { #puts stderr "*** Should we reconfigure [self]???" unset -nocomplain :parameterSpec + if {${:incremental}} { + if {${:accessor} eq "none"} { set :accessor "public" } + if {![:isMultivalued]} { set :multiplicity "0..n" } + } :makeAccessor if {${:per-object} && [info exists :default]} { :setCheckedInstVar -nocomplain=[info exists :nocomplain] ${:domain} ${:default} @@ -2462,7 +2466,7 @@ # Make the default protected methods # ::nx::configure defaultMethodCallProtection true - ::nx::configure defaultAccessor public + ::nx::configure defaultAccessor none # # Provide an ensemble-like interface to the ::nsf primitiva to Index: library/serialize/serializer.tcl =================================================================== diff -u -r048289203d8b3aad7478a00bd40832260a4ca383 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- library/serialize/serializer.tcl (.../serializer.tcl) (revision 048289203d8b3aad7478a00bd40832260a4ca383) +++ library/serialize/serializer.tcl (.../serializer.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -145,7 +145,7 @@ ########################################################################### Class create Serializer { - :property ignoreVarsRE + :property -accessor public ignoreVarsRE :public method ignore args { # Ignore the objects passed via args. Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -r9e766c226c7ddb35a4aa20ca7a9e8d6678a7c9e2 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 9e766c226c7ddb35a4aa20ca7a9e8d6678a7c9e2) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -952,7 +952,7 @@ # Create ::xotcl::Attribute for compatibility # ::xotcl::MetaSlot create ::xotcl::Attribute -superclass ::nx::VariableSlot { - :property multivalued { + :property -accessor public multivalued { :public object method assign {object property value} { set mClass [expr {$value ? "0..n" : "1..1"}] $object incremental $value Index: tests/cget.test =================================================================== diff -u -rfc77eaadabdd690239694a6f1cf155a7d16b5cd4 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/cget.test (.../cget.test) (revision fc77eaadabdd690239694a6f1cf155a7d16b5cd4) +++ tests/cget.test (.../cget.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -37,8 +37,8 @@ # - parameter without a value # ? {p1 cget} {wrong # of arguments: should be "cget /name/"} - ? {p1 cget -foo} {cannot lookup parameter value for -foo} - ? {p1 cget foo} {cannot lookup parameter value for foo} + ? {p1 cget -foo} {cget: cannot lookup parameter value for -foo} + ? {p1 cget foo} {cget: cannot lookup parameter value for foo} ? {p1 cget -sex} {can't read "sex": no such variable} # Index: tests/forward.test =================================================================== diff -u -rf858f142f5fab4f88996b3eb709c3afa55114be9 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/forward.test (.../forward.test) (revision f858f142f5fab4f88996b3eb709c3afa55114be9) +++ tests/forward.test (.../forward.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -30,7 +30,7 @@ x1 Incr x x1 Incr x x1 Incr x - ? {x1 x} 103 + ? {x1 cget -x} 103 } ########################################### Index: tests/info-method.test =================================================================== diff -u -r31404a50d429bd67e904a70797c4f67674fab09f -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/info-method.test (.../info-method.test) (revision 31404a50d429bd67e904a70797c4f67674fab09f) +++ tests/info-method.test (.../info-method.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -375,12 +375,12 @@ ? {o object method foo {} {return o.foo}} "::o::foo" ? {o object alias is ::nsf::is} "::o::is" #? {o object property x} {variable definition for 'x' (without value and accessor) is useless} - ? {o object property x} "::o::x" + ? {o object property x} "" ? {o object property -accessor public x} "::o::x" ? {lsort [o info object methods]} "foo is x" #? {o object property A} {variable definition for 'A' (without value and accessor) is useless} - ? {o object property A} ::o::A + ? {o object property A} "" ? {o object property -accessor public A} ::o::A ? {o object forward fwd ::set} ::o::fwd ? {lsort [o info object methods]} "A foo fwd is x" Index: tests/methods.test =================================================================== diff -u -r31404a50d429bd67e904a70797c4f67674fab09f -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/methods.test (.../methods.test) (revision 31404a50d429bd67e904a70797c4f67674fab09f) +++ tests/methods.test (.../methods.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -92,8 +92,8 @@ # class level setter nx::Test case class-level-setter { - #? {c2 plain_setter 1} {::c2: unable to dispatch method 'plain_setter'} - ? {c2 plain_setter 1} 1 + ? {c2 plain_setter 1} {::c2: unable to dispatch method 'plain_setter'} + #? {c2 plain_setter 1} 1 ? {c2 public_setter 2} "2" ? {catch {c2 protected_setter 3}} 1 ? {::nsf::dispatch c2 protected_setter 4} "4" @@ -127,8 +127,8 @@ # class level setter nx::Test case class-object-level-setter { - #? {C plain_object_setter 1} {method 'plain_object_setter' unknown for ::C; consider '::C create plain_object_setter 1' instead of '::C plain_object_setter 1'} - ? {C plain_object_setter 1} "1" + ? {C plain_object_setter 1} {method 'plain_object_setter' unknown for ::C; consider '::C create plain_object_setter 1' instead of '::C plain_object_setter 1'} + #? {C plain_object_setter 1} "1" ? {C public_object_setter 2} "2" ? {catch {C protected_object_setter 3}} 1 ? {::nsf::dispatch C protected_object_setter 4} "4" @@ -162,8 +162,8 @@ # object level setter nx::Test case object-level-setter { - #? {c1 plain_object_setter 1} {::c1: unable to dispatch method 'plain_object_setter'} - ? {c1 plain_object_setter 1} "1" + ? {c1 plain_object_setter 1} {::c1: unable to dispatch method 'plain_object_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" @@ -179,12 +179,12 @@ #? {lsort [c1 info object methods]} \ "plain_object_alias plain_object_forward plain_object_method public_object_alias public_object_forward public_object_method public_object_setter" ? {lsort [c1 info object methods]} \ - "plain_object_alias plain_object_forward plain_object_method plain_object_setter public_object_alias public_object_forward public_object_method public_object_setter" + "plain_object_alias plain_object_forward plain_object_method public_object_alias public_object_forward public_object_method public_object_setter" #? {lsort [C info methods]} \ "plain_object_alias plain_object_forward plain_object_method public_object_alias public_object_forward public_object_method public_object_setter s3" ? {lsort [C info object methods]} \ - "plain_object_alias plain_object_forward plain_object_method plain_object_setter public_object_alias public_object_forward public_object_method public_object_setter s3" + "plain_object_alias plain_object_forward plain_object_method public_object_alias public_object_forward public_object_method public_object_setter s3" } C destroy @@ -290,8 +290,8 @@ ? {C A 2} 2 ? {C A} 2 - #? {C B} {method 'B' unknown for ::C; consider '::C create B ' instead of '::C B '} - ? {C B} B2 + ? {C B} {method 'B' unknown for ::C; consider '::C create B ' instead of '::C B '} + #? {C B} B2 ? {C C} C2 ? {C D} "method 'D' unknown for ::C; consider '::C create D ' instead of '::C D '" @@ -305,8 +305,8 @@ :object property -accessor protected {d d1} } ? {o a 2} 2 - #? {o b} {::o: unable to dispatch method 'b'} - ? {o b} b1 + ? {o b} {::o: unable to dispatch method 'b'} + #? {o b} b1 ? {o c} c1 ? {o d} "::o: unable to dispatch method 'd'" } Index: tests/object-system.test =================================================================== diff -u -rfc77eaadabdd690239694a6f1cf155a7d16b5cd4 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/object-system.test (.../object-system.test) (revision fc77eaadabdd690239694a6f1cf155a7d16b5cd4) +++ tests/object-system.test (.../object-system.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -228,9 +228,9 @@ # "-flag=value" handling # nsf::method::create ::C m1 {} {;} -? {lsort [::C ::nsf::methods::class::info::methods]} {m1 x y} +? {lsort [::C ::nsf::methods::class::info::methods]} {m1} nsf::method::create ::C -per-object=false m2 {} {;} -? {lsort [::C ::nsf::methods::class::info::methods]} {m1 m2 x y} +? {lsort [::C ::nsf::methods::class::info::methods]} {m1 m2} nsf::method::create ::C -per-object=true m3 {} {;} ? {lsort [::C ::nsf::methods::object::info::methods]} {m3} Index: tests/parameters.test =================================================================== diff -u -r31404a50d429bd67e904a70797c4f67674fab09f -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/parameters.test (.../parameters.test) (revision 31404a50d429bd67e904a70797c4f67674fab09f) +++ tests/parameters.test (.../parameters.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -527,10 +527,10 @@ ? {d1 bar -c 1} {::d1-[current]-1-2} "substdefault in method parameter" nx::Class create Bar -superclass D { - :property {s "[current]"} - :property {literal "\\[current\\]"} - :property {c "[:info class]"} - :property {d "literal $d"} + :property -accessor public {s "[current]"} + :property -accessor public {literal "\\[current\\]"} + :property -accessor public {c "[:info class]"} + :property -accessor public {d "literal $d"} } ? {Bar property -accessor public ss:switch} "::nsf::classes::Bar::ss" @@ -890,12 +890,12 @@ ? {s1 baz} {expected integer but got "b" for parameter "x"} ? {s1 baz 20} 20 - s1 y 100 + s1 configure -y 100 ? {s1 baz} 100 ? {s1 baz 101} 101 ? {s1 boz} {1 2 3} - s1 z {1 x 100} + s1 configure -z {1 x 100} ? {s1 boz} {invalid value in "1 x 100": expected integer but got "x" for parameter "x"} ? {s1 boz {100 200}} {100 200} @@ -934,10 +934,10 @@ } Bar create ::b - ? {b s0} "::b" - ? {b s1} "::b" - ? {b s2} "::b" - ? {b s3} "::b" + ? {b cget -s0} "::b" + ? {b cget -s1} "::b" + ? {b cget -s2} "::b" + ? {b cget -s3} "::b" } # @@ -989,6 +989,7 @@ :property b:baseclass :property u:upper :property us:upper,1..* + :property -incremental us2:upper,1..* :property {x:object,1..* {o}} } @@ -1042,23 +1043,24 @@ set :incremental 1 :reconfigure } - ? {ParamTest create p -us {A B}} ::p + ? {ParamTest create p -us {A B} -us2 {A B}} ::p ? {p us add C end} "A B C" + ? {p us2 add C end} "A B C" - ? {p o o} \ - "o" \ + ? {p configure -o o} \ + "" \ "value is an object" - ? {p o xxx} \ - {expected object but got "xxx" for parameter "o"} \ + ? {p configure -o xxx} \ + {expected object but got "xxx" for parameter "-o"} \ "value is not an object" # # define multivalued property "os" via instance variables of the # slot object # ParamTest eval { - :property os { + :property -accessor public os { :type object :multiplicity 1..n } @@ -1171,7 +1173,7 @@ nx::Test case slot-specfic-converter { nx::Class create Person { - :property sex { + :property -accessor public sex { :type "sex" :convert true :object method type=sex {name value} { @@ -1186,6 +1188,7 @@ } Person create p1 -sex male + ? {p1 cget -sex} m ? {p1 sex} m Person public method foo {s:sex,slot=::Person::slot::sex,convert} {return $s} ? {p1 foo male} m @@ -1241,9 +1244,9 @@ nx::Test case slot-optimizer { nx::Class create C { - :property a - :property b:integer - :property c:integer,0..n + :property -accessor public a + :property -accessor public b:integer + :property -accessor public c:integer,0..n } C create c1 @@ -1255,7 +1258,7 @@ nx::Test parameter count 10 nx::Test case slot-nosetter { nx::Class create C { - :property a + :property -accessor public a :property -accessor none b:integer :property -accessor none {c ""} } @@ -1303,9 +1306,9 @@ nx::Test case slot-traces { ::nx::Object create o { - :object property a {set :defaultcmd { set _ 4 } } - :object property b {set :valuecmd { set _ 44 } } - :object property c {set :valuechangedcmd { ::nsf::var::set $obj $var 999 }} + :object property -accessor public a {set :defaultcmd { set _ 4 } } + :object property -accessor public b {set :valuecmd { set _ 44 } } + :object property -accessor public c {set :valuechangedcmd { ::nsf::var::set $obj $var 999 }} } ? {o a} 4 @@ -1321,9 +1324,9 @@ ? {::nsf::object::property o2 hasperobjectslots} 1 ::nx::Class create C { - :property a {set :defaultcmd { set _ 4 } } - :property b {set :valuecmd { set _ 44 } } - :property c {set :valuechangedcmd { ::nsf::var::set $obj $var 999 }} + :property -accessor public a {set :defaultcmd { set _ 4 } } + :property -accessor public b {set :valuecmd { set _ 44 } } + :property -accessor public c {set :valuechangedcmd { ::nsf::var::set $obj $var 999 }} :create c1 } ? {c1 a} 4 @@ -1380,7 +1383,7 @@ # ? {o eval {info exists :a}} 0 - o object property {a 0} { + o object property -accessor public {a 0} { set :valuechangedcmd {::nsf::var::set $obj $var [expr [list [::nsf::var::set $obj $var] + 1]]} } ? {o eval {info exists :a}} 1 @@ -1406,7 +1409,7 @@ set :valuecmd {set _ 44} }} "valuecmd can't be used together with defaultcmd" - Klass property {a 0} { + Klass property -accessor public {a 0} { set :valuechangedcmd {::nsf::var::set $obj $var [expr [list [::nsf::var::set $obj $var] + 1]]} } @@ -1449,25 +1452,21 @@ ::nx::Class create CC { :property a:0..n { set :defaultcmd { - if 1 { - set _ 4 - } + set _ 4 } } - :property b:0..n {set :valuecmd {if 1 {set _ 44}} } - :property c:0..n { + :property b:0..n {set :valuecmd {set _ 44} } + :property -accessor public c:0..n { set :valuechangedcmd { - if 1 { - ::nsf::var::set $obj $var 999 - } + ::nsf::var::set $obj $var 999 } } :create ::cc } - ? {cc a} 4 - ? {cc b} 44 + ? {cc cget -a} 4 + ? {cc cget -b} 44 ? {cc c 5} 999 } @@ -1608,7 +1607,7 @@ # nx::Test case dont-reset-to-defaults { nx::Class create C { - :property {a 1} + :property -accessor public {a 1} :create c1 } ? {c1 a} 1 @@ -1674,10 +1673,10 @@ set ::_ "" ? {C create c2 -y 1 -x} {value for parameter '-x' expected} ? {set ::_} "" - ? {c2 x} {can't read "x": no such variable} + ? {c2 cget -x} {can't read "x": no such variable} ? {C create c3 -y 1 -x 0} "::c3" ? {set ::_} "" - ? {c3 x} "0" + ? {c3 cget -x} "0" } ::nsf::configure checkarguments on @@ -1692,8 +1691,8 @@ :property {n2:any "[namespace tail [::nsf::self]]"} :create c1 } - ? {c1 n1} c1 - ? {c1 n2} c1 + ? {c1 cget -n1} c1 + ? {c1 cget -n2} c1 } # @@ -1804,7 +1803,7 @@ ? {c1 eval {set :x}} "x1" ? {c1 eval {set :foo}} "123 a b c F" ? {c1 eval {set :bar}} "aha" - ? {lsort [c1 info lookup methods -source application]} "D bar foo x" + ? {lsort [c1 info lookup methods -source application]} "bar foo x" } # @@ -2063,7 +2062,7 @@ ? {o eval {info exists :a}} 0 o object property {a oldvalue} ? {o eval {info exists :a}} 1 - ? {o a} oldvalue + ? {o cget -a} oldvalue # # By unsetting the var, upon recreating the property slot (or # calling reconfigure upon the property) we can trigger @@ -2076,7 +2075,7 @@ # o object property {a newvalue} ? {o eval {info exists :a}} 1 - ? {o a} newvalue + ? {o cget -a} newvalue o eval {unset :a} ? {o eval {info exists :a}} 0 [o info object slots a] default anothervalue @@ -2086,7 +2085,7 @@ # [o info object slots a] reconfigure ? {o eval {info exists :a}} 1 - ? {o a} anothervalue + ? {o cget -a} anothervalue } # @@ -2138,19 +2137,19 @@ # set 2 variables, one via variable, one via property ? [list [self] object variable -nocomplain captain1 "James Kirk"] "" - ? [list [self] object property -nocomplain [list captain2 "Jean Luc"]] "::enterprise::captain2" + ? [list [self] object property -nocomplain [list captain2 "Jean Luc"]] "" # in both cases, we expect instance variables ? [list [self] eval {set :captain1}] "James Kirk" ? [list [self] eval {set :captain2}] "Jean Luc" # just for the property, we have accessors ? [list [self] info lookup method captain1] "" - ? [list [self] info lookup method captain2] "::enterprise::captain2" + ? [list [self] info lookup method captain2] "" # set variable with a value checker ? [list [self] object variable -nocomplain x1:int 1] "" - ? [list [self] object property -nocomplain [list x2:int 2]] "::enterprise::x2" + ? [list [self] object property -nocomplain [list x2:int 2]] "" # set variable with a value checker and an invalid value ? [list [self] object variable y1:int a] {expected integer but got "a"} @@ -2162,7 +2161,7 @@ # set variable with a value checker, multiple ? [list [self] object variable -nocomplain xm1:int,1..n {1 2 3}] "" - ? [list [self] object property -nocomplain [list xm2:int,1..n {1 2 3}]] "::enterprise::xm2" + ? [list [self] object property -nocomplain [list xm2:int,1..n {1 2 3}]] "" # in both cases, we expect instance variables ? [list [self] eval {set :xm1}] "1 2 3" @@ -2199,8 +2198,7 @@ # valid value ? [list [self] object variable -nocomplain r1:range,arg=1-10 5] "" - ? [list [self] object property -nocomplain [list r2:range,arg=1-10 5]] \ - {::enterprise::r2} + ? [list [self] object property -nocomplain [list r2:range,arg=1-10 5]] "" # testing incremental ? [list [self] object variable -incremental -nocomplain i:int,0..* {}] "::enterprise::i" @@ -2220,7 +2218,7 @@ nx::Class create C { # set 2 class variables, one via variable, one via property ? [list [self] object variable -nocomplain v "v0"] "" - ? [list [self] object property -nocomplain [list a "a0"]] "::C::a" + ? [list [self] object property -nocomplain [list a "a0"]] "" # in both cases, we expect instance variables ? [list [self] eval {set :v}] "v0" @@ -2241,7 +2239,7 @@ # define 2 class-level variables, one via variable, one via property :variable v v0 - :property {a a0} + :property -accessor public {a a0} # create an instance :create c1 @@ -2302,7 +2300,7 @@ # define 2 class-level variables, one via variable, one via property :variable v v0 - :property {a a0} + :property -accessor public {a a0} # create an instance :create c1 @@ -2342,7 +2340,7 @@ # define 2 object-level variables, one via variable, one via property :object variable v v0 - :object property {a a0} + :object property -accessor public {a a0} } # the instance of C will have the two variables set ... @@ -2372,7 +2370,7 @@ # Create a class with an property of type switch and an instance of # the class ? {::nx::Class create C { - :property foo:switch + :property -accessor public foo:switch :create c1 }} "::C" @@ -2446,10 +2444,10 @@ ? {C info slot definition ::C::slot::v} "::C variable -accessor none v 100" nx::Class create D { - :property {p0 200} + :property -accessor public {p0 200} :property -accessor none {p1 201} :property -accessor none {p2:noconfig 202} - :property {p3:noconfig 203} + :property -accessor public {p3:noconfig 203} } # "p2" and "p3" do NOT show up in "info parameter" @@ -2485,10 +2483,10 @@ ? {o1 info slot definition ::o1::per-object-slot::v1} "::o1 object variable -accessor public v1 100" nx::Object create o2 { - :object property {p0 200} + :object property -accessor public {p0 200} :object property -accessor none {p1 201} :object property -accessor none {p2:noconfig 202} - :object property {p3:noconfig 203} + :object property -accessor public {p3:noconfig 203} } # "p1" and "p2" do NOT show up in "info methods" @@ -2516,8 +2514,8 @@ :property {b 1} } - ? {Foo info slot definition [Foo info slots a]} "::Foo property -accessor public a" - ? {Foo info slot definition [Foo info slots b]} "::Foo property -accessor public {b 1}" + ? {Foo info slot definition [Foo info slots a]} "::Foo property -accessor none a" + ? {Foo info slot definition [Foo info slots b]} "::Foo property -accessor none {b 1}" #? {Foo info properties} "a {b 1}" @@ -2526,26 +2524,26 @@ :property a:boolean :property {b:integer 1} } - ? {Foo info slot definition [Foo info slots a]} "::Foo property -accessor public a:boolean" - ? {Foo info slot definition [Foo info slots b]} "::Foo property -accessor public {b:integer 1}" + ? {Foo info slot definition [Foo info slots a]} "::Foo property -accessor none a:boolean" + ? {Foo info slot definition [Foo info slots b]} "::Foo property -accessor none {b:integer 1}" # required/optional properties nx::Class create Foo { :property a:required :property b:boolean,required } - ? {Foo info slot definition [Foo info slots a]} "::Foo property -accessor public a:required" - ? {Foo info slot definition [Foo info slots b]} "::Foo property -accessor public b:boolean,required" + ? {Foo info slot definition [Foo info slots a]} "::Foo property -accessor none a:required" + ? {Foo info slot definition [Foo info slots b]} "::Foo property -accessor none b:boolean,required" # properties with multiplicity nx::Class create Foo { :property {ints:integer,0..n ""} :property objs:object,1..n :property obj:object,0..1 } - ? {Foo info slot definition [Foo info slots objs]} "::Foo property -accessor public objs:object,1..n" - ? {Foo info slot definition [Foo info slots ints]} "::Foo property -accessor public {ints:integer,0..n {}}" - ? {Foo info slot definition [Foo info slots obj]} "::Foo property -accessor public obj:object,0..1" + ? {Foo info slot definition [Foo info slots objs]} "::Foo property -accessor none objs:object,1..n" + ? {Foo info slot definition [Foo info slots ints]} "::Foo property -accessor none {ints:integer,0..n {}}" + ? {Foo info slot definition [Foo info slots obj]} "::Foo property -accessor none obj:object,0..1" } # @@ -2597,7 +2595,7 @@ nx::Test case forward-to-assign { set ::slotcalls 0 nx::Class create Foo { - :property bar { + :property -accessor public bar { :public object method assign { object property value } { incr ::slotcalls 1 nsf::var::set $object $property $value @@ -2621,7 +2619,7 @@ # test cases for default set ::slotcalls 0 nx::Class create Foo { - :property {baz 1} { + :property -accessor public {baz 1} { :public object method assign { object property value } { incr ::slotcalls 1 nsf::var::set $object $property $value @@ -2715,7 +2713,7 @@ nx::Test case slot-container-name-interaction { nx::Class create Test2 { - :property list { + :property -accessor public list { :public object method assign { obj var val } { nsf::var::set $obj $var [list $obj $var $val] } Index: tests/properties.test =================================================================== diff -u -r31404a50d429bd67e904a70797c4f67674fab09f -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/properties.test (.../properties.test) (revision 31404a50d429bd67e904a70797c4f67674fab09f) +++ tests/properties.test (.../properties.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -61,14 +61,14 @@ ? {c1 cget -a} a1 ? {c1 cget -b} b1 - ? {c1 cget -c} {cannot lookup parameter value for -c} - ? {c1 cget -d} {cannot lookup parameter value for -d} - ? {c1 cget -va} {cannot lookup parameter value for -va} - ? {c1 cget -vb} {cannot lookup parameter value for -vb} - ? {c1 cget -vc} {cannot lookup parameter value for -vc} - ? {c1 cget -vd} {cannot lookup parameter value for -vd} - ? {c1 cget -ve} {cannot lookup parameter value for -ve} - ? {c1 cget -vf} {cannot lookup parameter value for -vf} + ? {c1 cget -c} {cget: cannot lookup parameter value for -c} + ? {c1 cget -d} {cget: cannot lookup parameter value for -d} + ? {c1 cget -va} {cget: cannot lookup parameter value for -va} + ? {c1 cget -vb} {cget: cannot lookup parameter value for -vb} + ? {c1 cget -vc} {cget: cannot lookup parameter value for -vc} + ? {c1 cget -vd} {cget: cannot lookup parameter value for -vd} + ? {c1 cget -ve} {cget: cannot lookup parameter value for -ve} + ? {c1 cget -vf} {cget: cannot lookup parameter value for -vf} # # No incremental used, so "a" and "e" have no slots @@ -234,12 +234,12 @@ ? {c1 cget -a} a1 ? {c1 cget -b} b1 - ? {c1 cget -c} {cannot lookup parameter value for -c} - ? {c1 cget -d} {cannot lookup parameter value for -d} - ? {c1 cget -va} {cannot lookup parameter value for -va} - ? {c1 cget -vb} {cannot lookup parameter value for -vb} - ? {c1 cget -vc} {cannot lookup parameter value for -vc} - ? {c1 cget -vd} {cannot lookup parameter value for -vd} + ? {c1 cget -c} {cget: cannot lookup parameter value for -c} + ? {c1 cget -d} {cget: cannot lookup parameter value for -d} + ? {c1 cget -va} {cget: cannot lookup parameter value for -va} + ? {c1 cget -vb} {cget: cannot lookup parameter value for -vb} + ? {c1 cget -vc} {cget: cannot lookup parameter value for -vc} + ? {c1 cget -vd} {cget: cannot lookup parameter value for -vd} # # The use of "-incremental" implies an accessor @@ -413,12 +413,12 @@ ? {o1 cget -a} a1 ? {o1 cget -b} b1 - ? {o1 cget -c} {cannot lookup parameter value for -c} - ? {o1 cget -d} {cannot lookup parameter value for -d} - ? {o1 cget -va} {cannot lookup parameter value for -va} - ? {o1 cget -vb} {cannot lookup parameter value for -vb} - ? {o1 cget -vc} {cannot lookup parameter value for -vc} - ? {o1 cget -vd} {cannot lookup parameter value for -vd} + ? {o1 cget -c} {cget: cannot lookup parameter value for -c} + ? {o1 cget -d} {cget: cannot lookup parameter value for -d} + ? {o1 cget -va} {cget: cannot lookup parameter value for -va} + ? {o1 cget -vb} {cget: cannot lookup parameter value for -vb} + ? {o1 cget -vc} {cget: cannot lookup parameter value for -vc} + ? {o1 cget -vd} {cget: cannot lookup parameter value for -vd} # @@ -537,12 +537,12 @@ ? {o1 cget -a} a1 ? {o1 cget -b} b1 - ? {o1 cget -c} {cannot lookup parameter value for -c} - ? {o1 cget -d} {cannot lookup parameter value for -d} - ? {o1 cget -va} {cannot lookup parameter value for -va} - ? {o1 cget -vb} {cannot lookup parameter value for -vb} - ? {o1 cget -vc} {cannot lookup parameter value for -vc} - ? {o1 cget -vd} {cannot lookup parameter value for -vd} + ? {o1 cget -c} {cget: cannot lookup parameter value for -c} + ? {o1 cget -d} {cget: cannot lookup parameter value for -d} + ? {o1 cget -va} {cget: cannot lookup parameter value for -va} + ? {o1 cget -vb} {cget: cannot lookup parameter value for -vb} + ? {o1 cget -vc} {cget: cannot lookup parameter value for -vc} + ? {o1 cget -vd} {cget: cannot lookup parameter value for -vd} # # The use of "-incremental" implies an accessor Index: tests/protected.test =================================================================== diff -u -rb531a50ecc43d0c13e2432b099a436c3260c7a49 -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/protected.test (.../protected.test) (revision b531a50ecc43d0c13e2432b099a436c3260c7a49) +++ tests/protected.test (.../protected.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -137,7 +137,7 @@ "redefine forward SET" # try to redefine via setter - ? {C property SET} \ + ? {C property -accessor public SET} \ {refuse to overwrite protected method 'SET'; derive e.g. a sub-class!} \ "redefine property SET" @@ -738,7 +738,7 @@ :property -accessor private {c c1d} :public method bard {p} {return [: -local $p]} :create d1 { - :object property {c c1o} + :object property -accessor public {c c1o} } } @@ -774,7 +774,7 @@ # nx::Test case private-shadows-public-property { nx::Class create C { - :property {x c} + :property -accessor public {x c} } nx::Class create D -superclass C { :property -accessor private {x d} Index: tests/serialize.test =================================================================== diff -u -r31404a50d429bd67e904a70797c4f67674fab09f -r2872e1f0a6523c7fb44952492e05414c4f8d9c84 --- tests/serialize.test (.../serialize.test) (revision 31404a50d429bd67e904a70797c4f67674fab09f) +++ tests/serialize.test (.../serialize.test) (revision 2872e1f0a6523c7fb44952492e05414c4f8d9c84) @@ -6,7 +6,7 @@ nx::Test case deepSerialize-map-filter { Object create ::a { - :object property ref:object,type=[:info class] + :object property -accessor public ref:object,type=[:info class] Object create [self]::b { [:info parent] ref [Object create [self]::c] } @@ -53,10 +53,10 @@ nx::Test case deepSerialize-ignoreVarsRE-filter { nx::Class create C { - :object property x - :object property y - :property a:int - :property b:int + :object property -accessor public x + :object property -accessor public y + :property -accessor public a:int + :property -accessor public b:int :create c1 }