Index: generic/gentclAPI.decls =================================================================== diff -u -re767edf5c498094f6e00150541bfb7beab52b619 -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- generic/gentclAPI.decls (.../gentclAPI.decls) (revision e767edf5c498094f6e00150541bfb7beab52b619) +++ generic/gentclAPI.decls (.../gentclAPI.decls) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -301,7 +301,7 @@ {-argName "object" -required 1 -type object} {-argName "-defined"} {-argName "-per-object"} - {-argName "-methodtype" -nrargs 1 -type "all|scripted|compiled|alias|forwarder|object|setter"} + {-argName "-methodtype" -nrargs 1 -type "all|scripted|system|alias|forwarder|object|setter"} {-argName "-nomixins"} {-argName "-incontext"} {-argName "pattern"} Index: generic/tclAPI.h =================================================================== diff -u -re767edf5c498094f6e00150541bfb7beab52b619 -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- generic/tclAPI.h (.../tclAPI.h) (revision e767edf5c498094f6e00150541bfb7beab52b619) +++ generic/tclAPI.h (.../tclAPI.h) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -1,12 +1,12 @@ static int convertToMethodtype(Tcl_Interp *interp, Tcl_Obj *objPtr, XOTclParam CONST *pPtr, ClientData *clientData) { int index, result; - static CONST char *opts[] = {"all", "scripted", "compiled", "alias", "forwarder", "object", "setter", NULL}; + static CONST char *opts[] = {"all", "scripted", "system", "alias", "forwarder", "object", "setter", NULL}; result = Tcl_GetIndexFromObj(interp, objPtr, opts, "-methodtype", 0, &index); *clientData = (ClientData) index + 1; return result; } -enum MethodtypeIdx {MethodtypeNULL, MethodtypeAllIdx, MethodtypeScriptedIdx, MethodtypeCompiledIdx, MethodtypeAliasIdx, MethodtypeForwarderIdx, MethodtypeObjectIdx, MethodtypeSetterIdx}; +enum MethodtypeIdx {MethodtypeNULL, MethodtypeAllIdx, MethodtypeScriptedIdx, MethodtypeSystemIdx, MethodtypeAliasIdx, MethodtypeForwarderIdx, MethodtypeObjectIdx, MethodtypeSetterIdx}; static int convertToConfigureoption(Tcl_Interp *interp, Tcl_Obj *objPtr, XOTclParam CONST *pPtr, ClientData *clientData) { int index, result; Index: generic/xotcl.c =================================================================== diff -u -r9f7fa883bf6ed48f1401f815caca1e34f56584a1 -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- generic/xotcl.c (.../xotcl.c) (revision 9f7fa883bf6ed48f1401f815caca1e34f56584a1) +++ generic/xotcl.c (.../xotcl.c) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -103,6 +103,11 @@ XOTCLINLINE static void CallStackDoDestroy(Tcl_Interp *interp, XOTclObject *obj); static int XOTclCInvalidateObjectParameterMethod(Tcl_Interp *interp, XOTclClass *cl); +static CONST char* AliasIndex(Tcl_DString *dsPtr, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object); +static int AliasAdd(Tcl_Interp *interp, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object, char *cmd); +static int AliasDelete(Tcl_Interp *interp, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object); +static Tcl_Obj *AliasGet(Tcl_Interp *interp, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object); + typedef enum { CALLING_LEVEL, ACTIVE_LEVEL } CallStackLevel; typedef struct callFrameContext { @@ -126,10 +131,10 @@ XOTclObject *obj; Tcl_Obj *cmdName; Tcl_ObjCmdProc *objProc; + ClientData clientData; int passthrough; int needobjmap; int verbose; - ClientData clientData; int nr_args; Tcl_Obj *args; int objscope; @@ -141,12 +146,13 @@ typedef struct AliasCmdClientData { XOTclObject *obj; - XOTclClass *class; Tcl_Obj *cmdName; Tcl_ObjCmdProc *objProc; + ClientData clientData; + XOTclClass *class; + Tcl_Interp *interp; Tcl_Command aliasedCmd; Tcl_Command aliasCmd; - ClientData clientData; } AliasCmdClientData; #define PARSE_CONTEXT_PREALLOC 20 @@ -1804,7 +1810,7 @@ */ static int -NSDeleteCmd(Tcl_Interp *interp, Tcl_Namespace *nsPtr, char *name) { +NSDeleteCmd(Tcl_Interp *interp, Tcl_Namespace *nsPtr, CONST char *name) { /* a simple deletion would delete a global command with the same name, if the command is not existing, so we use the CmdToken */ @@ -1927,12 +1933,12 @@ /* * cmd is an aliased object, reduce the refcount */ - /*fprintf(stderr, "NSCleanupNamespace cleanup aliased object %p\n",invokeObj);*/ + fprintf(stderr, "NSCleanupNamespace cleanup aliased object %p\n",invokeObj); XOTclCleanupObject(invokeObj); } - /*fprintf(stderr, "NSCleanupNamespace deleting %s %p\n", - Tcl_Command_nsPtr(cmd)->fullName, cmd);*/ + /*fprintf(stderr, "NSCleanupNamespace deleting %s %p (%s)\n", + Tcl_Command_nsPtr(cmd)->fullName, cmd, Tcl_GetCommandName(interp, cmd) );*/ XOTcl_DeleteCommandFromToken(interp, cmd); } } @@ -1977,7 +1983,7 @@ */ MEM_COUNT_FREE("TclNamespace", nsPtr); if (Tcl_Namespace_deleteProc(nsPtr)) { - /*fprintf(stderr, "calling deteteNamespace\n");*/ + /*fprintf(stderr, "calling deteteNamespace %s\n", nsPtr->fullName);*/ Tcl_DeleteNamespace(nsPtr); } } @@ -2175,6 +2181,9 @@ return result; } + /* delete an alias definition, if it exists */ + AliasDelete(interp, obj->cmdName, methodName, 1); + ALLOC_NAME_NS(dsPtr, ns->fullName, methodName); newCmd = Tcl_CreateObjCommand(interp, Tcl_DStringValue(dsPtr), proc, clientData, dp); @@ -2194,12 +2203,15 @@ Tcl_Command newCmd; int result; - /* Check, if we are allowed to redefine the method */ + /* Check, if we are allowed to redefine the method */ result = CanRedefineCmd(interp, cl->nsPtr, &cl->object, (char*)methodName); if (result != TCL_OK) { return result; } + /* delete an alias definition, if it exists */ + AliasDelete(interp, class->object.cmdName, methodName, 0); + ALLOC_NAME_NS(dsPtr, cl->nsPtr->fullName, methodName); newCmd = Tcl_CreateObjCommand(interp, Tcl_DStringValue(dsPtr), proc, clientData, dp); @@ -2695,7 +2707,7 @@ } static void -AssertionRemoveProc(XOTclAssertionStore *aStore, char *name) { +AssertionRemoveProc(XOTclAssertionStore *aStore, CONST char *name) { Tcl_HashEntry *hPtr; if (aStore) { hPtr = XOTcl_FindHashEntry(&aStore->procs, name); @@ -5560,6 +5572,8 @@ } else if (cp) { cscPtr = &csc; + /*fprintf(stderr, "we could stuff obj %p %s\n",obj,objectName(obj));*/ + /* some cmd with client data */ if (proc == XOTclObjDispatch) { /* @@ -8287,33 +8301,37 @@ } extern int -XOTclRemovePMethod(Tcl_Interp *interp, XOTcl_Object *obji, char *name) { - XOTclObject *obj = (XOTclObject*) obji; +XOTclRemovePMethod(Tcl_Interp *interp, XOTcl_Object *object, CONST char *methodName) { + XOTclObject *obj = (XOTclObject*) object; + AliasDelete(interp, obj->cmdName, methodName, 1); + if (obj->opt) - AssertionRemoveProc(obj->opt->assertions, name); + AssertionRemoveProc(obj->opt->assertions, methodName); if (obj->nsPtr) { - int rc = NSDeleteCmd(interp, obj->nsPtr, name); + int rc = NSDeleteCmd(interp, obj->nsPtr, methodName); if (rc < 0) - return XOTclVarErrMsg(interp, objectName(obj), " cannot delete method '", name, + return XOTclVarErrMsg(interp, objectName(obj), " cannot delete method '", methodName, "' of object ", objectName(obj), (char *) NULL); } return TCL_OK; } extern int -XOTclRemoveIMethod(Tcl_Interp *interp, XOTcl_Class *cli, char *name) { - XOTclClass *cl = (XOTclClass*) cli; +XOTclRemoveIMethod(Tcl_Interp *interp, XOTcl_Class *class, CONST char *methodName) { + XOTclClass *cl = (XOTclClass*) class; XOTclClassOpt *opt = cl->opt; int rc; + AliasDelete(interp, class->object.cmdName, methodName, 0); + if (opt && opt->assertions) - AssertionRemoveProc(opt->assertions, name); + AssertionRemoveProc(opt->assertions, methodName); - rc = NSDeleteCmd(interp, cl->nsPtr, name); + rc = NSDeleteCmd(interp, cl->nsPtr, methodName); if (rc < 0) - return XOTclVarErrMsg(interp, className(cl), " cannot delete method '", name, + return XOTclVarErrMsg(interp, className(cl), " cannot delete method '", methodName, "' of class ", className(cl), (char *) NULL); return TCL_OK; } @@ -8730,6 +8748,12 @@ char *methodName = ObjStr(objv[0]); /*TODO: resolve the 'real' command at the end of the imported cmd chain */ + if (self == NULL) { + return XOTclVarErrMsg(interp, "no object active for alias '", + Tcl_GetCommandName(interp, tcd->aliasCmd), + "'; don't call aliased methods via namespace paths", + (char *) NULL); + } return MethodDispatch((ClientData)self, interp, objc, objv, tcd->aliasedCmd, self, tcd->class, methodName, 0); } @@ -8740,7 +8764,7 @@ XOTclObject *obj = tcd->obj; int result; XOTcl_FrameDecls; - /*fprintf(stderr, "objscopedMethod obj=%p, ptr=%p\n", obj, tcd->objProc);*/ + /*fprintf(stderr, "objscopedMethod obj=%p %s, ptr=%p\n", obj, objectName(obj), tcd->objProc);*/ XOTcl_PushFrame(interp, obj); @@ -8758,6 +8782,19 @@ AliasCmdClientData *tcd = (AliasCmdClientData *)clientData; ImportRef *refPtr, *prevPtr = NULL; + /* + * Since we just get the clientData, we have to obtain interp, + * object, methodName and per-object from tcd; the obj might be + * deleted already. We need as well at least still the global + * namespace. + */ + if (tcd->interp && + ((Interp *)(tcd->interp))->globalNsPtr && + RUNTIME_STATE(tcd->interp)->exitHandlerDestroyRound != XOTCL_EXITHANDLER_ON_PHYSICAL_DESTROY) { + CONST char *methodName = Tcl_GetCommandName(tcd->interp, tcd->aliasCmd); + AliasDelete(tcd->interp, tcd->cmdName, methodName, tcd->class == NULL); + } + /*fprintf(stderr, "aliasCmdDeleteProc\n");*/ if (tcd->cmdName) {DECR_REF_COUNT(tcd->cmdName);} if (tcd->aliasedCmd) { @@ -9392,23 +9429,32 @@ #endif if (pattern && !Tcl_StringMatch(key, pattern)) continue; - if (proc == XOTclProcAliasMethod) { - if ((methodType & XOTCL_METHODTYPE_ALIAS) == 0) continue; + if (methodType == XOTCL_METHODTYPE_ALIAS) { + if (proc != XOTclProcAliasMethod) { + /* for the time being, we just return aliases, which are + aliases to procs or to other methods; aliases to built-in + cmds are not returned */ + continue; + } + } else { + if (proc == XOTclProcAliasMethod) { + if ((methodType & XOTCL_METHODTYPE_ALIAS) == 0) continue; + } + /* the following cases are disjoint */ + if (CmdIsProc(importedCmd)) { + /*fprintf(stderr,"%s scripted %d\n",key, methodType & XOTCL_METHODTYPE_SCRIPTED);*/ + if ((methodType & XOTCL_METHODTYPE_SCRIPTED) == 0) continue; + } else if (resolvedProc == XOTclForwardMethod) { + if ((methodType & XOTCL_METHODTYPE_FORWARDER) == 0) continue; + } else if (resolvedProc == XOTclSetterMethod) { + if ((methodType & XOTCL_METHODTYPE_SETTER) == 0) continue; + } else if (resolvedProc == XOTclObjDispatch) { + if ((methodType & XOTCL_METHODTYPE_OBJECT) == 0) continue; + } else if ((methodType & XOTCL_METHODTYPE_OTHER) == 0) { + /*fprintf(stderr,"OTHER %s not wanted %.4x\n",key, methodType);*/ + continue; + } } - /* the following cases are disjoint */ - if (CmdIsProc(importedCmd)) { - /*fprintf(stderr,"%s scripted %d\n",key, methodType & XOTCL_METHODTYPE_SCRIPTED);*/ - if ((methodType & XOTCL_METHODTYPE_SCRIPTED) == 0) continue; - } else if (resolvedProc == XOTclForwardMethod) { - if ((methodType & XOTCL_METHODTYPE_FORWARDER) == 0) continue; - } else if (resolvedProc == XOTclSetterMethod) { - if ((methodType & XOTCL_METHODTYPE_SETTER) == 0) continue; - } else if (resolvedProc == XOTclObjDispatch) { - if ((methodType & XOTCL_METHODTYPE_OBJECT) == 0) continue; - } else if ((methodType & XOTCL_METHODTYPE_OTHER) == 0) { - /*fprintf(stderr,"OTHER %s not wanted %.4x\n",key, methodType);*/ - continue; - } /* if (noCmds && proc != RUNTIME_STATE(interp)->objInterpProc) continue; if (noProcs && proc == RUNTIME_STATE(interp)->objInterpProc) continue; @@ -9697,10 +9743,53 @@ * End result setting commands ********************************/ +static CONST char* AliasIndex(Tcl_DString *dsPtr, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object) { + Tcl_DStringInit(dsPtr); + Tcl_DStringAppend(dsPtr, ObjStr(cmdName), -1); + Tcl_DStringAppend(dsPtr, ",", 1); + Tcl_DStringAppend(dsPtr, methodName, -11); + if (withPer_object) { + Tcl_DStringAppend(dsPtr, ",1", 2); + } else { + Tcl_DStringAppend(dsPtr, ",0", 2); + } + /*fprintf(stderr, "AI %s\n",Tcl_DStringValue(dsPtr));*/ + return Tcl_DStringValue(dsPtr); +} + +static int AliasAdd(Tcl_Interp *interp, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object, + char *cmd) { + Tcl_DString ds, *dsPtr = &ds; + Tcl_SetVar2Ex(interp, "::xotcl::alias", + AliasIndex(dsPtr, cmdName, methodName, withPer_object), + Tcl_NewStringObj(cmd,-1), + TCL_GLOBAL_ONLY); + Tcl_DStringFree(dsPtr); + return TCL_OK; +} + +static int AliasDelete(Tcl_Interp *interp, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object) { + Tcl_DString ds, *dsPtr = &ds; + int result = Tcl_UnsetVar2(interp, "::xotcl::alias", + AliasIndex(dsPtr, cmdName, methodName, withPer_object), + TCL_GLOBAL_ONLY); + Tcl_DStringFree(dsPtr); + return result; +} + +static Tcl_Obj *AliasGet(Tcl_Interp *interp, Tcl_Obj *cmdName, CONST char *methodName, int withPer_object) { + Tcl_DString ds, *dsPtr = &ds; + Tcl_Obj *obj = Tcl_GetVar2Ex(interp, "::xotcl::alias", + AliasIndex(dsPtr, cmdName, methodName, withPer_object), + TCL_GLOBAL_ONLY); + Tcl_DStringFree(dsPtr); + return obj; +} + + /********************************* * Begin generated XOTcl commands *********************************/ - static int XOTclAliasCmd(Tcl_Interp *interp, XOTclObject *object, char *methodName, int withObjscope, int withPer_object, int withProtected, Tcl_Obj *cmdName) { @@ -9719,6 +9808,17 @@ allocation = 'o'; } + { + Tcl_DString ds, *dsPtr = &ds; + 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, withPer_object, Tcl_DStringValue(dsPtr)); + Tcl_DStringFree(dsPtr); + } + cmd = Tcl_GetCommandFromObj(interp, cmdName); if (cmd == NULL) { return XOTclVarErrMsg(interp, "cannot lookup command '", @@ -9776,8 +9876,12 @@ * alias points to nowhere. We realize this via using the object * refcount. */ - /*fprintf(stderr, "registering an object %p\n",tcd);*/ + fprintf(stderr, "registering an object %p\n",tcd); + XOTclObjectRefCountIncr((XOTclObject *)Tcl_Command_objClientData(cmd)); + + /*newObjProc = XOTclProcAliasMethod;*/ + } else if (CmdIsProc(cmd)) { /* * if we have a tcl proc|xotcl-method as alias, then use the @@ -9795,14 +9899,16 @@ if (newObjProc) { /* add a wrapper */ tcd = NEW(AliasCmdClientData); - tcd->cmdName = NULL; + tcd->cmdName = object->cmdName; + tcd->interp = interp; /* just for deleting the associated variable */ tcd->obj = object; tcd->class = allocation == 'c' ? (XOTclClass *) object : NULL; tcd->objProc = objProc; tcd->aliasedCmd = cmd; tcd->clientData = Tcl_Command_objClientData(cmd); objProc = newObjProc; deleteProc = aliasCmdDeleteProc; + if (tcd->cmdName) {INCR_REF_COUNT(tcd->cmdName);} } else { /* call the command directly (must be a c-implemented command not depending on a volatile client data) */ tcd = Tcl_Command_objClientData(cmd); @@ -10052,10 +10158,10 @@ } destroyObjectSystems(interp); - XOTclClassListFree(RUNTIME_STATE(interp)->rootClasses); #ifdef DO_CLEANUP + /*fprintf(stderr, "CLEANUP TOP NS\n");*/ XOTcl_DeleteNamespace(interp, RUNTIME_STATE(interp)->XOTclClassesNS); XOTcl_DeleteNamespace(interp, RUNTIME_STATE(interp)->XOTclNS); #endif @@ -12125,13 +12231,13 @@ switch (withMethodtype) { case MethodtypeNULL: /* default */ case MethodtypeAllIdx: - methodType = XOTCL_METHODTYPE_SCRIPTED|XOTCL_METHODTYPE_CMD; + methodType = XOTCL_METHODTYPE_SCRIPTED|XOTCL_METHODTYPE_SYSTEM; break; case MethodtypeScriptedIdx: methodType = XOTCL_METHODTYPE_SCRIPTED|XOTCL_METHODTYPE_ALIAS; break; - case MethodtypeCompiledIdx: - methodType = XOTCL_METHODTYPE_CMD; + case MethodtypeSystemIdx: + methodType = XOTCL_METHODTYPE_SYSTEM; break; case MethodtypeForwarderIdx: methodType = XOTCL_METHODTYPE_FORWARDER; @@ -12898,7 +13004,7 @@ #ifdef DO_CLEANUP freeAllXOTclObjectsAndClasses(interp, commandTable); - + /*fprintf(stderr, "delete root classes\n");*/ for (os = RUNTIME_STATE(interp)->rootClasses; os; os = os->nextPtr) { rootClass = os->cl; rootMetaClass = (XOTclClass *)os->clientData; @@ -12912,8 +13018,6 @@ #endif - - MEM_COUNT_FREE("Tcl_InitHashTable", commandTable); Tcl_DeleteHashTable(commandTable); Index: generic/xotcl.decls =================================================================== diff -u -ra4d1fd30453e4e87467b02ed749fb4007d46a5e0 -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- generic/xotcl.decls (.../xotcl.decls) (revision a4d1fd30453e4e87467b02ed749fb4007d46a5e0) +++ generic/xotcl.decls (.../xotcl.decls) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -66,10 +66,10 @@ # ClientData cd, Tcl_CmdDeleteProc *dp) #} declare 13 generic { - int XOTclRemovePMethod(Tcl_Interp *interp,struct XOTcl_Object *obj, char *nm) + int XOTclRemovePMethod(Tcl_Interp *interp,struct XOTcl_Object *obj, CONST char *nm) } declare 14 generic { - int XOTclRemoveIMethod(Tcl_Interp *interp, struct XOTcl_Class *cl, char *nm) + int XOTclRemoveIMethod(Tcl_Interp *interp, struct XOTcl_Class *cl, CONST char *nm) } declare 15 generic { Tcl_Obj *XOTclOSetInstVar(struct XOTcl_Object *obj, Tcl_Interp *interp, Index: generic/xotclDecls.h =================================================================== diff -u -rcde16e9d87173d7ef9179ce40e10c2f1f708940e -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- generic/xotclDecls.h (.../xotclDecls.h) (revision cde16e9d87173d7ef9179ce40e10c2f1f708940e) +++ generic/xotclDecls.h (.../xotclDecls.h) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -79,13 +79,13 @@ #define XOTclRemovePMethod_TCL_DECLARED /* 13 */ EXTERN int XOTclRemovePMethod (Tcl_Interp * interp, - struct XOTcl_Object * obj, char * nm); + struct XOTcl_Object * obj, CONST char * nm); #endif #ifndef XOTclRemoveIMethod_TCL_DECLARED #define XOTclRemoveIMethod_TCL_DECLARED /* 14 */ EXTERN int XOTclRemoveIMethod (Tcl_Interp * interp, - struct XOTcl_Class * cl, char * nm); + struct XOTcl_Class * cl, CONST char * nm); #endif #ifndef XOTclOSetInstVar_TCL_DECLARED #define XOTclOSetInstVar_TCL_DECLARED @@ -273,8 +273,8 @@ int (*xOTclDeleteClass) (Tcl_Interp * interp, struct XOTcl_Class * cl); /* 10 */ void *reserved11; void *reserved12; - int (*xOTclRemovePMethod) (Tcl_Interp * interp, struct XOTcl_Object * obj, char * nm); /* 13 */ - int (*xOTclRemoveIMethod) (Tcl_Interp * interp, struct XOTcl_Class * cl, char * nm); /* 14 */ + int (*xOTclRemovePMethod) (Tcl_Interp * interp, struct XOTcl_Object * obj, CONST char * nm); /* 13 */ + int (*xOTclRemoveIMethod) (Tcl_Interp * interp, struct XOTcl_Class * cl, CONST char * nm); /* 14 */ Tcl_Obj * (*xOTclOSetInstVar) (struct XOTcl_Object * obj, Tcl_Interp * interp, Tcl_Obj * name, Tcl_Obj * value, int flgs); /* 15 */ Tcl_Obj * (*xOTclOGetInstVar) (struct XOTcl_Object * obj, Tcl_Interp * interp, Tcl_Obj * name, int flgs); /* 16 */ int (*xOTclInstVar) (struct XOTcl_Object * obj, Tcl_Interp * interp, char * name, char * destName); /* 17 */ Index: generic/xotclInt.h =================================================================== diff -u -re767edf5c498094f6e00150541bfb7beab52b619 -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- generic/xotclInt.h (.../xotclInt.h) (revision e767edf5c498094f6e00150541bfb7beab52b619) +++ generic/xotclInt.h (.../xotclInt.h) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -86,7 +86,7 @@ #if USE_ASSOC_DATA # define RUNTIME_STATE(interp) ((XOTclRuntimeState*)Tcl_GetAssocData((interp), "XOTclRuntimeState", NULL)) #else -# define RUNTIME_STATE(interp) ((XOTclRuntimeState*)((Interp*)interp)->globalNsPtr->clientData) +# define RUNTIME_STATE(interp) ((XOTclRuntimeState*)((Interp*)(interp))->globalNsPtr->clientData) #endif @@ -432,7 +432,7 @@ #define XOTCL_METHODTYPE_FORWARDER 0x0008 #define XOTCL_METHODTYPE_OBJECT 0x0010 #define XOTCL_METHODTYPE_OTHER 0x0100 -#define XOTCL_METHODTYPE_CMD XOTCL_METHODTYPE_ALIAS|XOTCL_METHODTYPE_SETTER|XOTCL_METHODTYPE_FORWARDER|XOTCL_METHODTYPE_OBJECT|XOTCL_METHODTYPE_OTHER +#define XOTCL_METHODTYPE_SYSTEM XOTCL_METHODTYPE_ALIAS|XOTCL_METHODTYPE_SETTER|XOTCL_METHODTYPE_FORWARDER|XOTCL_METHODTYPE_OBJECT|XOTCL_METHODTYPE_OTHER /* disallowed options */ #define XOTCL_ARG_METHOD_PARAMETER (XOTCL_ARG_RELATION) /* maybe add ARG_INITCMD */ Index: library/lib/xotcl1.xotcl =================================================================== diff -u -r1961a3b409a34f36625d8b51a94533d49867f1f3 -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- library/lib/xotcl1.xotcl (.../xotcl1.xotcl) (revision 1961a3b409a34f36625d8b51a94533d49867f1f3) +++ library/lib/xotcl1.xotcl (.../xotcl1.xotcl) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -264,7 +264,7 @@ } { set methodtype all if {$nocmds} {set methodtype scripted} - if {$noprocs} {if {$nocmds} {return ""}; set methodtype compiled} + if {$noprocs} {if {$nocmds} {return ""}; set methodtype system} set cmd [list ::xotcl::cmd::ObjectInfo::methods $o -methodtype $methodtype] if {$incontext} {lappend cmd -incontext} if {[::info exists pattern]} {lappend cmd $pattern} Index: tests/aliastest.xotcl =================================================================== diff -u -r9f7fa883bf6ed48f1401f815caca1e34f56584a1 -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- tests/aliastest.xotcl (.../aliastest.xotcl) (revision 9f7fa883bf6ed48f1401f815caca1e34f56584a1) +++ tests/aliastest.xotcl (.../aliastest.xotcl) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -23,10 +23,12 @@ Foo create f1 ? {f1 foo} 1 ? {f1 foo -x 2} 2 +? {Foo info methods -defined -methodtype alias} "foo" ? {Base info methods -defined -methodtype scripted} {foo} ? {Foo info methods -defined -methodtype scripted} {foo} Base method foo {} {} +? {Foo info methods -defined -methodtype alias} "" ? {Base info methods -defined -methodtype scripted} {} ? {Foo info methods -defined -methodtype scripted} {} @@ -35,35 +37,14 @@ ? {Base info methods -defined -methodtype scripted} {foo} "defined again" ? {Foo info methods -defined -methodtype scripted} {foo} "aliased again" -# When the next three lines are added, we crash on exit Foo method foo {} {} ? {Base info methods -defined -methodtype scripted} {foo} "still defined" ? {Foo info methods -defined -methodtype scripted} {} "removed" -::xotcl::use xotcl1 - -::xotcl::alias ::xotcl::Object contains ::xotcl::classes::xotcl2::Object::contains - -::xotcl::Class create C -::C contains -object ::C::slot { - Attribute create x -initcmd {set x 1} - Attribute create y -initcmd {incr ::hu} - Attribute create z -initcmd {my trace add variable z read T1} -} - -? {::C info slots} "::C::slot::x ::C::slot::y ::C::slot::z" - -? {catch {::C contains -x 1 -object ::C::slot { - Attribute create w -initcmd {my trace add variable z read T1} -}}} 1 - -::xotcl::use xotcl2 - # # chaining aliases # - Class create T Class create S T create t @@ -113,6 +94,7 @@ ::xotcl::alias T BAR -per-object ::T::FOO ::xotcl::alias T ZAP -per-object ::T::BAR ? {T info methods -defined -methodtype scripted} {foo} +? {lsort [T info methods -defined -per-object -methodtype alias]} {BAR FOO ZAP} ? {lsort [T info methods -per-object -defined -methodtype scripted]} {BAR FOO ZAP bar} ? {t foo} ::T->foo # Index: tests/destroytest.xotcl =================================================================== diff -u -r217d826e64107056ae97176552cae3c776991b9e -rf6be3f63eadda89d7f419a090d86669c6be84c3b --- tests/destroytest.xotcl (.../destroytest.xotcl) (revision 217d826e64107056ae97176552cae3c776991b9e) +++ tests/destroytest.xotcl (.../destroytest.xotcl) (revision f6be3f63eadda89d7f419a090d86669c6be84c3b) @@ -420,11 +420,13 @@ ? {o x} ::o2 "$case: call object via alias" ? {o x info vars} "" "$case: call info on aliased object" ? {o2 set x 10} 10 "$case: set variable on object" +? {o2 info vars} x "$case: query vars" ? {o x info vars} x "$case: query vars via alias" ? {o x set x} 10 "$case: set var via alias" o2 destroy catch {o x info vars} errMsg ? {set errMsg} "Trying to dispatch deleted object via method 'x'" "$case: 1st call on deleted object" +#? {set errMsg} "::o: unable to dispatch method 'x'" "$case: 1st call on deleted object" catch {o x info vars} errMsg ? {set errMsg} "::o: unable to dispatch method 'x'" "$case: 2nd call on deleted object" o destroy @@ -446,7 +448,6 @@ o::x destroy ? {Object isobject o3} 0 "$case: aliased object destroyed" o destroy - set case "create an alias, and recreate obj" Object o Object o3