Index: generic/predefined.xotcl =================================================================== diff -u -rd58e86e7557ee729a2a687854c4107d4b212cf35 -rf9e18344d59553044453d08e464acce46664ffcf --- generic/predefined.xotcl (.../predefined.xotcl) (revision d58e86e7557ee729a2a687854c4107d4b212cf35) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision f9e18344d59553044453d08e464acce46664ffcf) @@ -155,12 +155,12 @@ # # already emulated: # - # => info params + # => info params .... replaces # info args # info nonposargs # info default # - # => info instparams + # => info instparams .... replaces # info instargs # info instnonposargs # info instdefault @@ -172,12 +172,12 @@ # # TODO: not yet emulated: # - # => info is + # => info is (bzw. ::xotcl::is) replaces # isobject # isclass # ismetaclass # ismixin - # istype?? + # istype # # => method (should get pre- and postconditions via positional params) # proc @@ -240,6 +240,13 @@ ::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} + # emulation of isobject, ... + ::xotcl::Object instproc isobject {{object:substdefault "[self]"}} {::xotcl::is $object object} + ::xotcl::Object instproc isclass {{class:substdefault "[self]"}} {::xotcl::is $class class} + ::xotcl::Object instproc ismetaclass {{class:substdefault "[self]"}} {::xotcl::is $class metaclass} + ::xotcl::Object instproc ismixin {class} {::xotcl::is [self] mixin $class} + ::xotcl::Object instproc istype {class} {::xotcl::is [self] type $class} + # documentation stub object -> just ignore per default. # if xoDoc is loaded, documentation will be activated ::xotcl::Object create ::xotcl::@ @@ -467,12 +474,12 @@ return [$obj $prop [lsearch -all -not -glob -inline $old $value]] } elseif {[my elementtype] ne ""} { if {[string first :: $value] == -1} { - if {![my isobject $value]} { + if {![::xotcl::is $value object]} { error "$value does not appear to be an object" } set value [$value self] } - if {![$value isclass [my elementtype]]} { + if {![::xotcl::is [my elementtype] class]} { error "$value does not appear to be of type [my elementtype]" } } @@ -581,9 +588,9 @@ set __initcmd "" if {[::xotcl::my exists type]} { ::xotcl::my instvar type name - if {[::xotcl::Object isclass $type]} { + if {[::xotcl::is $type class]} { set predicate [subst -nocommands { - [::xotcl::Object isobject \$value] && [\$value istype $type] + [::xotcl::is \$value object] && [::xotcl::is \$value type $type] }] } elseif {[llength $type]>1} { set predicate "\[$type \$value\]" @@ -663,7 +670,7 @@ ::xotcl::ScopedNew instproc init {} { ::xotcl::my instproc new {-childof args} { [::xotcl::self class] instvar {inobject object} withclass - if {![::xotcl::my isobject $object]} { + if {![::xotcl::is $object object]} { $withclass create $object } eval ::xotcl::next -childof $object $args @@ -681,7 +688,7 @@ {-class ::xotcl::Object} cmds} { if {![info exists object]} {set object [::xotcl::self]} - if {![::xotcl::my isobject $object]} {$class create $object} + if {![::xotcl::is $object object]} {$class create $object} $object requireNamespace if {$withnew} { set m [::xotcl::ScopedNew new \ @@ -788,8 +795,8 @@ # support for XOTcl specific convenience routines ::xotcl::Object instproc hasclass cl { - if {[::xotcl::my ismixin $cl]} {return 1} - ::xotcl::my istype $cl + if {[::xotcl::is [self] mixin $cl]} {return 1} + ::xotcl::is [self] type $cl } ::xotcl::Class instproc allinstances {} { # TODO: mark it deprecated @@ -840,7 +847,7 @@ ::xotcl::Object::CopyHandler instproc makeTargetList t { ::xotcl::my lappend targetList $t # if it is an object without namespace, it is a leaf - if {[::xotcl::my isobject $t]} { + if {[::xotcl::is $t object]} { if {[$t info hasnamespace]} { # make target list from all children set children [$t info children] @@ -852,7 +859,7 @@ # now append all namespaces that are in the obj, but that # are not objects foreach c [namespace children $t] { - if {![::xotcl::my isobject $c]} { + if {![::xotcl::is $c object]} { lappend children [namespace children $t] } } @@ -879,9 +886,9 @@ #puts stderr "COPY will copy targetList = [::xotcl::my set targetList]" foreach origin [::xotcl::my set targetList] { set dest [::xotcl::my getDest $origin] - if {[::xotcl::my isobject $origin]} { + if {[::xotcl::is $origin object]} { # copy class information - if {[::xotcl::my isclass $origin]} { + if {[::xotcl::is $origin class]} { set cl [[$origin info class] create $dest -noinit] # class object set obj $cl @@ -909,7 +916,7 @@ foreach i [$origin info forward] { eval [concat $dest forward $i [$origin info forward -definition $i]] } - if {[::xotcl::my isclass $origin]} { + if {[::xotcl::is $origin class]} { foreach i [$origin info instforward] { eval [concat $dest instforward $i [$origin info instforward -definition $i]] } @@ -932,7 +939,7 @@ } # alter 'domain' and 'manager' in slot objects for classes foreach origin [::xotcl::my set targetList] { - if {[::xotcl::my isclass $origin]} { + if {[::xotcl::is $origin class]} { set dest [::xotcl::my getDest $origin] foreach oldslot [$origin info slots] { set newslot ${dest}::slot::[namespace tail $oldslot] @@ -967,7 +974,7 @@ ::xotcl::my copy $newName } ### let all subclasses get the copied class as superclass - if {[::xotcl::my isclass [::xotcl::self]] && $newName ne ""} { + if {[::xotcl::is [::xotcl::self] class] && $newName ne ""} { foreach subclass [::xotcl::my info subclass] { set scl [$subclass info superclass] if {[set index [lsearch -exact $scl [::xotcl::self]]] != -1} {