Index: generic/gentclAPI.decls =================================================================== diff -u -r962c96dcc0ddc25782570a831c104fb2b955891d -r142687efa93af981936db61ecfde494d8f269b0a --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 962c96dcc0ddc25782570a831c104fb2b955891d) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -21,7 +21,6 @@ {-argName "methodName"} {-argName "-objscope"} {-argName "-per-object"} - {-argName "-protected"} {-argName "cmdName" -required 1 -type tclobj} } xotclCmd configure XOTclConfigureCmd { @@ -232,7 +231,6 @@ {-argName "target" -type tclobj} {-argName "args" -type args} } -# todo -protected for XOTclCInstForwardMethod classMethod __invalidateobjectparameter XOTclCInvalidateObjectParameterMethod { } classMethod recreate XOTclCRecreateMethod { Index: generic/predefined.h =================================================================== diff -u -r962c96dcc0ddc25782570a831c104fb2b955891d -r142687efa93af981936db61ecfde494d8f269b0a --- generic/predefined.h (.../predefined.h) (revision 962c96dcc0ddc25782570a831c104fb2b955891d) +++ generic/predefined.h (.../predefined.h) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -21,71 +21,63 @@ "::xotcl::methodproperty Class dealloc static true\n" "::xotcl::methodproperty Class create static true\n" "::xotcl::dispatch Class ::xotcl::cmd::Class::class-method method {\n" -"-per-object:switch -public:switch -protected:switch\n" +"-per-object:switch\n" "name arguments body -precondition -postcondition} {\n" "set conditions [list]\n" "if {[info exists precondition]} {lappend conditions -precondition $precondition}\n" "if {[info exists postcondition]} {lappend conditions -postcondition $postcondition}\n" -"if {${per-object}} {\n" -"set cls Object\n" -"set prefix object} else {\n" -"set cls Class\n" -"set prefix class}\n" -"set result [::xotcl::dispatch [self] ::xotcl::cmd::${cls}::$prefix-method \\\n" -"$name $arguments $body {*}$conditions]\n" -"if {$protected} {::xotcl::methodproperty [self] $name protected true}\n" -"return $result}\n" +"set cls [expr {${per-object} ? \"Object\" : \"Class\"}]\n" +"::xotcl::dispatch [self] ::xotcl::cmd::${cls}::[string tolower $cls]-method \\\n" +"$name $arguments $body {*}$conditions}\n" "::xotcl::dispatch Object ::xotcl::cmd::Class::class-method method {\n" -"-public:switch -protected:switch\n" "name arguments body -precondition -postcondition} {\n" "set conditions [list]\n" "if {[info exists precondition]} {lappend conditions -precondition $precondition}\n" "if {[info exists postcondition]} {lappend conditions -postcondition $postcondition}\n" -"set result [::xotcl::dispatch [self] ::xotcl::cmd::Object::object-method \\\n" -"$name $arguments $body {*}$conditions]\n" -"if {$protected} {::xotcl::methodproperty [self] $name -per-object protected true}\n" -"return $result}\n" -"Object method -public public {args} {\n" +"::xotcl::dispatch [self] ::xotcl::cmd::Object::object-method \\\n" +"$name $arguments $body {*}$conditions}\n" +"::xotcl::dispatch Class -objscope ::eval {\n" +".method object {args} {\n" +"set p [expr {[lsearch -regexp $args {^(method|alias|forward|setter)$}] + 1}]\n" +"set cmd [linsert $args $p \"-per-object\"]\n" +"return [{*}.$cmd]}\n" +".method unknown {m args} {\n" +"error \"Method '$m' unknown for [self].\\\n" +"Consider '[self] create $m $args' instead of '[self] $m $args'\"}}\n" +"::xotcl::dispatch Object -objscope ::eval {\n" +".method public {args} {\n" "set p [lsearch -regexp $args {^(method|alias|forward|setter)$}]\n" "if {$p == -1} {error \"$args is not a method defining method\"}\n" "set r [{*}.$args]\n" "::xotcl::methodproperty [self] $r protected false\n" "return $r}\n" -"Object method -public protected {args} {\n" +".method protected {args} {\n" "set p [lsearch -regexp $args {^(method|alias|forward|setter)$}]\n" "if {$p == -1} {error \"$args is not a method defining command\"}\n" "set r [{*}.$args]\n" "::xotcl::methodproperty [self] $r [self proc] true\n" "return $r}\n" -"Class method -public object {args} {\n" -"set p [expr {[lsearch -regexp $args {^(method|alias|forward|setter)$}] + 1}]\n" -"set cmd [linsert $args $p \"-per-object\"]\n" -"return [{*}.$cmd]}\n" -"Class method unknown {m args} {\n" -"error \"Method '$m' unknown for [self]. Consider '[self] create $m $args' instead of '[self] $m $args'\"}\n" -"Object method unknown {m args} {\n" +".method unknown {m args} {\n" "if {![self isnext]} {\n" "error \"[self]: unable to dispatch method '$m'\"}}\n" -"Object method -protected init args {}\n" -"Object method defaultmethod {} {::xotcl::self}\n" -"Object method -protected objectparameter {} {;}\n" -"Class method -per-object __unknown {name} {}\n" -"Object method -public alias {-objscope:switch -protected:switch methodName cmd} {\n" +".protected method init args {}\n" +".protected method defaultmethod {} {::xotcl::self}\n" +".protected method objectparameter {} {;}}\n" +"Class protected object method __unknown {name} {}\n" +"Object public method alias {-objscope:switch methodName cmd} {\n" "::xotcl::alias [self] $methodName \\\n" "{*}[expr {${objscope} ? \"-objscope\" : \"\"}] \\\n" -"{*}[expr {${protected} ? \"-protected\" : \"\"}] \\\n" "$cmd}\n" -"Class method -public alias {-objscope:switch -per-object:switch -protected:switch methodName cmd} {\n" +"Class public method alias {-objscope:switch -per-object:switch methodName cmd} {\n" "::xotcl::alias [self] $methodName \\\n" "{*}[expr {${objscope} ? \"-objscope\" : \"\"}] \\\n" "{*}[expr {${per-object} ? \"-per-object\" : \"\"}] \\\n" -"{*}[expr {${protected} ? \"-protected\" : \"\"}] \\\n" "$cmd}\n" "Object create ::xotcl2::objectInfo\n" "Object create ::xotcl2::classInfo\n" "::xotcl::dispatch objectInfo -objscope ::eval {\n" ".alias is ::xotcl::is\n" -".method -public info {obj} {\n" +".public method info {obj} {\n" "set methods [list]\n" "foreach name [::xotcl::cmd::ObjectInfo::methods [self]] {\n" "if {$name eq \"unknown\"} continue\n" @@ -134,7 +126,7 @@ "namespace export Object Class}\n" "::xotcl2::Class create ::xotcl::MetaSlot\n" "::xotcl::relation ::xotcl::MetaSlot superclass ::xotcl2::Class\n" -"::xotcl::MetaSlot method -public new args {\n" +"::xotcl::MetaSlot public method new args {\n" "set slotobject [::xotcl::self callingobject]::slot\n" "if {![::xotcl::is $slotobject object]} {::xotcls::Object create $slotobject}\n" "eval next -childof $slotobject $args}\n" @@ -165,7 +157,7 @@ "unset arg}\n" "lappend parameterdefinitions $parameterdefinition}\n" "return $parameterdefinitions}\n" -"::xotcl2::Object method -protected objectparameter {} {\n" +"::xotcl2::Object protected method objectparameter {} {\n" "set parameterdefinitions [::xotcl::parametersFromSlots [self]]\n" "if {[::xotcl::is [self] class]} {\n" "lappend parameterdefinitions -parameter:method,optional}\n" @@ -211,13 +203,13 @@ "type}\n" "::xotcl::alias ::xotcl::Slot get ::xotcl::setinstvar\n" "::xotcl::alias ::xotcl::Slot assign ::xotcl::setinstvar\n" -"::xotcl::Slot method -public add {obj prop value {pos 0}} {\n" +"::xotcl::Slot public method add {obj prop value {pos 0}} {\n" "if {![set .multivalued]} {\n" "error \"Property $prop of [set .domain]->$obj ist not multivalued\"}\n" "if {[$obj exists $prop]} {\n" "::xotcl::setinstvar $obj $prop [linsert [::xotcl::setinstvar $obj $prop] $pos $value]} else {\n" "::xotcl::setinstvar $obj $prop [list $value]}}\n" -"::xotcl::Slot method -public delete {-nocomplain:switch obj prop value} {\n" +"::xotcl::Slot public method delete {-nocomplain:switch obj prop value} {\n" "set old [::xotcl::setinstvar $obj $prop]\n" "set p [lsearch -glob $old $value]\n" "if {$p>-1} {::xotcl::setinstvar $obj $prop [lreplace $old $p $p]} else {\n" @@ -229,7 +221,7 @@ "if {[string match __* $m]} continue\n" "lappend methods $m}\n" "error \"Method '$method' unknown for slot [::xotcl::self]; valid are: {[lsort $methods]]}\"}\n" -"::xotcl::Slot method -public destroy {} {\n" +"::xotcl::Slot public method destroy {} {\n" "if {${.domain} ne \"\"} {\n" "${.domain} __invalidateobjectparameter}\n" "next}\n" @@ -248,14 +240,14 @@ "{multivalued true}\n" "{elementtype ::xotcl2::Class}}\n" "::xotcl::relation ::xotcl::InfoSlot superclass ::xotcl::Slot\n" -"::xotcl::InfoSlot method -public get {obj prop} {\n" +"::xotcl::InfoSlot public method get {obj prop} {\n" "$obj info $prop}\n" -"::xotcl::InfoSlot method -public add {obj prop value {pos 0}} {\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" "puts stderr \"adding infoslot: $obj $prop [linsert [$obj info $prop] $pos $value]\"\n" "$obj $prop [linsert [$obj info $prop] $pos $value]}\n" -"::xotcl::InfoSlot method -public delete {-nocomplain:switch obj prop value} {\n" +"::xotcl::InfoSlot public method delete {-nocomplain:switch obj prop value} {\n" "puts stderr infoslot-delete-[self args]\n" "set old [$obj info $prop]\n" "if {[string first * $value] > -1 || [string first \\[ $value] > -1} {\n" @@ -276,9 +268,9 @@ "::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 method -public get {obj -per-object:switch prop} {\n" +"::xotcl::InterceptorSlot public method get {obj -per-object:switch prop} {\n" "::xotcl::relation $obj {*}[expr {${per-object} ? \"-per-object\" : \"\"}] $prop}\n" -"::xotcl::InterceptorSlot method -public add {obj -per-object:switch prop value {pos 0}} {\n" +"::xotcl::InterceptorSlot public method add {obj -per-object:switch prop value {pos 0}} {\n" "if {![set .multivalued]} {\n" "error \"Property $prop of ${.domain}->$obj ist not multivalued\"}\n" "set perObject [expr {${per-object} ? \"-per-object\" : \"\"}]\n" @@ -356,7 +348,7 @@ ".method method args {::xotcl::next; .optimize}\n" ".method forward args {::xotcl::next; .optimize}\n" ".method init args {::xotcl::next; .optimize}\n" -".method -public optimize {} {\n" +".public method optimize {} {\n" "if {[set .multivalued]} return\n" "if {[set .defaultmethods] ne {get assign}} return\n" "if {[.info callable -which assign] ne \"::xotcl::Slot alias assign ::xotcl::setinstvar\"} return\n" @@ -368,12 +360,12 @@ "{withclass ::xotcl2::Object}\n" "inobject}\n" "::xotcl::ScopedNew method init {} {\n" -".method -public new {-childof args} {\n" +".public method new {-childof args} {\n" "::xotcl::instvar -object [::xotcl::self class] {inobject object} withclass\n" "if {![::xotcl::is $object object]} {\n" "$withclass create $object}\n" "eval ::xotcl::next -childof $object $args}}\n" -"::xotcl2::Object method -public contains {\n" +"::xotcl2::Object public method contains {\n" "{-withnew:boolean true}\n" "-object\n" "{-class ::xotcl2::Object}\n" @@ -390,7 +382,7 @@ "namespace eval $object $cmds}}\n" "::xotcl2::Class forward slots %self contains \\\n" "-object {%::xotcl::dispatch [::xotcl::self] -objscope ::subst [::xotcl::self]::slot}\n" -"::xotcl2::Class method -public parameter arglist {\n" +"::xotcl2::Class public method parameter arglist {\n" "if {![::xotcl::is [::xotcl::self]::slot object]} {\n" "::xotcl2::Object create [::xotcl::self]::slot}\n" "foreach arg $arglist {\n" @@ -433,7 +425,7 @@ "if {![info exists setter]} {set setter set}\n" "if {![info exists getter]} {set getter set}\n" "if {![info exists access]} {set access ::xotcl::my}\n" -"$cl method -public $name args \"\n" +"$cl public method $name args \"\n" "if {\\[llength \\$args] == 0} {\n" "return \\[$access $getter $extra $name\\]} else {\n" "return \\[eval $access $setter $extra $name \\$args $defaultParam \\]}\"\n" @@ -504,15 +496,15 @@ "set newslot ${dest}::slot::[namespace tail $oldslot]\n" "if {[$oldslot domain] eq $origin} {$newslot domain $cl}\n" "if {[$oldslot manager] eq $oldslot} {$newslot manager $newslot}}}}}\n" -".method -public copy {obj dest} {\n" +".public method copy {obj dest} {\n" "set .objLength [string length $obj]\n" "set .dest $dest\n" ".makeTargetList $obj\n" ".copyTargets}}\n" -"::xotcl2::Object method -public copy newName {\n" +"::xotcl2::Object public method copy newName {\n" "if {[string compare [string trimleft $newName :] [string trimleft [::xotcl::self] :]]} {\n" "[::xotcl::CopyHandler new -volatile] copy [::xotcl::self] $newName}}\n" -"::xotcl2::Object method -public move newName {\n" +"::xotcl2::Object public method move newName {\n" "if {[string trimleft $newName :] ne [string trimleft [::xotcl::self] :]} {\n" "if {$newName ne \"\"} {\n" ".copy $newName}\n" Index: generic/predefined.xotcl =================================================================== diff -u -r962c96dcc0ddc25782570a831c104fb2b955891d -r142687efa93af981936db61ecfde494d8f269b0a --- generic/predefined.xotcl (.../predefined.xotcl) (revision 962c96dcc0ddc25782570a831c104fb2b955891d) +++ generic/predefined.xotcl (.../predefined.xotcl) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -48,118 +48,109 @@ ::xotcl::methodproperty Class dealloc static true ::xotcl::methodproperty Class create static true - # TODO: both switches -protected and -public don't make much sense, - # but we allow it for the time being - # - # TODO: methodproperty is not necessary, when the base method - # supports all settings (e.g. -callprotection public|protected) + # define method "method" for Class and Object ::xotcl::dispatch Class ::xotcl::cmd::Class::class-method method { - -per-object:switch -public:switch -protected:switch + -per-object:switch name arguments body -precondition -postcondition } { set conditions [list] if {[info exists precondition]} {lappend conditions -precondition $precondition} if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} - if {${per-object}} { - set cls Object - set prefix object - } else { - set cls Class - set prefix class - } - set result [::xotcl::dispatch [self] ::xotcl::cmd::${cls}::$prefix-method \ - $name $arguments $body {*}$conditions] - if {$protected} {::xotcl::methodproperty [self] $name protected true} - #puts stderr "[self] $name defined ($prefix-method)" - return $result + set cls [expr {${per-object} ? "Object" : "Class"}] + ::xotcl::dispatch [self] ::xotcl::cmd::${cls}::[string tolower $cls]-method \ + $name $arguments $body {*}$conditions } ::xotcl::dispatch Object ::xotcl::cmd::Class::class-method method { - -public:switch -protected:switch name arguments body -precondition -postcondition } { set conditions [list] if {[info exists precondition]} {lappend conditions -precondition $precondition} if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} - set result [::xotcl::dispatch [self] ::xotcl::cmd::Object::object-method \ - $name $arguments $body {*}$conditions] - if {$protected} {::xotcl::methodproperty [self] $name -per-object protected true} - #puts stderr "[self] $name defined (object-method)" - return $result + ::xotcl::dispatch [self] ::xotcl::cmd::Object::object-method \ + $name $arguments $body {*}$conditions } # define method modifiers "object", "public" and "protected" - Object method -public public {args} { - set p [lsearch -regexp $args {^(method|alias|forward|setter)$}] - if {$p == -1} {error "$args is not a method defining method"} - set r [{*}.$args] - ::xotcl::methodproperty [self] $r protected false - return $r - } + ::xotcl::dispatch Class -objscope ::eval { - Object method -public protected {args} { - set p [lsearch -regexp $args {^(method|alias|forward|setter)$}] - if {$p == -1} {error "$args is not a method defining command"} - set r [{*}.$args] - ::xotcl::methodproperty [self] $r [self proc] true - return $r - } + # method-modifier for object specific methos + .method object {args} { + set p [expr {[lsearch -regexp $args {^(method|alias|forward|setter)$}] + 1}] + set cmd [linsert $args $p "-per-object"] + return [{*}.$cmd] + } - Class method -public object {args} { - set p [expr {[lsearch -regexp $args {^(method|alias|forward|setter)$}] + 1}] - set cmd [linsert $args $p "-per-object"] - return [{*}.$cmd] - } + # define unknown handler for class + .method unknown {m args} { + error "Method '$m' unknown for [self].\ + Consider '[self] create $m $args' instead of '[self] $m $args'" + } - # - # unknown handlers - # - Class method unknown {m args} { - error "Method '$m' unknown for [self]. Consider '[self] create $m $args' instead of '[self] $m $args'" - #eval my create $args } - Object method unknown {m args} { - if {![self isnext]} { - error "[self]: unable to dispatch method '$m'" + ::xotcl::dispatch Object -objscope ::eval { + + # method modifier "public" + .method public {args} { + set p [lsearch -regexp $args {^(method|alias|forward|setter)$}] + if {$p == -1} {error "$args is not a method defining method"} + set r [{*}.$args] + ::xotcl::methodproperty [self] $r protected false + return $r } - } - # "init" must exist on Object. per default it is empty. - Object method -protected init args {} + # method modifier "protected" + .method protected {args} { + set p [lsearch -regexp $args {^(method|alias|forward|setter)$}] + if {$p == -1} {error "$args is not a method defining command"} + set r [{*}.$args] + ::xotcl::methodproperty [self] $r [self proc] true + return $r + } - # this method is called on calls to object without a specified method - Object method defaultmethod {} {::xotcl::self} + # unknown handler for Object + .method unknown {m args} { + if {![self isnext]} { + error "[self]: unable to dispatch method '$m'" + } + } + + # "init" must exist on Object. per default it is empty. + .protected method init args {} - # provide a placeholder for the bootup process. The real definition - # is based on slots, which are not available at this point. - Object method -protected objectparameter {} {;} + # this method is called on calls to object without a specified method + .protected method defaultmethod {} {::xotcl::self} + # provide a placeholder for the bootup process. The real definition + # is based on slots, which are not available at this point. + .protected method objectparameter {} {;} + } + # The method __unknown is called in cases, where we try to resolve # an unkown class. one could define a custom resolver with this name # to load the class on the fly. After the call to __unknwn, XOTcl # tries to resolve the class again. This meachnism is used e.g. by # the ::ttrace mechanism for partial loading by Zoran. - Class method -per-object __unknown {name} { - } + # + # TODO: check, of protected is OK + Class protected object method __unknown {name} {} # Add an alias method. cmdName for XOTcl method can be added via # [... info method name ] #::xotcl::alias Object $cmd -objscope ::$cmd - Object method -public alias {-objscope:switch -protected:switch methodName cmd} { + Object public method alias {-objscope:switch methodName cmd} { ::xotcl::alias [self] $methodName \ {*}[expr {${objscope} ? "-objscope" : ""}] \ - {*}[expr {${protected} ? "-protected" : ""}] \ $cmd } - Class method -public alias {-objscope:switch -per-object:switch -protected:switch methodName cmd} { + Class public method alias {-objscope:switch -per-object:switch methodName cmd} { ::xotcl::alias [self] $methodName \ {*}[expr {${objscope} ? "-objscope" : ""}] \ {*}[expr {${per-object} ? "-per-object" : ""}] \ - {*}[expr {${protected} ? "-protected" : ""}] \ $cmd } @@ -176,7 +167,7 @@ ::xotcl::dispatch objectInfo -objscope ::eval { .alias is ::xotcl::is - .method -public info {obj} { + .public method info {obj} { set methods [list] foreach name [::xotcl::cmd::ObjectInfo::methods [self]] { if {$name eq "unknown"} continue @@ -273,7 +264,7 @@ ::xotcl2::Class create ::xotcl::MetaSlot ::xotcl::relation ::xotcl::MetaSlot superclass ::xotcl2::Class -::xotcl::MetaSlot method -public new args { +::xotcl::MetaSlot public method new args { set slotobject [::xotcl::self callingobject]::slot if {![::xotcl::is $slotobject object]} {::xotcls::Object create $slotobject} eval next -childof $slotobject $args @@ -331,7 +322,7 @@ return $parameterdefinitions } -::xotcl2::Object method -protected objectparameter {} { +::xotcl2::Object protected method objectparameter {} { set parameterdefinitions [::xotcl::parametersFromSlots [self]] if {[::xotcl::is [self] class]} { lappend parameterdefinitions -parameter:method,optional @@ -421,7 +412,7 @@ ::xotcl::alias ::xotcl::Slot get ::xotcl::setinstvar ::xotcl::alias ::xotcl::Slot assign ::xotcl::setinstvar -::xotcl::Slot method -public add {obj prop value {pos 0}} { +::xotcl::Slot public method add {obj prop value {pos 0}} { if {![set .multivalued]} { error "Property $prop of [set .domain]->$obj ist not multivalued" } @@ -431,7 +422,7 @@ ::xotcl::setinstvar $obj $prop [list $value] } } -::xotcl::Slot method -public delete {-nocomplain:switch obj prop value} { +::xotcl::Slot public method delete {-nocomplain:switch obj prop value} { set old [::xotcl::setinstvar $obj $prop] set p [lsearch -glob $old $value] if {$p>-1} {::xotcl::setinstvar $obj $prop [lreplace $old $p $p]} else { @@ -449,7 +440,7 @@ error "Method '$method' unknown for slot [::xotcl::self]; valid are: {[lsort $methods]]}" } -::xotcl::Slot method -public destroy {} { +::xotcl::Slot public method destroy {} { if {${.domain} ne ""} { ${.domain} __invalidateobjectparameter } @@ -482,17 +473,17 @@ {elementtype ::xotcl2::Class} } ::xotcl::relation ::xotcl::InfoSlot superclass ::xotcl::Slot -::xotcl::InfoSlot method -public get {obj prop} { +::xotcl::InfoSlot public method get {obj prop} { $obj info $prop } -::xotcl::InfoSlot method -public add {obj prop value {pos 0}} { +::xotcl::InfoSlot public method add {obj prop value {pos 0}} { if {![set .multivalued]} { error "Property $prop of ${.domain}->$obj ist not multivalued" } puts stderr "adding infoslot: $obj $prop [linsert [$obj info $prop] $pos $value]" $obj $prop [linsert [$obj info $prop] $pos $value] } -::xotcl::InfoSlot method -public delete {-nocomplain:switch obj prop value} { +::xotcl::InfoSlot public method delete {-nocomplain:switch obj prop value} { puts stderr infoslot-delete-[self args] set old [$obj info $prop] if {[string first * $value] > -1 || [string first \[ $value] > -1} { @@ -530,10 +521,10 @@ ::xotcl::alias ::xotcl::InterceptorSlot set ::xotcl::relation ;# for backwards compatibility ::xotcl::alias ::xotcl::InterceptorSlot assign ::xotcl::relation -::xotcl::InterceptorSlot method -public get {obj -per-object:switch prop} { +::xotcl::InterceptorSlot public method get {obj -per-object:switch prop} { ::xotcl::relation $obj {*}[expr {${per-object} ? "-per-object" : ""}] $prop } -::xotcl::InterceptorSlot method -public add {obj -per-object:switch prop value {pos 0}} { +::xotcl::InterceptorSlot public method add {obj -per-object:switch prop value {pos 0}} { if {![set .multivalued]} { error "Property $prop of ${.domain}->$obj ist not multivalued" } @@ -670,7 +661,7 @@ .method method args {::xotcl::next; .optimize} .method forward args {::xotcl::next; .optimize} .method init args {::xotcl::next; .optimize} - .method -public optimize {} { + .public method optimize {} { if {[set .multivalued]} return if {[set .defaultmethods] ne {get assign}} return #puts stderr assign=[.info callable -which assign] @@ -695,7 +686,7 @@ } ::xotcl::ScopedNew method init {} { - .method -public new {-childof args} { + .public method new {-childof args} { ::xotcl::instvar -object [::xotcl::self class] {inobject object} withclass if {![::xotcl::is $object object]} { $withclass create $object @@ -709,7 +700,7 @@ # nested object structures. Optionally, creating new objects # in the specified scope can be turned off. # -::xotcl2::Object method -public contains { +::xotcl2::Object public method contains { {-withnew:boolean true} -object {-class ::xotcl2::Object} @@ -735,7 +726,7 @@ # Define method "parameter" for backward # compatibility and convenience ############################################ -::xotcl2::Class method -public parameter arglist { +::xotcl2::Class public method parameter arglist { if {![::xotcl::is [::xotcl::self]::slot object]} { ::xotcl2::Object create [::xotcl::self]::slot } @@ -792,7 +783,7 @@ if {![info exists setter]} {set setter set} if {![info exists getter]} {set getter set} if {![info exists access]} {set access ::xotcl::my} - $cl method -public $name args " + $cl public method $name args " if {\[llength \$args] == 0} { return \[$access $getter $extra $name\] } else { @@ -930,7 +921,7 @@ } } - .method -public copy {obj dest} { + .public method copy {obj dest} { #puts stderr "[::xotcl::self] copy <$obj> <$dest>" set .objLength [string length $obj] set .dest $dest @@ -939,13 +930,13 @@ } } -::xotcl2::Object method -public copy newName { +::xotcl2::Object public method copy newName { if {[string compare [string trimleft $newName :] [string trimleft [::xotcl::self] :]]} { [::xotcl::CopyHandler new -volatile] copy [::xotcl::self] $newName } } -::xotcl2::Object method -public move newName { +::xotcl2::Object public method move newName { if {[string trimleft $newName :] ne [string trimleft [::xotcl::self] :]} { if {$newName ne ""} { .copy $newName Index: generic/tclAPI.h =================================================================== diff -u -r962c96dcc0ddc25782570a831c104fb2b955891d -r142687efa93af981936db61ecfde494d8f269b0a --- generic/tclAPI.h (.../tclAPI.h) (revision 962c96dcc0ddc25782570a831c104fb2b955891d) +++ generic/tclAPI.h (.../tclAPI.h) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -253,7 +253,7 @@ static int XOTclOUpvarMethod(Tcl_Interp *interp, XOTclObject *obj, int objc, Tcl_Obj *CONST objv[]); static int XOTclOVolatileMethod(Tcl_Interp *interp, XOTclObject *obj); static int XOTclOVwaitMethod(Tcl_Interp *interp, XOTclObject *obj, char *varname); -static int XOTclAliasCmd(Tcl_Interp *interp, XOTclObject *object, char *methodName, int withObjscope, int withPer_object, int withProtected, Tcl_Obj *cmdName); +static int XOTclAliasCmd(Tcl_Interp *interp, XOTclObject *object, char *methodName, int withObjscope, int withPer_object, Tcl_Obj *cmdName); static int XOTclConfigureCmd(Tcl_Interp *interp, int configureoption, Tcl_Obj *value); static int XOTclCreateObjectSystemCmd(Tcl_Interp *interp, Tcl_Obj *rootClass, Tcl_Obj *rootMetaClass); static int XOTclDeprecatedCmd(Tcl_Interp *interp, char *what, char *oldCmd, char *newCmd); @@ -1776,11 +1776,10 @@ char *methodName = (char *)pc.clientData[1]; int withObjscope = (int )pc.clientData[2]; int withPer_object = (int )pc.clientData[3]; - int withProtected = (int )pc.clientData[4]; - Tcl_Obj *cmdName = (Tcl_Obj *)pc.clientData[5]; + Tcl_Obj *cmdName = (Tcl_Obj *)pc.clientData[4]; parseContextRelease(&pc); - return XOTclAliasCmd(interp, object, methodName, withObjscope, withPer_object, withProtected, cmdName); + return XOTclAliasCmd(interp, object, methodName, withObjscope, withPer_object, cmdName); } } @@ -2408,12 +2407,11 @@ {"::xotcl::cmd::Object::vwait", XOTclOVwaitMethodStub, 1, { {"varname", 1, 0, convertToString}} }, -{"::xotcl::alias", XOTclAliasCmdStub, 6, { +{"::xotcl::alias", XOTclAliasCmdStub, 5, { {"object", 0, 0, convertToObject}, {"methodName", 0, 0, convertToString}, {"-objscope", 0, 0, convertToString}, {"-per-object", 0, 0, convertToString}, - {"-protected", 0, 0, convertToString}, {"cmdName", 1, 0, convertToTclobj}} }, {"::xotcl::configure", XOTclConfigureCmdStub, 2, { Index: generic/xotcl.c =================================================================== diff -u -r962c96dcc0ddc25782570a831c104fb2b955891d -r142687efa93af981936db61ecfde494d8f269b0a --- generic/xotcl.c (.../xotcl.c) (revision 962c96dcc0ddc25782570a831c104fb2b955891d) +++ generic/xotcl.c (.../xotcl.c) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -10170,8 +10170,7 @@ * Begin generated XOTcl commands *********************************/ static int XOTclAliasCmd(Tcl_Interp *interp, XOTclObject *object, char *methodName, - int withObjscope, int withPer_object, int withProtected, - Tcl_Obj *cmdName) { + int withObjscope, int withPer_object, Tcl_Obj *cmdName) { Tcl_ObjCmdProc *objProc, *newObjProc = NULL; Tcl_CmdDeleteProc *deleteProc = NULL; AliasCmdClientData *tcd = NULL; /* make compiler happy */ @@ -10284,7 +10283,7 @@ tcd = Tcl_Command_objClientData(cmd); } - flags = withProtected ? XOTCL_CMD_PROTECTED_METHOD : 0; + flags = 0; if (allocation == 'c') { XOTclClass *cl = (XOTclClass *)object; @@ -10318,7 +10317,6 @@ Tcl_DStringInit(dsPtr); /*if (withPer_object) {Tcl_DStringAppend(dsPtr, "-per-object ", -1);}*/ if (withObjscope) {Tcl_DStringAppend(dsPtr, "-objscope ", -1);} - if (withProtected) {Tcl_DStringAppend(dsPtr, "-protected ", -1);} Tcl_DStringAppend(dsPtr, ObjStr(cmdName), -1); AliasAdd(interp, object->cmdName, methodName, allocation == 'o', Tcl_DStringValue(dsPtr)); Tcl_DStringFree(dsPtr); @@ -10648,21 +10646,14 @@ } } else { XOTclClass *cl; - char allocation; - if (XOTclObjectIsClass(object)) { - cl = (XOTclClass *)object; - allocation = 'c'; - } else { + if (withPer_object) { cl = NULL; - allocation = 'o'; + } else { + cl = XOTclObjectIsClass(object) ? (XOTclClass *)object : NULL; } - if (withPer_object) { - allocation = 'o'; - } - - if (allocation == 'o') { + if (cl == NULL) { if (object->nsPtr) cmd = FindMethod(object->nsPtr, methodName); if (!cmd) { Index: library/lib/test.xotcl =================================================================== diff -u -r04747ba752ca2b7a4f30586348e39ab04f190da9 -r142687efa93af981936db61ecfde494d8f269b0a --- library/lib/test.xotcl (.../test.xotcl) (revision 04747ba752ca2b7a4f30586348e39ab04f190da9) +++ library/lib/test.xotcl (.../test.xotcl) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -36,7 +36,7 @@ } { set .count 0 - .method -per-object -public new args { + .public object method new args { if {[info exists .case]} { if {![info exists .ccount(${.case})]} {set .ccount(${.case}) 0} set .name ${.case}.[format %.3d [incr .ccount(${.case})]] @@ -46,20 +46,20 @@ eval .create ${.name} -name ${.name} $args } - .method -per-object -public run {} { + .public object method run {} { set startTime [clock clicks -milliseconds] foreach example [lsort [.info instances -closure]] { $example run } puts stderr "Total Time: [expr {[clock clicks -milliseconds]-$startTime}] ms" } - - .method -public call {msg cmd} { + + .public method call {msg cmd} { if {[.verbose]} {puts stderr "$msg: $cmd"} namespace eval [set .namespace] $cmd } - .method -public run args { + .public method run args { if {[info exists .pre]} {.call "pre" ${.pre}} if {![info exists .msg]} {set .msg ${.cmd}} set r [.call "run" ${.cmd}] @@ -89,7 +89,7 @@ if {[info exists .post]} {.call "post" ${.post}} } - .method -per-object case {name} {set .case $name} + .public object method case {name} {set .case $name} } namespace export Test } Index: library/lib/xotcl1.xotcl =================================================================== diff -u -rbf9bae94d157de9bbd4c398f6a3a9a4d93626025 -r142687efa93af981936db61ecfde494d8f269b0a --- library/lib/xotcl1.xotcl (.../xotcl1.xotcl) (revision bf9bae94d157de9bbd4c398f6a3a9a4d93626025) +++ library/lib/xotcl1.xotcl (.../xotcl1.xotcl) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -582,18 +582,18 @@ {export {}} } { - .method -public -per-object create {name args} { + .public object method create {name args} { set nq [namespace qualifiers $name] if {$nq ne "" && ![namespace exists $nq]} {Object create $nq} next } - .method -public -per-object extend {name args} { + .public object method extend {name args} { .require $name eval $name configure $args } - .method -public -per-object contains script { + .public object method contains script { if {[.exists provide]} { package provide [set .provide] [set .version] } else { @@ -614,16 +614,16 @@ } } - .method -public -per-object unknown args { + .public object method unknown args { #puts stderr "unknown: package $args" eval [set .packagecmd] $args } - .method -public -per-object verbose value { + .public object method verbose value { set .verbose $value } - .method -public -per-object present args { + .public object method present args { if {$::tcl_version<8.3} { switch -exact -- [lindex $args 0] { -exact {set pkg [lindex $args 1]} @@ -639,7 +639,7 @@ } } - .method -public -per-object import {{-into ::} pkg} { + .public object method import {{-into ::} pkg} { .require $pkg namespace eval $into [subst -nocommands { #puts stderr "*** package import ${pkg}::* into [namespace current]" @@ -654,7 +654,7 @@ } } - .method -public -per-object require args { + .public object method require args { #puts "XOTCL package require $args, current=[namespace current]" set prevComponent ${.component} if {[catch {set v [eval package present $args]} msg]} { Index: tests/info-method.xotcl =================================================================== diff -u -rbf9bae94d157de9bbd4c398f6a3a9a4d93626025 -r142687efa93af981936db61ecfde494d8f269b0a --- tests/info-method.xotcl (.../info-method.xotcl) (revision bf9bae94d157de9bbd4c398f6a3a9a4d93626025) +++ tests/info-method.xotcl (.../info-method.xotcl) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -59,9 +59,9 @@ {::C method m-with-assertions {} {return proc-[self proc]} -precondition 1 -postcondition 2} ? {C info method parameter m} {x} ? {Class info method parameter method} \ - {{-per-object:switch 0} {-public:switch 0} {-protected:switch 0} name arguments body -precondition -postcondition} + {{-per-object:switch 0} name arguments body -precondition -postcondition} ? {Object info method parameter alias} \ - {{-objscope:switch 0} {-protected:switch 0} methodName cmd} + {{-objscope:switch 0} methodName cmd} # raises currently an error ? {catch {C info method parameter a}} 1 Index: tests/protected.xotcl =================================================================== diff -u -r666f7ad2cb2562f3d62fc9aea54efb9b0826f6b0 -r142687efa93af981936db61ecfde494d8f269b0a --- tests/protected.xotcl (.../protected.xotcl) (revision 666f7ad2cb2562f3d62fc9aea54efb9b0826f6b0) +++ tests/protected.xotcl (.../protected.xotcl) (revision 142687efa93af981936db61ecfde494d8f269b0a) @@ -70,7 +70,7 @@ ? {c2 bar-foo} {foo} # define a protected method -C method -protected foo {} {return [self proc]} +C protected method foo {} {return [self proc]} ? {::xotcl::methodproperty C SET protected} 0 ? {c1 SET x 3} 3 ? {::xotcl::dispatch c1 SET x 4} {4}