Index: TODO =================================================================== diff -u -r7e20ec3d04d3b6a0789c26b4e77a2291df02f609 -r353fdf460e5124d48f9ebe0f37e23abe51494b38 --- TODO (.../TODO) (revision 7e20ec3d04d3b6a0789c26b4e77a2291df02f609) +++ TODO (.../TODO) (revision 353fdf460e5124d48f9ebe0f37e23abe51494b38) @@ -5789,6 +5789,12 @@ - Allow combination of "-trace get" with default value (was previously disallowed) - Extend regression test +xotcl2: +- added "-returns" flag similar instprocs/procs and method, very similar + to nx +- extended serializer to handle "-returns" flag +- extended regression test + ======================================================================== TODO: Index: library/serialize/serializer.tcl =================================================================== diff -u -rf9f501ffe3b3bd7a3843416f82fc6189be2634ff -r353fdf460e5124d48f9ebe0f37e23abe51494b38 --- library/serialize/serializer.tcl (.../serializer.tcl) (revision f9f501ffe3b3bd7a3843416f82fc6189be2634ff) +++ library/serialize/serializer.tcl (.../serializer.tcl) (revision 353fdf460e5124d48f9ebe0f37e23abe51494b38) @@ -1035,9 +1035,15 @@ regsub "^(.*) (public|protected|private) object alias" $def {::nsf::method::alias \1 -per-object} def } } else { + if {$perObject eq ""} { + set returns [::nsf::method::property $o $m returns] + } else { + set returns [::nsf::method::property $o -per-object $m returns] + } set arglist [$o ::nsf::methods::${scope}::info::method parameter $m] lappend def ${:targetName} ${prefix}proc $m \ $arglist \ + {*}[expr {$returns ne "" ? [list -returns $returns] : {}}] \ [$o ::nsf::methods::${scope}::info::method body $m] foreach p {pre post} { set cond [$o ::nsf::methods::${scope}::info::method ${p}condition $m] Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -r52a6105ea8b966cf8cc33d2201f8d7fa8c05dbc3 -r353fdf460e5124d48f9ebe0f37e23abe51494b38 --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 52a6105ea8b966cf8cc33d2201f8d7fa8c05dbc3) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 353fdf460e5124d48f9ebe0f37e23abe51494b38) @@ -311,47 +311,51 @@ # define instproc and proc ::nsf::method::create Class instproc { -debug:switch -deprecated:switch - name arguments:parameter,0..* body precondition:optional postcondition:optional + name arguments:parameter,0..* -returns body precondition:optional postcondition:optional } { set conditions [list] if {[info exists precondition]} {lappend conditions -precondition $precondition} if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} set r [::nsf::method::create [self] $name $arguments $body {*}$conditions] if {$debug} {::nsf::method::property [self] $r debug true} if {$deprecated} {::nsf::method::property [self] $r deprecated true} + if {[info exists returns]} {::nsf::method::property [self] $r returns $returns} return $r } ::nsf::method::create Object proc { - -debug:switch -deprecated:switch - name arguments body precondition:optional postcondition:optional + -debug:switch -deprecated:switch + name arguments -returns body precondition:optional postcondition:optional } { set conditions [list] if {[info exists precondition]} {lappend conditions -precondition $precondition} if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} set r [::nsf::method::create [self] -per-object $name $arguments $body {*}$conditions] if {$debug} {::nsf::method::property [self] $r debug true} if {$deprecated} {::nsf::method::property [self] $r deprecated true} + if {[info exists returns]} {::nsf::method::property [self] $r returns $returns} return $r } # define a minimal implementation of "method" Object instproc method { - -debug:switch -deprecated:switch - name arguments:parameter,0..* body + -debug:switch -deprecated:switch + name arguments:parameter,0..* -returns body } { - :proc -debug=$debug -deprecated=$deprecated $name $arguments $body - } + set returns_flag [expr {[info exists returns] ? [list -returns $returns] : {}}] + :proc -debug=$debug -deprecated=$deprecated $name $arguments {*}$returns_flag $body + } Class instproc method { -debug:switch -deprecated:switch -per-object:switch name arguments:parameter,0..* body } { - if {${per-object}} { - :proc -debug=$debug -deprecated=$deprecated $name $arguments $body - } else { - :instproc -debug=$debug -deprecated=$deprecated $name $arguments $body - } - } + set returns_flag [expr {[info exists returns] ? [list -returns $returns] : {}}] + if {${per-object}} { + :proc -debug=$debug -deprecated=$deprecated $name $arguments {*}$returns_flag $body + } else { + :instproc -debug=$debug -deprecated=$deprecated $name $arguments {*}$returns_flag $body + } + } # define forward methods # Index: library/xotcl/tests/slottest.xotcl =================================================================== diff -u -rdadf28efd0707ae40076f49837e6b45ad5b2a989 -r353fdf460e5124d48f9ebe0f37e23abe51494b38 --- library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision dadf28efd0707ae40076f49837e6b45ad5b2a989) +++ library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 353fdf460e5124d48f9ebe0f37e23abe51494b38) @@ -710,6 +710,27 @@ ? {::nsf::method::property o obar debug} 1 } +nx::test case nx-retuns+serialize { + + ::xotcl::Class create Context + ? {Context instproc default_form_loader {arg} -returns integer { + return $arg + }} "::nsf::classes::Context::default_form_loader" + + Context create c + ? {c default_form_loader 0} 0 + ? {c default_form_loader ""} {expected integer but got "" as return value} + + set ::string [Context serialize] + c destroy + Context destroy + + ? {eval $::string} "::nsf::classes::Context::default_form_loader" + Context create c + ? {c default_form_loader 0} 0 + ? {c default_form_loader ""} {expected integer but got "" as return value} +} + # # Local variables: # mode: tcl