Index: generic/predefined.h =================================================================== diff -u -r1e72a93dd117734d0ab49c7ea7aa87f69f9a00b5 -r05f4b42f7615ea410b7ac33093f5b8382ce7e8c5 --- generic/predefined.h (.../predefined.h) (revision 1e72a93dd117734d0ab49c7ea7aa87f69f9a00b5) +++ generic/predefined.h (.../predefined.h) (revision 05f4b42f7615ea410b7ac33093f5b8382ce7e8c5) @@ -206,10 +206,10 @@ "-volatile:method,optional,noarg \\\n" "arg:initcmd,optional\n" "return $parameterdefinitions}\n" -"::xotcl::MetaSlot create ::xotcl::ParameterSlot\n" -"foreach cmd [info command ::xotcl::cmd::ParameterSlot::*] {\n" -"::xotcl::alias ::xotcl::ParameterSlot [namespace tail $cmd] $cmd}\n" -"::xotcl::ParameterSlot create ::xotcl::parameterSlot\n" +"::xotcl::MetaSlot create ::xotcl::MethodParameterSlot\n" +"foreach cmd [info command ::xotcl::cmd::MethodParameterSlot::*] {\n" +"::xotcl::alias ::xotcl::MethodParameterSlot [namespace tail $cmd] $cmd}\n" +"::xotcl::MethodParameterSlot create ::xotcl::methodParameterSlot\n" "proc createBootstrapAttributeSlots {class definitions} {\n" "if {![::xotcl::is ${class}::slot object]} {\n" "::xotcl2::Object create ${class}::slot}\n" @@ -278,18 +278,18 @@ "${:manager} \\\n" "[list %1 [${:manager} defaultmethods]] %self \\\n" "${:methodname}}}\n" -"::xotcl::MetaSlot create ::xotcl::InfoSlot\n" -"createBootstrapAttributeSlots ::xotcl::InfoSlot {\n" +"::xotcl::MetaSlot create ::xotcl::RelationSlot\n" +"createBootstrapAttributeSlots ::xotcl::RelationSlot {\n" "{multivalued true}\n" +"{type relation}\n" "{elementtype ::xotcl2::Class}}\n" -"::xotcl::relation ::xotcl::InfoSlot superclass ::xotcl::Slot\n" -"::xotcl::InfoSlot public method get {obj prop} {\n" -"$obj info $prop}\n" -"::xotcl::InfoSlot public method add {obj prop value {pos 0}} {\n" -"if {![set :multivalued]} {\n" -"error \"Property $prop of ${:domain}->$obj ist not multivalued\"}\n" -"$obj $prop [linsert [$obj info $prop] $pos $value]}\n" -"::xotcl::InfoSlot protected method delete_value {obj prop old value} {\n" +"::xotcl::relation ::xotcl::RelationSlot superclass ::xotcl::Slot\n" +"::xotcl::alias ::xotcl::RelationSlot assign ::xotcl::relation\n" +"::xotcl::RelationSlot protected method init {} {\n" +"if {${:type} ne \"relation\"} {\n" +"error \"RelationSlot requires type == \\\"relation\\\"\"}\n" +"next}\n" +"::xotcl::RelationSlot protected method delete_value {obj prop old value} {\n" "if {[string first * $value] > -1 || [string first \\[ $value] > -1} {\n" "if {${:elementtype} ne \"\" && ![string match ::* $value]} {\n" "set value ::$value}\n" @@ -304,40 +304,35 @@ "if {$p > -1} {\n" "return [lreplace $old $p $p]} else {\n" "error \"$value is not a $prop of $obj (valid are: $old)\"}}\n" -"::xotcl::InfoSlot public method delete {-nocomplain:switch obj prop value} {\n" +"::xotcl::RelationSlot public method delete {-nocomplain:switch obj prop value} {\n" "$obj $prop [:delete_value $obj $prop [$obj info $prop] $value]}\n" -"::xotcl::MetaSlot alloc ::xotcl::InterceptorSlot\n" -"::xotcl::relation ::xotcl::InterceptorSlot superclass ::xotcl::InfoSlot\n" -"::xotcl::alias ::xotcl::InterceptorSlot set ::xotcl::relation ;# for backwards compatibility\n" -"::xotcl::alias ::xotcl::InterceptorSlot assign ::xotcl::relation\n" -"::xotcl::InterceptorSlot public method get {obj prop} {\n" +"::xotcl::RelationSlot public method get {obj prop} {\n" "::xotcl::relation $obj $prop}\n" -"::xotcl::InterceptorSlot public method add {obj prop value {pos 0}} {\n" +"::xotcl::RelationSlot public method add {obj prop value {pos 0}} {\n" "if {![set :multivalued]} {\n" "error \"Property $prop of ${:domain}->$obj ist not multivalued\"}\n" "set oldSetting [::xotcl::relation $obj $prop]\n" "uplevel [list ::xotcl::relation $obj $prop [linsert $oldSetting $pos $value]]}\n" -"::xotcl::InterceptorSlot public method delete {-nocomplain:switch obj prop value} {\n" +"::xotcl::RelationSlot public method delete {-nocomplain:switch obj prop value} {\n" "uplevel [list ::xotcl::relation $obj $prop [:delete_value $obj $prop [::xotcl::relation $obj $prop] $value]]}\n" "proc ::xotcl::register_system_slots {os} {\n" "${os}::Object alloc ${os}::Class::slot\n" "${os}::Object alloc ${os}::Object::slot\n" -"::xotcl::InfoSlot create ${os}::Class::slot::superclass -type relation\n" +"::xotcl::RelationSlot create ${os}::Class::slot::superclass\n" "::xotcl::alias ${os}::Class::slot::superclass assign ::xotcl::relation\n" -"::xotcl::InfoSlot create ${os}::Object::slot::class -type relation\n" +"::xotcl::RelationSlot create ${os}::Object::slot::class -multivalued false\n" "::xotcl::alias ${os}::Object::slot::class assign ::xotcl::relation\n" -"::xotcl::InterceptorSlot create ${os}::Object::slot::mixin \\\n" -"-type relation -methodname object-mixin\n" -"::xotcl::InterceptorSlot create ${os}::Object::slot::filter \\\n" -"-elementtype \"\" -type relation\n" -"::xotcl::InterceptorSlot create ${os}::Class::slot::mixin \\\n" -"-type relation -methodname class-mixin\n" -"::xotcl::InterceptorSlot create ${os}::Class::slot::filter \\\n" -"-type relation -methodname filter-mixin\n" -"::xotcl::InterceptorSlot create ${os}::Class::slot::object-mixin \\\n" -"-type relation\n" -"::xotcl::InterceptorSlot create ${os}::Class::slot::object-filter \\\n" -"-elementtype \"\" -type relation}\n" +"::xotcl::RelationSlot create ${os}::Object::slot::mixin \\\n" +"-methodname object-mixin\n" +"::xotcl::RelationSlot create ${os}::Object::slot::filter \\\n" +"-elementtype \"\"\n" +"::xotcl::RelationSlot create ${os}::Class::slot::mixin \\\n" +"-methodname class-mixin\n" +"::xotcl::RelationSlot create ${os}::Class::slot::filter \\\n" +"-methodname filter-mixin\n" +"::xotcl::RelationSlot create ${os}::Class::slot::object-mixin\n" +"::xotcl::RelationSlot create ${os}::Class::slot::object-filter \\\n" +"-elementtype \"\"}\n" "::xotcl::register_system_slots ::xotcl2\n" "::xotcl::MetaSlot __invalidateobjectparameter\n" "::xotcl::MetaSlot create ::xotcl::Attribute -superclass ::xotcl::Slot\n" Index: generic/predefined.xotcl =================================================================== diff -u -r1e72a93dd117734d0ab49c7ea7aa87f69f9a00b5 -r05f4b42f7615ea410b7ac33093f5b8382ce7e8c5 --- generic/predefined.xotcl (.../predefined.xotcl) (revision 1e72a93dd117734d0ab49c7ea7aa87f69f9a00b5) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision 05f4b42f7615ea410b7ac33093f5b8382ce7e8c5) @@ -413,14 +413,14 @@ } # - # create class and object for parameter slots - ::xotcl::MetaSlot create ::xotcl::ParameterSlot - foreach cmd [info command ::xotcl::cmd::ParameterSlot::*] { - ::xotcl::alias ::xotcl::ParameterSlot [namespace tail $cmd] $cmd + # create class and object for method parameter slots + ::xotcl::MetaSlot create ::xotcl::MethodParameterSlot + foreach cmd [info command ::xotcl::cmd::MethodParameterSlot::*] { + ::xotcl::alias ::xotcl::MethodParameterSlot [namespace tail $cmd] $cmd } # create an object for dispatching - ::xotcl::ParameterSlot create ::xotcl::parameterSlot + ::xotcl::MethodParameterSlot create ::xotcl::methodParameterSlot # use low level interface for defining slot values. Normally, this is @@ -542,25 +542,24 @@ } ############################################ - # InfoSlot + # RelationSlot ############################################ - ::xotcl::MetaSlot create ::xotcl::InfoSlot - createBootstrapAttributeSlots ::xotcl::InfoSlot { + ::xotcl::MetaSlot create ::xotcl::RelationSlot + createBootstrapAttributeSlots ::xotcl::RelationSlot { {multivalued true} + {type relation} {elementtype ::xotcl2::Class} } - ::xotcl::relation ::xotcl::InfoSlot superclass ::xotcl::Slot - ::xotcl::InfoSlot public method get {obj prop} { - $obj info $prop - } - ::xotcl::InfoSlot public method add {obj prop value {pos 0}} { - if {![set :multivalued]} { - error "Property $prop of ${:domain}->$obj ist not multivalued" + ::xotcl::relation ::xotcl::RelationSlot superclass ::xotcl::Slot + ::xotcl::alias ::xotcl::RelationSlot assign ::xotcl::relation + + ::xotcl::RelationSlot protected method init {} { + if {${:type} ne "relation"} { + error "RelationSlot requires type == \"relation\"" } - #puts stderr "adding infoslot: $obj $prop [linsert [$obj info $prop] $pos $value]" - $obj $prop [linsert [$obj info $prop] $pos $value] + next } - ::xotcl::InfoSlot protected method delete_value {obj prop old value} { + ::xotcl::RelationSlot protected method delete_value {obj prop old value} { if {[string first * $value] > -1 || [string first \[ $value] > -1} { # string contains meta characters if {${:elementtype} ne "" && ![string match ::* $value]} { @@ -587,69 +586,55 @@ } } - ::xotcl::InfoSlot public method delete {-nocomplain:switch obj prop value} { - #puts stderr infoslot-delete-[self args] + ::xotcl::RelationSlot public method delete {-nocomplain:switch obj prop value} { + #puts stderr RelationSlot-delete-[self args] $obj $prop [:delete_value $obj $prop [$obj info $prop] $value] } - ############################################ - # InterceptorSlot - ############################################ - ::xotcl::MetaSlot alloc ::xotcl::InterceptorSlot - - ::xotcl::relation ::xotcl::InterceptorSlot superclass ::xotcl::InfoSlot - ::xotcl::alias ::xotcl::InterceptorSlot set ::xotcl::relation ;# for backwards compatibility - ::xotcl::alias ::xotcl::InterceptorSlot assign ::xotcl::relation - - ::xotcl::InterceptorSlot public method get {obj prop} { + ::xotcl::RelationSlot public method get {obj prop} { ::xotcl::relation $obj $prop } - ::xotcl::InterceptorSlot public method add {obj prop value {pos 0}} { + ::xotcl::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] # use uplevel to avoid namespace surprises uplevel [list ::xotcl::relation $obj $prop [linsert $oldSetting $pos $value]] } - ::xotcl::InterceptorSlot public method delete {-nocomplain:switch obj prop 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]] } + ############################################ # system slots ############################################ proc ::xotcl::register_system_slots {os} { ${os}::Object alloc ${os}::Class::slot ${os}::Object alloc ${os}::Object::slot - ::xotcl::InfoSlot create ${os}::Class::slot::superclass -type relation + ::xotcl::RelationSlot create ${os}::Class::slot::superclass ::xotcl::alias ${os}::Class::slot::superclass assign ::xotcl::relation - ::xotcl::InfoSlot create ${os}::Object::slot::class -type relation + ::xotcl::RelationSlot create ${os}::Object::slot::class -multivalued false ::xotcl::alias ${os}::Object::slot::class assign ::xotcl::relation - ::xotcl::InterceptorSlot create ${os}::Object::slot::mixin \ - -type relation -methodname object-mixin + ::xotcl::RelationSlot create ${os}::Object::slot::mixin \ + -methodname object-mixin - ::xotcl::InterceptorSlot create ${os}::Object::slot::filter \ - -elementtype "" -type relation + ::xotcl::RelationSlot create ${os}::Object::slot::filter \ + -elementtype "" - ::xotcl::InterceptorSlot create ${os}::Class::slot::mixin \ - -type relation -methodname class-mixin - ::xotcl::InterceptorSlot create ${os}::Class::slot::filter \ - -type relation -methodname filter-mixin + ::xotcl::RelationSlot create ${os}::Class::slot::mixin \ + -methodname class-mixin + ::xotcl::RelationSlot create ${os}::Class::slot::filter \ + -methodname filter-mixin # create tho conveniance slots to allow configuration of # object-slots for classes via object-mixin - ::xotcl::InterceptorSlot create ${os}::Class::slot::object-mixin \ - -type relation - ::xotcl::InterceptorSlot create ${os}::Class::slot::object-filter \ - -elementtype "" -type relation - - # We could define a mixin on class, the calls always class-mixin. - # therfore, - #::xotcl::InterceptorSlot create ${os}::Class::slot::mixin \ - # -type relation -methodname class-mixin + ::xotcl::RelationSlot create ${os}::Class::slot::object-mixin + ::xotcl::RelationSlot create ${os}::Class::slot::object-filter \ + -elementtype "" } ::xotcl::register_system_slots ::xotcl2 Index: generic/xotcl.c =================================================================== diff -u -r1e72a93dd117734d0ab49c7ea7aa87f69f9a00b5 -r05f4b42f7615ea410b7ac33093f5b8382ce7e8c5 --- generic/xotcl.c (.../xotcl.c) (revision 1e72a93dd117734d0ab49c7ea7aa87f69f9a00b5) +++ generic/xotcl.c (.../xotcl.c) (revision 05f4b42f7615ea410b7ac33093f5b8382ce7e8c5) @@ -6250,7 +6250,7 @@ Tcl_Obj *ov[5]; int result, oc; - ov[0] = XOTclGlobalObjects[XOTE_PARAMETER_SLOT_OBJ]; + ov[0] = XOTclGlobalObjects[XOTE_METHOD_PARAMETER_SLOT_OBJ]; ov[1] = pPtr->converterName; ov[2] = pPtr->nameObj; ov[3] = objPtr; @@ -6374,7 +6374,7 @@ XOTclClass *pcl; Tcl_Command cmd; - result = GetObjectFromObj(interp, XOTclGlobalObjects[XOTE_PARAMETER_SLOT_OBJ], ¶mObj); + result = GetObjectFromObj(interp, XOTclGlobalObjects[XOTE_METHOD_PARAMETER_SLOT_OBJ], ¶mObj); if (result != TCL_OK) return result; Index: generic/xotclInt.h =================================================================== diff -u -rd3aa8e069917e7ba7d69e936ec4e563b7e0dc34d -r05f4b42f7615ea410b7ac33093f5b8382ce7e8c5 --- generic/xotclInt.h (.../xotclInt.h) (revision d3aa8e069917e7ba7d69e936ec4e563b7e0dc34d) +++ generic/xotclInt.h (.../xotclInt.h) (revision 05f4b42f7615ea410b7ac33093f5b8382ce7e8c5) @@ -506,7 +506,7 @@ XOTE_AUTONAMES, XOTE_DEFAULTMETACLASS, XOTE_DEFAULTSUPERCLASS, XOTE_ALIAS_ARRAY, /* object/class names */ - XOTE_PARAMETER_SLOT_OBJ, + XOTE_METHOD_PARAMETER_SLOT_OBJ, /* constants */ XOTE_ALIAS, XOTE_ARGS, XOTE_CMD, XOTE_FILTER, XOTE_FORWARD, XOTE_METHOD, XOTE_OBJECT, XOTE_SETTER, @@ -529,7 +529,7 @@ "__autonames", "__default_metaclass", "__default_superclass", "::xotcl::alias", /* object/class names */ - "::xotcl::parameterSlot", + "::xotcl::methodParameterSlot", /* constants */ "alias", "args", "cmd", "filter", "forward", "method", "object", "setter", Index: library/lib/xotcl1.xotcl =================================================================== diff -u -r1e72a93dd117734d0ab49c7ea7aa87f69f9a00b5 -r05f4b42f7615ea410b7ac33093f5b8382ce7e8c5 --- library/lib/xotcl1.xotcl (.../xotcl1.xotcl) (revision 1e72a93dd117734d0ab49c7ea7aa87f69f9a00b5) +++ library/lib/xotcl1.xotcl (.../xotcl1.xotcl) (revision 05f4b42f7615ea410b7ac33093f5b8382ce7e8c5) @@ -128,20 +128,20 @@ ${os}::Object alloc ${os}::Class::slot ${os}::Object alloc ${os}::Object::slot - ::xotcl::InfoSlot create ${os}::Class::slot::superclass -type relation + ::xotcl::RelationSlot create ${os}::Class::slot::superclass ::xotcl::alias ${os}::Class::slot::superclass assign ::xotcl::relation - ::xotcl::InfoSlot create ${os}::Object::slot::class -type relation + ::xotcl::RelationSlot create ${os}::Object::slot::class -multivalued false ::xotcl::alias ${os}::Object::slot::class assign ::xotcl::relation - ::xotcl::InterceptorSlot create ${os}::Object::slot::mixin \ - -type relation -methodname object-mixin - ::xotcl::InterceptorSlot create ${os}::Object::slot::filter \ - -type relation -methodname object-filter \ + ::xotcl::RelationSlot create ${os}::Object::slot::mixin \ + -methodname object-mixin + ::xotcl::RelationSlot create ${os}::Object::slot::filter \ + -methodname object-filter \ -elementtype "" - ::xotcl::InterceptorSlot create ${os}::Class::slot::instmixin \ - -type relation -methodname class-mixin - ::xotcl::InterceptorSlot create ${os}::Class::slot::instfilter \ - -type relation -methodname class-filter \ + ::xotcl::RelationSlot create ${os}::Class::slot::instmixin \ + -methodname class-mixin + ::xotcl::RelationSlot create ${os}::Class::slot::instfilter \ + -methodname class-filter \ -elementtype "" } ::xotcl::register_system_slots1 ::xotcl Index: tests/parameters.xotcl =================================================================== diff -u -rd3aa8e069917e7ba7d69e936ec4e563b7e0dc34d -r05f4b42f7615ea410b7ac33093f5b8382ce7e8c5 --- tests/parameters.xotcl (.../parameters.xotcl) (revision d3aa8e069917e7ba7d69e936ec4e563b7e0dc34d) +++ tests/parameters.xotcl (.../parameters.xotcl) (revision 05f4b42f7615ea410b7ac33093f5b8382ce7e8c5) @@ -64,7 +64,36 @@ # objectOfType YES YES NO NO YES YES YES # userdefined YES YES NO YES YES YES YES -# MetaSlot create ParameterSlot -parameter {type required multivalued noarg arg} +#::xotcl::Slot { +# {name "[namespace tail [::xotcl::self]]"} +# {methodname} +# {domain "[lindex [regexp -inline {^(.*)::slot::[^:]+$} [::xotcl::self]] 1]"} +# {defaultmethods {get assign}} +# {manager "[::xotcl::self]"} +# {multivalued false} +# {per-object false} +# {forward-per-object} +# {required false} +# default +# type +# } -- No instances +# +# ::xotcl::RelationSlot -superclass ::xotcl::Slot { +# {multivalued true} +# {type relation} +# {elementtype ::xotcl2::Class} +# } -- sample instances: class superclass, mixin filter +# +# ::xotcl::Attribute -superclass ::xotcl::Slot { +# {value_check once} +# initcmd +# valuecmd +# valuechangedcmd +# arg +# } -- typical object parameters +# +# MethodParameterSlot -parameter {type required multivalued noarg arg} +# -- typical method parameters ####################################################### @@ -375,7 +404,7 @@ Test case user-types # create a userdefined type -::xotcl::parameterSlot method type=mytype {name value args} { +::xotcl::methodParameterSlot method type=mytype {name value args} { if {$value < 1 || $value > 3} { error "Value '$value' of parameter $name is not between 1 and 3" } @@ -395,11 +424,11 @@ } ? {d1 foo 10} \ - "::xotcl::parameterSlot: unable to dispatch method 'type=unknowntype'" \ + "::xotcl::methodParameterSlot: unable to dispatch method 'type=unknowntype'" \ "missing type checker" # create a userdefined type with a simple argument -::xotcl::parameterSlot method type=in {name value arg} { +::xotcl::methodParameterSlot method type=in {name value arg} { if {$value ni [split $arg |]} { error "Value '$value' of parameter $name not in permissible values $arg" } @@ -424,7 +453,7 @@ "Value 'very good' of parameter b not in permissible values good|bad" \ "invalid value (not included)" -::xotcl::parameterSlot method type=range {name value arg} { +::xotcl::methodParameterSlot method type=range {name value arg} { foreach {min max} [split $arg -] break if {$value < $min || $value > $max} { error "Value '$value' of parameter $name not between $min and $max" @@ -449,7 +478,7 @@ # # handling of arg with spaces/arg as list # -::xotcl::parameterSlot method type=list {name value arg} { +::xotcl::methodParameterSlot method type=list {name value arg} { #puts $value/$arg } @@ -482,17 +511,17 @@ # are already predefined, define the rest. # TODO: should go finally to predefined. -::xotcl::parameterSlot method type=mixin {name value arg} { +::xotcl::methodParameterSlot method type=mixin {name value arg} { if {![::xotcl::is $value mixin $arg]} { error "Value '$value' of $name has not mixin $arg" } } -::xotcl::parameterSlot method type=baseclass {name value} { +::xotcl::methodParameterSlot method type=baseclass {name value} { if {![::xotcl::is $value baseclass]} { error "Value '$value' of $name is not a baseclass" } } -::xotcl::parameterSlot method type=metaclass {name value} { +::xotcl::methodParameterSlot method type=metaclass {name value} { if {![::xotcl::is $value metaclass]} { error "Value '$value' of $name is not a metaclass" } Index: tests/slottest.xotcl =================================================================== diff -u -red15b5be7e88cbbcdf6121f3869722dbc354d76f -r05f4b42f7615ea410b7ac33093f5b8382ce7e8c5 --- tests/slottest.xotcl (.../slottest.xotcl) (revision ed15b5be7e88cbbcdf6121f3869722dbc354d76f) +++ tests/slottest.xotcl (.../slottest.xotcl) (revision 05f4b42f7615ea410b7ac33093f5b8382ce7e8c5) @@ -85,7 +85,8 @@ ? {O mixin} ::M2 O mixin "" ? {O mixin} "" -O mixin set M ;# not sure, whether we should keep set here, or use assign or some better term +#O mixin set M ;# not sure, whether we should keep set here, or use assign or some better term +O mixin assign M ;# new name ? {O mixin} ::M ? {O mixin ""} "" @@ -96,7 +97,7 @@ # "class" is not multivalued, therefore we should not add (or remove) add/delete # from the set of subcommands... -? {::xotcl::InfoSlot class} "::xotcl::MetaSlot" +? {::xotcl::RelationSlot class} "::xotcl::MetaSlot" O o1 ? {o1 class} "::O" o1 class Object