Index: generic/predefined.h =================================================================== diff -u -rfad871fc9a27570119d6bf9dbed84b7469701bd6 -rc11ab22190bdfe6231b454e9969b6ffafb547f9c --- generic/predefined.h (.../predefined.h) (revision fad871fc9a27570119d6bf9dbed84b7469701bd6) +++ generic/predefined.h (.../predefined.h) (revision c11ab22190bdfe6231b454e9969b6ffafb547f9c) @@ -1,5 +1,6 @@ static char cmd[] = -"# first we create the ::xotcl2 object system.\n" +"#\n" +"set bootstrap 1\n" "namespace eval xotcl2 {\n" "namespace path ::xotcl\n" "::xotcl::createobjectsystem ::xotcl2::Object ::xotcl2::Class\n" @@ -19,24 +20,24 @@ "error \"[self]: unable to dispatch method '$m'\"}}\n" "Object method init args {}\n" "Object method objectparameter {} {;}\n" -"Class create ParameterType\n" +"Class create ::xotcl2::ParameterType\n" "foreach cmd [info command ::xotcl::cmd::ParameterType::*] {\n" -"::xotcl::alias ParameterType [namespace tail $cmd] $cmd}\n" -"ParameterType create parameterType\n" -"Object create objectInfo\n" -"Object create classInfo\n" +"::xotcl::alias ::xotcl2::ParameterType [namespace tail $cmd] $cmd}\n" +"::xotcl2::ParameterType create ::xotcl2::parameterType\n" +"Object create ::xotcl2::objectInfo\n" +"Object create ::xotcl2::classInfo\n" "foreach cmd [info command ::xotcl::cmd::ObjectInfo::*] {\n" -"::xotcl::alias objectInfo [namespace tail $cmd] $cmd\n" -"::xotcl::alias classInfo [namespace tail $cmd] $cmd}\n" +"::xotcl::alias ::xotcl2::objectInfo [namespace tail $cmd] $cmd\n" +"::xotcl::alias ::xotcl2::classInfo [namespace tail $cmd] $cmd}\n" "foreach cmd [info command ::xotcl::cmd::ClassInfo::*] {\n" -"::xotcl::alias classInfo [namespace tail $cmd] $cmd}\n" +"::xotcl::alias ::xotcl2::classInfo [namespace tail $cmd] $cmd}\n" "unset cmd\n" -"::xotcl::alias objectInfo is ::xotcl::is\n" -"::xotcl::alias classInfo is ::xotcl::is\n" -"::xotcl::alias classInfo classparent ::xotcl::cmd::ObjectInfo::parent\n" -"::xotcl::alias classInfo classchildren ::xotcl::cmd::ObjectInfo::children\n" -"Object instforward info -onerror ::xotcl::infoError ::xotcl::objectInfo %1 {%@2 %self}\n" -"Class instforward info -onerror ::xotcl::infoError ::xotcl::classInfo %1 {%@2 %self}\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" +"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" @@ -62,32 +63,32 @@ "error \"unknown info option \\\"$method\\\"; [.info info]\"}\n" "namespace export Object Class}\n" "namespace eval ::xotcl {\n" -"::xotcl::createobjectsystem ::xotcl::Object ::xotcl::Class}\n" -"set bootstrap 1\n" +"::xotcl::createobjectsystem ::xotcl::Object ::xotcl::Class\n" "foreach cmd [info command ::xotcl::cmd::Object::*] {\n" -"::xotcl::alias ::xotcl::Object [namespace tail $cmd] $cmd}\n" +"::xotcl::alias Object [namespace tail $cmd] $cmd}\n" "foreach cmd {array append eval incr lappend set subst unset trace} {\n" -"::xotcl::alias ::xotcl::Object $cmd -objscope ::$cmd}\n" +"::xotcl::alias Object $cmd -objscope ::$cmd}\n" "foreach cmd [info command ::xotcl::cmd::Class::*] {\n" -"::xotcl::alias ::xotcl::Class [namespace tail $cmd] $cmd}\n" -"::xotcl::methodproperty ::xotcl::Object destroy static true\n" -"::xotcl::methodproperty ::xotcl::Class alloc static true\n" -"::xotcl::methodproperty ::xotcl::Class dealloc static true\n" -"::xotcl::methodproperty ::xotcl::Class create static true\n" -"::xotcl::Class method unknown {args} {\n" +"::xotcl::alias Class [namespace tail $cmd] $cmd}\n" +"unset cmd\n" +"::xotcl::methodproperty Object destroy static true\n" +"::xotcl::methodproperty Class alloc static true\n" +"::xotcl::methodproperty Class dealloc static true\n" +"::xotcl::methodproperty Class create static true\n" +"Class method unknown {args} {\n" "eval my create $args}\n" -"::xotcl::Object method unknown {m args} {\n" +"Object method unknown {m args} {\n" "if {![self isnext]} {\n" "error \"[self]: unable to dispatch method '$m'\"}}\n" -"::xotcl::Object method init args {}\n" -"::xotcl::Object method objectparameter {} {;}\n" -"::xotcl::Class create ::xotcl::ParameterType\n" +"Object method init args {}\n" +"Object method objectparameter {} {;}\n" +"Class create ::xotcl::ParameterType\n" "foreach cmd [info command ::xotcl::cmd::ParameterType::*] {\n" "::xotcl::alias ::xotcl::ParameterType [namespace tail $cmd] $cmd}\n" "::xotcl::alias ::xotcl::ParameterType type=switch ::xotcl::cmd::ParameterType::type=boolean\n" "::xotcl::ParameterType create ::xotcl::parameterType\n" -"::xotcl::Object create ::xotcl::objectInfo\n" -"::xotcl::Object create ::xotcl::classInfo\n" +"Object create ::xotcl::objectInfo\n" +"Object create ::xotcl::classInfo\n" "foreach cmd [info command ::xotcl::cmd::ObjectInfo::*] {\n" "::xotcl::alias ::xotcl::objectInfo [namespace tail $cmd] $cmd\n" "::xotcl::alias ::xotcl::classInfo [namespace tail $cmd] $cmd}\n" @@ -98,30 +99,30 @@ "::xotcl::alias ::xotcl::classInfo is ::xotcl::is\n" "::xotcl::alias ::xotcl::classInfo classparent ::xotcl::cmd::ObjectInfo::parent\n" "::xotcl::alias ::xotcl::classInfo classchildren ::xotcl::cmd::ObjectInfo::children\n" -"::xotcl::Object instforward info -onerror ::xotcl::infoError ::xotcl::objectInfo %1 {%@2 %self}\n" -"::xotcl::Class instforward info -onerror ::xotcl::infoError ::xotcl::classInfo %1 {%@2 %self}\n" +"Object instforward info -onerror ::xotcl::infoError ::xotcl::objectInfo %1 {%@2 %self}\n" +"Class instforward info -onerror ::xotcl::infoError ::xotcl::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" -"::xotcl::objectInfo method info {obj} {\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" -"::xotcl::objectInfo method unknown {method args} {\n" +"objectInfo method unknown {method args} {\n" "error \"unknown info option \\\"$method\\\"; [.info info]\"}\n" -"::xotcl::classInfo method info {cl} {\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" -"::xotcl::classInfo method unknown {method args} {\n" +"classInfo method unknown {method args} {\n" "error \"unknown info option \\\"$method\\\"; [.info info]\"}\n" "# info instargs\n" "# istype\n" @@ -151,52 +152,51 @@ "set default \"\"\n" "return 0}}\n" "error \"procedure \\\"$method\\\" doesn't have an argument \\\"$varName\\\"\"}\n" -"::xotcl::classInfo method instargs {o method} {::xotcl::info_args inst $o $method}\n" -"::xotcl::classInfo method args {o method} {::xotcl::info_args \"\" $o $method}\n" -"::xotcl::objectInfo method args {o method} {::xotcl::info_args \"\" $o $method}\n" -"::xotcl::classInfo method instnonposargs {o method} {::xotcl::info_nonposargs inst $o $method}\n" -"::xotcl::classInfo method nonposargs {o method} {::xotcl::info_nonposargs \"\" $o $method}\n" -"::xotcl::objectInfo method nonposargs {o method} {::xotcl::info_nonposargs \"\" $o $method}\n" -"::xotcl::classInfo method instdefault {o method arg var} {::xotcl::info_default inst $o $method $arg $var}\n" -"::xotcl::classInfo method default {o method arg var} {::xotcl::info_default \"\" $o $method $arg $var}\n" -"::xotcl::objectInfo method default {o method arg var} {::xotcl::info_default \"\" $o $method $arg $var}\n" -"::xotcl::Object method isobject {{object:substdefault \"[self]\"}} {::xotcl::is $object object}\n" -"::xotcl::Object method isclass {{class:substdefault \"[self]\"}} {::xotcl::is $class class}\n" -"::xotcl::Object method ismetaclass {{class:substdefault \"[self]\"}} {::xotcl::is $class metaclass}\n" -"::xotcl::Object method ismixin {class} {::xotcl::is [self] mixin $class}\n" -"::xotcl::Object method istype {class} {::xotcl::is [self] type $class}\n" -"::xotcl::Object method proc {name arglist body precondition:optional postcondition:optional} {\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" +"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" +"Object method ismixin {class} {::xotcl::is [self] mixin $class}\n" +"Object method istype {class} {::xotcl::is [self] type $class}\n" +"Object method proc {name arglist body precondition:optional postcondition:optional} {\n" "set cmd [list my method $name $arglist $body]\n" "if {[info exists precondition]} {lappend cmd -precondition $precondition}\n" "if {[info exists postcondition]} {lappend cmd -postcondition $postcondition}\n" "eval $cmd}\n" -"::xotcl::Class method proc {name arglist body precondition:optional postcondition:optional} {\n" +"Class method proc {name arglist body precondition:optional postcondition:optional} {\n" "set cmd [list my method -per-object $name $arglist $body]\n" "if {[info exists precondition]} {lappend cmd -precondition $precondition}\n" "if {[info exists postcondition]} {lappend cmd -postcondition $postcondition}\n" "eval $cmd}\n" -"::xotcl::Class method instproc {name arglist body precondition:optional postcondition:optional} {\n" +"Class method instproc {name arglist body precondition:optional postcondition:optional} {\n" "set cmd [list my method $name $arglist $body]\n" "if {[info exists precondition]} {lappend cmd -precondition $precondition}\n" "if {[info exists postcondition]} {lappend cmd -postcondition $postcondition}\n" "eval $cmd}\n" -"::xotcl::Object create ::xotcl::@\n" -"::xotcl::@ method unknown args {}\n" -"proc ::xotcl::myproc {args} {linsert $args 0 [::xotcl::self]}\n" -"proc ::xotcl::myvar {var} {.requireNamespace; return [::xotcl::self]::$var}\n" -"namespace eval ::xotcl {\n" +"Object create ::xotcl::@\n" +"@ method unknown args {}\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::Class create ::xotcl::MetaSlot\n" -"::xotcl::relation ::xotcl::MetaSlot superclass ::xotcl::Class\n" +"::xotcl2::Class create ::xotcl::MetaSlot\n" +"::xotcl::relation ::xotcl::MetaSlot superclass ::xotcl2::Class\n" "::xotcl::MetaSlot method new args {\n" "set slotobject [::xotcl::self callingobject]::slot\n" -"if {![::xotcl::is $slotobject object]} {::xotcl::Object create $slotobject}\n" +"if {![::xotcl::is $slotobject object]} {::xotcls::Object create $slotobject}\n" "eval next -childof $slotobject $args}\n" "::xotcl::MetaSlot create ::xotcl::Slot\n" "::xotcl::MetaSlot invalidateobjectparameter\n" "proc ::xotcl::parametersFromSlots {obj} {\n" "set parameterdefinitions [list]\n" -"set slots [::xotcl::objectInfo slotobjects $obj]\n" +"set slots [::xotcl2::objectInfo slotobjects $obj]\n" "foreach slot $slots {\n" "set parameterdefinition \"-[namespace tail $slot]\"\n" "set opts [list]\n" @@ -227,7 +227,7 @@ "return $parameterdefinitions}\n" "proc createBootstrapAttributeSlots {class definitions} {\n" "if {![::xotcl::is ${class}::slot object]} {\n" -"::xotcl::Object create ${class}::slot}\n" +"::xotcl2::Object create ${class}::slot}\n" "foreach att $definitions {\n" "if {[llength $att]>1} {foreach {att default} $att break}\n" "::xotcl::Slot create ${class}::slot::$att\n" @@ -240,7 +240,8 @@ "if {[info exists default]} {\n" "foreach i [$class info instances] {\n" "if {![$i exists $att]} {\n" -"if {[string match {*[*]*} $default]} {set default [$i eval subst $default]}\n" +"if {[string match {*[*]*} $default]} {\n" +"set default [::xotcl::dispatch $i -objscope ::eval subst $default]}\n" "::xotcl::setinstvar $i $att $default}}\n" "unset default}}\n" "$class invalidateobjectparameter}\n" @@ -273,24 +274,25 @@ "::xotcl::Slot method unknown {method args} {\n" "set methods [list]\n" "foreach m [.info methods] {\n" -"if {[::xotcl::Object info methods $m] ne \"\"} continue\n" +"if {[::xotcl2::Object info methods $m] ne \"\"} continue\n" "if {[string match __* $m]} continue\n" "lappend methods $m}\n" "error \"Method '$method' unknown for slot [::xotcl::self]; valid are: {[lsort $methods]]}\"}\n" "::xotcl::Slot method destroy {} {\n" "if {${.domain} ne \"\"} {\n" "${.domain} invalidateobjectparameter}\n" "next}\n" -"::xotcl::Slot method init {} {\n" +"::xotcl::Slot method init {args} {\n" "set forwarder [expr {${.per-object} ? \"forward\" : \"instforward\"}]\n" "if {${.domain} eq \"\"} {\n" "set .domain [::xotcl::self callingobject]} else {\n" "${.domain} invalidateobjectparameter}\n" -"${.domain} $forwarder ${.name} -default [${.manager} defaultmethods] ${.manager} %1 %self %proc}\n" +"if {${.domain} ne \"\"} {\n" +"${.domain} $forwarder ${.name} -default [${.manager} defaultmethods] ${.manager} %1 %self %proc}}\n" "::xotcl::MetaSlot create ::xotcl::InfoSlot\n" "createBootstrapAttributeSlots ::xotcl::InfoSlot {\n" "{multivalued true}\n" -"{elementtype ::xotcl::Class}}\n" +"{elementtype ::xotcl2::Class}}\n" "::xotcl::relation ::xotcl::InfoSlot superclass ::xotcl::Slot\n" "::xotcl::InfoSlot method get {obj prop} {$obj info $prop}\n" "::xotcl::InfoSlot method add {obj prop value {pos 0}} {\n" @@ -338,6 +340,7 @@ "-elementtype \"\" \\\n" "-type relation}\n" "::xotcl::MetaSlot create ::xotcl::Attribute -superclass ::xotcl::Slot\n" +"::xotcl::relation ::xotcl::Attribute superclass ::xotcl::Slot\n" "createBootstrapAttributeSlots ::xotcl::Attribute {\n" "{value_check once}\n" "initcmd\n" @@ -350,9 +353,7 @@ "::xotcl::setinstvar $obj $var [$obj eval $cmd]}\n" "::xotcl::Attribute method __value_changed_cmd {obj cmd var sub op} {\n" "eval $cmd}\n" -"::xotcl::Attribute method check_single_value {\n" -"{-keep_old_value:boolean true}\n" -"value predicate type obj var} {\n" +"::xotcl::Attribute method check_single_value { {-keep_old_value:boolean true} value predicate type obj var} {\n" "if {![expr $predicate]} {\n" "if {[$obj exists __oldvalue($var)]} {\n" "::xotcl::setinstvar $obj $var [::xotcl::setinstvar $obj __oldvalue($var)]} else {\n" @@ -390,10 +391,10 @@ "\\[list [::xotcl::self] __value_changed_cmd \\[::xotcl::self\\] [list [set .valuechangedcmd]]\\]\"}\n" "if {$__initcmd ne \"\"} {\n" "set .initcmd $__initcmd}}\n" -"::xotcl::Class create ::xotcl::Slot::Nocheck \\\n" +"::xotcl2::Class create ::xotcl::Slot::Nocheck \\\n" "-method check_single_value args {;} -method check_multiple_values args {;} \\\n" "-method mk_type_checker args {return \"\"}\n" -"::xotcl::Class create ::xotcl::Slot::Optimizer \\\n" +"::xotcl2::Class create ::xotcl::Slot::Optimizer \\\n" "-method proc args {::xotcl::next; .optimize} \\\n" "-method forward args {::xotcl::next; .optimize} \\\n" "-method init args {::xotcl::next; .optimize} \\\n" @@ -405,36 +406,38 @@ "set forwarder [expr {[set .per-object] ? \"parametercmd\":\"instparametercmd\"}]\n" "${.domain} $forwarder ${.name}}\n" "::xotcl::Attribute instmixin add ::xotcl::Slot::Optimizer\n" -"::xotcl::Class create ::xotcl::ScopedNew -superclass ::xotcl::Class\n" +"::xotcl2::Class create ::xotcl::ScopedNew -superclass ::xotcl2::Class\n" "createBootstrapAttributeSlots ::xotcl::ScopedNew {\n" -"{withclass ::xotcl::Object}\n" +"{withclass ::xotcl2::Object}\n" "inobject}\n" "::xotcl::ScopedNew method init {} {\n" ".method new {-childof args} {\n" "[::xotcl::self class] instvar {inobject object} withclass\n" "if {![::xotcl::is $object object]} {\n" "$withclass create $object}\n" "eval ::xotcl::next -childof $object $args}}\n" -"::xotcl::Object method contains {\n" +"::xotcl2::Object method contains {\n" "{-withnew:boolean true}\n" "-object\n" -"{-class ::xotcl::Object}\n" +"{-class ::xotcl2::Object}\n" "cmds} {\n" "if {![info exists object]} {set object [::xotcl::self]}\n" "if {![::xotcl::is $object object]} {$class create $object}\n" "$object requireNamespace\n" "if {$withnew} {\n" "set m [::xotcl::ScopedNew new \\\n" "-inobject $object -withclass $class -volatile]\n" -"::xotcl::Class instmixin add $m end\n" +"::xotcl2::Class instmixin add $m end\n" "namespace eval $object $cmds\n" -"::xotcl::Class instmixin delete $m} else {\n" +"::xotcl2::Class instmixin delete $m} else {\n" "namespace eval $object $cmds}}\n" +"::xotcl2::Class instforward slots %self contains \\\n" +"-object {%::xotcl::dispatch [::xotcl::self] -objscope ::subst [::xotcl::self]::slot}\n" "::xotcl::Class instforward slots %self contains \\\n" "-object {%::xotcl::dispatch [::xotcl::self] -objscope ::subst [::xotcl::self]::slot}\n" -"::xotcl::Class method parameter arglist {\n" +"::xotcl2::Class method parameter arglist {\n" "if {![::xotcl::is [::xotcl::self]::slot object]} {\n" -"::xotcl::Object create [::xotcl::self]::slot}\n" +"::xotcl2::Object create [::xotcl::self]::slot}\n" "foreach arg $arglist {\n" "set l [llength $arg]\n" "set name [lindex $arg 0]\n" @@ -461,7 +464,7 @@ "lappend cmd -default $paramstring\n" "eval $cmd\n" "continue}\n" -"set po ::xotcl::Class::Parameter\n" +"set po ::xotcl2::Class::Parameter\n" "puts stderr \"deprecated parameter usage '$arg'; use '-slots {Attribute ...}' instead\"\n" "set cl [::xotcl::self]\n" "::xotcl::setinstvar $po name $name\n" @@ -491,7 +494,8 @@ "::xotcl::is [self] type $cl}\n" "::xotcl::Class method allinstances {} {\n" "return [.info instances -closure]}\n" -"::xotcl::alias ::xotcl2::Class parameter ::xotcl::classes::xotcl::Class::parameter\n" +"::xotcl::alias ::xotcl::Class parameter ::xotcl::classes::xotcl2::Class::parameter\n" +"::xotcl::alias ::xotcl::Object contains ::xotcl::classes::xotcl2::Object::contains\n" "::xotcl::alias ::xotcl2::Object defaultmethod ::xotcl::classes::xotcl::Object::defaultmethod\n" "::xotcl::Object method -per-object unsetExitHandler {} {\n" "::xotcl::Object method -per-object __exitHandler {} {\n" @@ -511,7 +515,7 @@ "if {!\\[::xotcl::self isnextcall\\]} {\n" "error \\\"Abstract method $methname $arglist called\\\"} else {::xotcl::next}\n" "\"}\n" -"::xotcl::Class create ::xotcl::Object::CopyHandler -parameter {\n" +"::xotcl2::Class create ::xotcl::Object::CopyHandler -parameter {\n" "{targetList \"\"}\n" "{dest \"\"}\n" "objLength}\n" @@ -560,7 +564,7 @@ "eval [concat $dest instforward $i [$origin info instforward -definition $i]]}}\n" "set traces [list]\n" "foreach var [$origin info vars] {\n" -"set cmds [$origin trace info variable $var]\n" +"set cmds [::xotcl::dispatch $origin -objscope ::trace info variable $var]\n" "if {$cmds ne \"\"} {\n" "foreach cmd $cmds {\n" "foreach {op def} $cmd break\n"