Index: generic/predefined.xotcl =================================================================== diff -u -rf4471765bb7aec8c793b5e365499726619119f63 -rf11b03a9a764254c5a1ba45480ebf5eb19e2bf8d --- generic/predefined.xotcl (.../predefined.xotcl) (revision f4471765bb7aec8c793b5e365499726619119f63) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision f11b03a9a764254c5a1ba45480ebf5eb19e2bf8d) @@ -108,15 +108,15 @@ foreach cmd [info command ::xotcl::cmd::ClassInfo::*] { ::xotcl::alias ::xotcl::classInfo [namespace tail $cmd] $cmd } + unset cmd ::xotcl::alias ::xotcl::objectInfo is ::xotcl::is ::xotcl::alias ::xotcl::classInfo is ::xotcl::is ::xotcl::alias ::xotcl::classInfo classparent ::xotcl::cmd::ObjectInfo::parent ::xotcl::alias ::xotcl::classInfo classchildren ::xotcl::cmd::ObjectInfo::children - unset cmd ::xotcl::Object instforward info -onerror ::xotcl::infoError ::xotcl::objectInfo %1 {%@2 %self} ::xotcl::Class instforward info -onerror ::xotcl::infoError ::xotcl::classInfo %1 {%@2 %self} - + proc ::xotcl::infoError msg { #puts stderr "INFO ERROR: <$msg>\n$::errorInfo" regsub -all " " $msg "" msg @@ -150,6 +150,60 @@ error "unknown info option \"$method\"; [my info info]" } + # + # Backward compatibility info subcommands; TODO: should go finally into a library. + # + proc ::xotcl::info_args {inst o method} { + set result [list] + foreach \ + argName [::xotcl::classInfo ${inst}params $o $method -varNames] \ + flag [::xotcl::classInfo ${inst}params $o $method] { + if {[string match -* $flag]} continue + lappend result $argName + } + #puts stderr "+++ get ${inst}args for $o $method => $result" + return $result + } + proc ::xotcl::info_nonposargs {inst o method} { + set result [list] + foreach flag [::xotcl::classInfo ${inst}params $o $method] { + if {![string match -* $flag]} continue + lappend result $flag + } + #puts stderr "+++ get ${inst}nonposargs for $o $method => $result" + return $result + } + proc ::xotcl::info_default {inst o method arg varName} { + foreach \ + argName [::xotcl::classInfo ${inst}params $o $method -varNames] \ + flag [::xotcl::classInfo ${inst}params $o $method] { + if {$argName eq $arg} { + upvar 3 $varName default + if {[llength $flag] == 2} { + set default [lindex $flag 1] + #puts stderr "--- get ${inst}default for $o $method $arg => $default" + return 1 + } + #puts stderr "--- get ${inst}default for $o $method $arg fails" + set default "" + return 0 + } + } + error "procedure \"$method\" doesn't have an argument \"$varName\"" + } + + ::xotcl::classInfo proc instargs {o method} {::xotcl::info_args inst $o $method} + ::xotcl::classInfo proc args {o method} {::xotcl::info_args "" $o $method} + ::xotcl::objectInfo proc args {o method} {::xotcl::info_args "" $o $method} + + ::xotcl::classInfo proc instnonposargs {o method} {::xotcl::info_nonposargs inst $o $method} + ::xotcl::classInfo proc nonposargs {o method} {::xotcl::info_nonposargs "" $o $method} + ::xotcl::objectInfo proc nonposargs {o method} {::xotcl::info_nonposargs "" $o $method} + + ::xotcl::classInfo proc instdefault {o method arg var} {::xotcl::info_default inst $o $method $arg $var} + ::xotcl::classInfo proc default {o method arg var} {::xotcl::info_default "" $o $method $arg $var} + ::xotcl::objectInfo proc default {o method arg var} {::xotcl::info_default "" $o $method $arg $var} + # documentation stub object -> just ignore per default. # if xoDoc is loaded, documentation will be activated ::xotcl::Object create ::xotcl::@ @@ -799,12 +853,10 @@ # class object set obj $cl $cl superclass [$origin info superclass] - #$cl parameterclass [$origin info parameterclass] $cl instinvar [$origin info instinvar] $cl instfilter [$origin info instfilter -guards] $cl instmixin [$origin info instmixin] my copyNSVarsAndCmds ::xotcl::classes$origin ::xotcl::classes$dest - #$cl parameter [$origin info parameter] } else { # create obj set obj [[$origin info class] create $dest -noinit] @@ -814,9 +866,6 @@ $obj check [$origin info check] $obj mixin [$origin info mixin] $obj filter [$origin info filter -guards] - # set md [$origin info metadata] - # $obj metadata add $md - # foreach m $md { $obj metadata $m [$origin metadata $m] } if {[$origin info hasnamespace]} { $obj requireNamespace }