Index: generic/predefined.xotcl =================================================================== diff -u -r9474936bd01f25c80caa91f9b3164a3072457f66 -r81c800c8b9cb42ef6743d9b80ac2be5ca211a69a --- generic/predefined.xotcl (.../predefined.xotcl) (revision 9474936bd01f25c80caa91f9b3164a3072457f66) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision 81c800c8b9cb42ef6743d9b80ac2be5ca211a69a) @@ -1,18 +1,17 @@ -namespace eval ::xotcl { + +namespace eval ::next { # # By setting the variable bootstrap, we can check later, whether we # are in bootstrapping mode # set bootstrap 1 -} -# -# First create the ::xotcl2 object system. -# + #namespace path ::xotcl -namespace eval xotcl2 { - namespace path ::xotcl - ::xotcl::createobjectsystem ::xotcl2::Object ::xotcl2::Class { + # + # First create the ::next object system. + # + ::next::core::createobjectsystem ::next::Object ::next::Class { -class.alloc alloc -class.create create -class.dealloc dealloc @@ -28,54 +27,65 @@ -object.unknown unknown } - # provide the standard command set for ::xotcl2::Object - foreach cmd [info command ::xotcl::cmd::Object::*] { + # + # get frequenly used primitiva into the ::next namespace + # + namespace eval ::next::core { + namespace export next self \ + my is relation interp + } + namespace import ::next::core::next ::next::core::self + + # + # provide the standard command set for ::next::Object + # + foreach cmd [info command ::next::core::cmd::Object::*] { set cmdName [namespace tail $cmd] if {$cmdName in [list "instvar"]} continue - ::xotcl::alias Object $cmdName $cmd + ::next::core::alias Object $cmdName $cmd } - # provide ::eval as method for ::xotcl2::Object - ::xotcl::alias Object eval -nonleaf ::eval + # provide ::eval as method for ::next::Object + ::next::core::alias Object eval -nonleaf ::eval # provide the standard command set for Class - foreach cmd [info command ::xotcl::cmd::Class::*] { + foreach cmd [info command ::next::core::cmd::Class::*] { set cmdName [namespace tail $cmd] - ::xotcl::alias Class $cmdName $cmd + ::next::core::alias Class $cmdName $cmd } # set a few aliases as protected foreach cmd [list __next cleanup noinit residualargs uplevel upvar] { - ::xotcl::methodproperty Object $cmd protected 1 + ::next::core::methodproperty Object $cmd protected 1 } foreach cmd [list recreate] { - ::xotcl::methodproperty Class $cmd protected 1 + ::next::core::methodproperty Class $cmd protected 1 } # TODO: info methods shows finally "slots" and "slot". Wanted? # protect some methods against redefinition - ::xotcl::methodproperty Object destroy redefine-protected true - ::xotcl::methodproperty Class alloc redefine-protected true - ::xotcl::methodproperty Class dealloc redefine-protected true - ::xotcl::methodproperty Class create redefine-protected true + ::next::core::methodproperty Object destroy redefine-protected true + ::next::core::methodproperty Class alloc redefine-protected true + ::next::core::methodproperty Class dealloc redefine-protected true + ::next::core::methodproperty Class create redefine-protected true # define method "method" for Class and Object - ::xotcl::method Class method { + ::next::core::method Class method { name arguments body -precondition -postcondition } { set conditions [list] if {[info exists precondition]} {lappend conditions -precondition $precondition} if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} - ::xotcl::method [::xotcl::current object] $name $arguments $body {*}$conditions + ::next::core::method [::next::core::current object] $name $arguments $body {*}$conditions } - ::xotcl::method Object method { + ::next::core::method Object method { name arguments body -precondition -postcondition } { set conditions [list] if {[info exists precondition]} {lappend conditions -precondition $precondition} if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} - ::xotcl::method [::xotcl::current object] -per-object $name $arguments $body {*}$conditions + ::next::core::method [::next::core::current object] -per-object $name $arguments $body {*}$conditions } # define method modifiers "object", "public" and "protected" @@ -84,26 +94,26 @@ # method-modifier for object specific methos :method object {what args} { if {$what in [list "alias" "attribute" "forward" "method" "setter"]} { - return [::xotcl::dispatch [::xotcl::current object] ::xotcl::classes::xotcl2::Object::$what {*}$args] + return [::next::core::dispatch [::next::core::current object] ::next::core::classes::next::Object::$what {*}$args] } if {$what in [list "info"]} { - return [::xotcl2::objectInfo [lindex $args 0] [::xotcl::current object] {*}[lrange $args 1 end]] + return [::next::objectInfo [lindex $args 0] [::next::core::current object] {*}[lrange $args 1 end]] } if {$what in [list "filter" "mixin"]} { return [:object-$what {*}$args] } if {$what in [list "filterguard" "mixinguard"]} { - return [::xotcl::dispatch [::xotcl::current object] ::xotcl::cmd::Object::$what {*}$args] + return [::next::core::dispatch [::next::core::current object] ::next::core::cmd::Object::$what {*}$args] } } # define unknown handler for class :method unknown {m args} { - error "Method '$m' unknown for [::xotcl::current object].\ - Consider '[::xotcl::current object] create $m $args' instead of '[::xotcl::current object] $m $args'" + error "Method '$m' unknown for [::next::core::current object].\ + Consider '[::next::core::current object] create $m $args' instead of '[::next::core::current object] $m $args'" } # protected is not jet defined - ::xotcl::methodproperty [::xotcl::current object] unknown protected 1 + ::next::core::methodproperty [::next::core::current object] unknown protected 1 } @@ -114,7 +124,7 @@ set p [lsearch -regexp $args {^(method|alias|attribute|forward|setter)$}] if {$p == -1} {error "$args is not a method defining method"} set r [{*}:$args] - ::xotcl::methodproperty [::xotcl::current object] $r protected false + ::next::core::methodproperty [::next::core::current object] $r protected false return $r } @@ -123,31 +133,31 @@ set p [lsearch -regexp $args {^(method|alias|attribute|forward|setter)$}] if {$p == -1} {error "$args is not a method defining command"} set r [{*}:$args] - ::xotcl::methodproperty [::xotcl::current object] $r [::xotcl::current method] true + ::next::core::methodproperty [::next::core::current object] $r [::next::core::current method] true return $r } # unknown handler for Object :protected method unknown {m args} { - if {![::xotcl::current isnext]} { - error "[::xotcl::current object]: unable to dispatch method '$m'" + if {![::next::core::current isnext]} { + error "[::next::core::current object]: unable to dispatch method '$m'" } } # "init" must exist on Object. per default it is empty. :protected method init args {} # this method is called on calls to object without a specified method - :protected method defaultmethod {} {::xotcl::current object} + :protected method defaultmethod {} {::next::core::current object} # provide a placeholder for the bootup process. The real definition # is based on slots, which are not available at this point. :protected method objectparameter {} {;} } # define forward methods - ::xotcl::forward Object forward ::xotcl::forward %self -per-object - ::xotcl::forward Class forward ::xotcl::forward %self + ::next::core::forward Object forward ::next::core::forward %self -per-object + ::next::core::forward Class forward ::next::core::forward %self # The method __unknown is called in cases, where we try to resolve # an unkown class. one could define a custom resolver with this name @@ -164,13 +174,13 @@ # -objscope implies -nonleaf # Object public method alias {-nonleaf:switch -objscope:switch methodName cmd} { - ::xotcl::alias [::xotcl::current object] -per-object $methodName \ + ::next::core::alias [::next::core::current object] -per-object $methodName \ {*}[expr {${objscope} ? "-objscope" : ""}] \ {*}[expr {${nonleaf} ? "-nonleaf" : ""}] \ $cmd } Class public method alias {-nonleaf:switch -objscope:switch methodName cmd} { - ::xotcl::alias [::xotcl::current object] $methodName \ + ::next::core::alias [::next::core::current object] $methodName \ {*}[expr {${objscope} ? "-objscope" : ""}] \ {*}[expr {${nonleaf} ? "-nonleaf" : ""}] \ $cmd @@ -179,64 +189,64 @@ # Add setter methods. # Object public method setter {methodName} { - ::xotcl::setter [::xotcl::current object] -per-object $methodName + ::next::core::setter [::next::core::current object] -per-object $methodName } Class public method setter {methodName} { - ::xotcl::setter [::xotcl::current object] $methodName + ::next::core::setter [::next::core::current object] $methodName } ######################## # Info definition ######################## - Object create ::xotcl2::objectInfo - Object create ::xotcl2::classInfo + Object create ::next::objectInfo + Object create ::next::classInfo # # It would be nice to do here "objectInfo configure {alias ..}", but # we have no working objectparameter yet due to bootstrapping # objectInfo eval { - :alias is ::xotcl::objectproperty + :alias is ::next::core::objectproperty # info info :public method info {obj} { set methods [list] - foreach name [::xotcl::cmd::ObjectInfo::methods [::xotcl::current object]] { + foreach name [::next::core::cmd::ObjectInfo::methods [::next::core::current object]] { if {$name eq "unknown"} continue lappend methods $name } return "valid options are: [join [lsort $methods] {, }]" } :method unknown {method obj args} { - error "[::xotcl::current object] unknown info option \"$method\"; [$obj info info]" + error "[::next::core::current object] unknown info option \"$method\"; [$obj info info]" } } classInfo eval { - :alias is ::xotcl::objectproperty - :alias classparent ::xotcl::cmd::ObjectInfo::parent - :alias classchildren ::xotcl::cmd::ObjectInfo::children - :alias info [::xotcl::cmd::ObjectInfo::method objectInfo name info] - :alias unknown [::xotcl::cmd::ObjectInfo::method objectInfo name info] + :alias is ::next::core::objectproperty + :alias classparent ::next::core::cmd::ObjectInfo::parent + :alias classchildren ::next::core::cmd::ObjectInfo::children + :alias info [::next::core::cmd::ObjectInfo::method objectInfo name info] + :alias unknown [::next::core::cmd::ObjectInfo::method objectInfo name info] } - foreach cmd [info command ::xotcl::cmd::ObjectInfo::*] { - ::xotcl::alias ::xotcl2::objectInfo [namespace tail $cmd] $cmd - ::xotcl::alias ::xotcl2::classInfo [namespace tail $cmd] $cmd + foreach cmd [info command ::next::core::cmd::ObjectInfo::*] { + ::next::core::alias ::next::objectInfo [namespace tail $cmd] $cmd + ::next::core::alias ::next::classInfo [namespace tail $cmd] $cmd } - foreach cmd [info command ::xotcl::cmd::ClassInfo::*] { + foreach cmd [info command ::next::core::cmd::ClassInfo::*] { set cmdName [namespace tail $cmd] if {$cmdName in [list "object-mixin-of" "class-mixin-of"]} continue - ::xotcl::alias ::xotcl2::classInfo $cmdName $cmd + ::next::core::alias ::next::classInfo $cmdName $cmd } unset cmd # register method "info" on Object and Class - Object forward info -onerror ::xotcl::infoError ::xotcl2::objectInfo %1 {%@2 %self} - Class forward info -onerror ::xotcl::infoError ::xotcl2::classInfo %1 {%@2 %self} + Object forward info -onerror ::next::core::infoError ::next::objectInfo %1 {%@2 %self} + Class forward info -onerror ::next::core::infoError ::next::classInfo %1 {%@2 %self} - proc ::xotcl::infoError msg { + proc ::next::core::infoError msg { #puts stderr "INFO ERROR: <$msg>\n$::errorInfo" regsub -all " " $msg "" msg regsub -all " " $msg "" msg @@ -252,9 +262,9 @@ error "invalid method type '$methtype', must be 'method'" } set body " - if {!\[::xotcl::current isnextcall\]} { + if {!\[::next::core::current isnextcall\]} { error \"Abstract method $methname $arglist called\" - } else {::xotcl::next} + } else {::next::core::next} " if {${per-object}} { :method -per-object $methname $arglist $body @@ -266,43 +276,43 @@ # # exit handlers # - proc ::xotcl::unsetExitHandler {} { - proc ::xotcl::__exitHandler {} { + proc ::next::core::unsetExitHandler {} { + proc ::next::core::__exitHandler {} { # clients should append exit handlers to this proc body } } - proc ::xotcl::setExitHandler {newbody} {::proc ::xotcl::__exitHandler {} $newbody} - proc ::xotcl::getExitHandler {} {::info body ::xotcl::__exitHandler} + proc ::next::core::setExitHandler {newbody} {::proc ::next::core::__exitHandler {} $newbody} + proc ::next::core::getExitHandler {} {::info body ::next::core::__exitHandler} # initialize exit handler - ::xotcl::unsetExitHandler + ::next::core::unsetExitHandler - namespace export Object Class + namespace export Object Class next self } ######################################## # Slot definitions ######################################## -namespace eval ::xotcl { +namespace eval ::next { # # We are in bootstrap code; we cannot use slots/parameter to define # slots, so the code is a little low level. After the defintion of # the slots, we can use slot-based code such as "-parameter" or # "objectparameter". # - ::xotcl2::Class create ::xotcl::MetaSlot - ::xotcl::relation ::xotcl::MetaSlot superclass ::xotcl2::Class + ::next::Class create ::next::MetaSlot + ::next::core::relation ::next::MetaSlot superclass ::next::Class - ::xotcl::MetaSlot public method slotName {name baseObject} { + ::next::MetaSlot public method slotName {name baseObject} { # Create slot parent object if needed set slotParent ${baseObject}::slot - if {![::xotcl::objectproperty ${slotParent} object]} { - ::xotcl2::Object create ${slotParent} + if {![::next::core::objectproperty ${slotParent} object]} { + ::next::Object create ${slotParent} } return ${slotParent}::$name } - ::xotcl::MetaSlot method createFromParameterSyntax {target -per-object:switch + ::next::MetaSlot method createFromParameterSyntax {target -per-object:switch {-initblock ""} value default:optional} { set opts [list] @@ -343,40 +353,34 @@ } :create [:slotName $name $target] {*}$opts $initblock - return [::xotcl::cmd::${info}::method $target name $name] + return [::next::core::cmd::${info}::method $target name $name] } - - # ::xotcl::MetaSlot public method new args { - # set slotobject [::xotcl::current callingobject]::slot - # if {![::xotcl::objectproperty $slotobject object]} {::xotcls::Object create $slotobject} - # eval next -childof $slotobject $args - # } - ::xotcl::MetaSlot create ::xotcl::Slot - ::xotcl::MetaSlot create ::xotcl::ObjectParameterSlot - ::xotcl::relation ::xotcl::ObjectParameterSlot superclass ::xotcl::Slot + ::next::MetaSlot create ::next::Slot + ::next::MetaSlot create ::next::ObjectParameterSlot + ::next::core::relation ::next::ObjectParameterSlot superclass ::next::Slot # # create class and object for method parameter slots - ::xotcl::MetaSlot create ::xotcl::MethodParameterSlot - ::xotcl::relation ::xotcl::MethodParameterSlot superclass ::xotcl::Slot + ::next::MetaSlot create ::next::MethodParameterSlot + ::next::core::relation ::next::MethodParameterSlot superclass ::next::Slot # create an object for dispatching - ::xotcl::MethodParameterSlot create ::xotcl::methodParameterSlot + ::next::MethodParameterSlot create ::next::methodParameterSlot # use low level interface for defining slot values. Normally, this is # done via slot objects, which are defined later. proc createBootstrapAttributeSlots {class definitions} { foreach att $definitions { if {[llength $att]>1} {foreach {att default} $att break} - set slotObj [::xotcl::ObjectParameterSlot slotName $att $class] - ::xotcl::ObjectParameterSlot create $slotObj + set slotObj [::next::ObjectParameterSlot slotName $att $class] + ::next::ObjectParameterSlot create $slotObj if {[info exists default]} { - ::xotcl::setvar $slotObj default $default + ::next::core::setvar $slotObj default $default unset default } - ::xotcl::setter $class $att + ::next::core::setter $class $att } # @@ -388,14 +392,14 @@ if {[info exists default]} { # checking subclasses is not required during bootstrap - foreach i [::xotcl::cmd::ClassInfo::instances $class] { + foreach i [::next::core::cmd::ClassInfo::instances $class] { if {![$i exists $att]} { if {[string match {*\[*\]*} $default]} { - set value [::xotcl::dispatch $i -objscope ::eval subst $default] + set value [::next::core::dispatch $i -objscope ::eval subst $default] } else { set value $default } - ::xotcl::setvar $i $att $value + ::next::core::setvar $i $att $value } } unset default @@ -410,82 +414,82 @@ ############################################ # Define slots for slots ############################################ - createBootstrapAttributeSlots ::xotcl::Slot { + createBootstrapAttributeSlots ::next::Slot { {name} {multivalued false} {required false} default type } - createBootstrapAttributeSlots ::xotcl::ObjectParameterSlot { - {name "[namespace tail [::xotcl::current object]]"} + createBootstrapAttributeSlots ::next::ObjectParameterSlot { + {name "[namespace tail [::next::core::current object]]"} {methodname} - {domain "[lindex [regexp -inline {^(.*)::slot::[^:]+$} [::xotcl::current object]] 1]"} + {domain "[lindex [regexp -inline {^(.*)::slot::[^:]+$} [::next::core::current object]] 1]"} {defaultmethods {get assign}} - {manager "[::xotcl::current object]"} + {manager "[::next::core::current object]"} {per-object false} } # maybe add the following slots at some later time here # initcmd # valuecmd # valuechangedcmd - ::xotcl::alias ::xotcl::ObjectParameterSlot get ::xotcl::setvar - ::xotcl::alias ::xotcl::ObjectParameterSlot assign ::xotcl::setvar + ::next::core::alias ::next::ObjectParameterSlot get ::next::core::setvar + ::next::core::alias ::next::ObjectParameterSlot assign ::next::core::setvar - ::xotcl::ObjectParameterSlot public method add {obj prop value {pos 0}} { + ::next::ObjectParameterSlot public method add {obj prop value {pos 0}} { if {![set :multivalued]} { error "Property $prop of [set :domain]->$obj ist not multivalued" } if {[$obj exists $prop]} { - ::xotcl::setvar $obj $prop [linsert [::xotcl::setvar $obj $prop] $pos $value] + ::next::core::setvar $obj $prop [linsert [::next::core::setvar $obj $prop] $pos $value] } else { - ::xotcl::setvar $obj $prop [list $value] + ::next::core::setvar $obj $prop [list $value] } } - ::xotcl::ObjectParameterSlot public method delete {-nocomplain:switch obj prop value} { - set old [::xotcl::setvar $obj $prop] + ::next::ObjectParameterSlot public method delete {-nocomplain:switch obj prop value} { + set old [::next::core::setvar $obj $prop] set p [lsearch -glob $old $value] - if {$p>-1} {::xotcl::setvar $obj $prop [lreplace $old $p $p]} else { + if {$p>-1} {::next::core::setvar $obj $prop [lreplace $old $p $p]} else { error "$value is not a $prop of $obj (valid are: $old)" } } - ::xotcl::ObjectParameterSlot method unknown {method args} { + ::next::ObjectParameterSlot method unknown {method args} { set methods [list] foreach m [:info callable] { - if {[::xotcl2::Object info callable $m] ne ""} continue + if {[::next::Object info callable $m] ne ""} continue if {[string match __* $m]} continue lappend methods $m } - error "Method '$method' unknown for slot [::xotcl::current object]; valid are: {[lsort $methods]}" + error "Method '$method' unknown for slot [::next::core::current object]; valid are: {[lsort $methods]}" } - ::xotcl::ObjectParameterSlot public method destroy {} { - if {${:domain} ne "" && [::xotcl::objectproperty ${:domain} class]} { + ::next::ObjectParameterSlot public method destroy {} { + if {${:domain} ne "" && [::next::core::objectproperty ${:domain} class]} { ${:domain} __invalidateobjectparameter } - next + ::next::core::next } - ::xotcl::ObjectParameterSlot protected method init {args} { + ::next::ObjectParameterSlot protected method init {args} { if {${:domain} eq ""} { - set :domain [::xotcl::current callingobject] + set :domain [::next::core::current callingobject] } if {${:domain} ne ""} { if {![info exists :methodname]} { set :methodname ${:name} } - if {[::xotcl::objectproperty ${:domain} class]} { + if {[::next::core::objectproperty ${:domain} class]} { ${:domain} __invalidateobjectparameter } if {${:per-object} && [info exists :default] } { - ::xotcl::setvar ${:domain} ${:name} ${:default} + ::next::core::setvar ${:domain} ${:name} ${:default} } set cl [expr {${:per-object} ? "Object" : "Class"}] - #puts stderr "Slot [::xotcl::current object] init, forwarder on ${:domain}" - ::xotcl::forward ${:domain} ${:name} \ + #puts stderr "Slot [::next::core::current object] init, forwarder on ${:domain}" + ::next::core::forward ${:domain} ${:name} \ ${:manager} \ [list %1 [${:manager} defaultmethods]] %self \ ${:methodname} @@ -499,11 +503,11 @@ # definition here before we refine the slot definitions. # # Invalidate previously defined object parameter. - ::xotcl::MetaSlot __invalidateobjectparameter + ::next::MetaSlot __invalidateobjectparameter # Provide the a slot based mechanism for building an object # configuration interface from slot definitions - ::xotcl::ObjectParameterSlot method toParameterSyntax {{name:substdefault ${:name}}} { + ::next::ObjectParameterSlot method toParameterSyntax {{name:substdefault ${:name}}} { set objparamdefinition $name set methodparamdefinition "" set objopts [list] @@ -515,7 +519,7 @@ } if {[info exists :type]} { if {[string match ::* ${:type}]} { - set type [expr {[::xotcl::objectproperty ${:type} metaclass] ? "class" : "object"}] + set type [expr {[::next::core::objectproperty ${:type} metaclass] ? "class" : "object"}] lappend objopts type=${:type} lappend methodopts type=${:type} } else { @@ -550,14 +554,14 @@ if {${:methodname} ne ${:name}} { lappend objopts arg=${:methodname} lappend methodopts arg=${:methodname} - #puts stderr "..... setting arg for methodname: [::xotcl::current object] has arg arg=${:methodname}" + #puts stderr "..... setting arg for methodname: [::next::core::current object] has arg arg=${:methodname}" } } if {$type ne ""} { set objopts [linsert $objopts 0 $type] set methodopts [linsert $methodopts 0 $type] } - lappend objopts slot=[::xotcl::current object] + lappend objopts slot=[::next::core::current object] if {[llength $objopts] > 0} { append objparamdefinition :[join $objopts ,] @@ -568,16 +572,16 @@ if {[info exists arg]} { lappend objparamdefinition $arg } - #puts stderr "[::xotcl::current method] ${name} returns [list oparam $objparamdefinition mparam $methodparamdefinition]" + #puts stderr "[::next::core::current method] ${name} returns [list oparam $objparamdefinition mparam $methodparamdefinition]" return [list oparam $objparamdefinition mparam $methodparamdefinition] } - proc ::xotcl::parametersFromSlots {obj} { + proc ::next::core::parametersFromSlots {obj} { set parameterdefinitions [list] - foreach slot [::xotcl2::objectInfo slotobjects $obj] { - # Skip some slots for xotcl1; - # TODO: maybe different parameterFromSlots for xotcl1? - if {[::xotcl::objectproperty $obj type ::xotcl::Object] && + foreach slot [::next::objectInfo slotobjects $obj] { + # Skip some slots for xotcl; + # TODO: maybe different parameterFromSlots for xotcl? + if {[::next::core::objectproperty $obj type ::xotcl::Object] && ([$slot name] eq "mixin" || [$slot name] eq "filter") } continue array set "" [$slot toParameterSyntax] @@ -586,40 +590,40 @@ return $parameterdefinitions } - ::xotcl2::Object protected method objectparameter {{lastparameter __initcmd:initcmd,optional}} { - #puts stderr "... objectparameter [::xotcl::current object]" - set parameterdefinitions [::xotcl::parametersFromSlots [::xotcl::current object]] - if {[::xotcl::objectproperty [::xotcl::current object] class]} { + ::next::Object protected method objectparameter {{lastparameter __initcmd:initcmd,optional}} { + #puts stderr "... objectparameter [::next::core::current object]" + set parameterdefinitions [::next::core::parametersFromSlots [::next::core::current object]] + if {[::next::core::objectproperty [::next::core::current object] class]} { lappend parameterdefinitions -parameter:method,optional } lappend parameterdefinitions \ -noinit:method,optional,noarg \ -volatile:method,optional,noarg \ {*}$lastparameter - #puts stderr "*** parameter definition for [::xotcl::current object]: $parameterdefinitions" + #puts stderr "*** parameter definition for [::next::core::current object]: $parameterdefinitions" return $parameterdefinitions } ############################################ # RelationSlot ############################################ - ::xotcl::MetaSlot create ::xotcl::RelationSlot - createBootstrapAttributeSlots ::xotcl::RelationSlot { + ::next::MetaSlot create ::next::RelationSlot + createBootstrapAttributeSlots ::next::RelationSlot { {multivalued true} {type relation} - {elementtype ::xotcl2::Class} + {elementtype ::next::Class} } - ::xotcl::relation ::xotcl::RelationSlot superclass ::xotcl::ObjectParameterSlot - ::xotcl::alias ::xotcl::RelationSlot assign ::xotcl::relation + ::next::core::relation ::next::RelationSlot superclass ::next::ObjectParameterSlot + ::next::core::alias ::next::RelationSlot assign ::next::core::relation - ::xotcl::RelationSlot protected method init {} { + ::next::RelationSlot protected method init {} { if {${:type} ne "relation"} { error "RelationSlot requires type == \"relation\"" } - next + ::next::core::next } - ::xotcl::RelationSlot protected method delete_value {obj prop old value} { + ::next::RelationSlot protected method delete_value {obj prop old value} { if {[string first * $value] > -1 || [string first \[ $value] > -1} { # value contains globbing meta characters if {${:elementtype} ne "" && ![string match ::* $value]} { @@ -631,12 +635,12 @@ # value contains no globbing meta characters, but elementtype is given if {[string first :: $value] == -1} { # get fully qualified name - if {![::xotcl::objectproperty $value object]} { + if {![::next::core::objectproperty $value object]} { error "$value does not appear to be an object" } - set value [::xotcl::dispatch $value -objscope ::xotcl::current object] + set value [::next::core::dispatch $value -objscope ::next::core::current object] } - if {![::xotcl::objectproperty ${:elementtype} class]} { + if {![::next::core::objectproperty ${:elementtype} class]} { error "$value does not appear to be of type ${:elementtype}" } } @@ -648,61 +652,61 @@ } } - ::xotcl::RelationSlot public method delete {-nocomplain:switch obj prop value} { - #puts stderr RelationSlot-delete-[::xotcl::current args] + ::next::RelationSlot public method delete {-nocomplain:switch obj prop value} { + #puts stderr RelationSlot-delete-[::next::core::current args] $obj $prop [:delete_value $obj $prop [$obj info $prop] $value] } - ::xotcl::RelationSlot public method get {obj prop} { - ::xotcl::relation $obj $prop + ::next::RelationSlot public method get {obj prop} { + ::next::core::relation $obj $prop } - ::xotcl::RelationSlot public method add {obj prop value {pos 0}} { + ::next::RelationSlot public method add {obj prop value {pos 0}} { if {![set :multivalued]} { error "Property $prop of ${:domain}->$obj ist not multivalued" } - set oldSetting [::xotcl::relation $obj $prop] + set oldSetting [::next::core::relation $obj $prop] # use uplevel to avoid namespace surprises - uplevel [list ::xotcl::relation $obj $prop [linsert $oldSetting $pos $value]] + uplevel [list ::next::core::relation $obj $prop [linsert $oldSetting $pos $value]] } - ::xotcl::RelationSlot public method delete {-nocomplain:switch obj prop value} { - uplevel [list ::xotcl::relation $obj $prop [:delete_value $obj $prop [::xotcl::relation $obj $prop] $value]] + ::next::RelationSlot public method delete {-nocomplain:switch obj prop value} { + uplevel [list ::next::core::relation $obj $prop [:delete_value $obj $prop [::next::core::relation $obj $prop] $value]] } ############################################ # system slots ############################################ - proc ::xotcl::register_system_slots {os} { + proc ::next::core::register_system_slots {os} { ${os}::Object alloc ${os}::Class::slot ${os}::Object alloc ${os}::Object::slot - ::xotcl::RelationSlot create ${os}::Class::slot::superclass - ::xotcl::alias ${os}::Class::slot::superclass assign ::xotcl::relation - ::xotcl::RelationSlot create ${os}::Object::slot::class -multivalued false - ::xotcl::alias ${os}::Object::slot::class assign ::xotcl::relation + ::next::RelationSlot create ${os}::Class::slot::superclass + ::next::core::alias ${os}::Class::slot::superclass assign ::next::core::relation + ::next::RelationSlot create ${os}::Object::slot::class -multivalued false + ::next::core::alias ${os}::Object::slot::class assign ::next::core::relation - ::xotcl::RelationSlot create ${os}::Object::slot::mixin -methodname object-mixin - ::xotcl::RelationSlot create ${os}::Object::slot::filter -elementtype "" + ::next::RelationSlot create ${os}::Object::slot::mixin -methodname object-mixin + ::next::RelationSlot create ${os}::Object::slot::filter -elementtype "" - ::xotcl::RelationSlot create ${os}::Class::slot::mixin -methodname class-mixin - ::xotcl::RelationSlot create ${os}::Class::slot::filter -elementtype "" \ + ::next::RelationSlot create ${os}::Class::slot::mixin -methodname class-mixin + ::next::RelationSlot create ${os}::Class::slot::filter -elementtype "" \ -methodname class-filter # Create two conveniance slots to allow configuration of # object-slots for classes via object-mixin - ::xotcl::RelationSlot create ${os}::Class::slot::object-mixin - ::xotcl::RelationSlot create ${os}::Class::slot::object-filter -elementtype "" + ::next::RelationSlot create ${os}::Class::slot::object-mixin + ::next::RelationSlot create ${os}::Class::slot::object-filter -elementtype "" } - ::xotcl::register_system_slots ::xotcl2 - proc ::xotcl::register_system_slots {} {} + ::next::core::register_system_slots ::next + proc ::next::core::register_system_slots {} {} ############################################ # Attribute slots ############################################ - ::xotcl::MetaSlot __invalidateobjectparameter - ::xotcl::MetaSlot create ::xotcl::Attribute -superclass ::xotcl::ObjectParameterSlot + ::next::MetaSlot __invalidateobjectparameter + ::next::MetaSlot create ::next::Attribute -superclass ::next::ObjectParameterSlot - createBootstrapAttributeSlots ::xotcl::Attribute { + createBootstrapAttributeSlots ::next::Attribute { {value_check once} incremental initcmd @@ -711,62 +715,69 @@ arg } - ::xotcl::Attribute method __default_from_cmd {obj cmd var sub op} { - #puts "GETVAR [::xotcl::current method] obj=$obj cmd=$cmd, var=$var, op=$op" - $obj trace remove variable $var $op [list [::xotcl::current object] [::xotcl::current method] $obj $cmd] - ::xotcl::setvar $obj $var [$obj eval $cmd] + ::next::Attribute method __default_from_cmd {obj cmd var sub op} { + #puts "GETVAR [::next::core::current method] obj=$obj cmd=$cmd, var=$var, op=$op" + $obj trace remove variable $var $op [list [::next::core::current object] [::next::core::current method] $obj $cmd] + ::next::core::setvar $obj $var [$obj eval $cmd] } - ::xotcl::Attribute method __value_from_cmd {obj cmd var sub op} { - #puts "GETVAR [::xotcl::current method] obj=$obj cmd=$cmd, var=$var, op=$op" - ::xotcl::setvar $obj $var [$obj eval $cmd] + ::next::Attribute method __value_from_cmd {obj cmd var sub op} { + #puts "GETVAR [::next::core::current method] obj=$obj cmd=$cmd, var=$var, op=$op" + ::next::core::setvar $obj $var [$obj eval $cmd] } - ::xotcl::Attribute method __value_changed_cmd {obj cmd var sub op} { + ::next::Attribute method __value_changed_cmd {obj cmd var sub op} { # puts stderr "**************************" - # puts "valuechanged obj=$obj cmd=$cmd, var=$var, op=$op, ...\n$obj exists $var -> [::xotcl::setvar $obj $var]" + # puts "valuechanged obj=$obj cmd=$cmd, var=$var, op=$op, ...\n$obj exists $var -> [::next::core::setvar $obj $var]" eval $cmd } - ::xotcl::Attribute protected method init {} { - next ;# do first ordinary slot initialization + ::next::Attribute protected method init {} { + ::next::core::next ;# do first ordinary slot initialization # there might be already default values registered on the class set __initcmd "" if {[:exists default]} { } elseif [:exists initcmd] { append __initcmd ":trace add variable [list ${:name}] read \ - \[list [::xotcl::current object] __default_from_cmd \[::xotcl::current object\] [list [set :initcmd]]\]\n" + \[list [::next::core::current object] __default_from_cmd \[::next::core::current object\] [list [set :initcmd]]\]\n" } elseif [:exists valuecmd] { append __initcmd ":trace add variable [list ${:name}] read \ - \[list [::xotcl::current object] __value_from_cmd \[::xotcl::current object\] [list [set :valuecmd]]\]" + \[list [::next::core::current object] __value_from_cmd \[::next::core::current object\] [list [set :valuecmd]]\]" } array set "" [:toParameterSyntax ${:name}] - #puts stderr "Attribute.init valueParam for [::xotcl::current object] is $(mparam)" + #puts stderr "Attribute.init valueParam for [::next::core::current object] is $(mparam)" if {$(mparam) ne ""} { if {[info exists :multivalued] && ${:multivalued}} { - #puts stderr "adding assign [list obj var value:$(mparam),multivalued] // for [::xotcl::current object] with $(mparam)" - :method assign [list obj var value:$(mparam),multivalued,slot=[::xotcl::current object]] {::xotcl::setvar $obj $var $value} - #puts stderr "adding add method for [::xotcl::current object] with value:$(mparam)" - :method add [list obj prop value:$(mparam),slot=[::xotcl::current object] {pos 0}] {next} + #puts stderr "adding assign [list obj var value:$(mparam),multivalued] // for [::next::core::current object] with $(mparam)" + :method assign [list obj var value:$(mparam),multivalued,slot=[::next::core::current object]] { + ::next::core::setvar $obj $var $value + } + #puts stderr "adding add method for [::next::core::current object] with value:$(mparam)" + :method add [list obj prop value:$(mparam),slot=[::next::core::current object] {pos 0}] { + ::next::core::next + } } else { - #puts stderr "SV adding assign [list obj var value:$(mparam)] // for [::xotcl::current object] with $(mparam)" - :method assign [list obj var value:$(mparam),slot=[::xotcl::current object]] {::xotcl::setvar $obj $var $value} - #::xotcl::setter ${:domain} ${:name}:$(mparam),slot=[::xotcl::current object] - #puts stderr "::xotcl::setter ${:domain} ${:name}:$(mparam),slot=[::xotcl::current object]" + #puts stderr "SV adding assign [list obj var value:$(mparam)] // for [::next::core::current object] with $(mparam)" + :method assign [list obj var value:$(mparam),slot=[::next::core::current object]] { + ::next::core::setvar $obj $var $value + } + } } if {[:exists valuechangedcmd]} { append __initcmd ":trace add variable [list ${:name}] write \ - \[list [::xotcl::current object] __value_changed_cmd \[::xotcl::current object\] [list [set :valuechangedcmd]]\]" + \[list [::next::core::current object] __value_changed_cmd \[::next::core::current object\] [list [set :valuechangedcmd]]\]" } if {$__initcmd ne ""} { set :initcmd $__initcmd } } # mixin class for optimizing slots - ::xotcl2::Class create ::xotcl::Attribute::Optimizer { - :method method args {::xotcl::next; :optimize} - :method forward args {::xotcl::next; :optimize} - :protected method init args {::xotcl::next; :optimize} + ::next::Class create ::next::Attribute::Optimizer { + + :method method args {::next::core::next; :optimize} + :method forward args {::next::core::next; :optimize} + :protected method init args {::next::core::next; :optimize} + :public method optimize {} { #puts stderr OPTIMIZER-[info exists :incremental] if {![info exists :methodname]} {return} @@ -778,58 +789,59 @@ set perObject "" set infokind Class } - if {[::xotcl::cmd::${infokind}Info::method ${:domain} name ${:name}] ne ""} { - #puts stderr "RESETTING ${:domain} slot ${:name}" - ::xotcl::forward ${:domain} {*}$perObject ${:name} \ + if {[::next::core::cmd::${infokind}Info::method ${:domain} name ${:name}] ne ""} { + #puts stderr "OPTIMIZER RESETTING ${:domain} slot ${:name}" + ::next::core::forward ${:domain} {*}$perObject ${:name} \ ${:manager} \ [list %1 [${:manager} defaultmethods]] %self \ ${:methodname} } - #if {[set :multivalued]} return + #puts stderr "OPTIMIZER incremental [info exists :incremental] def '[set :defaultmethods]'" if {[info exists :incremental] && ${:incremental}} return if {[set :defaultmethods] ne {get assign}} return set assignInfo [:info callable -which assign] - #puts stderr assign=$assignInfo//[lindex $assignInfo {end 0}] - if {$assignInfo ne "::xotcl::ObjectParameterSlot alias assign ::xotcl::setvar" && - [lindex $assignInfo {end 0}] ne "::xotcl::setvar" } return - if {[:info callable -which get] ne "::xotcl::ObjectParameterSlot alias get ::xotcl::setvar"} return + #puts stderr "OPTIMIZER assign=$assignInfo//[lindex $assignInfo {end 0}]//[:info precedence]" + if {$assignInfo ne "::next::ObjectParameterSlot alias assign ::next::core::setvar" && + [lindex $assignInfo {end 0}] ne "::next::core::setvar" } return + if {[:info callable -which get] ne "::next::ObjectParameterSlot alias get ::next::core::setvar"} return + array set "" [:toParameterSyntax ${:name}] if {$(mparam) ne ""} { set setterParam [lindex $(oparam) 0] #puts stderr "setterParam=$setterParam, op=$(oparam)" } else { set setterParam ${:name} } - ::xotcl::setter ${:domain} {*}$perObject $setterParam - #puts stderr "::xotcl::setter ${:domain} {*}$perObject $setterParam" + ::next::core::setter ${:domain} {*}$perObject $setterParam + #puts stderr "::next::core::setter ${:domain} {*}$perObject $setterParam" } } # register the optimizer per default - ::xotcl::Attribute mixin add ::xotcl::Attribute::Optimizer + ::next::Attribute mixin add ::next::Attribute::Optimizer ############################################ # Define method "attribute" for convenience ############################################ - ::xotcl2::Class method attribute {spec {-slotclass ::xotcl::Attribute} {initblock ""}} { - $slotclass createFromParameterSyntax [::xotcl::current object] -initblock $initblock {*}$spec + ::next::Class method attribute {spec {-slotclass ::next::Attribute} {initblock ""}} { + $slotclass createFromParameterSyntax [::next::core::current object] -initblock $initblock {*}$spec } - ::xotcl2::Object method attribute {spec {-slotclass ::xotcl::Attribute} {initblock ""}} { - $slotclass createFromParameterSyntax [::xotcl::current object] -per-object -initblock $initblock {*}$spec + ::next::Object method attribute {spec {-slotclass ::next::Attribute} {initblock ""}} { + $slotclass createFromParameterSyntax [::next::core::current object] -per-object -initblock $initblock {*}$spec } ############################################ # Define method "parameter" for backward # compatibility and convenience ############################################ - ::xotcl2::Class public method parameter arglist { + ::next::Class public method parameter arglist { foreach arg $arglist { - ::xotcl::Attribute createFromParameterSyntax [::xotcl::current object] {*}$arg + ::next::Attribute createFromParameterSyntax [::next::core::current object] {*}$arg } # todo needed? - set slot [::xotcl::current object]::slot - if {![::xotcl::objectproperty $slot object]} {::xotcl2::Object create $slot} - ::xotcl::setvar $slot __parameter $arglist + set slot [::next::core::current object]::slot + if {![::next::core::objectproperty $slot object]} {::next::Object create $slot} + ::next::core::setvar $slot __parameter $arglist } ################################################################## @@ -841,25 +853,25 @@ proc createBootstrapAttributeSlots {} {} ################################################################## - # create user-level converter/checker based on ::xotcl::ls + # create user-level converter/checker based on ::next::core primitves ################################################################## - ::xotcl::Slot method type=hasmixin {name value arg} { - if {![::xotcl::objectproperty $value hasmixin $arg]} { + ::next::Slot method type=hasmixin {name value arg} { + if {![::next::core::objectproperty $value hasmixin $arg]} { error "expected object with mixin $arg but got \"$value\" for parameter $name" } return $value } - ::xotcl::Slot method type=baseclass {name value} { - if {![::xotcl::objectproperty $value baseclass]} { + ::next::Slot method type=baseclass {name value} { + if {![::next::core::objectproperty $value baseclass]} { error "expected baseclass but got \"$value\" for parameter $name" } return $value } - ::xotcl::Slot method type=metaclass {name value} { - if {![::xotcl::objectproperty $value metaclass]} { + ::next::Slot method type=metaclass {name value} { + if {![::next::core::objectproperty $value metaclass]} { error "expected metaclass but got \"$value\" for parameter $name" } return $value @@ -869,22 +881,22 @@ ################################################################## # Create a mixin class to overload method "new" such it does not -# allocate new objects in ::xotcl::*, but in the specified object +# allocate new objects in ::next::*, but in the specified object # (without syntactic overhead). ################################################################## -::xotcl2::Class create ::xotcl::ScopedNew -superclass ::xotcl2::Class { +::next::Class create ::next::ScopedNew -superclass ::next::Class { - :attribute {withclass ::xotcl2::Object} + :attribute {withclass ::next::Object} :attribute container :protected method init {} { :public method new {-childof args} { - ::xotcl::importvar [::xotcl::current class] {container object} withclass - if {![::xotcl::objectproperty $object object]} { + ::next::core::importvar [::next::core::current class] {container object} withclass + if {![::next::core::objectproperty $object object]} { $withclass create $object } - eval ::xotcl::next -childof $object $args + eval ::next::core::next -childof $object $args } } } @@ -896,36 +908,36 @@ # creating new objects in the specified scope can be turned off. ################################################################## -::xotcl2::Object public method contains { +::next::Object public method contains { {-withnew:boolean true} -object - {-class ::xotcl2::Object} + {-class ::next::Object} cmds } { - if {![info exists object]} {set object [::xotcl::current object]} - if {![::xotcl::objectproperty $object object]} {$class create $object} + if {![info exists object]} {set object [::next::core::current object]} + if {![::next::core::objectproperty $object object]} {$class create $object} $object requireNamespace if {$withnew} { - set m [::xotcl::ScopedNew new -volatile \ + set m [::next::ScopedNew new -volatile \ -container $object -withclass $class] - ::xotcl2::Class mixin add $m end - # TODO: the following is not pretty; however, contains might build xotcl1 and xotcl2 objects. - if {[::xotcl::objectproperty ::xotcl::Class class]} {::xotcl::Class instmixin add $m end} + ::next::Class mixin add $m end + # TODO: the following is not pretty; however, contains might build xotcl1 and next objects. + if {[::next::core::objectproperty ::xotcl::Class class]} {::xotcl::Class instmixin add $m end} namespace eval $object $cmds - ::xotcl2::Class mixin delete $m - if {[::xotcl::objectproperty ::xotcl::Class class]} {::xotcl::Class instmixin delete $m} + ::next::Class mixin delete $m + if {[::next::core::objectproperty ::xotcl::Class class]} {::xotcl::Class instmixin delete $m} } else { namespace eval $object $cmds } } -::xotcl2::Class forward slots %self contains \ - -object {%::xotcl::dispatch [::xotcl::current object] -objscope ::subst [::xotcl::current object]::slot} +::next::Class forward slots %self contains \ + -object {%::next::core::dispatch [::next::core::current object] -objscope ::subst [::next::core::current object]::slot} ################################################################## # copy/move implementation ################################################################## -::xotcl2::Class create ::xotcl::CopyHandler { +::next::Class create ::next::CopyHandler { :attribute {targetList ""} :attribute {dest ""} @@ -935,7 +947,7 @@ lappend :targetList $t #puts stderr "COPY makeTargetList $t target= ${:targetList}" # if it is an object without namespace, it is a leaf - if {[::xotcl::objectproperty $t object]} { + if {[::next::core::objectproperty $t object]} { if {[$t info hasnamespace]} { # make target list from all children set children [$t info children] @@ -947,7 +959,7 @@ # now append all namespaces that are in the obj, but that # are not objects foreach c [namespace children $t] { - if {![::xotcl::objectproperty $c object]} { + if {![::next::core::objectproperty $c object]} { lappend children [namespace children $t] } } @@ -961,8 +973,8 @@ :method copyNSVarsAndCmds {orig dest} { - ::xotcl::namespace_copyvars $orig $dest - ::xotcl::namespace_copycmds $orig $dest + ::next::core::namespace_copyvars $orig $dest + ::next::core::namespace_copycmds $orig $dest } # construct destination obj name from old qualified ns name @@ -975,44 +987,44 @@ #puts stderr "COPY will copy targetList = [set :targetList]" foreach origin [set :targetList] { set dest [:getDest $origin] - if {[::xotcl::objectproperty $origin object]} { + if {[::next::core::objectproperty $origin object]} { # copy class information - if {[::xotcl::objectproperty $origin class]} { + if {[::next::core::objectproperty $origin class]} { set cl [[$origin info class] create $dest -noinit] # class object set obj $cl $cl superclass [$origin info superclass] - ::xotcl::assertion $cl class-invar [::xotcl::assertion $origin class-invar] - ::xotcl::relation $cl class-filter [::xotcl::relation $origin class-filter] - ::xotcl::relation $cl class-mixin [::xotcl::relation $origin class-mixin] - :copyNSVarsAndCmds ::xotcl::classes$origin ::xotcl::classes$dest + ::next::core::assertion $cl class-invar [::next::core::assertion $origin class-invar] + ::next::core::relation $cl class-filter [::next::core::relation $origin class-filter] + ::next::core::relation $cl class-mixin [::next::core::relation $origin class-mixin] + :copyNSVarsAndCmds ::next::core::classes$origin ::next::core::classes$dest } else { # create obj set obj [[$origin info class] create $dest -noinit] } # copy object -> may be a class obj - ::xotcl::assertion $obj check [::xotcl::assertion $origin check] - ::xotcl::assertion $obj object-invar [::xotcl::assertion $origin object-invar] - ::xotcl::relation $obj object-filter [::xotcl::relation $origin object-filter] - ::xotcl::relation $obj object-mixin [::xotcl::relation $origin object-mixin] + ::next::core::assertion $obj check [::next::core::assertion $origin check] + ::next::core::assertion $obj object-invar [::next::core::assertion $origin object-invar] + ::next::core::relation $obj object-filter [::next::core::relation $origin object-filter] + ::next::core::relation $obj object-mixin [::next::core::relation $origin object-mixin] if {[$origin info hasnamespace]} { $obj requireNamespace } } else { namespace eval $dest {} } :copyNSVarsAndCmds $origin $dest - foreach i [::xotcl::cmd::ObjectInfo::forward $origin] { - eval [concat ::xotcl::forward $dest -per-object $i [::xotcl::cmd::ObjectInfo::forward $origin -definition $i]] + foreach i [::next::core::cmd::ObjectInfo::forward $origin] { + eval [concat ::next::core::forward $dest -per-object $i [::next::core::cmd::ObjectInfo::forward $origin -definition $i]] } - if {[::xotcl::objectproperty $origin class]} { - foreach i [::xotcl::cmd::ClassInfo::forward $origin] { - eval [concat ::xotcl::forward $dest $i [::xotcl::cmd::ClassInfo::forward $origin -definition $i]] + if {[::next::core::objectproperty $origin class]} { + foreach i [::next::core::cmd::ClassInfo::forward $origin] { + eval [concat ::next::core::forward $dest $i [::next::core::cmd::ClassInfo::forward $origin -definition $i]] } } set traces [list] foreach var [$origin info vars] { - set cmds [::xotcl::dispatch $origin -objscope ::trace info variable $var] + set cmds [::next::core::dispatch $origin -objscope ::trace info variable $var] if {$cmds ne ""} { foreach cmd $cmds { foreach {op def} $cmd break @@ -1028,10 +1040,10 @@ } # alter 'domain' and 'manager' in slot objects for classes foreach origin [set :targetList] { - if {[::xotcl::objectproperty $origin class]} { + if {[::next::core::objectproperty $origin class]} { set dest [:getDest $origin] foreach oldslot [$origin info slots] { - set newslot [::xotcl::Slot slotName [namespace tail $oldslot] $dest] + set newslot [::next::Slot slotName [namespace tail $oldslot] $dest] if {[$oldslot domain] eq $origin} {$newslot domain $cl} if {[$oldslot manager] eq $oldslot} {$newslot manager $newslot} } @@ -1040,7 +1052,7 @@ } :public method copy {obj dest} { - #puts stderr "[::xotcl::current object] copy <$obj> <$dest>" + #puts stderr "[::next::core::current object] copy <$obj> <$dest>" set :objLength [string length $obj] set :dest $dest :makeTargetList $obj @@ -1049,22 +1061,22 @@ } -::xotcl2::Object public method copy newName { - if {[string compare [string trimleft $newName :] [string trimleft [::xotcl::current object] :]]} { - [::xotcl::CopyHandler new -volatile] copy [::xotcl::current object] $newName +::next::Object public method copy newName { + if {[string compare [string trimleft $newName :] [string trimleft [::next::core::current object] :]]} { + [::next::CopyHandler new -volatile] copy [::next::core::current object] $newName } } -::xotcl2::Object public method move newName { - if {[string trimleft $newName :] ne [string trimleft [::xotcl::current object] :]} { +::next::Object public method move newName { + if {[string trimleft $newName :] ne [string trimleft [::next::core::current object] :]} { if {$newName ne ""} { :copy $newName } ### let all subclasses get the copied class as superclass - if {[::xotcl::objectproperty [::xotcl::current object] class] && $newName ne ""} { + if {[::next::core::objectproperty [::next::core::current object] class] && $newName ne ""} { foreach subclass [:info subclass] { set scl [$subclass info superclass] - if {[set index [lsearch -exact $scl [::xotcl::current object]]] != -1} { + if {[set index [lsearch -exact $scl [::next::core::current object]]] != -1} { set scl [lreplace $scl $index $index $newName] $subclass superclass $scl } @@ -1078,31 +1090,10 @@ # some utilities ####################################################### -# documentation stub object -> just ignore per default. -# if xoDoc is loaded, documentation will be activated -::xotcl2::Object create ::xotcl::@ { - :method unknown args {} -} - - - - - -####################################################################### - - -# common code for all xotcl versions -namespace eval ::xotcl { - - # export the contents for all xotcl versions - namespace export @ Attribute current - - # if HOME is not set, and ~ is resolved, Tcl chokes on that - if {![info exists ::env(HOME)]} {set ::env(HOME) /root} - set ::xotcl::confdir ~/.xotcl - set ::xotcl::logdir $::xotcl::confdir/log - - # return platform aware temp directory +namespace eval ::next::core { + # + # determine platform aware temp directory + # proc tmpdir {} { foreach e [list TMPDIR TEMP TMP] { if {[info exists ::env($e)] \ @@ -1119,23 +1110,50 @@ } } return /tmp - } + } proc use {version} { set callingNs [uplevel {namespace current}] switch -exact $version { + xotcl - xotcl1 { - package require xotcl1 + package require XOTcl #puts stderr "current=[namespace current], ul=[uplevel {namespace current}]" if {$callingNs ne "::xotcl"} {uplevel {namespace import -force ::xotcl::*}} } default { if {$callingNs ne "::xotcl"} {uplevel {namespace import -force ::xotcl::*}} - if {$callingNs ne "::xotcl2"} {uplevel {namespace import -force ::xotcl2::*}} + if {$callingNs ne "::next"} {uplevel {namespace import -force ::next::*}} } } } + + namespace export tmpdir use +} + +####################################################################### +# common code for all xotcl versions +namespace eval ::next { + + # export the contents for all xotcl versions + namespace export Attribute current + + # if HOME is not set, and ~ is resolved, Tcl chokes on that + if {![info exists ::env(HOME)]} {set ::env(HOME) /root} + + set ::next::confdir ~/.xotcl + set ::next::logdir $::next::confdir/log + unset bootstrap } +# +# The following will go away +# +#namespace eval ::xotcl { +# namespace import ::next::core::use +#} +#foreach ns {::next ::next::core} { +# puts stderr "$ns exports [namespace eval $ns {lsort [namespace export]}]" +#}