Index: library/nx/nx.tcl =================================================================== diff -u -ra866226c4ca39c65f5f98539c140326c617da884 -rbae2fc790df28562c0d80e54bf83ef0d97de250d --- library/nx/nx.tcl (.../nx.tcl) (revision a866226c4ca39c65f5f98539c140326c617da884) +++ library/nx/nx.tcl (.../nx.tcl) (revision bae2fc790df28562c0d80e54bf83ef0d97de250d) @@ -1638,7 +1638,11 @@ ::nx::VariableSlot protected method getParameterOptions { {-withMultiplicity 0} {-forObjectParameter 0} + {-forValueCheck 0} } { + if {$forObjectParameter && $forValueCheck} { + error "The options 'forObjectParameter' and 'forValueCheck' are mutually exclusive." + } set options "" set slotObject "" if {[info exists :type]} { @@ -1666,20 +1670,26 @@ # In case the "get" method was provided on the slot, ask nsf to call it directly lappend options slot=[::nsf::self] } - if {[:info lookup method initialize] ne "" && $forObjectParameter} { - if {"slot=[::nsf::self]" ni $options} {lappend options slot=[::nsf::self]} - lappend options slotinitialize - } - if {[info exists :arg]} {lappend options arg=${:arg}} - if {${:required}} { - lappend options required - } elseif {[info exists :positional] && ${:positional}} { - lappend options optional - } - if {${:convert}} {lappend options convert} + if {$withMultiplicity && [info exists :multiplicity] && ${:multiplicity} ne "1..1"} { lappend options ${:multiplicity} } + + if {[info exists :arg]} {lappend options arg=${:arg}} + + if {!$forValueCheck} { + if {[:info lookup method initialize] ne "" && $forObjectParameter} { + if {"slot=[::nsf::self]" ni $options} {lappend options slot=[::nsf::self]} + lappend options slotinitialize + } + if {${:required}} { + lappend options required + } elseif {[info exists :positional] && ${:positional}} { + lappend options optional + } + if {${:convert}} {lappend options convert} + } + if {$forObjectParameter} { if {[info exists :substdefault] && ${:substdefault}} { lappend options substdefault @@ -1688,7 +1698,7 @@ lappend options noconfig } } - #puts stderr "*** getParameterOptions [self] returns '$options'" + puts stderr "*** getParameterOptions [self] returns '$options'" return $options } Index: tests/parameters.test =================================================================== diff -u -ra866226c4ca39c65f5f98539c140326c617da884 -rbae2fc790df28562c0d80e54bf83ef0d97de250d --- tests/parameters.test (.../parameters.test) (revision a866226c4ca39c65f5f98539c140326c617da884) +++ tests/parameters.test (.../parameters.test) (revision bae2fc790df28562c0d80e54bf83ef0d97de250d) @@ -2232,6 +2232,23 @@ } +nx::Test case object-level-defaults { + # + # Right now, this fails yelling: + # 'invalid value constraints "slot=::objekt::per-object-slot::a,slotassign"' + # + nx::Object create objekt + ? {objekt eval {info exists :a}} 0 + ? {catch { + objekt variable -accessor -initblock { + :public method assign args { + next + } + } a 1}} 0 + ? {objekt eval {info exists :a}} 1 + ? {objekt a} 1 +} + # # test class level property and variable #