Index: generic/predefined.xotcl =================================================================== diff -u -r147831f1098cb9b96a28d4d5b0f9f3ccea35b9da -r901ceb8f58714e31d28ed3277923fc69c085d252 --- generic/predefined.xotcl (.../predefined.xotcl) (revision 147831f1098cb9b96a28d4d5b0f9f3ccea35b9da) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision 901ceb8f58714e31d28ed3277923fc69c085d252) @@ -309,16 +309,11 @@ ::xotcl::MetaSlot create ::xotcl::ObjectParameterSlot ::xotcl::relation ::xotcl::ObjectParameterSlot superclass ::xotcl::Slot - # # create class and object for method parameter slots ::xotcl::MetaSlot create ::xotcl::MethodParameterSlot ::xotcl::relation ::xotcl::MethodParameterSlot superclass ::xotcl::Slot - foreach cmd [info command ::xotcl::cmd::MethodParameterSlot::*] { - ::xotcl::alias ::xotcl::MethodParameterSlot [namespace tail $cmd] $cmd - } - # create an object for dispatching ::xotcl::MethodParameterSlot create ::xotcl::methodParameterSlot @@ -842,15 +837,54 @@ ################################################################## # now the slots are defined; now we can defines the Objects or - # classes with parameters more easily. + # classes with parameters more easily than above. ################################################################## + + # remove helper proc proc createBootstrapAttributeSlots {} {} + + ################################################################## + # create user-level converter/checker based on ::xotcl::ls + ################################################################## + # ::xotcl::is supports predicates for objects + # + # ::xotcl::is object + # ::xotcl::is type + # ::xotcl::is class + # ::xotcl::is baseclass + # ::xotcl::is metaclass + # ::xotcl::is mixin + # + # Map these to type checkers. "object" and "class" + # are already predefined, define the rest. + + ::xotcl::Slot method type=mixin {name value arg} { + if {![::xotcl::is $value mixin $arg]} { + error "Value '$value' of $name has not mixin $arg" + } + return $value + } + ::xotcl::Slot method type=baseclass {name value} { + if {![::xotcl::is $value baseclass]} { + error "Value '$value' of $name is not a baseclass" + } + return $value + } + ::xotcl::Slot method type=metaclass {name value} { + if {![::xotcl::is $value metaclass]} { + error "Value '$value' of $name is not a metaclass" + } + return $value + } + } +################################################################## # Create a mixin class to overload method "new" such it does not # allocate new objects in ::xotcl::*, but in the specified object # (without syntactic overhead). -# +################################################################## + ::xotcl2::Class create ::xotcl::ScopedNew -superclass ::xotcl2::Class -parameter { {withclass ::xotcl2::Object} container @@ -864,12 +898,14 @@ eval ::xotcl::next -childof $object $args } } -# + +################################################################## # The method 'contains' changes the namespace in which objects with # realtive names are created. Therefore, 'contains' provides a # friendly notation for creating nested object structures. Optionally, # creating new objects in the specified scope can be turned off. -# +################################################################## + ::xotcl2::Object public method contains { {-withnew:boolean true} -object @@ -895,9 +931,10 @@ ::xotcl2::Class forward slots %self contains \ -object {%::xotcl::dispatch [::xotcl::self] -objscope ::subst [::xotcl::self]::slot} -# +################################################################## # copy/move implementation -# +################################################################## + ::xotcl2::Class create ::xotcl::CopyHandler -parameter { {targetList ""} {dest ""}