Index: generic/predefined.h =================================================================== diff -u -r663efcd5c70b2338bdfadf30e4ce125347362ec0 -r25416326167316f41d0a90ffa53bac3e1104128f --- generic/predefined.h (.../predefined.h) (revision 663efcd5c70b2338bdfadf30e4ce125347362ec0) +++ generic/predefined.h (.../predefined.h) (revision 25416326167316f41d0a90ffa53bac3e1104128f) @@ -21,6 +21,19 @@ "Object method init args {}\n" "Object method defaultmethod {} {::xotcl::self}\n" "Object method objectparameter {} {;}\n" +"Class method -per-object __unknown {name} {}\n" +"Object method alias {-per-object:switch methodName -cmd -source-object -source-method -source-per-object:switch} {\n" +"if {[info exists cmd]} {\n" +"set cmd [namespace origin $cmd]} elseif {[info exists source-method]} {\n" +"if {![info exists source-object]} {\n" +"set source-object [self]} else {\n" +"set source-object [::xotcl::dispatch ${source-object} -objscope ::xotcl::self]}\n" +"if {${source-per-object}} {\n" +"set cmd ${source-object}::$methodName} else {\n" +"set cmd ::xotcl::classes${source-object}::${source-method}}}\n" +"if {${per-object} && [::xotcl::is [self] class]} {\n" +"eval ::xotcl::alias [self] $methodName -per-object $cmd} else {\n" +"eval ::xotcl::alias [self] $methodName $cmd}}\n" "Object create ::xotcl2::objectInfo\n" "Object create ::xotcl2::classInfo\n" "foreach cmd [info command ::xotcl::cmd::ObjectInfo::*] {\n" @@ -29,35 +42,29 @@ "foreach cmd [info command ::xotcl::cmd::ClassInfo::*] {\n" "::xotcl::alias ::xotcl2::classInfo [namespace tail $cmd] $cmd}\n" "unset cmd\n" -"::xotcl::alias ::xotcl2::objectInfo is ::xotcl::is\n" -"::xotcl::alias ::xotcl2::classInfo is ::xotcl::is\n" -"::xotcl::alias ::xotcl2::classInfo classparent ::xotcl::cmd::ObjectInfo::parent\n" -"::xotcl::alias ::xotcl2::classInfo classchildren ::xotcl::cmd::ObjectInfo::children\n" -"Object instforward info -onerror ::xotcl::infoError ::xotcl2::objectInfo %1 {%@2 %self}\n" +"::xotcl::dispatch objectInfo -objscope ::eval {\n" +".alias is -cmd ::xotcl::is\n" +".method info {obj} {\n" +"set methods [list]\n" +"foreach name [::xotcl::dispatch [self] ::xotcl::cmd::ObjectInfo::methods [self] -defined] {\n" +"if {$name eq \"unknown\"} continue\n" +"lappend methods $name}\n" +"return \"valid options are: [join [lsort $methods] {, }]\"}\n" +".method unknown {method obj args} {\n" +"error \"[::xotcl::self] unknown info option \\\"$method\\\"; [$obj info info]\"}}\n" +"::xotcl::dispatch classInfo -objscope ::eval {\n" +".alias is -cmd ::xotcl::is\n" +".alias classparent -cmd ::xotcl::cmd::ObjectInfo::parent\n" +".alias classchildren -cmd ::xotcl::cmd::ObjectInfo::children\n" +".alias info -source-object objectInfo -source-per-object -source-method info\n" +".alias unknown -source-object objectInfo -source-per-object -source-method unknown}\n" +"Object instforward info -verbose -onerror ::xotcl::infoError ::xotcl2::objectInfo %1 {%@2 %self}\n" "Class instforward info -onerror ::xotcl::infoError ::xotcl2::classInfo %1 {%@2 %self}\n" "proc ::xotcl::infoError msg {\n" "regsub -all \" \" $msg \"\" msg\n" "regsub -all \" \" $msg \"\" msg\n" "regsub {\\\"} $msg \"\\\"info \" msg\n" "error $msg \"\"}\n" -"objectInfo method info {obj} {\n" -"set methods [list]\n" -"foreach m [::info commands ::xotcl::objectInfo::*] {\n" -"set name [namespace tail $m]\n" -"if {$name eq \"unknown\"} continue\n" -"lappend methods $name}\n" -"return \"valid options are: [join [lsort $methods] {, }]\"}\n" -"objectInfo method unknown {method args} {\n" -"error \"[::xotcl::self] unknown info option \\\"$method\\\"; [.info info]\"}\n" -"classInfo method info {cl} {\n" -"set methods [list]\n" -"foreach m [::info commands ::xotcl::classInfo::*] {\n" -"set name [namespace tail $m]\n" -"if {$name eq \"unknown\"} continue\n" -"lappend methods $name}\n" -"return \"valid options are: [join [lsort $methods] {, }]\"}\n" -"classInfo method unknown {method args} {\n" -"error \"[::xotcl::self] unknown info option \\\"$method\\\"; [.info info]\"}\n" "Object method abstract {methtype -per-object:switch methname arglist} {\n" "if {$methtype ne \"method\"} {\n" "error \"invalid method type '$methtype', must be 'method'\"}\n" @@ -376,8 +383,8 @@ "::xotcl2::Class create ::xotcl::CopyHandler -parameter {\n" "{targetList \"\"}\n" "{dest \"\"}\n" -"objLength}\n" -"::xotcl::CopyHandler method makeTargetList t {\n" +"objLength} {\n" +".method makeTargetList {t} {\n" "lappend .targetList $t\n" "if {[::xotcl::is $t object]} {\n" "if {[$t info hasnamespace]} {\n" @@ -388,13 +395,13 @@ "lappend children [namespace children $t]}}\n" "foreach c $children {\n" ".makeTargetList $c}}\n" -"::xotcl::CopyHandler method copyNSVarsAndCmds {orig dest} {\n" +".method copyNSVarsAndCmds {orig dest} {\n" "::xotcl::namespace_copyvars $orig $dest\n" "::xotcl::namespace_copycmds $orig $dest}\n" -"::xotcl::CopyHandler method getDest origin {\n" +".method getDest origin {\n" "set tail [string range $origin [set .objLength] end]\n" "return ::[string trimleft [set .dest]$tail :]}\n" -"::xotcl::CopyHandler method copyTargets {} {\n" +".method copyTargets {} {\n" "foreach origin [set .targetList] {\n" "set dest [.getDest $origin]\n" "if {[::xotcl::is $origin object]} {\n" @@ -436,11 +443,25 @@ "set newslot ${dest}::slot::[namespace tail $oldslot]\n" "if {[$oldslot domain] eq $origin} {$newslot domain $cl}\n" "if {[$oldslot manager] eq $oldslot} {$newslot manager $newslot}}}}}\n" -"::xotcl::CopyHandler method copy {obj dest} {\n" +".method copy {obj dest} {\n" "set .objLength [string length $obj]\n" "set .dest $dest\n" ".makeTargetList $obj\n" -".copyTargets}\n" +".copyTargets}}\n" +"::xotcl2::Object method copy newName {\n" +"if {[string compare [string trimleft $newName :] [string trimleft [::xotcl::self] :]]} {\n" +"[::xotcl::CopyHandler new -volatile] copy [::xotcl::self] $newName}}\n" +"::xotcl2::Object method move newName {\n" +"if {[string trimleft $newName :] ne [string trimleft [::xotcl::self] :]} {\n" +"if {$newName ne \"\"} {\n" +".copy $newName}\n" +"if {[::xotcl::is [::xotcl::self] class] && $newName ne \"\"} {\n" +"foreach subclass [.info subclass] {\n" +"set scl [$subclass info superclass]\n" +"if {[set index [lsearch -exact $scl [::xotcl::self]]] != -1} {\n" +"set scl [lreplace $scl $index $index $newName]\n" +"$subclass superclass $scl}} }\n" +".destroy}}\n" "::xotcl2::Object create ::xotcl::@ {\n" ".method unknown args {}}\n" "namespace eval ::xotcl {\n" @@ -536,15 +557,29 @@ "set default \"\"\n" "return 0}}\n" "error \"procedure \\\"$method\\\" doesn't have an argument \\\"$varName\\\"\"}\n" -"classInfo method instargs {o method} {::xotcl::info_args inst $o $method}\n" -"classInfo method args {o method} {::xotcl::info_args \"\" $o $method}\n" -"objectInfo method args {o method} {::xotcl::info_args \"\" $o $method}\n" -"classInfo method instnonposargs {o method} {::xotcl::info_nonposargs inst $o $method}\n" -"classInfo method nonposargs {o method} {::xotcl::info_nonposargs \"\" $o $method}\n" -"objectInfo method nonposargs {o method} {::xotcl::info_nonposargs \"\" $o $method}\n" -"classInfo method instdefault {o method arg var} {::xotcl::info_default inst $o $method $arg $var}\n" -"classInfo method default {o method arg var} {::xotcl::info_default \"\" $o $method $arg $var}\n" -"objectInfo method default {o method arg var} {::xotcl::info_default \"\" $o $method $arg $var}\n" +"classInfo eval {\n" +".method instargs {o method} {::xotcl::info_args inst $o $method}\n" +".method args {o method} {::xotcl::info_args \"\" $o $method}\n" +".method instnonposargs {o method} {::xotcl::info_nonposargs inst $o $method}\n" +".method nonposargs {o method} {::xotcl::info_nonposargs \"\" $o $method}\n" +".method instdefault {o method arg var} {::xotcl::info_default inst $o $method $arg $var}\n" +".method default {o method arg var} {::xotcl::info_default \"\" $o $method $arg $var}\n" +".method instprocs {o pattern:optional} {\n" +"if {[::info exists pattern]} {\n" +"$o info methods -defined -nocmds $pattern} {\n" +"$o info methods -defined -nocmds}}\n" +".method procs {o pattern:optional} {\n" +"if {[::info exists pattern]} {\n" +"$o info methods -defined -per-object -nocmds $pattern} {\n" +"$o info methods -defined -per-object -nocmds}}}\n" +"objectInfo eval {\n" +".method args {o method} {::xotcl::info_args \"\" $o $method}\n" +".method nonposargs {o method} {::xotcl::info_nonposargs \"\" $o $method}\n" +".method default {o method arg var} {::xotcl::info_default \"\" $o $method $arg $var}\n" +".method procs {o pattern:optional} {\n" +"if {[::info exists pattern]} {\n" +"$o info methods -defined -nocmds $pattern} {\n" +"$o info methods -defined -nocmds}}}\n" "Object method isobject {{object:substdefault \"[self]\"}} {::xotcl::is $object object}\n" "Object method isclass {{class:substdefault \"[self]\"}} {::xotcl::is $class class}\n" "Object method ismetaclass {{class:substdefault \"[self]\"}} {::xotcl::is $class metaclass}\n" @@ -584,42 +619,30 @@ "Object method -per-object unsetExitHandler {} {::xotcl::unsetExitHandler $newbody}\n" "Object method -per-object setExitHandler {newbody} {::xotcl::setExitHandler $newbody}\n" "Object method -per-object getExitHandler {} {:xotcl::getExitHandler}\n" -"::xotcl::alias ::xotcl::Class parameter ::xotcl::classes::xotcl2::Class::parameter\n" +"::xotcl::alias ::xotcl::Object copy ::xotcl::classes::xotcl2::Object::copy\n" +"::xotcl::alias ::xotcl::Object move ::xotcl::classes::xotcl2::Object::move\n" "::xotcl::alias ::xotcl::Object defaultmethod ::xotcl::classes::xotcl2::Object::defaultmethod\n" +"::xotcl::alias ::xotcl::Class __unknown -per-object ::xotcl2::Class::__unknown\n" +"::xotcl::alias ::xotcl::Class parameter ::xotcl::classes::xotcl2::Class::parameter\n" "proc myproc {args} {linsert $args 0 [::xotcl::self]}\n" "proc myvar {var} {.requireNamespace; return [::xotcl::self]::$var}\n" -"namespace export Object Class @ myproc myvar Attribute}\n" -"::xotcl::Object method copy newName {\n" -"if {[string compare [string trimleft $newName :] [string trimleft [::xotcl::self] :]]} {\n" -"[::xotcl::CopyHandler new -volatile] copy [::xotcl::self] $newName}}\n" -"::xotcl::Object method move newName {\n" -"if {[string trimleft $newName :] ne [string trimleft [::xotcl::self] :]} {\n" -"if {$newName ne \"\"} {\n" -".copy $newName}\n" -"if {[::xotcl::is [::xotcl::self] class] && $newName ne \"\"} {\n" -"foreach subclass [.info subclass] {\n" -"set scl [$subclass info superclass]\n" -"if {[set index [lsearch -exact $scl [::xotcl::self]]] != -1} {\n" -"set scl [lreplace $scl $index $index $newName]\n" -"$subclass superclass $scl}} }\n" -".destroy}}\n" -"::xotcl::Object create ::xotcl::config\n" -"::xotcl::config method load {obj file} {\n" +"Object create ::xotcl::config\n" +"config method load {obj file} {\n" "source $file\n" "foreach i [array names ::auto_index [list $obj *proc *]] {\n" "set type [lindex $i 1]\n" "set meth [lindex $i 2]\n" "if {[$obj info ${type}s $meth] == {}} {\n" "$obj $type $meth auto $::auto_index($i)}}}\n" -"::xotcl::config method mkindex {meta dir args} {\n" +"config method mkindex {meta dir args} {\n" "set sp {[ ]+}\n" "set st {^[ ]*}\n" "set wd {([^ ;]+)}\n" "foreach creator $meta {\n" "::lappend cp $st$creator${sp}create$sp$wd\n" "::lappend ap $st$creator$sp$wd}\n" -"foreach method {proc instproc} {\n" -"::lappend mp $st$wd${sp}($method)$sp$wd}\n" +"foreach methodkind {proc instproc} {\n" +"::lappend mp $st$wd${sp}($methodkind)$sp$wd}\n" "foreach cl [concat ::xotcl::Class [::xotcl::Class info heritage]] {\n" "eval ::lappend meths [$cl info instcommands]}\n" "set old [pwd]\n" @@ -661,7 +684,7 @@ "close $t\n" "cd $old\n" "return \"$oc objects, $mc methods\"}\n" -"::xotcl::Object method extractConfigureArg {al name {cutTheArg 0}} {\n" +"Object method extractConfigureArg {al name {cutTheArg 0}} {\n" "set value \"\"\n" "upvar $al argList\n" "set largs [llength $argList]\n" @@ -676,32 +699,28 @@ "if {[info exists startIndex] && $cutTheArg != 0} {\n" "set argList [lreplace $argList $startIndex [expr {$endIndex - 1}]]}\n" "return $value}\n" -"::xotcl::Object create ::xotcl::rcs\n" -"::xotcl::rcs method date string {\n" +"Object create ::xotcl::rcs\n" +"rcs method date string {\n" "lreplace [lreplace $string 0 0] end end}\n" -"::xotcl::rcs method version string {\n" +"rcs method version string {\n" "lindex $string 2}\n" -"if {![info exists ::env(HOME)]} {set ::env(HOME) /root}\n" -"set ::xotcl::confdir ~/.xotcl\n" -"set ::xotcl::logdir $::xotcl::confdir/log\n" -"::xotcl::Class method -per-object __unknown name {}\n" "::xotcl::Class method uses list {\n" "foreach package $list {\n" "::xotcl::package import -into [::xotcl::self] $package\n" "puts stderr \"*** using ${package}::* in [::xotcl::self]\"}}\n" -"::xotcl::Class create ::xotcl::package -superclass ::xotcl::Class -parameter {\n" +"::xotcl2::Class create ::xotcl::package -superclass ::xotcl::Class -parameter {\n" "provide\n" "{version 1.0}\n" "{autoexport {}}\n" -"{export {}}}\n" -"::xotcl::package method -per-object create {name args} {\n" +"{export {}}} {\n" +".method -per-object create {name args} {\n" "set nq [namespace qualifiers $name]\n" "if {$nq ne \"\" && ![namespace exists $nq]} {Object create $nq}\n" "next}\n" -"::xotcl::package method -per-object extend {name args} {\n" +".method -per-object extend {name args} {\n" ".require $name\n" "eval $name configure $args}\n" -"::xotcl::package method -per-object contains script {\n" +".method -per-object contains script {\n" "if {[.exists provide]} {\n" "package provide [set .provide] [set .version]} else {\n" "package provide [::xotcl::self] [set .version]}\n" @@ -714,15 +733,11 @@ "namespace eval [::xotcl::self] [list namespace export $e]}}\n" "foreach e [set .autoexport] {\n" "namespace eval :: [list namespace import [::xotcl::self]::$e]}}\n" -"::xotcl::package configure \\\n" -"-set component . \\\n" -"-set verbose 0 \\\n" -"-set packagecmd ::package\n" -"::xotcl::package method -per-object unknown args {\n" +".method -per-object unknown args {\n" "eval [set .packagecmd] $args}\n" -"::xotcl::package method -per-object verbose value {\n" +".method -per-object verbose value {\n" "set .verbose $value}\n" -"::xotcl::package method -per-object present args {\n" +".method -per-object present args {\n" "if {$::tcl_version<8.3} {\n" "switch -exact -- [lindex $args 0] {\n" "-exact {set pkg [lindex $args 1]}\n" @@ -731,15 +746,15 @@ "return ${.loaded}($pkg)} else {\n" "error \"not found\"}} else {\n" "eval [set .packagecmd] present $args}}\n" -"::xotcl::package method -per-object import {{-into ::} pkg} {\n" +".method -per-object import {{-into ::} pkg} {\n" ".require $pkg\n" "namespace eval $into [subst -nocommands {\n" "namespace import ${pkg}::*}]\n" "foreach e [$pkg export] {\n" "set nq [namespace qualifiers $e]\n" "if {$nq ne \"\"} {\n" "namespace eval $into$nq [list namespace import ${pkg}::$e]}}}\n" -"::xotcl::package method -per-object require args {\n" +".method -per-object require args {\n" "set prevComponent ${.component}\n" "if {[catch {set v [eval package present $args]} msg]} {\n" "switch -exact -- [lindex $args 0] {\n" @@ -754,7 +769,15 @@ "set .loaded($pkg) $v ;# loaded stuff needed for Tcl 8.0}}\n" "set .component $prevComponent\n" "return $v}\n" +"set .component .\n" +"set .verbose 0\n" +"set .packagecmd ::package}\n" +"namespace export Object Class myproc myvar}\n" "namespace eval ::xotcl {\n" +"namespace export @ Attribute\n" +"if {![info exists ::env(HOME)]} {set ::env(HOME) /root}\n" +"set ::xotcl::confdir ~/.xotcl\n" +"set ::xotcl::logdir $::xotcl::confdir/log\n" "proc tmpdir {} {\n" "foreach e [list TMPDIR TEMP TMP] {\n" "if {[info exists ::env($e)] \\\n"