Index: generic/predefined.xotcl =================================================================== diff -u -rf0f0b5422a37c8d05f6b835de37fda6bb7347dfd -rdaafc0f0261f6b47a01c7cc8975acdd66f91f360 --- generic/predefined.xotcl (.../predefined.xotcl) (revision f0f0b5422a37c8d05f6b835de37fda6bb7347dfd) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision daafc0f0261f6b47a01c7cc8975acdd66f91f360) @@ -42,7 +42,7 @@ # foreach cmd [info command ::nx::core::cmd::Object::*] { set cmdName [namespace tail $cmd] - if {$cmdName in [list "instvar"]} continue + if {$cmdName in [list "exists" "instvar"]} continue ::nx::core::alias Object $cmdName $cmd } @@ -445,9 +445,11 @@ return ${slotParent}::$name } - ::nx::MetaSlot method createFromParameterSyntax {target -per-object:switch - {-initblock ""} - value default:optional} { + ::nx::MetaSlot method createFromParameterSyntax { + target -per-object:switch + {-initblock ""} + value default:optional + } { set opts [list] set colonPos [string first : $value] if {$colonPos == -1} { @@ -518,7 +520,7 @@ # 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} @@ -541,7 +543,7 @@ # checking subclasses is not required during bootstrap foreach i [::nx::core::cmd::ClassInfo::instances $class] { - if {![$i exists $att]} { + if {![::nx::core::existsvar $i $att]} { if {[string match {*\[*\]*} $default]} { set value [::nx::core::dispatch $i -objscope ::eval subst $default] } else { @@ -557,8 +559,7 @@ #puts stderr "Bootstrapslot for $class calls __invalidateobjectparameter" $class __invalidateobjectparameter } - - + ############################################ # Define slots for slots ############################################ @@ -619,6 +620,7 @@ # # If set to {{{true}}}, the accessor methods are registered with the # domain object scope only. It defaults to {{{false}}}. + createBootstrapAttributeSlots ::nx::ObjectParameterSlot { {name "[namespace tail [::nx::core::current object]]"} {methodname} @@ -639,7 +641,7 @@ if {![set :multivalued]} { error "Property $prop of [set :domain]->$obj ist not multivalued" } - if {[$obj exists $prop]} { + if {[::nx::core::existsvar $obj $prop]} { ::nx::core::setvar $obj $prop [linsert [::nx::core::setvar $obj $prop] $pos $value] } else { ::nx::core::setvar $obj $prop [list $value] @@ -692,7 +694,7 @@ ${:methodname} } } - + ################################################################# # We have no working objectparameter yet, since it requires a # minimal slot infrastructure to build object parameters from @@ -775,7 +777,8 @@ #puts stderr "[::nx::core::current method] ${name} returns [list oparam $objparamdefinition mparam $methodparamdefinition]" return [list oparam $objparamdefinition mparam $methodparamdefinition] } - + + proc ::nx::core::parametersFromSlots {obj} { set parameterdefinitions [list] foreach slot [::nx::objectInfo slotobjects $obj] { @@ -789,7 +792,7 @@ } return $parameterdefinitions } - + # @method ::nx::Object#objectparameter ::nx::Object protected method objectparameter {{lastparameter __initcmd:initcmd,optional}} { #puts stderr "... objectparameter [::nx::core::current object]" @@ -804,8 +807,8 @@ #puts stderr "*** parameter definition for [::nx::core::current object]: $parameterdefinitions" return $parameterdefinitions } - + ############################################ # RelationSlot ############################################ @@ -852,7 +855,7 @@ error "$value is not a $prop of $obj (valid are: $old)" } } - + ::nx::RelationSlot public method delete {-nocomplain:switch obj prop value} { #puts stderr RelationSlot-delete-[::nx::core::current args] $obj $prop [:delete_value $obj $prop [$obj info $prop] $value] @@ -861,6 +864,7 @@ ::nx::RelationSlot public method get {obj prop} { ::nx::core::relation $obj $prop } + ::nx::RelationSlot public method add {obj prop value {pos 0}} { if {![set :multivalued]} { error "Property $prop of ${:domain}->$obj ist not multivalued" @@ -872,8 +876,8 @@ ::nx::RelationSlot public method delete {-nocomplain:switch obj prop value} { uplevel [list ::nx::core::relation $obj $prop [:delete_value $obj $prop [::nx::core::relation $obj $prop] $value]] } - - + + ############################################ # system slots ############################################ @@ -951,16 +955,18 @@ ::nx::RelationSlot create ${os}::Class::slot::object-mixin ::nx::RelationSlot create ${os}::Class::slot::object-filter -elementtype "" } + ::nx::core::register_system_slots ::nx proc ::nx::core::register_system_slots {} {} + ############################################ # Attribute slots ############################################ ::nx::MetaSlot __invalidateobjectparameter # @object ::nx::Attribute - # + # Attribute slots are used to manage the access, mutation, and # querying of instance variables. There is a helper method {{@method # ::nx::Object class attribute}} to define the attributes of classes @@ -982,7 +988,7 @@ # @param arg # @superclass ::nx::doc::entities::object::nx::ObjectParameterSlot ::nx::MetaSlot create ::nx::Attribute -superclass ::nx::ObjectParameterSlot - + createBootstrapAttributeSlots ::nx::Attribute { {value_check once} incremental @@ -1010,11 +1016,11 @@ ::nx::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] { + if {[info exists :default]} { + } elseif [info exists :initcmd] { append __initcmd ":trace add variable [list ${:name}] read \ \[list [::nx::core::current object] __default_from_cmd \[::nx::core::current object\] [list [set :initcmd]]\]\n" - } elseif [:exists valuecmd] { + } elseif [info exists :valuecmd] { append __initcmd ":trace add variable [list ${:name}] read \ \[list [::nx::core::current object] __value_from_cmd \[::nx::core::current object\] [list [set :valuecmd]]\]" } @@ -1039,7 +1045,7 @@ } } - if {[:exists valuechangedcmd]} { + if {[info exists :valuechangedcmd]} { append __initcmd ":trace add variable [list ${:name}] write \ \[list [::nx::core::current object] __value_changed_cmd \[::nx::core::current object\] [list [set :valuechangedcmd]]\]" }