Index: doc/index.html =================================================================== diff -u -r4ce8b09b87f62b4070cde2a7bbc615b4a9c83393 -rfb73930aa9ecf6ce966e512e6f899acb5784ea8c --- doc/index.html (.../index.html) (revision 4ce8b09b87f62b4070cde2a7bbc615b4a9c83393) +++ doc/index.html (.../index.html) (revision fb73930aa9ecf6ce966e512e6f899acb5784ea8c) @@ -23,7 +23,7 @@
Index: generic/predefined.h =================================================================== diff -u -r3f0573cc75724179f416942b974373e5a62ec05e -rfb73930aa9ecf6ce966e512e6f899acb5784ea8c --- generic/predefined.h (.../predefined.h) (revision 3f0573cc75724179f416942b974373e5a62ec05e) +++ generic/predefined.h (.../predefined.h) (revision fb73930aa9ecf6ce966e512e6f899acb5784ea8c) @@ -286,7 +286,8 @@ "lappend methodopts $prefix=${:arg}}\n" "if {[info exists :default]} {\n" "set arg ${:default}\n" -"if {[string match {*\\[*\\]*} $arg]} {\n" +"if {[string match {*\\[*\\]*} $arg]\n" +"&& $type ne \"substdefault\"} {\n" "lappend objopts substdefault}} elseif {[info exists :initcmd]} {\n" "set arg ${:initcmd}\n" "lappend objopts initcmd}\n" @@ -296,7 +297,7 @@ "lappend methodopts arg=${:methodname}}}\n" "if {$type ne \"\"} {\n" "set objopts [linsert $objopts 0 $type]\n" -"set methodopts [linsert $methodopts 0 $type]}\n" +"if {$type ne \"substdefault\"} {set methodopts [linsert $methodopts 0 $type]}}\n" "lappend objopts slot=[::nx::core::current object]\n" "if {[llength $objopts] > 0} {\n" "append objparamdefinition :[join $objopts ,]}\n" Index: generic/predefined.xotcl =================================================================== diff -u -r3f0573cc75724179f416942b974373e5a62ec05e -rfb73930aa9ecf6ce966e512e6f899acb5784ea8c --- generic/predefined.xotcl (.../predefined.xotcl) (revision 3f0573cc75724179f416942b974373e5a62ec05e) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision fb73930aa9ecf6ce966e512e6f899acb5784ea8c) @@ -543,7 +543,8 @@ if {[info exists :default]} { set arg ${:default} # deactivated for now: || [string first {$} $arg] > -1 - if {[string match {*\[*\]*} $arg]} { + if {[string match {*\[*\]*} $arg] + && $type ne "substdefault"} { lappend objopts substdefault } } elseif {[info exists :initcmd]} { @@ -559,7 +560,9 @@ } if {$type ne ""} { set objopts [linsert $objopts 0 $type] - set methodopts [linsert $methodopts 0 $type] + # Never add "substdefault" to methodopts, since these are for + # provided values, not for defaults. + if {$type ne "substdefault"} {set methodopts [linsert $methodopts 0 $type]} } lappend objopts slot=[::nx::core::current object] Index: generic/xotcl.c =================================================================== diff -u -r3f0573cc75724179f416942b974373e5a62ec05e -rfb73930aa9ecf6ce966e512e6f899acb5784ea8c --- generic/xotcl.c (.../xotcl.c) (revision 3f0573cc75724179f416942b974373e5a62ec05e) +++ generic/xotcl.c (.../xotcl.c) (revision fb73930aa9ecf6ce966e512e6f899acb5784ea8c) @@ -12147,7 +12147,7 @@ setterClientData->paramsPtr = ParamsNew(1); result = ParamParse(interp, "setter", parameter, - XOTCL_DISALLOWED_ARG_METHOD_PARAMETER| XOTCL_ARG_HAS_DEFAULT, + XOTCL_DISALLOWED_ARG_SETTER|XOTCL_ARG_HAS_DEFAULT, setterClientData->paramsPtr, &possibleUnknowns, &plainParams); if (result != TCL_OK) { Index: generic/xotclInt.h =================================================================== diff -u -r3f0573cc75724179f416942b974373e5a62ec05e -rfb73930aa9ecf6ce966e512e6f899acb5784ea8c --- generic/xotclInt.h (.../xotclInt.h) (revision 3f0573cc75724179f416942b974373e5a62ec05e) +++ generic/xotclInt.h (.../xotclInt.h) (revision fb73930aa9ecf6ce966e512e6f899acb5784ea8c) @@ -374,6 +374,7 @@ /* disallowed options */ #define XOTCL_DISALLOWED_ARG_METHOD_PARAMETER (XOTCL_ARG_METHOD|XOTCL_ARG_INITCMD|XOTCL_ARG_RELATION) +#define XOTCL_DISALLOWED_ARG_SETTER (XOTCL_ARG_SUBST_DEFAULT|XOTCL_DISALLOWED_ARG_METHOD_PARAMETER) #define XOTCL_DISALLOWED_ARG_OBJECT_PARAMETER 0 #define XOTCL_DISALLOWED_ARG_VALUEECHECK (XOTCL_ARG_SUBST_DEFAULT|XOTCL_ARG_METHOD|XOTCL_ARG_INITCMD|XOTCL_ARG_RELATION|XOTCL_ARG_SWITCH|XOTCL_ARG_CURRENTLY_UNKNOWN) Index: tests/parameters.xotcl =================================================================== diff -u -r3f0573cc75724179f416942b974373e5a62ec05e -rfb73930aa9ecf6ce966e512e6f899acb5784ea8c --- tests/parameters.xotcl (.../parameters.xotcl) (revision 3f0573cc75724179f416942b974373e5a62ec05e) +++ tests/parameters.xotcl (.../parameters.xotcl) (revision fb73930aa9ecf6ce966e512e6f899acb5784ea8c) @@ -96,7 +96,7 @@ # substdefault: if no value given, subst on default (result is substituted value); # susbt cmd can use variable resolvers, # works for scripted/c-methods and obj-parm, -# autmatically set by "$slot toParameterSyntax" if default contains "[" ... "]". +# autmatically set by "$slot toParameterSyntax" if default contains "[" ... "]". # # initcmd: evaluate body in an xotcl nonleaf frame, called via configure # (example: last arg on create) @@ -699,7 +699,38 @@ ? {s1 method foo {{a:substdefault [self]}} {return $a}} ::s1::foo ? {s1 foo} ::s1 } + ####################################################### +# testing substdefault for object parameters +####################################################### +Test case substdefault-objparam { + + Class create Bar { + + # simple, implicit substdefault + :attribute {s0 "[self]"} + + # explicit substdefault + :attribute {s1:substdefault "[self]"} + + # unneeded double substdefault + :attribute {s2:substdefault,substdefault "[self]"} + + # substdefault with incremental + :attribute {s3:substdefault "[self]"} { + # Bypassing the Optimizer helps after applying the patch (solving step 1) + set :incremental 1 + } + } + + Bar create ::b + ? {b s0} "::b" + ? {b s1} "::b" + ? {b s2} "::b" + ? {b s3} "::b" +} + +####################################################### # testing object types in object parameters ####################################################### Test case op-object-types { @@ -952,4 +983,5 @@ } ## TODO regression test for type checking, parameter options (initcmd, ## substdefault, combinations with defaults, ...), etc. + puts stderr =====END