Index: TODO =================================================================== diff -u -r3be87f20ac5f89fac33e2db3b95e80c9adfc92d9 -r4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5 --- TODO (.../TODO) (revision 3be87f20ac5f89fac33e2db3b95e80c9adfc92d9) +++ TODO (.../TODO) (revision 4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5) @@ -4589,12 +4589,31 @@ Allowing 0..n makes the usage simpler and the program shorter. +Removed oboslete item. At least in this concrete form, the +warning does not show up. +- NSF_WITH_VALUE_WARNINGS: Right now, value warnings are also fired + for arg vectors with a delimiting "--"; right now, this gives a warning: + + Object create o { + :public object method foo {-np1 -np2 p1} { + return $p1 + } + } + + ? {o foo -np1 1 -np2 2 -- -X} "-X" + +nsf.c: +- when creation with an required configure parameter failed, + delete the half-baked object to avoid confusing states. + ======================================================================== TODO: - handling of "required" in reconfigure (see parameter-object-mixin-dependency in parameters.test) - handling of recreate (see regression test for class-level properties) + + - maybe "::nsf::object::property /obj/ volatile 0|1" to alter volatile state. @@ -4840,22 +4859,6 @@ TODO "Kleinigkeiten" -- NSF_WITH_VALUE_WARNINGS: Right now, value warnings are also fired - for arg vectors with a delimiting "--"; right now, this gives a warning: - - Object create o { - :public method foo {-np1 -np2 p1} { - return $p1 - } - } - - ? {o foo -np1 1 -np2 2 -- -X} "-X" - - However, the warning-generating code in Nsf_ConvertToTclobj() does - not receive any word of a dashdash having been processed in the - overall argv ... the NSF_ARG_CHECK_NONPOS set on the parsed (and - cached) param is the only condition to must hold. - - should we continue to work on the problem of the interp-aliased class, exported from one ns, imported into another one? Index: generic/nsf.c =================================================================== diff -u -re0419345b49587b5738f87c6d828dfc5ae4b3276 -r4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5 --- generic/nsf.c (.../nsf.c) (revision e0419345b49587b5738f87c6d828dfc5ae4b3276) +++ generic/nsf.c (.../nsf.c) (revision 4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5) @@ -15594,6 +15594,12 @@ if (likely(result == TCL_OK)) { Tcl_SetObjResult(interp, savedObjResult); } + } else { + /* + * Configure failed, therefore, the object might be in an undefined + * state. To avoid strange errors, we delete the half-baked object. + */ + DispatchDestroyMethod(interp, (NsfObject *)object, 0); } NsfCleanupObject(object, "obj init"); Index: library/xotcl/tests/slottest.xotcl =================================================================== diff -u -r9cead8929011bb4dcc6c44630a91bc5d597520b2 -r4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5 --- library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 9cead8929011bb4dcc6c44630a91bc5d597520b2) +++ library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5) @@ -379,7 +379,7 @@ set ::_ "" ? {C create c2 -y 1 -x} {value for parameter '-x' expected} ? {set ::_} "" - ? {c2 x} {can't read "x": no such variable} + ? {::nsf::is object c2} 0 ? {C create c3 -y 1 -x 0} "::c3" ? {set ::_} "" ? {c3 x} "0" Index: tests/disposition.test =================================================================== diff -u -r9cead8929011bb4dcc6c44630a91bc5d597520b2 -r4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5 --- tests/disposition.test (.../disposition.test) (revision 9cead8929011bb4dcc6c44630a91bc5d597520b2) +++ tests/disposition.test (.../disposition.test) (revision 4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5) @@ -833,28 +833,28 @@ # C setObjectParams {{args:alias,int,method=Residualargs,args {hello world}}} ? {C create c1} {refuse to redefine parameter type of 'args' from type 'integer' to type 'args'} - ? {c1 eval {info exists :args}} 0 + ? {nsf::is object c1} 0 C setObjectParams {{args:int,alias,method=Residualargs,args {hello world}}} ? {C create c1} {refuse to redefine parameter type of 'args' from type 'integer' to type 'args'} - ? {c1 eval {info exists :args}} 0 + ? {nsf::is object c1} 0 # # don't allow multiplicity settings for parameter option "args" # C setObjectParams {{args:alias,method=Residualargs,0..n,args {hello world}}} ? {C create c1} {multiplicity settings for variable argument parameter "args" not allowed} - ? {c1 eval {info exists :args}} 0 + ? {nsf::is object c1} 0 C setObjectParams {args:alias,method=Residualargs,args,1..n} ? {C create c1} {multiplicity settings for variable argument parameter "args" not allowed} - ? {c1 eval {info exists :args}} 0 + ? {nsf::is object c1} 0 # # make sure, parameter with parameter option "args" is used in last parameter # C setObjectParams {a:alias,method=Residualargs,args -b:integer} ? {C create c1 hello world} {parameter option "args" invalid for parameter "a"; only allowed for last parameter} - ? {c1 eval {info exists :args}} 0 + ? {nsf::is object c1} 0 } Index: tests/parameters.test =================================================================== diff -u -r3be87f20ac5f89fac33e2db3b95e80c9adfc92d9 -r4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5 --- tests/parameters.test (.../parameters.test) (revision 3be87f20ac5f89fac33e2db3b95e80c9adfc92d9) +++ tests/parameters.test (.../parameters.test) (revision 4c6c39cd6a1aa703a9a8cf7dc89baf7d4a58d6c5) @@ -1663,19 +1663,40 @@ } } +# +# test required configure parameter +# + nx::Test case req-param { ::nx::Class create C { :property y:required :property x:required - :method init args {set ::_ $args} + :method init args {set ::_ "passed args '$args'"} } set ::_ "" ? {C create c2 -y 1 -x} {value for parameter '-x' expected} + + # Was the constructor called? Should not. ? {set ::_} "" - ? {c2 cget -x} {can't read "x": no such variable} - ? {C create c3 -y 1 -x 0} "::c3" + + # Did the object survive the error? Should not. + ? {::nsf::is object c2} 0 + + set ::_ "" + ? {C create c2} \ +"required argument 'x' is missing, should be: + ::c2 __configure -x /value/ -y /value/ ?-volatile? ?-noinit? ?-object-mixin /mixinreg .../? ?-class /class/? ?-object-filter /filterreg .../? ?/__initblock/?" + + # Was the constructor called? Should not. ? {set ::_} "" + + # Did the object survive the error? Should not. + ? {::nsf::is object c2} 0 + + # The following should run through without erros + ? {C create c3 -y 1 -x 0} "::c3" + ? {set ::_} "passed args ''" ? {c3 cget -x} "0" } @@ -1830,6 +1851,8 @@ ? {::C::slot::x2 getParameterSpec} {-x2:alias,substdefault {[self]}} } + + # # Test interactions between per-object-mixins and objectparameters # (case without per-object property)