Index: TODO =================================================================== diff -u -N -r92e6424562685bcc3665bf23dfcdc3ee489c25ef -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- TODO (.../TODO) (revision 92e6424562685bcc3665bf23dfcdc3ee489c25ef) +++ TODO (.../TODO) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -1705,46 +1705,58 @@ - added support for aolserver (essentially Makefile + aol-xotcl.tcl) - removed unneded content from serializer output -TODO: - -- "-returns" - * leave syntax as is for method? - * add flag to alias and forward? - * handle "returns" in serializer - - the two flags "-objscope" and "-nonleaf" are for adding frames, and they are mutual exclusive. Make them a single flag? check if both options are in every case sensible. possible realizations: - -varscope instance|proc -scope object|method - -varscope instance|resolver + -varscope instance|proc + -varscope instance|resolver|none + -frame object|method|default - * instance: within this method, all non-prefixed var names + * instance|object: within this method, all non-prefixed var names refer to instance variables; the method can use most probably not "next" (actually, only needed for XOTcl) - * proc: within this method, we can use colon-prefixed + * method|proc|resolver: within this method, we can use colon-prefixed variables; the method can use "next" "object" könnte mit dem -per-object (dem registierungpunkt) leicht verwechselt werden. es ginge auch -varscope instance|method allerdings, meint method eigentlich "scripted method". - Eine weitere option wäre: - -varscope instance|resolver + "none" would be dangerous for "-frame", since it could imply + to avoid frame stacking at all. + effected are: alias, forward, dispatch für "alias" betrifft das in gleicher form auch die cmds, bei "dispatch" und "forward" gibt es dzt. kein "-nonleaf" -- in the following, we need just a frame, but not necessarily an "-objscope" - set x [::xotcl::dispatch $value -objscope ::xotcl::self] +- replaced "-objscope" and "-nonleaf" by + "-frame object|method|default" + for nsf::alias and nsf::default +- added functionality for "-frame method" to nsf::dispatch +- made the order of argument in ::nsf::alias and method "alias" + the same (always first the method, then "-frame ...") +- extened regression test +TODO: + +- "-returns" + * leave syntax as is for method? + * add flag to alias and forward? + * handle "returns" in serializer + +- forward has just "-objscope", no general "-frame method|object". + Since forwarder have client data, they always push a method frame. + So, the situation is different to nsd::alias and ::nsf::dispatch. + not sure, if we should rename "-objscope" to something different. + - when compiled on my home machine for tcl 8.5.9 + aolserver, i see the behavior that "info exists :type" does not appear to work, leading to messages like the following @@ -1764,6 +1776,7 @@ - extend coro regression test - handle bug with ::variable with colon-prefixed name + (shadowCommands does not help, see above) - work on replacing SKIP_LEVELS by SKIP_LAMBDE for openacs (works with regression test, has problems with OrderedComposite::ChildManager.init) Index: generic/gentclAPI.decls =================================================================== diff -u -N -r18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision 18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -25,13 +25,12 @@ {-argName "object" -type object} {-argName "-per-object"} {-argName "methodName"} - {-argName "-nonleaf"} - {-argName "-objscope"} + {-argName "-frame" -required 0 -nrargs 1 -type "method|object|default" -default "default"} {-argName "cmdName" -required 1 -type tclobj} } nsfCmd assertion NsfAssertionCmd { {-argName "object" -type object} - {-argName "assertionsubcmd" -required 1 -type "check|object-invar|class-invar"} + {-argName "assertionsubcmd" -required 1 -nrargs 1 -type "check|object-invar|class-invar"} {-argName "arg" -required 0 -type tclobj} } nsfCmd configure NsfConfigureCmd { @@ -50,7 +49,7 @@ } nsfCmd dispatch NsfDispatchCmd { {-argName "object" -required 1 -type object} - {-argName "-objscope"} + {-argName "-frame" -required 0 -nrargs 1 -type "method|object|default" -default "default"} {-argName "command" -required 1 -type tclobj} {-argName "args" -type args} } Index: generic/nsf.c =================================================================== diff -u -N -r7a6e32605412db15c6b9a1d61ce0a9dfd92bfbf6 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- generic/nsf.c (.../nsf.c) (revision 7a6e32605412db15c6b9a1d61ce0a9dfd92bfbf6) +++ generic/nsf.c (.../nsf.c) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -6465,10 +6465,12 @@ */ return result; - } else if (cp || Tcl_Command_flags(cmd) & NSF_CMD_NONLEAF_METHOD) { + } else if (cp + || (Tcl_Command_flags(cmd) & NSF_CMD_NONLEAF_METHOD) + || (cscPtr->flags & NSF_CSC_FORCE_FRAME)) { /* - * The cmd has client data or is an aliased method with the - * nonleaf property + * The cmd has client data or we force the frame either via + * cmd-flag or csc-flag */ if (proc == NsfObjDispatch) { /* @@ -11461,13 +11463,16 @@ Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("class-object", 12)); } Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj(registerCmdName, -1)); + Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj(methodName, -1)); + if (withObjscope) { - Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("-objscope", 9)); + Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("-frame", 6)); + Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("object", 6)); } if (Tcl_Command_flags(cmd) & NSF_CMD_NONLEAF_METHOD) { - Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("-nonleaf", 8)); + Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("-frame", 6)); + Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj("method", 6)); } - Tcl_ListObjAppendElement(interp, listObj, Tcl_NewStringObj(methodName, -1)); } static int @@ -11683,7 +11688,9 @@ Tcl_ListObjGetElements(interp, entryObj, &nrElements, &listElements); /* todo: don't hard-code registering command name "alias" / NSF_ALIAS */ AppendMethodRegistration(interp, resultObj, NsfGlobalStrings[NSF_ALIAS], - regObject, methodName, cmd, nrElements!=1, outputPerObject, 1); + regObject, methodName, cmd, + procPtr == NsfObjscopedMethod, + outputPerObject, 1); Tcl_ListObjAppendElement(interp, resultObj, listElements[nrElements-1]); Tcl_SetObjResult(interp, resultObj); break; @@ -12216,14 +12223,14 @@ {-argName "object" -type object} {-argName "-per-object"} {-argName "methodName"} - {-argName "-nonleaf"} + {-argName "-frame" -required 0 -nrargs 1 -type "method|object|default" -default "default"} {-argName "-objscope"} {-argName "cmdName" -required 1 -type tclobj} } */ static int NsfAliasCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, - CONST char *methodName, int withNonleaf, int withObjscope, + CONST char *methodName, int withFrame, Tcl_Obj *cmdName) { Tcl_ObjCmdProc *objProc, *newObjProc = NULL; Tcl_CmdDeleteProc *deleteProc = NULL; @@ -12261,7 +12268,7 @@ when the original command is deleted. */ - if (withObjscope) { + if (withFrame == FrameObjectIdx) { newObjProc = NsfObjscopedMethod; } @@ -12285,10 +12292,10 @@ * proc/method is deleted. */ newObjProc = NsfProcAliasMethod; - - if (withObjscope) { - return NsfVarErrMsg(interp, "cannot use -objscope for tcl implemented command '", - ObjStr(cmdName), "'", (char *) NULL); + if (withFrame && withFrame != FrameDefaultIdx) { + return NsfVarErrMsg(interp, + "cannot use -frame object|method in alias for scripted command '", + ObjStr(cmdName), "'", (char *) NULL); } } @@ -12342,14 +12349,13 @@ if (newCmd) { Tcl_DString ds, *dsPtr = &ds; + Tcl_DStringInit(dsPtr); - /*if (withPer_object) {Tcl_DStringAppend(dsPtr, "-per-object ", -1);}*/ - if (withObjscope) {Tcl_DStringAppend(dsPtr, "-objscope ", -1);} Tcl_DStringAppend(dsPtr, ObjStr(cmdName), -1); AliasAdd(interp, object->cmdName, methodName, cl == NULL, Tcl_DStringValue(dsPtr)); Tcl_DStringFree(dsPtr); - if (!withObjscope && withNonleaf) { + if (withFrame == FrameMethodIdx) { Tcl_Command_flags(newCmd) |= NSF_CMD_NONLEAF_METHOD; /*fprintf(stderr, "setting aliased for cmd %p %s flags %.6x, tcd = %p\n", newCmd,methodName,Tcl_Command_flags(newCmd), tcd);*/ @@ -12601,13 +12607,13 @@ /* nsfCmd dispatch NsfDispatchCmd { {-argName "object" -required 1 -type object} - {-argName "-objscope"} + {-argName "-frame" -required 0 -nrargs 1 -type "method|object|default" -default "default"} {-argName "command" -required 1 -type tclobj} {-argName "args" -type args} } */ static int -NsfDispatchCmd(Tcl_Interp *interp, NsfObject *object, int withObjscope, +NsfDispatchCmd(Tcl_Interp *interp, NsfObject *object, int withFrame, Tcl_Obj *command, int nobjc, Tcl_Obj *CONST nobjv[]) { int result; CONST char *methodName = ObjStr(command); @@ -12624,10 +12630,11 @@ if (*methodName == ':') { Tcl_Command cmd, importedCmd; CallFrame frame, *framePtr = &frame; + int flags = 0; /* * We have an absolute name. We assume, the name is the name of a - * Tcl command, that will be dispatched. If "withObjscope" is + * Tcl command, that will be dispatched. If "withFrame == instance" is * specified, a callstack frame is pushed to make instvars * accessible for the command. */ @@ -12644,21 +12651,35 @@ methodName, "'", (char *) NULL); } - if (withObjscope) { - Nsf_PushFrameObj(interp, object, framePtr); + if (withFrame && withFrame != FrameDefaultIdx) { + Tcl_ObjCmdProc *proc = Tcl_Command_objProc(cmd); + if (proc == TclObjInterpProc || + proc == NsfForwardMethod || + proc == NsfObjscopedMethod || + proc == NsfSetterMethod || + proc == NsfObjDispatch) { + return NsfVarErrMsg(interp, + "cannot use -frame object|method in dispatch for command '", + methodName, "'", (char *) NULL); + } + if (withFrame == FrameObjectIdx) { + Nsf_PushFrameObj(interp, object, framePtr); + flags = NSF_CSC_IMMEDIATE; + } else if (withFrame == FrameMethodIdx) { + flags = NSF_CSC_FORCE_FRAME|NSF_CSC_IMMEDIATE; + } } /* * Since we know, that we are always called with a full argument * vector, we can include the cmd name in the objv by using * nobjv-1; this way, we avoid a memcpy() */ - result = MethodDispatch((ClientData)object, interp, nobjc+1, nobjv-1, cmd, object, NULL /*NsfClass *cl*/, Tcl_GetCommandName(interp,cmd), - NSF_CSC_TYPE_PLAIN, 0, 5); - if (withObjscope) { + NSF_CSC_TYPE_PLAIN, flags, 5); + if (withFrame == FrameObjectIdx) { Nsf_PopFrameObj(interp, framePtr); } } else { @@ -12667,10 +12688,17 @@ * order, with filters etc. -- strictly speaking unneccessary, * since we could dispatch the method also without * NsfDispatchCmd(), but it can be used to invoke protected - * methods. 'withObjscope' is here a no-op. + * methods. 'withFrame == FrameObjectIdx' is here a no-op. */ + Tcl_Obj *arg; Tcl_Obj *CONST *objv; + + if (withFrame && withFrame != FrameDefaultIdx) { + return NsfVarErrMsg(interp, + "cannot use -frame object|method in dispatch for plain method name '", + methodName, "'", (char *) NULL); + } if (nobjc >= 1) { arg = nobjv[0]; Index: generic/nsfInt.h =================================================================== diff -u -N -r3b75a92f67f6614a7ee823e4d37bc8724f9fb77d -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- generic/nsfInt.h (.../nsfInt.h) (revision 3b75a92f67f6614a7ee823e4d37bc8724f9fb77d) +++ generic/nsfInt.h (.../nsfInt.h) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -633,15 +633,16 @@ #define NSF_CSC_CALL_IS_NEXT 1 #define NSF_CSC_CALL_IS_GUARD 2 -#define NSF_CSC_CALL_IS_ENSEMBLE 4 +#define NSF_CSC_CALL_IS_ENSEMBLE 4 #define NSF_CSC_IMMEDIATE 0x0020 -#define NSF_CSC_CALL_IS_NRE 0x0100 -#define NSF_CSC_MIXIN_STACK_PUSHED 0x0200 +#define NSF_CSC_FORCE_FRAME 0x0040 +#define NSF_CSC_CALL_IS_NRE 0x0100 +#define NSF_CSC_MIXIN_STACK_PUSHED 0x0200 #define NSF_CSC_FILTER_STACK_PUSHED 0x0400 #define NSF_CSC_UNKNOWN 0x0800 #define NSF_CSC_CALL_IS_TRANSPARENT 0x1000 #define NSF_CSC_OBJECT_ACTIVATED 0x2000 -#define NSF_CSC_COPY_FLAGS (NSF_CSC_MIXIN_STACK_PUSHED|NSF_CSC_FILTER_STACK_PUSHED|NSF_CSC_IMMEDIATE|NSF_CSC_CALL_IS_TRANSPARENT) +#define NSF_CSC_COPY_FLAGS (NSF_CSC_MIXIN_STACK_PUSHED|NSF_CSC_FILTER_STACK_PUSHED|NSF_CSC_IMMEDIATE|NSF_CSC_CALL_IS_TRANSPARENT|NSF_CSC_FORCE_FRAME) /* flags for call method */ #define NSF_CM_NO_UNKNOWN 1 Index: generic/tclAPI.h =================================================================== diff -u -N -r7a6e32605412db15c6b9a1d61ce0a9dfd92bfbf6 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- generic/tclAPI.h (.../tclAPI.h) (revision 7a6e32605412db15c6b9a1d61ce0a9dfd92bfbf6) +++ generic/tclAPI.h (.../tclAPI.h) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -55,6 +55,18 @@ return result; } +enum FrameIdx {FrameNULL, FrameMethodIdx, FrameObjectIdx, FrameDefaultIdx}; + +static int ConvertToFrame(Tcl_Interp *interp, Tcl_Obj *objPtr, NsfParam CONST *pPtr, + ClientData *clientData, Tcl_Obj **outObjPtr) { + int index, result; + static CONST char *opts[] = {"method", "object", "default", NULL}; + result = Tcl_GetIndexFromObj(interp, objPtr, opts, "-frame", 0, &index); + *clientData = (ClientData) INT2PTR(index + 1); + *outObjPtr = objPtr; + return result; +} + enum AssertionsubcmdIdx {AssertionsubcmdNULL, AssertionsubcmdCheckIdx, AssertionsubcmdObject_invarIdx, AssertionsubcmdClass_invarIdx}; static int ConvertToAssertionsubcmd(Tcl_Interp *interp, Tcl_Obj *objPtr, NsfParam CONST *pPtr, @@ -141,17 +153,18 @@ static enumeratorConverterEntry enumeratorConverterEntries[] = { - {ConvertToRelationtype, "object-mixin|class-mixin|object-filter|class-filter|class|superclass|rootclass"}, + {ConvertToScope, "all|class|object"}, + {ConvertToInfomethodsubcmd, "args|body|definition|handle|parameter|parametersyntax|type|precondition|postcondition|submethods"}, + {ConvertToCallprotection, "all|protected|public"}, + {ConvertToMethodtype, "all|scripted|builtin|alias|forwarder|object|setter"}, + {ConvertToFrame, "method|object|default"}, {ConvertToCurrentoption, "proc|method|methodpath|object|class|activelevel|args|activemixin|calledproc|calledmethod|calledclass|callingproc|callingmethod|callingclass|callinglevel|callingobject|filterreg|isnextcall|next"}, - {ConvertToSource, "all|application|baseclasses"}, {ConvertToObjectkind, "class|baseclass|metaclass"}, {ConvertToMethodproperty, "class-only|call-protected|redefine-protected|returns|slotcontainer|slotobj"}, - {ConvertToAssertionsubcmd, "check|object-invar|class-invar"}, - {ConvertToScope, "all|class|object"}, + {ConvertToRelationtype, "object-mixin|class-mixin|object-filter|class-filter|class|superclass|rootclass"}, + {ConvertToSource, "all|application|baseclasses"}, {ConvertToConfigureoption, "filter|softrecreate|objectsystems|keepinitcmd|checkresults|checkarguments"}, - {ConvertToMethodtype, "all|scripted|builtin|alias|forwarder|object|setter"}, - {ConvertToCallprotection, "all|protected|public"}, - {ConvertToInfomethodsubcmd, "args|body|definition|handle|parameter|parametersyntax|type|precondition|postcondition|submethods"}, + {ConvertToAssertionsubcmd, "check|object-invar|class-invar"}, {NULL, NULL} }; @@ -276,15 +289,15 @@ static int NsfClassInfoMixinguardMethod(Tcl_Interp *interp, NsfClass *cl, CONST char *mixin); static int NsfClassInfoSubclassMethod(Tcl_Interp *interp, NsfClass *cl, int withClosure, CONST char *patternString, NsfObject *patternObj); static int NsfClassInfoSuperclassMethod(Tcl_Interp *interp, NsfClass *cl, int withClosure, Tcl_Obj *pattern); -static int NsfAliasCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, CONST char *methodName, int withNonleaf, int withObjscope, Tcl_Obj *cmdName); +static int NsfAliasCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, CONST char *methodName, int withFrame, Tcl_Obj *cmdName); static int NsfAssertionCmd(Tcl_Interp *interp, NsfObject *object, int assertionsubcmd, Tcl_Obj *arg); static int NsfColonCmd(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]); static int NsfConfigureCmd(Tcl_Interp *interp, int configureoption, Tcl_Obj *value); static int NsfCreateObjectSystemCmd(Tcl_Interp *interp, Tcl_Obj *rootClass, Tcl_Obj *rootMetaClass, Tcl_Obj *systemMethods); static int NsfCurrentCmd(Tcl_Interp *interp, int currentoption); static int NsfDebugRunAssertionsCmd(Tcl_Interp *interp); static int NsfDeprecatedCmd(Tcl_Interp *interp, CONST char *what, CONST char *oldCmd, CONST char *newCmd); -static int NsfDispatchCmd(Tcl_Interp *interp, NsfObject *object, int withObjscope, Tcl_Obj *command, int nobjc, Tcl_Obj *CONST nobjv[]); +static int NsfDispatchCmd(Tcl_Interp *interp, NsfObject *object, int withFrame, Tcl_Obj *command, int nobjc, Tcl_Obj *CONST nobjv[]); static int NsfExistsVarCmd(Tcl_Interp *interp, NsfObject *object, CONST char *var); static int NsfFinalizeObjCmd(Tcl_Interp *interp); static int NsfForwardCmd(Tcl_Interp *interp, NsfObject *object, int withPer_object, Tcl_Obj *method, Tcl_Obj *withDefault, int withEarlybinding, Tcl_Obj *withMethodprefix, int withObjscope, Tcl_Obj *withOnerror, int withVerbose, Tcl_Obj *target, int nobjc, Tcl_Obj *CONST nobjv[]); @@ -873,12 +886,11 @@ NsfObject *object = (NsfObject *)pc.clientData[0]; int withPer_object = (int )PTR2INT(pc.clientData[1]); CONST char *methodName = (CONST char *)pc.clientData[2]; - int withNonleaf = (int )PTR2INT(pc.clientData[3]); - int withObjscope = (int )PTR2INT(pc.clientData[4]); - Tcl_Obj *cmdName = (Tcl_Obj *)pc.clientData[5]; + int withFrame = (int )PTR2INT(pc.clientData[3]); + Tcl_Obj *cmdName = (Tcl_Obj *)pc.clientData[4]; ParseContextRelease(&pc); - return NsfAliasCmd(interp, object, withPer_object, methodName, withNonleaf, withObjscope, cmdName); + return NsfAliasCmd(interp, object, withPer_object, methodName, withFrame, cmdName); } } @@ -1018,11 +1030,11 @@ return TCL_ERROR; } else { NsfObject *object = (NsfObject *)pc.clientData[0]; - int withObjscope = (int )PTR2INT(pc.clientData[1]); + int withFrame = (int )PTR2INT(pc.clientData[1]); Tcl_Obj *command = (Tcl_Obj *)pc.clientData[2]; ParseContextRelease(&pc); - return NsfDispatchCmd(interp, object, withObjscope, command, objc-pc.lastobjc, objv+pc.lastobjc); + return NsfDispatchCmd(interp, object, withFrame, command, objc-pc.lastobjc, objv+pc.lastobjc); } } @@ -2137,17 +2149,16 @@ {"-closure", 0, 0, ConvertToString}, {"pattern", 0, 0, ConvertToTclobj}} }, -{"::nsf::alias", NsfAliasCmdStub, 6, { +{"::nsf::alias", NsfAliasCmdStub, 5, { {"object", 0, 0, ConvertToObject}, {"-per-object", 0, 0, ConvertToString}, {"methodName", 0, 0, ConvertToString}, - {"-nonleaf", 0, 0, ConvertToString}, - {"-objscope", 0, 0, ConvertToString}, + {"-frame", 0|NSF_ARG_IS_ENUMERATION, 1, ConvertToFrame}, {"cmdName", NSF_ARG_REQUIRED, 0, ConvertToTclobj}} }, {"::nsf::assertion", NsfAssertionCmdStub, 3, { {"object", 0, 0, ConvertToObject}, - {"assertionsubcmd", NSF_ARG_REQUIRED|NSF_ARG_IS_ENUMERATION, 0, ConvertToAssertionsubcmd}, + {"assertionsubcmd", NSF_ARG_REQUIRED|NSF_ARG_IS_ENUMERATION, 1, ConvertToAssertionsubcmd}, {"arg", 0, 0, ConvertToTclobj}} }, {"::nsf::colon", NsfColonCmdStub, 1, { @@ -2175,7 +2186,7 @@ }, {"::nsf::dispatch", NsfDispatchCmdStub, 4, { {"object", NSF_ARG_REQUIRED, 0, ConvertToObject}, - {"-objscope", 0, 0, ConvertToString}, + {"-frame", 0|NSF_ARG_IS_ENUMERATION, 1, ConvertToFrame}, {"command", NSF_ARG_REQUIRED, 0, ConvertToTclobj}, {"args", 0, 0, ConvertToNothing}} }, Index: library/nx/nx.tcl =================================================================== diff -u -N -r92e6424562685bcc3665bf23dfcdc3ee489c25ef -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- library/nx/nx.tcl (.../nx.tcl) (revision 92e6424562685bcc3665bf23dfcdc3ee489c25ef) +++ library/nx/nx.tcl (.../nx.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -44,7 +44,7 @@ } # provide ::eval as method for ::nx::Object - ::nsf::alias Object eval -nonleaf ::eval + ::nsf::alias Object eval -frame method ::eval # # class methods @@ -312,28 +312,22 @@ # 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 + # -frame object|method make only sense for c-defined cmds, # - Object public method alias {-nonleaf:switch -objscope:switch methodName cmd} { + Object public method alias {methodName {-frame default} cmd} { array set "" [:__resolve_method_path -per-object $methodName] #puts "object alias $(object).$(methodName) $cmd" set r [::nsf::alias $(object) -per-object $(methodName) \ - {*}[expr {${objscope} ? "-objscope" : ""}] \ - {*}[expr {${nonleaf} ? "-nonleaf" : ""}] \ - $cmd] + -frame $frame $cmd] ::nsf::methodproperty $(object) -per-object $r call-protected \ [::nsf::dispatch $(object) __default_method_call_protection] return $r } - Class public method alias {-nonleaf:switch -objscope:switch methodName cmd} { + Class public method alias {methodName {-frame default} cmd} { array set "" [:__resolve_method_path $methodName] #puts "class alias $(object).$(methodName) $cmd" - set r [::nsf::alias $(object) $(methodName) \ - {*}[expr {${objscope} ? "-objscope" : ""}] \ - {*}[expr {${nonleaf} ? "-nonleaf" : ""}] \ - $cmd] + set r [::nsf::alias $(object) $(methodName) -frame $frame $cmd] ::nsf::methodproperty $(object) $r call-protected \ [::nsf::dispatch $(object) __default_method_call_protection] return $r @@ -671,7 +665,7 @@ foreach i [::nsf::dispatch $class ::nsf::methods::class::info::instances] { if {![::nsf::existsvar $i $att]} { if {[string match {*\[*\]*} $default]} { - set value [::nsf::dispatch $i -objscope ::eval subst $default] + set value [::nsf::dispatch $i -frame object ::eval subst $default] } else { set value $default } @@ -942,7 +936,7 @@ if {![::nsf::isobject $value]} { error "$value does not appear to be an object" } - set value [::nsf::dispatch $value -objscope ::nsf::current object] + set value [::nsf::dispatch $value -frame method ::nsf::current object] } if {![::nsf::is class ${:elementtype}]} { error "$value does not appear to be of type ${:elementtype}" @@ -1071,7 +1065,7 @@ Attribute method __default_from_cmd {obj cmd var sub op} { #puts "GETVAR [::nsf::current method] obj=$obj cmd=$cmd, var=$var, op=$op" - ::nsf::dispatch $obj -objscope \ + ::nsf::dispatch $obj -frame object \ ::trace remove variable $var $op [list [::nsf::current object] [::nsf::current method] $obj $cmd] ::nsf::setvar $obj $var [$obj eval $cmd] } @@ -1088,7 +1082,7 @@ # Do first ordinary slot initialization ::nsf::next set __initcmd "" - set trace {::nsf::dispatch [::nsf::current object] -objscope ::trace} + set trace {::nsf::dispatch [::nsf::current object] -frame object ::trace} # There might be already default values registered on the # class. If so, defaultcmd is ignored. if {[info exists :default]} { @@ -1391,7 +1385,7 @@ } set traces [list] foreach var [$origin info vars] { - set cmds [::nsf::dispatch $origin -objscope ::trace info variable $var] + set cmds [::nsf::dispatch $origin -frame object ::trace info variable $var] if {$cmds ne ""} { foreach cmd $cmds { foreach {op def} $cmd break Index: library/serialize/serializer.tcl =================================================================== diff -u -N -r92e6424562685bcc3665bf23dfcdc3ee489c25ef -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- library/serialize/serializer.tcl (.../serializer.tcl) (revision 92e6424562685bcc3665bf23dfcdc3ee489c25ef) +++ library/serialize/serializer.tcl (.../serializer.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -303,7 +303,7 @@ :public class-object method allChildren o { # return o and all its children fully qualified - set set [::nsf::dispatch $o -objscope ::nsf::current] + set set [::nsf::dispatch $o -frame method ::nsf::current] foreach c [$o info children] { lappend set {*}[:allChildren $c] } @@ -466,7 +466,7 @@ :public method registerTrace {on} { if {$on} { - ::nsf::alias ${:rootClass} __trace__ -objscope ::trace + ::nsf::alias ${:rootClass} __trace__ -frame object ::trace } else { ::nsf::method ${:rootClass} __trace__ {} {} } @@ -714,7 +714,7 @@ } :collect-var-traces $o $s - set objectName [::nsf::dispatch $o -objscope ::nsf::current object] + set objectName [::nsf::dispatch $o -frame method ::nsf::current object] set isSlotContainer [::nx::isSlotContainer $objectName] if {$isSlotContainer} { append cmd [list ::nx::slotObj [$o ::nsf::methods::object::info::parent]]\n @@ -790,7 +790,7 @@ } :public method serialize-all-end {s} { - return "[next]\n::nsf::alias ::xotcl::Object trace -objscope ::trace\n" + return "[next]\n::nsf::alias ::xotcl::Object trace -frame object ::trace\n" } @@ -849,7 +849,7 @@ :method Object-serialize {o s} { :collect-var-traces $o $s - append cmd [list [$o info class] create [::nsf::dispatch $o -objscope ::nsf::current object]] + append cmd [list [$o info class] create [::nsf::dispatch $o -frame method ::nsf::current object]] append cmd " -noinit\n" foreach i [$o ::nsf::methods::object::info::methods -methodtype scripted -callprotection all] { append cmd [:method-serialize $o $i ""] "\n" @@ -886,12 +886,8 @@ } # provide limited support for exporting aliases for XOTcl objects foreach i [$o ::nsf::methods::class::info::methods -methodtype alias -callprotection all] { - set xotcl2Def [$o ::nsf::methods::class::info::method definition $i] - set objscope [lindex $xotcl2Def end-2] - set methodName [lindex $xotcl2Def end-1] - set cmdName [lindex $xotcl2Def end] - if {$objscope ne "-objscope"} {set objscope ""} - append cmd [list ::nsf::alias $o $methodName {*}$objscope $cmdName]\n + set nxDef [$o ::nsf::methods::class::info::method definition $i] + append cmd [list ::nsf::alias $o {*}[lrange $nxDef 2 end]\n } append cmd \ [:frameWorkCmd ::nsf::relation $o superclass -unless ${:rootClass}] \ Index: library/xotcl/library/xotcl2.tcl =================================================================== diff -u -N -r18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision 18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30) +++ library/xotcl/library/xotcl2.tcl (.../xotcl2.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -204,7 +204,7 @@ # 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 + ::nsf::alias Object $cmd -frame object ::$cmd } # provide the standard command set for ::xotcl::Class @@ -612,7 +612,7 @@ ::nsf::alias Object contains ::nsf::classes::nx::Object::contains ::xotcl::Class instforward slots %self contains \ - -object {%::nsf::dispatch [::xotcl::self] -objscope ::subst [::xotcl::self]::slot} + -object {%::nsf::dispatch [::xotcl::self] -frame method ::subst [::xotcl::self]::slot} # assertion handling proc checkoption_xotcl1_to_internal checkoptions { @@ -667,7 +667,7 @@ set kind parametercmd } elseif {$kind eq "alias"} { set kind "cmd" - set name [lindex $definition end-1] + set name [lindex $definition 3] } set definition [list [lindex $definition 0] ${prefix}$kind $name] } Index: library/xotcl/tests/slottest.xotcl =================================================================== diff -u -N -r7d7f47ce5d7b7c2d252af5d4499b50996f6475ff -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision 7d7f47ce5d7b7c2d252af5d4499b50996f6475ff) +++ library/xotcl/tests/slottest.xotcl (.../slottest.xotcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -165,18 +165,18 @@ Object o1 o1 set i 0 -::nsf::alias o1 Incr -objscope ::incr +::nsf::alias o1 Incr -frame object ::incr ? {o1 incr i} 1 "method incr" ? {o1 Incr i} 1002 "aliased tcl incr" ? {o1 incr i} 2003 "method incr" ? {o1 Incr i} 3004 "aliased tcl incr" -::nsf::alias ::xotcl::Object Set -objscope ::set +::nsf::alias ::xotcl::Object Set -frame object ::set ? {o1 set i 1} 1 "method set" ? {o1 set i} 1 "method set" ? {o1 Set i 1} 1 "aliased tcl set" ? {o1 Set i} 1 "aliased tcl set" -::nsf::alias o1 Set -objscope ::set +::nsf::alias o1 Set -frame object ::set ? {o1 Set i 1} 1 "aliased object tcl set" ? {o1 Set i} 1 "aliased object tcl set" ::xotcl::Object instforward SSet -earlybinding -objscope ::set @@ -575,7 +575,7 @@ ? {o1 myfdset y} "get instvar value via forward -earlybinding" ? {o1 myfdset y 123} "set instvar value via forward -earlybinding" -::nsf::alias o1 myset -objscope ::set +::nsf::alias o1 myset -frame object ::set o1 myset x 101 ? {o1 myset x} 101 Index: tests/aliastest.tcl =================================================================== diff -u -N -r18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- tests/aliastest.tcl (.../aliastest.tcl) (revision 18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30) +++ tests/aliastest.tcl (.../aliastest.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -11,10 +11,27 @@ "::nx::ObjectParameterSlot public alias get ::nsf::setvar" # define an alias and retrieve its definition - set cmd "::nx::Object public alias -objscope set ::set" + set cmd "::nx::Object public alias set ::set" eval $cmd ? {Object info method definition set} $cmd + + # define an alias and retrieve its definition + set cmd "::nx::Object public alias set -frame method ::set" + eval $cmd + ? {Object info method definition set} $cmd + + # define an alias and retrieve its definition + set cmd "::nx::Object public alias set -frame object ::set" + eval $cmd + ? {Object info method definition set} $cmd + proc ::foo {} {return foo} + ? {Object alias foo -frame object ::foo} \ + "cannot use -frame object|method in alias for scripted command '::foo'" + ? {Object alias foo -frame method ::foo} \ + "cannot use -frame object|method in alias for scripted command '::foo'" + ? {Object alias foo -frame default ::foo} "::nsf::classes::nx::Object::foo" + } Test case alias-simple { @@ -24,7 +41,7 @@ } Class create Foo - ::nsf::alias ::Foo foo ::nsf::classes::Base::foo + ? {::nsf::alias ::Foo foo ::nsf::classes::Base::foo} "::nsf::classes::Foo::foo" ? {Foo info method definition foo} "::Foo public alias foo ::nsf::classes::Base::foo" Index: tests/destroytest.tcl =================================================================== diff -u -N -r18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- tests/destroytest.tcl (.../destroytest.tcl) (revision 18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30) +++ tests/destroytest.tcl (.../destroytest.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -4,7 +4,7 @@ Test parameter count 10 -::nsf::alias ::nx::Object set -objscope ::set +::nsf::alias ::nx::Object set -frame object ::set Class create O -superclass Object { :method init {} { Index: tests/info-method.tcl =================================================================== diff -u -N -r18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- tests/info-method.tcl (.../info-method.tcl) (revision 18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30) +++ tests/info-method.tcl (.../info-method.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -50,7 +50,7 @@ ? {nx::Class info method parameter method} \ {name arguments body -precondition -postcondition} ? {nx::Object info method parameter alias} \ - {-nonleaf:switch -objscope:switch methodName cmd} + {methodName {-frame default} cmd} # raises currently an error ? {catch {C info method parameter a}} 1 Index: tests/method-require.tcl =================================================================== diff -u -N -re2f11549ef70518cca8c9c49b1d78f4383b00a87 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- tests/method-require.tcl (.../method-require.tcl) (revision e2f11549ef70518cca8c9c49b1d78f4383b00a87) +++ tests/method-require.tcl (.../method-require.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -12,10 +12,10 @@ # producing these.... # - nsf::provide_method append {::nsf::alias append -objscope ::append} - nsf::provide_method lappend {::nsf::alias lappend -objscope ::lappend} - nsf::provide_method set {::nsf::alias set -objscope ::set} - nsf::provide_method tcl::set {::nsf::alias set -objscope ::set} + nsf::provide_method append {::nsf::alias append -frame object ::append} + nsf::provide_method lappend {::nsf::alias lappend -frame object ::lappend} + nsf::provide_method set {::nsf::alias set -frame object ::set} + nsf::provide_method tcl::set {::nsf::alias set -frame object ::set} nsf::provide_method exists {::nsf::alias exists ::nsf::methods::object::exists} nsf::provide_method foo {::nsf::method foo {x y} {return x=$x,y=$y}} nsf::provide_method x {::nsf::mixin ::MIX} { Index: tests/object-system.tcl =================================================================== diff -u -N -re2f11549ef70518cca8c9c49b1d78f4383b00a87 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- tests/object-system.tcl (.../object-system.tcl) (revision e2f11549ef70518cca8c9c49b1d78f4383b00a87) +++ tests/object-system.tcl (.../object-system.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -135,12 +135,26 @@ # dispatch with colon names Object create o {set :x 1} ::nsf::dispatch ::o ::incr x -? {o eval {set :x}} 1 "cmd dispatch without -objscope did not modify the instance variable" -::nsf::dispatch ::o -objscope ::incr x -? {o eval {set :x}} 2 "cmd dispatch -objscope modifies the instance variable" -? {catch {::nsf::dispatch ::o -objscope ::xxx x}} 1 "cmd dispatch with unknown command" +? {o eval {set :x}} 1 "cmd dispatch without -frame object did not modify the instance variable" +::nsf::dispatch ::o -frame object ::incr x +? {o eval {set :x}} 2 "cmd dispatch -frame object modifies the instance variable" +? {catch {::nsf::dispatch ::o -frame object ::xxx x}} 1 "cmd dispatch with unknown command" o destroy +Object create o { + :public method foo {} { + foreach var [list x1 y1 x2 y2 x3 y3] { + lappend results $var [info exists :$var] + } + return $results + } +} +::nsf::dispatch o ::eval {set x1 1; set :y1 1} +::nsf::dispatch o -frame method ::eval {set x2 1; set :y2 1} +::nsf::dispatch o -frame object ::eval {set x3 1; set :y3 1} +? {o foo} "x1 0 y1 0 x2 0 y2 1 x3 1 y3 1" +o destroy + puts stderr ===MINI-OBJECTSYSTEM # test object system # create a minimal object system without internally dipatched methods Index: tests/returns.tcl =================================================================== diff -u -N -r18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- tests/returns.tcl (.../returns.tcl) (revision 18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30) +++ tests/returns.tcl (.../returns.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -19,8 +19,8 @@ # scripted method with paramdefs :method bar-nok {a b:integer} {return a} # alias to tcl-cmd (no param defs) - :alias -objscope incr ::incr - :alias -objscope lappend ::lappend + :alias incr -frame object ::incr + :alias lappend -frame object ::lappend :create c1 } @@ -75,8 +75,8 @@ :method bar-ok1 {a b} {return 1} :method bar-ok2 {a b} {return $a} :method bar-nok {a b:integer} {return a} - :alias -objscope incr ::incr - :alias -objscope lappend ::lappend + :alias incr -frame object ::incr + :alias lappend -frame object ::lappend :create c1 } @@ -112,7 +112,7 @@ :method bar-ok1 {a b} {return male} :method bar-ok2 {a b} {return $a} :method bar-nok {a b:integer} {return $b} - :alias -objscope set ::set + :alias set -frame object ::set :create c1 } @@ -161,8 +161,8 @@ # scripted method with paramdefs :method bar-nok {a b:integer} {return a} # alias to tcl-cmd (no param defs) - :alias -objscope incr ::incr - :alias -objscope lappend ::lappend + :alias incr -frame object ::incr + :alias lappend -frame object ::lappend :create c1 } @@ -212,8 +212,8 @@ :method bar-ok1 {a b} {return 1} :method bar-ok2 {a b} {return $a} :method bar-nok {a b:integer} {return a} - :alias -objscope incr ::incr - :alias -objscope lappend ::lappend + :alias incr -frame object ::incr + :alias lappend -frame object ::lappend :create c1 } @@ -249,7 +249,7 @@ :method bar-ok1 {a b} {return male} :method bar-ok2 {a b} {return $a} :method bar-nok {a b:integer} {return $b} - :alias -objscope set ::set + :alias set -frame object ::set :create c1 } Index: tests/varresolutiontest.tcl =================================================================== diff -u -N -r18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30 -rc5d841d4cd001b85e95e01202b4fc0afe75df6a8 --- tests/varresolutiontest.tcl (.../varresolutiontest.tcl) (revision 18d4d9c1a99310c3fb9b2f2bed03e9d59fb30d30) +++ tests/varresolutiontest.tcl (.../varresolutiontest.tcl) (revision c5d841d4cd001b85e95e01202b4fc0afe75df6a8) @@ -7,12 +7,12 @@ Test parameter count 1 -::nsf::alias ::nx::Object objeval -objscope ::eval -::nsf::alias ::nx::Object array -objscope ::array -::nsf::alias ::nx::Object lappend -objscope ::lappend -::nsf::alias ::nx::Object incr -objscope ::incr -::nsf::alias ::nx::Object set -objscope ::set -::nsf::alias ::nx::Object unset -objscope ::unset +::nsf::alias ::nx::Object objeval -frame object ::eval +::nsf::alias ::nx::Object array -frame object ::array +::nsf::alias ::nx::Object lappend -frame object ::lappend +::nsf::alias ::nx::Object incr -frame object ::incr +::nsf::alias ::nx::Object set -frame object ::set +::nsf::alias ::nx::Object unset -frame object ::unset ########################################### # Basic tests for var resolution under @@ -402,8 +402,8 @@ array set ::tmpArray {key value} Class create ::C -::nsf::alias ::C Set -objscope ::set -::nsf::alias ::C Unset -objscope ::unset +::nsf::alias ::C Set -frame object ::set +::nsf::alias ::C Unset -frame object ::unset ::C create ::c namespace eval ::c {} @@ -422,16 +422,13 @@ unset ::tmpArray ################################################## -# Testing aliases for eval with and without flags -# -# -objscope, -# -nonleaf -# -# with a required namespace and without +# Testing aliases for eval with and without +# -varscope flags and with a +# required namespace and without ################################################## Test case eval-variants -::nsf::alias ::nx::Object objeval -objscope ::eval -::nsf::alias ::nx::Object softeval -nonleaf ::eval +::nsf::alias ::nx::Object objeval -frame object ::eval +::nsf::alias ::nx::Object softeval -frame method ::eval ::nsf::alias ::nx::Object softeval2 ::eval set G 1 @@ -594,8 +591,8 @@ # Test with proc scopes ################################################## Test case proc-scopes -::nsf::alias ::nx::Object objscoped-eval -objscope ::eval -::nsf::alias ::nx::Object nonleaf-eval -nonleaf ::eval +::nsf::alias ::nx::Object objscoped-eval -frame object ::eval +::nsf::alias ::nx::Object nonleaf-eval -frame method ::eval ::nsf::alias ::nx::Object plain-eval ::eval proc foo-via-initcmd {} {