Index: generic/gentclAPI.decls =================================================================== diff -u -r6458c13882afd52e8719ee0e0e054b42e9aee696 -radc4affd14701109f5d9b655dddf58d6b42cd781 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 6458c13882afd52e8719ee0e0e054b42e9aee696) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision adc4affd14701109f5d9b655dddf58d6b42cd781) @@ -222,82 +222,10 @@ {-argName "varname" -required 1} } -# # temporary xxx -# # TODO: remove me xxx -# TODO mixinguard method -# TODO instmixinguard method -# TODO remove option -guard -objectInfoMethod filtermethods XOTclObjInfoFiltermethodsMethod { - {-argName "-guards"} - {-argName "-order"} - {-argName "pattern"} -} -objectInfoMethod filterguard XOTclObjInfoFilterguardMethod { - {-argName "filter" -required 1} -} -objectInfoMethod vars XOTclOVarsMethod { - {-argName "pattern" -required 0} -} - -classInfoMethod filtermethods XOTclClassInfoFiltermethodsMethod { - {-argName "-guards"} - {-argName "pattern"} -} -classInfoMethod filterguard XOTclClassInfoFilterguardMethod { - {-argName "filter" -required 1} -} - # -# class methods -# - -classMethod alloc XOTclCAllocMethod { - {-argName "name" -required 1 -type tclobj} -} - -classMethod create XOTclCCreateMethod { - {-argName "name" -required 1} - {-argName "args" -type allargs} -} - -classMethod dealloc XOTclCDeallocMethod { - {-argName "object" -required 1 -type tclobj} -} - -classMethod new XOTclCNewMethod { - {-argName "-childof" -type object -nrargs 1} - {-argName "args" -required 0 -type args} -} -classMethod filterguard XOTclCFilterGuardMethod { - {-argName "filter" -required 1} - {-argName "guard" -required 1 -type tclobj} -} -classMethod mixinguard XOTclCMixinGuardMethod { - {-argName "mixin" -required 1} - {-argName "guard" -required 1 -type tclobj} -} - -classMethod recreate XOTclCRecreateMethod { - {-argName "name" -required 1 -type tclobj} - {-argName "args" -type allargs} -} -# -# check methods -# -# checkMethod required XOTclCheckRequiredArgs { -# {-argName "name" -required 1} -# {-argName "value" -required 0 -type tclobj} -# } -# checkMethod boolean XOTclCheckBooleanArgs { -# {-argName "name" -required 1} -# {-argName "value" -required 0 -type tclobj} -# } - -# # info object methods # -infoObjectMethod callable XOTclObjInfoCallableMethod { - {-argName "object" -type object} +objectInfoMethod callable XOTclObjInfoCallableMethod { {-argName "infocallablesubcmd" -nrargs 1 -type "filter|method|methods" -required 1} {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default all} @@ -306,114 +234,157 @@ {-argName "-incontext"} {-argName "pattern" -required 0} } -infoObjectMethod children XOTclObjInfoChildrenMethod { - {-argName "object" -required 1 -type object} +objectInfoMethod children XOTclObjInfoChildrenMethod { {-argName "pattern" -required 0} } -infoObjectMethod class XOTclObjInfoClassMethod { - {-argName "object" -required 1 -type object} +objectInfoMethod class XOTclObjInfoClassMethod { } - -infoObjectMethod forward XOTclObjInfoForwardMethod { - {-argName "object" -required 1 -type object} +objectInfoMethod filtermethods XOTclObjInfoFiltermethodsMethod { + {-argName "-guards"} + {-argName "-order"} + {-argName "pattern"} +} +objectInfoMethod filterguard XOTclObjInfoFilterguardMethod { + {-argName "filter" -required 1} +} +objectInfoMethod forward XOTclObjInfoForwardMethod { {-argName "-definition"} {-argName "name"} } -infoObjectMethod hasnamespace XOTclObjInfoHasnamespaceMethod { - {-argName "object" -required 1 -type object} +objectInfoMethod hasnamespace XOTclObjInfoHasnamespaceMethod { } -infoObjectMethod method XOTclObjInfoMethodMethod { - {-argName "object" -type object} +objectInfoMethod method XOTclObjInfoMethodMethod { {-argName "infomethodsubcmd" -type "args|body|definition|handle|parameter|parametersyntax|type|precondition|postcondition"} {-argName "name"} } -infoObjectMethod methods XOTclObjInfoMethodsMethod { - {-argName "object" -type object} +objectInfoMethod methods XOTclObjInfoMethodsMethod { {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default public} {-argName "-nomixins"} {-argName "-incontext"} {-argName "pattern"} } -infoObjectMethod mixin XOTclObjInfoMixinMethod { - {-argName "object" -required 1 -type object} - {-argName "-guard"} + +objectInfoMethod mixinclasses XOTclObjInfoMixinclassesMethod { {-argName "-guards"} {-argName "-order"} {-argName "pattern" -type objpattern} } -infoObjectMethod parent XOTclObjInfoParentMethod { - {-argName "object" -required 1 -type object} +objectInfoMethod mixinguard XOTclObjInfoMixinguardMethod { + {-argName "mixin" -required 1} } -infoObjectMethod precedence XOTclObjInfoPrecedenceMethod { - {-argName "object" -required 1 -type object} +objectInfoMethod parent XOTclObjInfoParentMethod { +} +objectInfoMethod precedence XOTclObjInfoPrecedenceMethod { {-argName "-intrinsic"} {-argName "pattern" -required 0} } -infoObjectMethod slotobjects XOTclObjInfoSlotObjectsMethod { - {-argName "object" -required 1 -type object} +objectInfoMethod slotobjects XOTclObjInfoSlotObjectsMethod { {-argName "pattern" -required 0} } -infoObjectMethod vars XOTclObjInfoVarsMethod { - {-argName "object" -required 1 -type object} +objectInfoMethod vars XOTclObjInfoVarsMethod { {-argName "pattern" -required 0} } - # # info class methods # -infoClassMethod heritage XOTclClassInfoHeritageMethod { - {-argName "class" -required 1 -type class} +classInfoMethod filtermethods XOTclClassInfoFiltermethodsMethod { + {-argName "-guards"} {-argName "pattern"} } -infoClassMethod instances XOTclClassInfoInstancesMethod { - {-argName "class" -required 1 -type class} - {-argName "-closure"} - {-argName "pattern" -type objpattern} +classInfoMethod filterguard XOTclClassInfoFilterguardMethod { + {-argName "filter" -required 1} } -infoClassMethod forward XOTclClassInfoForwardMethod { - {-argName "class" -required 1 -type class} +classInfoMethod forward XOTclClassInfoForwardMethod { {-argName "-definition"} {-argName "name"} } -infoClassMethod method XOTclClassInfoMethodMethod { - {-argName "class" -type class} +classInfoMethod heritage XOTclClassInfoHeritageMethod { + {-argName "pattern"} +} +classInfoMethod instances XOTclClassInfoInstancesMethod { + {-argName "-closure"} + {-argName "pattern" -type objpattern} +} + +classInfoMethod method XOTclClassInfoMethodMethod { {-argName "infomethodsubcmd" -type "args|body|definition|handle|parameter|parametersyntax|type|precondition|postcondition"} {-argName "name"} } -infoClassMethod methods XOTclClassInfoMethodsMethod { - {-argName "class" -type class} +classInfoMethod methods XOTclClassInfoMethodsMethod { {-argName "-methodtype" -nrargs 1 -type "all|scripted|builtin|alias|forwarder|object|setter"} {-argName "-callprotection" -nrargs 1 -type "all|protected|public" -default public} {-argName "-nomixins"} {-argName "-incontext"} {-argName "pattern"} } -infoClassMethod mixin XOTclClassInfoMixinMethod { - {-argName "class" -required 1 -type class} +classInfoMethod mixinclasses XOTclClassInfoMixinclassesMethod { {-argName "-closure"} - {-argName "-guard"} {-argName "-guards"} {-argName "pattern" -type objpattern} } -infoClassMethod mixinof XOTclClassInfoMixinOfMethod { - {-argName "class" -required 1 -type class} +classInfoMethod mixinguard XOTclClassInfoMixinguardMethod { + {-argName "mixin" -required 1} +} +classInfoMethod mixinof XOTclClassInfoMixinOfMethod { {-argName "-closure"} {-argName "-scope" -required 0 -nrargs 1 -type "all|class|object"} {-argName "pattern" -type objpattern} } -infoClassMethod slots XOTclClassInfoSlotsMethod { - {-argName "class" -required 1 -type class} +classInfoMethod slots XOTclClassInfoSlotsMethod { } -infoClassMethod subclass XOTclClassInfoSubclassMethod { - {-argName "class" -required 1 -type class} +classInfoMethod subclass XOTclClassInfoSubclassMethod { {-argName "-closure"} {-argName "pattern" -type objpattern} } -infoClassMethod superclass XOTclClassInfoSuperclassMethod { - {-argName "class" -required 1 -type class} +classInfoMethod superclass XOTclClassInfoSuperclassMethod { {-argName "-closure"} {-argName "pattern" -type tclobj} } +# +# class methods +# + +classMethod alloc XOTclCAllocMethod { + {-argName "name" -required 1 -type tclobj} +} + +classMethod create XOTclCCreateMethod { + {-argName "name" -required 1} + {-argName "args" -type allargs} +} + +classMethod dealloc XOTclCDeallocMethod { + {-argName "object" -required 1 -type tclobj} +} + +classMethod new XOTclCNewMethod { + {-argName "-childof" -type object -nrargs 1} + {-argName "args" -required 0 -type args} +} +classMethod filterguard XOTclCFilterGuardMethod { + {-argName "filter" -required 1} + {-argName "guard" -required 1 -type tclobj} +} +classMethod mixinguard XOTclCMixinGuardMethod { + {-argName "mixin" -required 1} + {-argName "guard" -required 1 -type tclobj} +} + +classMethod recreate XOTclCRecreateMethod { + {-argName "name" -required 1 -type tclobj} + {-argName "args" -type allargs} +} +# +# check methods +# +# checkMethod required XOTclCheckRequiredArgs { +# {-argName "name" -required 1} +# {-argName "value" -required 0 -type tclobj} +# } +# checkMethod boolean XOTclCheckBooleanArgs { +# {-argName "name" -required 1} +# {-argName "value" -required 0 -type tclobj} +# } Index: library/nx/nx.tcl =================================================================== diff -u -r6458c13882afd52e8719ee0e0e054b42e9aee696 -radc4affd14701109f5d9b655dddf58d6b42cd781 --- library/nx/nx.tcl (.../nx.tcl) (revision 6458c13882afd52e8719ee0e0e054b42e9aee696) +++ library/nx/nx.tcl (.../nx.tcl) (revision adc4affd14701109f5d9b655dddf58d6b42cd781) @@ -340,33 +340,40 @@ path } { # TODO: handle -create (actually, its absence) + #puts "resolve_method_path" set methodName $path if {[string first " " $path]} { set methodName [lindex $path end] foreach w [lrange $path 0 end-1] { - #puts stderr "check $object info methods $w => '[$object info methods -methodtype all $w]'" + #puts stderr "check $object info methods $path @ <$w>" set scope [expr {[nsf::objectproperty $object class] && !${per-object} ? "Class" : "Object"}] - if {[::nsf::cmd::${scope}Info::methods $object -methodtype all $w] eq ""} { + if {[::nsf::dispatch $object ::nsf::cmd::${scope}Info2::methods -methodtype all $w] eq ""} { # # Create dispatch object an accessor method (if wanted) # - set o [Object create ${object}::$w] - if {$verbose} {puts stderr "... create object $o"} if {$scope eq "Class"} { - # we are on a class, and have to create an alias to be + if {![::nsf::objectproperty ${object}::slot object]} { + Object create ${object}::slot + if {$verbose} {puts stderr "... create object ${object}::slot"} + } + set o [Object create ${object}::slot::__$w] + if {$verbose} {puts stderr "... create object $o"} + # We are on a class, and have to create an alias to be # accessible for objects ::nsf::alias $object $w $o if {$verbose} {puts stderr "... create alias $object $w $o"} + } else { + set o [Object create ${object}::$w] + if {$verbose} {puts stderr "... create object $o"} } - #puts stderr "... $object info methods $w => '[$object info methods -methodtype all $w]'" set object $o } else { # # The accessor method exists already, check, if it is # appropriate for extending. # - set type [::nsf::cmd::${scope}Info::method $object type $w] - set definition [::nsf::cmd::${scope}Info::method $object definition $w] + set type [::nsf::dispatch $object ::nsf::cmd::${scope}Info2::method type $w] + set definition [::nsf::dispatch $object ::nsf::cmd::${scope}Info2::method definition $w] if {$scope eq "Class"} { if {$type ne "alias"} {error "can't append to $type"} if {$definition eq ""} {error "definition must not be empty"} @@ -416,6 +423,7 @@ if {[info exists precondition]} {lappend conditions -precondition $precondition} if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} array set "" [::nx::Object resolve_method_path -create -verbose [::nsf::current object] $name] + #puts "class method $(object).$(methodName) [list $arguments] {...}" set r [::nsf::method $(object) $(methodName) $arguments $body {*}$conditions] if {[info exists returns]} {nsf::methodproperty $(object) $r returns $returns} return $r @@ -449,6 +457,7 @@ if {[info exists precondition]} {lappend conditions -precondition $precondition} if {[info exists postcondition]} {lappend conditions -postcondition $postcondition} array set "" [::nx::Object resolve_method_path -create -per-object -verbose [::nsf::current object] $name] + #puts "object method $(object).$(methodName) [list $arguments] {...}" set r [::nsf::method $(object) -per-object $(methodName) $arguments $body {*}$conditions] if {[info exists returns]} {nsf::methodproperty $(object) $r returns $returns} return $r @@ -463,7 +472,7 @@ return [::nsf::dispatch [::nsf::current object] ::nsf::classes::nx::Object::$what {*}$args] } if {$what in [list "info"]} { - return [::nx::objectInfo [lindex $args 0] [::nsf::current object] {*}[lrange $args 1 end]] + return [::nsf::dispatch [::nsf::current object] ::nx::Object::slot::__info [lindex $args 0] {*}[lrange $args 1 end]] } if {$what in [list "filter" "mixin"]} { # @@ -637,20 +646,24 @@ # Class protected object method __unknown {name} {} - # Add alias methods. cmdName for XOTcl method can be added via + # Add alias methods. cmdName for a method can be added via # [... info method handle ] # # -nonleaf and -objscope make only sense for c-defined cmds, # -objscope implies -nonleaf # Object public method alias {-nonleaf:switch -objscope:switch methodName cmd} { - ::nsf::alias [::nsf::current object] -per-object $methodName \ + array set "" [::nx::Object resolve_method_path -per-object -create -verbose [::nsf::current object] $methodName] + #puts "object alias $(object).$(methodName) $cmd" + ::nsf::alias $(object) -per-object $(methodName) \ {*}[expr {${objscope} ? "-objscope" : ""}] \ {*}[expr {${nonleaf} ? "-nonleaf" : ""}] \ $cmd } Class public method alias {-nonleaf:switch -objscope:switch methodName cmd} { - ::nsf::alias [::nsf::current object] $methodName \ + array set "" [::nx::Object resolve_method_path -create -verbose [::nsf::current object] $methodName] + #puts "class alias $(object).$(methodName) $cmd" + ::nsf::alias $(object) $(methodName) \ {*}[expr {${objscope} ? "-objscope" : ""}] \ {*}[expr {${nonleaf} ? "-nonleaf" : ""}] \ $cmd @@ -684,67 +697,120 @@ } } + # allocate system slot parents + Object alloc ::nx::Class::slot + Object alloc ::nx::Object::slot + ######################## # Info definition ######################## - Object create ::nx::objectInfo - Object create ::nx::classInfo + # we have to use "eval", since objectParameters are not defined yet + Object eval { + :alias "info callable" ::nsf::cmd::ObjectInfo2::callable + :alias "info children" ::nsf::cmd::ObjectInfo2::children + :alias "info class" ::nsf::cmd::ObjectInfo2::class + :alias "info filter guard" ::nsf::cmd::ObjectInfo2::filterguard + :alias "info filter methods" ::nsf::cmd::ObjectInfo2::filtermethods + :alias "info forward" ::nsf::cmd::ObjectInfo2::forward + :alias "info hasnamespace" ::nsf::cmd::ObjectInfo2::hasnamespace + :method "info is" {kind value:optional} {::nsf::objectproperty [::nsf::current object] $kind {*}$value} + :alias "info methods" ::nsf::cmd::ObjectInfo2::methods + :alias "info mixin guard" ::nsf::cmd::ObjectInfo2::mixinguard + :alias "info mixin classes" ::nsf::cmd::ObjectInfo2::mixinclasses + :alias "info parent" ::nsf::cmd::ObjectInfo2::parent + :alias "info precedence" ::nsf::cmd::ObjectInfo2::precedence + :alias "info slotobjects" ::nsf::cmd::ObjectInfo2::slotobjects + :alias "info vars" ::nsf::cmd::ObjectInfo2::vars + } + + # Create the object here to prepare for copy of the above + # definitions. Potentially, some names are overwritten by the + # class. Note, that the automatically created name has to be the + # same. + + Object create ::nx::Class::slot::__info + Class alias info ::nx::Class::slot::__info + # - # It would be nice to do here "objectInfo configure {alias ..}", but - # we have no working objectparameter yet due to bootstrapping + # copy all methods except the subobjects to ::nx::Class::slot::__info # - objectInfo eval { - :alias is ::nsf::objectproperty + foreach m [nsf::dispatch ::nx::Object::slot::__info ::nsf::cmd::ObjectInfo2::methods] { + set definition [nsf::dispatch ::nx::Object::slot::__info ::nsf::cmd::ObjectInfo2::method definition $m] + #puts "$m $definition" + #puts "classInfo [lrange $definition 1 end]" + ::nx::Class::slot::__info {*}[lrange $definition 1 end] + } - # info info - :public method info {obj} { - set methods [list] - foreach name [::nsf::cmd::ObjectInfo::methods -methodtype all [::nsf::current object]] { - if {$name eq "unknown"} continue - lappend methods $name - } - return "valid options are: [join [lsort $methods] {, }]" - } - - :method filter {o submethod args} { - switch $submethod { - guard {::nsf::dispatch $o ::nsf::cmd::ObjectInfo2::filterguard {*}$args} - methods {::nsf::dispatch $o ::nsf::cmd::ObjectInfo2::filtermethods {*}$args} - } - } - :method unknown {method obj args} { - error "[::nsf::current object] unknown info option \"$method\"; [$obj info info]" - } + Class eval { + # TODO: are the next two needed? + :alias "info classparent" ::nsf::cmd::ObjectInfo2::parent + :alias "info classchildren" ::nsf::cmd::ObjectInfo2::children + :alias "info filter guard" ::nsf::cmd::ClassInfo2::filterguard + :alias "info filter methods" ::nsf::cmd::ClassInfo2::filtermethods + :alias "info forward" ::nsf::cmd::ClassInfo2::forward + :alias "info heritage" ::nsf::cmd::ClassInfo2::heritage + :alias "info instances" ::nsf::cmd::ClassInfo2::instances + :alias "info methods" ::nsf::cmd::ClassInfo2::methods + :alias "info mixin guard" ::nsf::cmd::ClassInfo2::mixinguard + :alias "info mixin classes" ::nsf::cmd::ClassInfo2::mixinclasses + :alias "info slots" ::nsf::cmd::ClassInfo2::slots + :alias "info subclass" ::nsf::cmd::ClassInfo2::subclass + :alias "info superclass" ::nsf::cmd::ClassInfo2::superclass } - classInfo eval { - :alias is ::nsf::objectproperty - :alias classparent ::nsf::cmd::ObjectInfo::parent - :alias classchildren ::nsf::cmd::ObjectInfo::children - :method filter {o submethod args} { - switch $submethod { - guard {::nsf::dispatch $o ::nsf::cmd::ClassInfo2::filterguard {*}$args} - methods {::nsf::dispatch $o ::nsf::cmd::ClassInfo2::filtermethods {*}$args} - } + # + # Define "info info" and unknown + # + proc infoOptions {obj} { + puts stderr "$obj INFO '[::nsf::dispatch $obj ::nsf::cmd::ObjectInfo2::methods -methodtype all]'" + set methods [list] + foreach name [::nsf::dispatch $obj ::nsf::cmd::ObjectInfo2::methods -methodtype all] { + if {$name eq "unknown"} continue + lappend methods $name } + return "valid options are: [join [lsort $methods] {, }]" } - foreach cmd [info command ::nsf::cmd::ObjectInfo::*] { - set cmdName [namespace tail $cmd] - ::nsf::alias ::nx::objectInfo $cmdName $cmd - ::nsf::alias ::nx::classInfo $cmdName $cmd + Object method "info unknown" {method obj args} { + error "[::nsf::current object] unknown info option \"$method\"; [$obj info info]" } - foreach cmd [info command ::nsf::cmd::ClassInfo::*] { - set cmdName [namespace tail $cmd] - ::nsf::alias ::nx::classInfo $cmdName $cmd - } - unset cmd + Object method "info info" {} {infoOptions ::nx::Object::slot::__info} + Class method "info info" {} {infoOptions ::nx::Class::slot::__info} + + # finally register method "method" (otherwise, we cannot use "method" above) + Object alias "info method" ::nsf::cmd::ObjectInfo2::method + Class alias "info method" ::nsf::cmd::ClassInfo2::method + # register method "info" on Object and Class - Object forward info -onerror ::nsf::infoError ::nx::objectInfo %1 {%@2 %self} - Class forward info -onerror ::nsf::infoError ::nx::classInfo %1 {%@2 %self} + #Object forward info -onerror ::nsf::infoError ::nx::objectInfo %1 {%@2 %self} + #Class forward info -onerror ::nsf::infoError ::nx::classInfo %1 {%@2 %self} + #Object alias info ::nx::objectInfo + #Class alias info ::nx::classInfo + # TOOD REMOVE BLOCK + # puts "After Info" + # puts object-methods=[Object info methods] + # puts class-methods=[Class info methods] + # puts "" + # puts Object::info-methods=[lsort [nsf::dispatch ::nx::Object::slot::__info ::nsf::cmd::ObjectInfo2::methods]] + # puts Class::info-methods_=[lsort [nsf::dispatch ::nx::Class::slot::__info ::nsf::cmd::ObjectInfo2::methods]] + # puts "" + # puts Object::info-callable=[nsf::dispatch ::nx::Object ::nsf::cmd::ObjectInfo2::callable method info] + # puts Class::info-callable_=[nsf::dispatch ::nx::Class ::nsf::cmd::ObjectInfo2::callable method info] + # puts "" + # puts Object::info-def=[nsf::dispatch ::nx::Object ::nsf::cmd::ClassInfo2::method definition info] + # puts Class::info-def_=[nsf::dispatch ::nx::Class ::nsf::cmd::ClassInfo2::method definition info] + # puts "" + # puts object-superclass=[Object info superclass] + # puts class-superclass=[Class info superclass] + + # # Object create o1 + # # puts obj-info-info=[o1 info info] + # # puts class-info-info=[Object info info] + # puts "" + # # Definition of "abstract method foo ...." # @@ -784,8 +850,8 @@ MetaSlot public method slotName {name baseObject} { # Create slot parent object if needed set slotParent ${baseObject}::slot - if {![::nsf::objectproperty ${slotParent} object]} { - ::nx::Object create ${slotParent} + if {![::nsf::objectproperty $slotParent object]} { + ::nx::Object create $slotParent } return ${slotParent}::$name } @@ -827,13 +893,13 @@ } if {${per-object}} { lappend opts -per-object true - set info ObjectInfo + set info ObjectInfo2 } else { - set info ClassInfo + set info ClassInfo2 } :create [:slotName $name $target] {*}$opts $initblock - return [::nsf::cmd::${info}::method $target handle $name] + return [::nsf::dispatch $target ::nsf::cmd::${info}::method handle $name] } } @@ -884,14 +950,14 @@ # # Perform a second round to set default values for already defined - # objects. + # slot objects. # foreach att $definitions { if {[llength $att]>1} {foreach {att default} $att break} if {[info exists default]} { # checking subclasses is not required during bootstrap - foreach i [::nsf::cmd::ClassInfo::instances $class] { + foreach i [::nsf::dispatch $class ::nsf::cmd::ClassInfo2::instances] { if {![::nsf::existsvar $i $att]} { if {[string match {*\[*\]*} $default]} { set value [::nsf::dispatch $i -objscope ::eval subst $default] @@ -1136,7 +1202,9 @@ proc ::nsf::parametersFromSlots {obj} { set parameterdefinitions [list] - foreach slot [::nx::objectInfo slotobjects $obj] { + foreach slot [::nsf::dispatch $obj ::nsf::cmd::ObjectInfo2::slotobjects] { + # TODO: the following line is just for the somehwat dummy "info slot" + if {![::nsf::objectproperty $slot type ::nx::Slot]} continue # Skip some slots for xotcl; # TODO: maybe different parameterFromSlots for xotcl? if {[::nsf::objectproperty ::xotcl::Object class] @@ -1249,8 +1317,6 @@ # system slots ############################################ proc ::nsf::register_system_slots {os} { - ${os}::Object alloc ${os}::Class::slot - ${os}::Object alloc ${os}::Object::slot # @param ::nx::Class#superclass # @@ -1372,7 +1438,7 @@ ::nsf::register_system_slots ::nx proc ::nsf::register_system_slots {} {} - + ############################################ # Attribute slots ############################################ @@ -1491,14 +1557,14 @@ set perObject "" set infokind Class } - if {[::nsf::cmd::${infokind}Info::method ${:domain} handle ${:name}] ne ""} { + if {[::nsf::dispatch ${:domain} ::nsf::cmd::${infokind}Info2::method handle ${:name}] ne ""} { #puts stderr "OPTIMIZER RESETTING ${:domain} slot ${:name}" ::nsf::forward ${:domain} {*}$perObject ${:name} \ ${:manager} \ [list %1 [${:manager} defaultmethods]] %self \ ${:methodname} } - #puts stderr "OPTIMIZER incremental [info exists :incremental] def '[set :defaultmethods]'" + #puts "*** stderr "OPTIMIZER incremental [info exists :incremental] def '[set :defaultmethods]'" if {[info exists :incremental] && ${:incremental}} return if {[set :defaultmethods] ne {get assign}} return @@ -1555,7 +1621,9 @@ if {![::nsf::objectproperty $slot object]} {Object create $slot} ::nsf::setvar $slot __parameter $arglist } - ::nsf::method classInfo parameter {class} { + + Class method "info parameter" {} { + set class [::nsf::current object] set slot ${class}::slot if {![::nsf::objectproperty $slot object]} {Object create $slot} if {[::nsf::existsvar $slot __parameter]} { @@ -1737,13 +1805,13 @@ namespace eval $dest {} } :copyNSVarsAndCmds $origin $dest - foreach i [::nsf::cmd::ObjectInfo::forward $origin] { - ::nsf::forward $dest -per-object $i {*}[::nsf::cmd::ObjectInfo::forward $origin -definition $i] + foreach i [::nsf::dispatch $origin ::nsf::cmd::ObjectInfo2::forward] { + ::nsf::forward $dest -per-object $i {*}[::nsf::dipatch $origin ::nsf::cmd::ObjectInfo2::forward -definition $i] } if {[::nsf::objectproperty $origin class]} { - foreach i [::nsf::cmd::ClassInfo::forward $origin] { - ::nsf::forward $dest $i {*}[::nsf::cmd::ClassInfo::forward $origin -definition $i] + foreach i [nsf::dispatch $origin ::nsf::cmd::ClassInfo2::forward] { + ::nsf::forward $dest $i {*}[::nsf::dipatch $origin ::nsf::cmd::ClassInfo2::forward -definition $i] } } set traces [list] Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -re849d060161385466c782e46c19344428934cd7f -radc4affd14701109f5d9b655dddf58d6b42cd781 --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision e849d060161385466c782e46c19344428934cd7f) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision adc4affd14701109f5d9b655dddf58d6b42cd781) @@ -61,13 +61,146 @@ } } + # @object ::xotcl::Object + # + # Xotcl programs are constructed out of objects. This class + # describes common structural and behavioural features for all XOTcl + # objects. It is the root object-class in the XOTcl 2 object system. + # provide the standard command set for ::xotcl::Object foreach cmd [info command ::nsf::cmd::Object::*] { set cmdName [namespace tail $cmd] if {$cmdName in [list "setter"]} continue ::nsf::alias Object $cmdName $cmd } + # + # object methods + # + + # @method ::xotcl::Object#autoname + # + # Provides a facility for auto-generating object identifiers. It is + # constructed from a seeding string which is appended a numeric + # index. This numeric index is incremented upon each call to + # {{{autoname}}}. + # {{{ + # set obj [Object new] + # $obj autoname a; # yields "a1" + # $obj autoname -instance B; # yields "b1" + # $obj autoname a; # yields "a2" + # $obj autoname b; # yields "b1" + # $obj autoname -reset a; # "" + # $obj autoname -reset -instance B; # "" + # $obj autoname -instance a; # yields "a1", and NOT "a3"! + # $obj autoname -instance B; # yields "b1" + # $obj autoname b; # yields "b2" + # }}} + # The seeding string may also contain {{{[format]}}} expressions (see ...): + # {{{ + # $obj autoname a%06d; # gives you "a000001", ... + # }}} + # + # @param -instance Have the generated name start with a lower letter (though the seed string has a major first letter) + # @param -reset Reset the object-internal counter for a given seed string + # @param name The seeding string which is used as a base for name generation + # @return The generated name string + + # @method ::xotcl::Object#cleanup + # + # TODO: this is a method not used in the Next Scripting Langauge. This + # mehtod is just called via recreate, so everything necessary can be + # performed there as well. However, it is available for backward + # compatibility available in XOTcl 2.0 + # + # Resets an object or class to its initial state, as after object + # allocation (see {{@method ::xotcl::Class class alloc}}). This method + # participates in recreating objects, i.e, it is called during the + # recreation process by {{@method ::xotcl::Class class recreate}}. + # Depending on the recreation scheme applied (see {{@command + # ::nsf::configure}}, object variables are deleted, per-object + # namespaces are cleared, and the object's relationsships (e.g., mixin + # relations) are reset. + # + # @properties interally-called + + # @method ::xotcl::Object#destroy + # + # @use ::xotcl::Object#destroy + + # @method ::xotcl::Object#exists + # + # A helper method for checking whether the variable {{{var}}} is + # defined on the object and assigned a value. You may use a variable + # name with or without prefix, both will resolve to the object scope: + # {{{ + # $obj eval { + # set :foo 1 + # set bar 2 + # } + # + # $obj exists foo; # returns 1 + # $obj exists :foo; # returns 1 + # $obj exists bar; # returns 0 + # $obj exists :bar; # returns 0 + # }}} + # + # @param var The name of the variable to verify + # @return :boolean 1 if the variable exists, 0 otherwise + + # @method ::xotcl::Object#instvar + # + # @param args + + # @method ::xotcl::Object#noinit + # + # Calling upon this method during object construction allows you to + # bypass the constructor method: + # {{{ + # Class create C + # C instproc init {} {puts stderr "A class-specific constructor shouts out ..."} + # C c1 -noinit + # }}} + # This bypassing feature comes handy when streaming an object into a + # scripted form (e.g., by using the bundled Serializer). Upon + # deserializing the object, using the {{{noinit}}} flag helps you to + # preserve the serialized object state (rather then having the + # object re-initialized). + + # @method ::xotcl::Object#requireNamespace + # + # This method allows you to request the creation of a namespace for + # the given object, a per-object namespace. The namespace is then used + # to store instance variables, methods and nested objects. Per-object + # namespaces are needed for using and binding object variables to + # non-object scopes in Tcl and Tk. For instance, you may use an + # per-object namespace to have object variables accessible Tk widgets + # and Tk callbacks. To verify whether a per-object namespace is + # available for an object, see ... + # + # Beware that there is a difference between per-object namespaces and + # Tcl namespaces which shadow an existing object (i.e., carry the same + # name): + # {{{ + # Object create Foo + # Foo requireNamespace + # namespace exists Foo; # returns 1 + # Foo info hasnamespace; # returns 1 + # + # Object create Bar + # namespace eval ::Bar {} + # namespace exists Bar; # returns 1 + # Bar info hasnamespace; # returns 0 + # }}} + + # @method ::xotcl::Object#vwait + # + # A method variant of the Tcl {{{vwait}}} command. You can use it to + # have the {{{interp}}} enter an event loop until the specified + # variable {{{varname}}} is set on the object. + # + # @param varname The name of the signalling object variable. + # provide some Tcl-commands as methods for ::xotcl::Object foreach cmd {array append eval incr lappend set subst unset trace} { ::nsf::alias Object $cmd -objscope ::$cmd @@ -459,6 +592,16 @@ ::nsf::alias Object parametercmd ::nsf::classes::nx::Object::setter ::nsf::alias Class instparametercmd ::nsf::classes::nx::Class::setter + # @method ::xotcl::Class#mixinguard + # + # @param mixin + # @param guard + + # @method ::nx::Class#instmixinguard + # + # @param mixin + # @param guard + # assertion handling proc checkoption_xotcl1_to_internal checkoptions { set options [list] @@ -544,6 +687,15 @@ if {[::nsf::is [self] object -hasmixin $cl]} {return 1} ::nsf::is [self] type $cl } + + # @method ::nx::Object#filtersearch + # + # Search a fully qualified method name which is currently registered + # as a filter. + # + # @param filter Handle to identify and address a filter once registered + # @param guard A list of guard expressions + # @return A list in proc qualifier format: 'objName|className proc|instproc methodName'. Object instproc filtersearch {filter} { set handle [::nsf::cmd::ObjectInfo::callable [self] filter $filter] return [method_handle_to_xotcl $handle]