Index: TODO =================================================================== diff -u -r9b6d912b4fa7ce4cfa982e28b511b9e104985809 -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- TODO (.../TODO) (revision 9b6d912b4fa7ce4cfa982e28b511b9e104985809) +++ TODO (.../TODO) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -3182,12 +3182,17 @@ - nsf.c: added cmd __db_compile_epoch for compile-epoch introspection -TODO: - - zzz why is the method recompiled for /tmp/sp.tcl ? - debug output with VAR_RESOLVER_TRACE + - Mystery solved, why in the script below the interp>compileEpoch is + incremented, when D is redefined, but in other cases not. In the + script below the method D.init is compiled by tcl, since it has a + trivial body. Therefore, a redefinition of D will remove this + compiled body and all its potential usages. Therefore the + interp->epoch is incremented. If the body is e.g. "return", the + epoch is not incremented (observed with Tcl 8.5.10) + ================================================= # -*- Tcl -*- -package require XOTcl; namespace import ::xotcl::* +package require XOTcl; namespace import -force ::xotcl::* package require nx::test; namespace import nx::Test Class C; C c @@ -3196,7 +3201,9 @@ Test new \ -count 100 \ - -pre {Class D; Class E; Class E1; Class X -instmixin {D E E1}} \ + -pre { + puts stderr ===create-D;Class create D; puts stderr ===D-created; + Class E; Class E1; Class X -instmixin {D E E1}} \ -cmd {X info instmixin ::E*} \ -expected {::E ::E1} \ -post {foreach o {D E E1 X} {$o destroy}} @@ -3211,6 +3218,18 @@ Test run; exit ================================================= +- nsf.c: + * enabled MEM_COUNT debugging for multi-threaded + apps. We collect the MEM_COUNT statistics now + per interp. Therefore, we have to pass around + "interp" in case where alloc() and free() + or refCount functions are used (textually, + a big change) + * verified, that nsf runs clean in aolserver/naviserver + (all INCR_REF_COUNTS all balanced) + + +TODO: - strange refcounting bug in 8.6b2 bug-is-86.tcl where 2 refcounted items are not freed (value:class, issued from nx.tcl around line 120). Compile with DEBUG86B2 Index: generic/nsf.c =================================================================== diff -u -r9b6d912b4fa7ce4cfa982e28b511b9e104985809 -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- generic/nsf.c (.../nsf.c) (revision 9b6d912b4fa7ce4cfa982e28b511b9e104985809) +++ generic/nsf.c (.../nsf.c) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -80,6 +80,7 @@ ClientData oldDeleteData; Tcl_CmdDeleteProc *oldDeleteProc; NsfParamDefs *paramDefs; + INTERP_DECL1; } NsfProcContext; /* @@ -95,6 +96,7 @@ typedef struct SetterCmdClientData { NsfObject *object; Nsf_Param *paramsPtr; + INTERP_DECL1; } SetterCmdClientData; typedef struct ForwardCmdClientData { @@ -113,6 +115,7 @@ Tcl_Obj *prefix; int nr_subcommands; Tcl_Obj *subcommands; + INTERP_DECL1; } ForwardCmdClientData; typedef struct AliasCmdClientData { @@ -205,7 +208,7 @@ static void PrimitiveCDestroy(ClientData clientData); static void PrimitiveODestroy(ClientData clientData); static void PrimitiveDestroy(ClientData clientData); -static void NsfCleanupObject_(NsfObject *object); +static void NsfCleanupObject_(INTERP_DECL NsfObject *object); /* prototypes for object and command lookup */ static NsfObject *GetObjectFromString(Tcl_Interp *interp, CONST char *name); @@ -222,25 +225,25 @@ CONST char *name); static Tcl_Namespace *RequireObjNamespace(Tcl_Interp *interp, NsfObject *object); static int NSDeleteCmd(Tcl_Interp *interp, Tcl_Namespace *nsPtr, CONST char *methodName); -static void NSNamespacePreserve(Tcl_Namespace *nsPtr); -static void NSNamespaceRelease(Tcl_Namespace *nsPtr); +static void NSNamespacePreserve(INTERP_DECL Tcl_Namespace *nsPtr); +static void NSNamespaceRelease(INTERP_DECL Tcl_Namespace *nsPtr); /* prototypes for filters and mixins */ static void FilterComputeDefined(Tcl_Interp *interp, NsfObject *object); static void MixinComputeDefined(Tcl_Interp *interp, NsfObject *object); -NSF_INLINE static void GuardAdd(NsfCmdList *filterCL, Tcl_Obj *guardObj); +NSF_INLINE static void GuardAdd(INTERP_DECL NsfCmdList *filterCL, Tcl_Obj *guardObj); static int GuardCall(NsfObject *object, Tcl_Interp *interp, Tcl_Obj *guardObj, NsfCallStackContent *cscPtr); -static void GuardDel(NsfCmdList *filterCL); +static void GuardDel(INTERP_DECL NsfCmdList *filterCL); /* properties of objects and classes */ static int IsBaseClass(NsfClass *cl); static int IsMetaClass(Tcl_Interp *interp, NsfClass *cl, int withMixins); -static int IsSubType(NsfClass *subcl, NsfClass *cl); +static int IsSubType(INTERP_DECL NsfClass *subcl, NsfClass *cl); static NsfClass *DefaultSuperClass(Tcl_Interp *interp, NsfClass *cl, NsfClass *mcl, int isMeta); /* prototypes for call stack specific calls */ -NSF_INLINE static void CscInit_(NsfCallStackContent *cscPtr, NsfObject *object, NsfClass *cl, +NSF_INLINE static void CscInit_(INTERP_DECL NsfCallStackContent *cscPtr, NsfObject *object, NsfClass *cl, Tcl_Command cmd, int frameType, int flags); NSF_INLINE static void CscFinish_(Tcl_Interp *interp, NsfCallStackContent *cscPtr); NSF_INLINE static void CallStackDoDestroy(Tcl_Interp *interp, NsfObject *object); @@ -252,8 +255,8 @@ Tcl_Obj *methodNameObj, int objc, Tcl_Obj *CONST objv[]); static int ParameterCheck(Tcl_Interp *interp, Tcl_Obj *paramObjPtr, Tcl_Obj *valueObj, const char *argNamePrefix, int doCheck, Nsf_Param **paramPtrPtr); -static void ParamDefsRefCountIncr(NsfParamDefs *paramDefs); -static void ParamDefsRefCountDecr(NsfParamDefs *paramDefs); +static void ParamDefsRefCountIncr(INTERP_DECL NsfParamDefs *paramDefs); +static void ParamDefsRefCountDecr(INTERP_DECL NsfParamDefs *paramDefs); static int ParamSetFromAny(Tcl_Interp *interp, register Tcl_Obj *objPtr); static int ArgumentParse(Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], NsfObject *obj, Tcl_Obj *procName, @@ -271,8 +274,8 @@ CONST char *methodName, int withFrame, Tcl_Obj *cmdName); /* prototypes for (class) list handling */ -static NsfClasses ** NsfClassListAdd(NsfClasses **firstPtrPtr, NsfClass *cl, ClientData clientData); -static void NsfClassListFree(NsfClasses *firstPtr); +static NsfClasses ** NsfClassListAdd(INTERP_DECL NsfClasses **firstPtrPtr, NsfClass *cl, ClientData clientData); +static void NsfClassListFree(INTERP_DECL NsfClasses *firstPtr); /* misc prototypes */ static int SetInstVar(Tcl_Interp *interp, NsfObject *object, Tcl_Obj *nameObj, Tcl_Obj *valueObj); @@ -282,10 +285,10 @@ static int NextSearchAndInvoke(Tcl_Interp *interp, CONST char *methodName, int objc, Tcl_Obj *CONST objv[], NsfCallStackContent *cscPtr, int freeArgumentVector); -static void AssertionRemoveProc(NsfAssertionStore *aStore, CONST char *name); +static void AssertionRemoveProc(INTERP_DECL NsfAssertionStore *aStore, CONST char *name); -static void NsfCommandPreserve(Tcl_Command cmd); -static void NsfCommandRelease(Tcl_Command cmd); +static void NsfCommandPreserve(INTERP_DECL Tcl_Command cmd); +static void NsfCommandRelease(INTERP_DECL Tcl_Command cmd); static Tcl_Command GetOriginalCommand(Tcl_Command cmd); void NsfDStringArgv(Tcl_DString *dsPtr, int objc, Tcl_Obj *CONST objv[]); static int MethodSourceMatches(int withSource, NsfClass *cl, NsfObject *object); @@ -444,7 +447,7 @@ *---------------------------------------------------------------------- */ static void -ParseContextInit(ParseContext *pcPtr, int objc, NsfObject *object, Tcl_Obj *procName) { +ParseContextInit(INTERP_DECL ParseContext *pcPtr, int objc, NsfObject *object, Tcl_Obj *procName) { if (objc < PARSE_CONTEXT_PREALLOC) { /* the single larger memset below .... */ memset(pcPtr, 0, sizeof(ParseContext)); @@ -490,7 +493,7 @@ *---------------------------------------------------------------------- */ static void -ParseContextExtendObjv(ParseContext *pcPtr, int from, int elts, Tcl_Obj *CONST source[]) { +ParseContextExtendObjv(INTERP_DECL ParseContext *pcPtr, int from, int elts, Tcl_Obj *CONST source[]) { int requiredSize = from + elts + 1; /*NsfPrintObjv("BEFORE: ", pcPtr->objc, pcPtr->full_objv);*/ @@ -542,7 +545,7 @@ *---------------------------------------------------------------------- */ static void -ParseContextRelease(ParseContext *pcPtr) { +ParseContextRelease(INTERP_DECL ParseContext *pcPtr) { int status = pcPtr->status; /*fprintf(stderr, "ParseContextRelease %p status %.6x %d elements, " @@ -770,7 +773,7 @@ *---------------------------------------------------------------------- */ static void -NsfCommandPreserve(Tcl_Command cmd) { +NsfCommandPreserve(INTERP_DECL Tcl_Command cmd) { Tcl_Command_refCount(cmd)++; MEM_COUNT_ALLOC("command.refCount", cmd); } @@ -790,7 +793,7 @@ *---------------------------------------------------------------------- */ static void -NsfCommandRelease(Tcl_Command cmd) { +NsfCommandRelease(INTERP_DECL Tcl_Command cmd) { /*fprintf(stderr,"NsfCommandRelease %p\n", cmd);*/ MEM_COUNT_FREE("command.refCount", cmd); TclCleanupCommandMacro((Command *)cmd); @@ -899,7 +902,7 @@ #if defined(NSF_WITH_ASSERTIONS) if (object->opt) { - AssertionRemoveProc(object->opt->assertions, methodName); + AssertionRemoveProc(INTERP object->opt->assertions, methodName); } #endif @@ -924,7 +927,7 @@ #if defined(NSF_WITH_ASSERTIONS) if (opt && opt->assertions) { - AssertionRemoveProc(opt->assertions, methodName); + AssertionRemoveProc(INTERP opt->assertions, methodName); } #endif @@ -1075,7 +1078,7 @@ } static void -NsfCleanupObject_(NsfObject *object) { +NsfCleanupObject_(INTERP_DECL NsfObject *object) { NsfObjectRefCountDecr(object); /*fprintf(stderr, "NsfCleanupObject obj refCount of %p after decr %d id %p interp %p flags %.6x\n", @@ -1396,7 +1399,7 @@ return TCL_OK; } if ((GetClassFromObj(interp, pPtr->converterArg, &cl, 0) == TCL_OK) - && IsSubType(object->cl, cl)) { + && IsSubType(INTERP object->cl, cl)) { return TCL_OK; } @@ -1462,7 +1465,7 @@ *---------------------------------------------------------------------- */ static NsfClasses * -NsfReverseClasses(NsfClasses *sl) { +NsfReverseClasses(INTERP_DECL NsfClasses *sl) { NsfClasses *firstPtr = NULL; for (; sl; sl = sl->nextPtr) { NsfClasses *element = NEW(NsfClasses); @@ -1489,7 +1492,7 @@ *---------------------------------------------------------------------- */ static void -NsfClassListFree(NsfClasses *sl) { +NsfClassListFree(INTERP_DECL NsfClasses *sl) { NsfClasses *n; for (; sl; sl = n) { n = sl->nextPtr; @@ -1514,7 +1517,7 @@ */ static NsfClasses ** -NsfClassListAdd(NsfClasses **firstPtrPtr, NsfClass *cl, ClientData clientData) { +NsfClassListAdd(INTERP_DECL NsfClasses **firstPtrPtr, NsfClass *cl, ClientData clientData) { NsfClasses *l = *firstPtrPtr, *element = NEW(NsfClasses); element->cl = cl; element->clientData = clientData; @@ -1545,7 +1548,7 @@ */ static NsfClasses ** -NsfClassListAddNoDup(NsfClasses **firstPtrPtr, NsfClass *cl, ClientData clientData, int *isNewPtr) { +NsfClassListAddNoDup(INTERP_DECL NsfClasses **firstPtrPtr, NsfClass *cl, ClientData clientData, int *isNewPtr) { NsfClasses *clPtr = *firstPtrPtr, **nextPtr; if (clPtr) { @@ -1665,7 +1668,7 @@ Sub(NsfClass *cl) { return cl->sub; } static int -TopoSort(NsfClass *cl, NsfClass *baseClass, NsfClasses *(*next)(NsfClass *)) { +TopoSort(INTERP_DECL NsfClass *cl, NsfClass *baseClass, NsfClasses *(*next)(NsfClass *)) { /*NsfClasses *sl = (*next)(cl);*/ NsfClasses *sl = next == Super ? cl->super : cl->sub; NsfClasses *pl; @@ -1680,7 +1683,7 @@ for (; sl; sl = sl->nextPtr) { NsfClass *sc = sl->cl; if (sc->color == GRAY) { cl->color = WHITE; return 0; } - if (sc->color == WHITE && !TopoSort(sc, baseClass, next)) { + if (sc->color == WHITE && !TopoSort(INTERP sc, baseClass, next)) { cl->color = WHITE; if (cl == baseClass) { register NsfClasses *pc; @@ -1702,40 +1705,40 @@ } static NsfClasses * -TopoOrder(NsfClass *cl, NsfClasses *(*next)(NsfClass *)) { - if (TopoSort(cl, cl, next)) { +TopoOrder(INTERP_DECL NsfClass *cl, NsfClasses *(*next)(NsfClass *)) { + if (TopoSort(INTERP cl, cl, next)) { return cl->order; } - NsfClassListFree(cl->order); + NsfClassListFree(INTERP cl->order); return cl->order = NULL; } static NsfClasses * -ComputeOrder(NsfClass *cl, NsfClasses *order, NsfClasses *(*direction)(NsfClass *)) { +ComputeOrder(INTERP_DECL NsfClass *cl, NsfClasses *order, NsfClasses *(*direction)(NsfClass *)) { if (likely(order != NULL)) { return order; } - return cl->order = TopoOrder(cl, direction); + return cl->order = TopoOrder(INTERP cl, direction); } static void -FlushPrecedencesOnSubclasses(NsfClass *cl) { +FlushPrecedencesOnSubclasses(INTERP_DECL NsfClass *cl) { NsfClasses *pc; - NsfClassListFree(cl->order); + NsfClassListFree(INTERP cl->order); cl->order = NULL; - pc = ComputeOrder(cl, cl->order, Sub); + pc = ComputeOrder(INTERP cl, cl->order, Sub); /* - * ordering doesn't matter here - we're just using toposort + * ordering doesn't matter here - we're just using TopoSort * to find all lower classes so we can flush their caches */ if (pc) pc = pc->nextPtr; for (; pc; pc = pc->nextPtr) { - NsfClassListFree(pc->cl->order); + NsfClassListFree(INTERP pc->cl->order); pc->cl->order = NULL; } - NsfClassListFree(cl->order); + NsfClassListFree(INTERP cl->order); cl->order = NULL; } @@ -1765,7 +1768,7 @@ */ static void -AS(NsfClass *s, NsfClasses **sl) { +AS(INTERP_DECL NsfClass *s, NsfClasses **sl) { register NsfClasses *l = *sl; while (l && l->cl != s) l = l->nextPtr; if (!l) { @@ -1777,18 +1780,18 @@ } static void -AddSuper(NsfClass *cl, NsfClass *super) { +AddSuper(INTERP_DECL NsfClass *cl, NsfClass *super) { if (cl && super) { /* * keep corresponding sub in step with super */ - AS(super, &cl->super); - AS(cl, &super->sub); + AS(INTERP super, &cl->super); + AS(INTERP cl, &super->sub); } } static int -RemoveSuper1(NsfClass *s, NsfClasses **sl) { +RemoveSuper1(INTERP_DECL NsfClass *s, NsfClasses **sl) { NsfClasses *l = *sl; if (!l) return 0; @@ -1808,12 +1811,12 @@ } static int -RemoveSuper(NsfClass *cl, NsfClass *super) { +RemoveSuper(INTERP_DECL NsfClass *cl, NsfClass *super) { /* * keep corresponding sub in step with super */ - int sp = RemoveSuper1(super, &cl->super); - int sb = RemoveSuper1(cl, &super->sub); + int sp = RemoveSuper1(INTERP super, &cl->super); + int sb = RemoveSuper1(INTERP cl, &super->sub); return sp && sb; } @@ -2187,9 +2190,9 @@ *---------------------------------------------------------------------- */ static NsfClass * -SearchCMethod(/*@notnull@*/ NsfClass *cl, CONST char *methodName, Tcl_Command *cmdPtr) { +SearchCMethod(INTERP_DECL /*@notnull@*/ NsfClass *cl, CONST char *methodName, Tcl_Command *cmdPtr) { assert(cl); - return SearchPLMethod(ComputeOrder(cl, cl->order, Super), methodName, cmdPtr); + return SearchPLMethod(ComputeOrder(INTERP cl, cl->order, Super), methodName, cmdPtr); } /* @@ -2210,10 +2213,10 @@ *---------------------------------------------------------------------- */ static NsfClass * -SearchSimpleCMethod(Tcl_Interp *UNUSED(interp), /*@notnull@*/ NsfClass *cl, +SearchSimpleCMethod(Tcl_Interp *interp, /*@notnull@*/ NsfClass *cl, Tcl_Obj *methodObj, Tcl_Command *cmdPtr) { assert(cl); - return SearchPLMethod(ComputeOrder(cl, cl->order, Super), ObjStr(methodObj), cmdPtr); + return SearchPLMethod(ComputeOrder(INTERP cl, cl->order, Super), ObjStr(methodObj), cmdPtr); } /* @@ -2243,7 +2246,7 @@ assert(cl); - for (pl = ComputeOrder(cl, cl->order, Super); pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP cl, cl->order, Super); pl; pl = pl->nextPtr) { NsfObject *regObject, *defObject; Tcl_Command cmd; @@ -2372,7 +2375,7 @@ } if (osPtr->rootMetaClass && osPtr->rootClass) { - RemoveSuper(osPtr->rootMetaClass, osPtr->rootClass); + RemoveSuper(INTERP osPtr->rootMetaClass, osPtr->rootClass); RemoveInstance((NsfObject *)osPtr->rootMetaClass, osPtr->rootMetaClass); RemoveInstance((NsfObject *)osPtr->rootClass, osPtr->rootMetaClass); @@ -2724,7 +2727,7 @@ */ static NsfObjectOpt * -NsfRequireObjectOpt(NsfObject *object) { +NsfRequireObjectOpt(INTERP_DECL NsfObject *object) { if (!object->opt) { object->opt = NEW(NsfObjectOpt); memset(object->opt, 0, sizeof(NsfObjectOpt)); @@ -2733,7 +2736,7 @@ } static NsfClassOpt * -NsfRequireClassOpt(/*@notnull@*/ NsfClass *cl) { +NsfRequireClassOpt(INTERP_DECL /*@notnull@*/ NsfClass *cl) { assert(cl); if (!cl->opt) { cl->opt = NEW(NsfClassOpt); @@ -2992,6 +2995,7 @@ NsfObject *lastObject; Tcl_Var var; Tcl_Obj *nameObj; + INTERP_DECL1; } NsfResolvedVarInfo; /* @@ -3144,6 +3148,7 @@ static void CompiledColonVarFree(Tcl_ResolvedVarInfo *vInfoPtr) { NsfResolvedVarInfo *resVarInfo = (NsfResolvedVarInfo *)vInfoPtr; + INTERP_MEMBER_GET(resVarInfo) #if defined(VAR_RESOLVER_TRACE) fprintf(stderr, "CompiledColonVarFree %p for variable '%s'\n", @@ -3208,6 +3213,7 @@ resVarInfo->lastObject = NULL; resVarInfo->var = NULL; resVarInfo->nameObj = Tcl_NewStringObj(name+1, length-1); + INTERP_MEMBER_SET(resVarInfo, interp) INCR_REF_COUNT(resVarInfo->nameObj); #if defined(VAR_RESOLVER_TRACE) @@ -3639,7 +3645,7 @@ *---------------------------------------------------------------------- */ static void -NSNamespacePreserve(Tcl_Namespace *nsPtr) { +NSNamespacePreserve(INTERP_DECL Tcl_Namespace *nsPtr) { assert(nsPtr); MEM_COUNT_ALLOC("NSNamespace", nsPtr); Tcl_Namespace_refCount(nsPtr)++; @@ -3659,7 +3665,7 @@ *---------------------------------------------------------------------- */ static void -NSNamespaceRelease(Tcl_Namespace *nsPtr) { +NSNamespaceRelease(INTERP_DECL Tcl_Namespace *nsPtr) { assert(nsPtr); MEM_COUNT_FREE("NSNamespace", nsPtr); @@ -4552,7 +4558,7 @@ Tcl_SetObjResult(interp, savedResultObj); DECR_REF_COUNT(savedResultObj); } - NsfCleanupObject(object, "CallStackDoDestroy"); + NsfCleanupObject(INTERP object, "CallStackDoDestroy"); } } @@ -4607,7 +4613,7 @@ * Cmd List Add/Remove ... returns the new element */ static NsfCmdList * -CmdListAdd(NsfCmdList **cList, Tcl_Command c, NsfClass *clorobj, int noDuplicates) { +CmdListAdd(INTERP_DECL NsfCmdList **cList, Tcl_Command c, NsfClass *clorobj, int noDuplicates) { NsfCmdList *l = *cList, *new; /* @@ -4635,7 +4641,7 @@ */ new = NEW(NsfCmdList); new->cmdPtr = c; - NsfCommandPreserve(new->cmdPtr); + NsfCommandPreserve(INTERP new->cmdPtr); new->clientData = NULL; new->clorobj = clorobj; new->nextPtr = NULL; @@ -4650,12 +4656,12 @@ } static void -CmdListReplaceCmd(NsfCmdList *replace, Tcl_Command cmd, NsfClass *clorobj) { +CmdListReplaceCmd(INTERP_DECL NsfCmdList *replace, Tcl_Command cmd, NsfClass *clorobj) { Tcl_Command del = replace->cmdPtr; replace->cmdPtr = cmd; replace->clorobj = clorobj; - NsfCommandPreserve(cmd); - NsfCommandRelease(del); + NsfCommandPreserve(INTERP cmd); + NsfCommandRelease(INTERP del); } #if 0 @@ -4681,11 +4687,11 @@ * physically delete an entry 'del' */ static void -CmdListDeleteCmdListEntry(NsfCmdList *del, NsfFreeCmdListClientData *freeFct) { +CmdListDeleteCmdListEntry(INTERP_DECL NsfCmdList *del, NsfFreeCmdListClientData *freeFct) { if (freeFct) { - (*freeFct)(del); + (*freeFct)(INTERP del); } - NsfCommandRelease(del->cmdPtr); + NsfCommandRelease(INTERP del->cmdPtr); FREE(NsfCmdList, del); } @@ -4718,14 +4724,14 @@ * remove all command pointers from a list that have a bumped epoch */ static void -CmdListRemoveEpoched(NsfCmdList **cmdList, NsfFreeCmdListClientData *freeFct) { +CmdListRemoveEpoched(INTERP_DECL NsfCmdList **cmdList, NsfFreeCmdListClientData *freeFct) { NsfCmdList *f = *cmdList, *del; while (f) { if (Tcl_Command_cmdEpoch(f->cmdPtr)) { del = f; f = f->nextPtr; del = CmdListRemoveFromList(cmdList, del); - CmdListDeleteCmdListEntry(del, freeFct); + CmdListDeleteCmdListEntry(INTERP del, freeFct); } else f = f->nextPtr; } @@ -4736,17 +4742,17 @@ * delete all cmds with given context class object */ static void -CmdListRemoveContextClassFromList(NsfCmdList **cmdList, NsfClass *clorobj, +CmdListRemoveContextClassFromList(INTERP_DECL NsfCmdList **cmdList, NsfClass *clorobj, NsfFreeCmdListClientData *freeFct) { NsfCmdList *c, *del = NULL; /* - CmdListRemoveEpoched(cmdList, freeFct); + CmdListRemoveEpoched(INTERP cmdList, freeFct); */ c = *cmdList; while (c && c->clorobj == clorobj) { del = c; *cmdList = c->nextPtr; - CmdListDeleteCmdListEntry(del, freeFct); + CmdListDeleteCmdListEntry(INTERP del, freeFct); c = *cmdList; } @@ -4760,7 +4766,7 @@ if (c->nextPtr == del) { c->nextPtr = del->nextPtr; } - CmdListDeleteCmdListEntry(del, freeFct); + CmdListDeleteCmdListEntry(INTERP del, freeFct); } c = c->nextPtr; } @@ -4770,12 +4776,12 @@ * free the memory of a whole 'cmdList' */ static void -CmdListRemoveList(NsfCmdList **cmdList, NsfFreeCmdListClientData *freeFct) { +CmdListRemoveList(INTERP_DECL NsfCmdList **cmdList, NsfFreeCmdListClientData *freeFct) { NsfCmdList *del; while (*cmdList) { del = *cmdList; *cmdList = (*cmdList)->nextPtr; - CmdListDeleteCmdListEntry(del, freeFct); + CmdListDeleteCmdListEntry(INTERP del, freeFct); } } @@ -4848,7 +4854,7 @@ */ static void -TclObjListFreeList(NsfTclObjList *list) { +TclObjListFreeList(INTERP_DECL NsfTclObjList *list) { NsfTclObjList *del; while (list) { del = list; @@ -4859,7 +4865,7 @@ } static Tcl_Obj * -TclObjListNewElement(NsfTclObjList **list, Tcl_Obj *ov) { +TclObjListNewElement(INTERP_DECL NsfTclObjList **list, Tcl_Obj *ov) { NsfTclObjList *elt = NEW(NsfTclObjList); INCR_REF_COUNT2("listContent", ov); elt->content = ov; @@ -4877,7 +4883,7 @@ if (oc > 0) { int i; for (i=oc-1; i>=0; i--) { - TclObjListNewElement(&last, ov[i]); + TclObjListNewElement(INTERP &last, ov[i]); } } } @@ -4939,15 +4945,15 @@ } static void -AssertionRemoveProc(NsfAssertionStore *aStore, CONST char *name) { +AssertionRemoveProc(INTERP_DECL NsfAssertionStore *aStore, CONST char *name) { Tcl_HashEntry *hPtr; if (aStore) { hPtr = Tcl_CreateHashEntry(&aStore->procs, name, NULL); if (hPtr) { NsfProcAssertion *procAss = (NsfProcAssertion *) Tcl_GetHashValue(hPtr); - TclObjListFreeList(procAss->pre); - TclObjListFreeList(procAss->post); + TclObjListFreeList(INTERP procAss->pre); + TclObjListFreeList(INTERP procAss->post); FREE(NsfProcAssertion, procAss); Tcl_DeleteHashEntry(hPtr); } @@ -4961,7 +4967,7 @@ Tcl_HashEntry *hPtr = NULL; NsfProcAssertion *procs = NEW(NsfProcAssertion); - AssertionRemoveProc(aStore, name); + AssertionRemoveProc(INTERP aStore, name); procs->pre = AssertionNewList(interp, pre); procs->post = AssertionNewList(interp, post); hPtr = Tcl_CreateHashEntry(&aStore->procs, name, &new); @@ -4971,7 +4977,7 @@ } static NsfAssertionStore * -AssertionCreateStore() { +AssertionCreateStore(INTERP_DECL1) { NsfAssertionStore *aStore = NEW(NsfAssertionStore); aStore->invariants = NULL; Tcl_InitHashTable(&aStore->procs, TCL_STRING_KEYS); @@ -4980,7 +4986,7 @@ } static void -AssertionRemoveStore(NsfAssertionStore *aStore) { +AssertionRemoveStore(INTERP_DECL NsfAssertionStore *aStore) { Tcl_HashSearch hSrch; Tcl_HashEntry *hPtr; @@ -4991,11 +4997,11 @@ * AssertionRemoveProc calls Tcl_DeleteHashEntry(hPtr), thus * we get the FirstHashEntry afterwards again to proceed */ - AssertionRemoveProc(aStore, Tcl_GetHashKey(&aStore->procs, hPtr)); + AssertionRemoveProc(INTERP aStore, Tcl_GetHashKey(&aStore->procs, hPtr)); } Tcl_DeleteHashTable(&aStore->procs); MEM_COUNT_FREE("Tcl_InitHashTable", &aStore->procs); - TclObjListFreeList(aStore->invariants); + TclObjListFreeList(INTERP aStore->invariants); FREE(NsfAssertionStore, aStore); } } @@ -5104,7 +5110,7 @@ if (result != TCL_ERROR && checkoptions & CHECK_CLINVAR) { NsfClasses *clPtr; - clPtr = ComputeOrder(object->cl, object->cl->order, Super); + clPtr = ComputeOrder(INTERP object->cl, object->cl->order, Super); while (clPtr && result != TCL_ERROR) { NsfAssertionStore *aStore = (clPtr->cl->opt) ? clPtr->cl->opt->assertions : NULL; if (aStore) { @@ -5151,7 +5157,7 @@ static int AssertionSetCheckOptions(Tcl_Interp *interp, NsfObject *object, Tcl_Obj *arg) { - NsfObjectOpt *opt = NsfRequireObjectOpt(object); + NsfObjectOpt *opt = NsfRequireObjectOpt(INTERP object); int ocArgs; Tcl_Obj **ovArgs; opt->checkoptions = CHECK_NONE; @@ -5200,9 +5206,9 @@ static void AssertionSetInvariants(Tcl_Interp *interp, NsfAssertionStore **assertions, Tcl_Obj *arg) { if (*assertions) { - TclObjListFreeList((*assertions)->invariants); + TclObjListFreeList(INTERP (*assertions)->invariants); } else { - *assertions = AssertionCreateStore(); + *assertions = AssertionCreateStore(INTERP1); } (*assertions)->invariants = AssertionNewList(interp, arg); } @@ -5219,7 +5225,7 @@ * push a mixin stack information on this object */ static int -MixinStackPush(NsfObject *object) { +MixinStackPush(INTERP_DECL NsfObject *object) { register NsfMixinStack *h = NEW(NsfMixinStack); h->currentCmdPtr = NULL; @@ -5233,7 +5239,7 @@ * pop a mixin stack information on this object */ static void -MixinStackPop(NsfObject *object) { +MixinStackPop(INTERP_DECL NsfObject *object) { register NsfMixinStack *h = object->mixinStack; /*fprintf(stderr, "MixinStackPop %p %s\n", object, ObjectName(object));*/ object->mixinStack = h->nextPtr; @@ -5251,13 +5257,13 @@ NsfCmdList *m; NsfClasses *pl, **clPtr = mixinClasses; - CmdListRemoveEpoched(mixinList, GuardDel); + CmdListRemoveEpoched(INTERP mixinList, GuardDel); for (m = *mixinList; m; m = m->nextPtr) { NsfClass *mCl = NsfGetClassFromCmdPtr(m->cmdPtr); if (mCl) { - for (pl = ComputeOrder(mCl, mCl->order, Super); pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP mCl, mCl->order, Super); pl; pl = pl->nextPtr) { if ((pl->cl->object.flags & NSF_IS_ROOT_CLASS) == 0) { NsfClassOpt *opt = pl->cl->opt; @@ -5271,22 +5277,22 @@ * Compute transitively the (class) mixin classes of this * added class. */ - NsfClassListAdd(checkList, pl->cl, NULL); + NsfClassListAdd(INTERP checkList, pl->cl, NULL); /*fprintf(stderr, "+++ transitive %s\n", ClassName(pl->cl));*/ MixinComputeOrderFullList(interp, &opt->classmixins, mixinClasses, checkList, level+1); } /*fprintf(stderr, "+++ add to mixinClasses %p path: %s clPtr %p\n", mixinClasses, ClassName(pl->cl), clPtr);*/ - clPtr = NsfClassListAddNoDup(clPtr, pl->cl, m->clientData, NULL); + clPtr = NsfClassListAddNoDup(INTERP clPtr, pl->cl, m->clientData, NULL); } } } } } if (level == 0 && *checkList) { - NsfClassListFree(*checkList); + NsfClassListFree(INTERP *checkList); *checkList = NULL; } } @@ -5306,9 +5312,9 @@ *---------------------------------------------------------------------- */ static void -MixinResetOrder(NsfObject *object) { +MixinResetOrder(INTERP_DECL NsfObject *object) { /*fprintf(stderr, "MixinResetOrder for object %s \n", ObjectName(object));*/ - CmdListRemoveList(&object->mixinOrder, NULL /*GuardDel*/); + CmdListRemoveList(INTERP &object->mixinOrder, NULL /*GuardDel*/); object->mixinOrder = NULL; } @@ -5332,7 +5338,7 @@ NsfClasses **classList, NsfClasses **checkList) { NsfClasses *pl; - for (pl = ComputeOrder(cl, cl->order, Super); pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP cl, cl->order, Super); pl; pl = pl->nextPtr) { NsfClassOpt *clopt = pl->cl->opt; if (clopt && clopt->classmixins) { MixinComputeOrderFullList(interp, &clopt->classmixins, @@ -5361,7 +5367,7 @@ MixinComputeOrder(Tcl_Interp *interp, NsfObject *object) { NsfClasses *fullList, *checkList = NULL, *mixinClasses = NULL, *clPtr; - if (object->mixinOrder) MixinResetOrder(object); + if (object->mixinOrder) MixinResetOrder(INTERP object); /* Append per-obj mixins */ if (object->opt) { @@ -5379,7 +5385,7 @@ for (m = object->opt->mixins; m; m = m->nextPtr) { NsfClass *mCl = NsfGetClassFromCmdPtr(m->cmdPtr); if (mCl) { - NsfClassListAddNoDup(&checkList, mCl, NULL, NULL); + NsfClassListAddNoDup(INTERP &checkList, mCl, NULL, NULL); } } } @@ -5394,7 +5400,7 @@ NsfClassListPrint("MixinComputeOrder poms+pcms", mixinClasses); CmdListPrint(interp, "mixinOrder", object->mixinOrder);*/ - NsfClassListFree(checkList); + NsfClassListFree(INTERP checkList); fullList = mixinClasses; /* @@ -5415,7 +5421,7 @@ */ if (checker == NULL) { /* check object->cl hierachy */ - checker = NsfClassListFind(ComputeOrder(object->cl, object->cl->order, Super), cl); + checker = NsfClassListFind(ComputeOrder(INTERP object->cl, object->cl->order, Super), cl); /* * if checker is set, it was found in the class hierarchy and it is ignored */ @@ -5426,7 +5432,7 @@ /*fprintf(stderr, "--- adding to mixinOrder %s to cmdlist %p of object %s\n", ClassName(cl), object->mixinOrder, ObjectName(object));*/ - new = CmdListAdd(&object->mixinOrder, cl->object.id, NULL, /*noDuplicates*/ 0); + new = CmdListAdd(INTERP &object->mixinOrder, cl->object.id, NULL, /*noDuplicates*/ 0); /*CmdListPrint(interp, "mixinOrder", object->mixinOrder);*/ /* @@ -5442,7 +5448,7 @@ } /* ... and free the memory of the full list */ - NsfClassListFree(fullList); + NsfClassListFree(INTERP fullList); /*CmdListPrint(interp, "mixin order\n", obj->mixinOrder);*/ } @@ -5483,11 +5489,11 @@ NsfMixinregGet(nameObj, &mixinCl, &guardObj); - new = CmdListAdd(mixinList, mixinCl->object.id, NULL, /*noDuplicates*/ 1); + new = CmdListAdd(INTERP mixinList, mixinCl->object.id, NULL, /*noDuplicates*/ 1); if (guardObj) { - GuardAdd(new, guardObj); + GuardAdd(INTERP new, guardObj); } else if (new->clientData) { - GuardDel(new); + GuardDel(INTERP new); } return TCL_OK; @@ -6001,7 +6007,7 @@ */ static void -RemoveFromClassMixinsOf(Tcl_Command cmd, NsfCmdList *cmdlist) { +RemoveFromClassMixinsOf(INTERP_DECL Tcl_Command cmd, NsfCmdList *cmdlist) { for ( ; cmdlist; cmdlist = cmdlist->nextPtr) { NsfClass *ncl = NsfGetClassFromCmdPtr(cmdlist->cmdPtr); @@ -6012,7 +6018,7 @@ /* fprintf(stderr, "Removing class %s from isClassMixinOf of class %s\n", ClassName(cl), ObjStr(NsfGetClassFromCmdPtr(cmdlist->cmdPtr)->object.cmdName)); */ del = CmdListRemoveFromList(&nclopt->isClassMixinOf, del); - CmdListDeleteCmdListEntry(del, GuardDel); + CmdListDeleteCmdListEntry(INTERP del, GuardDel); } } } @@ -6035,7 +6041,7 @@ */ static void -RemoveFromObjectMixinsOf(Tcl_Command cmd, NsfCmdList *cmdlist) { +RemoveFromObjectMixinsOf(INTERP_DECL Tcl_Command cmd, NsfCmdList *cmdlist) { for ( ; cmdlist; cmdlist = cmdlist->nextPtr) { NsfClass *cl = NsfGetClassFromCmdPtr(cmdlist->cmdPtr); NsfClassOpt *clopt = cl ? cl->opt : NULL; @@ -6045,7 +6051,7 @@ /* fprintf(stderr, "Removing object %s from isObjectMixinOf of Class %s\n", ObjectName(object), ObjStr(NsfGetClassFromCmdPtr(cmdlist->cmdPtr)->object.cmdName)); */ del = CmdListRemoveFromList(&clopt->isObjectMixinOf, del); - CmdListDeleteCmdListEntry(del, GuardDel); + CmdListDeleteCmdListEntry(INTERP del, GuardDel); } } /* else fprintf(stderr, "CleanupDestroyObject %s: NULL pointer in mixins!\n", ObjectName(object)); */ } @@ -6068,7 +6074,7 @@ */ static void -RemoveFromClassmixins(Tcl_Command cmd, NsfCmdList *cmdlist) { +RemoveFromClassmixins(INTERP_DECL Tcl_Command cmd, NsfCmdList *cmdlist) { for ( ; cmdlist; cmdlist = cmdlist->nextPtr) { NsfClass *cl = NsfGetClassFromCmdPtr(cmdlist->cmdPtr); NsfClassOpt *clopt = cl ? cl->opt : NULL; @@ -6078,8 +6084,8 @@ /* fprintf(stderr, "Removing class %s from mixins of object %s\n", ClassName(cl), ObjStr(NsfGetObjectFromCmdPtr(cmdlist->cmdPtr)->cmdName)); */ del = CmdListRemoveFromList(&clopt->classmixins, del); - CmdListDeleteCmdListEntry(del, GuardDel); - if (cl->object.mixinOrder) MixinResetOrder(&cl->object); + CmdListDeleteCmdListEntry(INTERP del, GuardDel); + if (cl->object.mixinOrder) MixinResetOrder(INTERP &cl->object); } } } @@ -6101,7 +6107,7 @@ *---------------------------------------------------------------------- */ static void -RemoveFromObjectMixins(Tcl_Command cmd, NsfCmdList *cmdlist) { +RemoveFromObjectMixins(INTERP_DECL Tcl_Command cmd, NsfCmdList *cmdlist) { for ( ; cmdlist; cmdlist = cmdlist->nextPtr) { NsfObject *nobj = NsfGetObjectFromCmdPtr(cmdlist->cmdPtr); NsfObjectOpt *objopt = nobj ? nobj->opt : NULL; @@ -6111,8 +6117,8 @@ /* fprintf(stderr, "Removing class %s from mixins of object %s\n", ClassName(cl), ObjStr(NsfGetObjectFromCmdPtr(cmdlist->cmdPtr)->cmdName)); */ del = CmdListRemoveFromList(&objopt->mixins, del); - CmdListDeleteCmdListEntry(del, GuardDel); - if (nobj->mixinOrder) MixinResetOrder(nobj); + CmdListDeleteCmdListEntry(INTERP del, GuardDel); + if (nobj->mixinOrder) MixinResetOrder(INTERP nobj); } } } @@ -6136,7 +6142,7 @@ */ static void -MixinResetOrderForInstances(NsfClass *cl) { +MixinResetOrderForInstances(INTERP_DECL NsfClass *cl) { Tcl_HashSearch hSrch; Tcl_HashEntry *hPtr; @@ -6152,7 +6158,7 @@ if (object && !(object->flags & NSF_DURING_DELETE) && (object->flags & NSF_MIXIN_ORDER_DEFINED_AND_VALID)) { - MixinResetOrder(object); + MixinResetOrder(INTERP object); object->flags &= ~NSF_MIXIN_ORDER_VALID; } } @@ -6174,7 +6180,7 @@ *---------------------------------------------------------------------- */ static void -ResetOrderOfClassesUsedAsMixins(NsfClass *cl) { +ResetOrderOfClassesUsedAsMixins(INTERP_DECL NsfClass *cl) { /*fprintf(stderr, "ResetOrderOfClassesUsedAsMixins %s - %p\n", ClassName(cl), cl->opt);*/ @@ -6183,7 +6189,7 @@ for (ml = cl->opt->isObjectMixinOf; ml; ml = ml->nextPtr) { NsfObject *object = NsfGetObjectFromCmdPtr(ml->cmdPtr); if (object) { - if (object->mixinOrder) { MixinResetOrder(object); } + if (object->mixinOrder) { MixinResetOrder(INTERP object); } object->flags &= ~NSF_MIXIN_ORDER_VALID; } } @@ -6220,27 +6226,27 @@ /* * Iterate over the subclass hierarchy. */ - for (clPtr = ComputeOrder(cl, cl->order, Sub); clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = ComputeOrder(INTERP cl, cl->order, Sub); clPtr; clPtr = clPtr->nextPtr) { Tcl_HashSearch hSrch; Tcl_HashEntry *hPtr; /* * Reset mixin order for all objects having this class as per object mixin */ - ResetOrderOfClassesUsedAsMixins(clPtr->cl); + ResetOrderOfClassesUsedAsMixins(INTERP clPtr->cl); /* fprintf(stderr, "invalidating instances of class %s\n", ClassName(clPtr)); */ instanceTablePtr = &clPtr->cl->instances; for (hPtr = Tcl_FirstHashEntry(instanceTablePtr, &hSrch); hPtr; hPtr = Tcl_NextHashEntry(&hSrch)) { NsfObject *object = (NsfObject *)Tcl_GetHashKey(instanceTablePtr, hPtr); - if (object->mixinOrder) { MixinResetOrder(object); } + if (object->mixinOrder) { MixinResetOrder(INTERP object); } object->flags &= ~NSF_MIXIN_ORDER_VALID; } } - NsfClassListFree(cl->order); + NsfClassListFree(INTERP cl->order); cl->order = saved; /* @@ -6258,7 +6264,7 @@ NsfClass *ncl = (NsfClass *)Tcl_GetHashKey(commandTable, hPtr); /*fprintf(stderr, "Got %s, reset for ncl %p\n", ncl?ClassName(ncl):"NULL", ncl);*/ if (ncl) { - MixinResetOrderForInstances(ncl); + MixinResetOrderForInstances(INTERP ncl); /* * This place seems to be sufficient to invalidate the computed object * parameter definitions. @@ -6341,21 +6347,21 @@ if (pattern) { if (!Tcl_StringMatch(ClassName(mixin), pattern)) continue; } - npl = NsfClassListAdd(npl, mixin, NULL); + npl = NsfClassListAdd(INTERP npl, mixin, NULL); ml = ml->nextPtr; } } } - pcl = ComputeOrder(object->cl, object->cl->order, Super); + pcl = ComputeOrder(INTERP object->cl, object->cl->order, Super); for (; pcl; pcl = pcl->nextPtr) { if (withRootClass == 0 && pcl->cl->object.flags & NSF_IS_ROOT_CLASS) { continue; } if (pattern && !Tcl_StringMatch(ClassName(pcl->cl), pattern)) { continue; } - npl = NsfClassListAdd(npl, pcl->cl, NULL); + npl = NsfClassListAdd(INTERP npl, pcl->cl, NULL); } return precedenceList; } @@ -6499,12 +6505,12 @@ */ static Tcl_Command -MixinSearchMethodByName(NsfCmdList *mixinList, CONST char *name, NsfClass **cl) { +MixinSearchMethodByName(INTERP_DECL NsfCmdList *mixinList, CONST char *name, NsfClass **cl) { Tcl_Command cmd; for (; mixinList; mixinList = mixinList->nextPtr) { NsfClass *foundCl = NsfGetClassFromCmdPtr(mixinList->cmdPtr); - if (foundCl && SearchCMethod(foundCl, name, &cmd)) { + if (foundCl && SearchCMethod(INTERP foundCl, name, &cmd)) { if (cl) *cl = foundCl; return cmd; } @@ -6526,7 +6532,7 @@ */ static Tcl_Command -FilterSearch(CONST char *name, NsfObject *startingObject, +FilterSearch(INTERP_DECL CONST char *name, NsfObject *startingObject, NsfClass *startingClass, NsfClass **cl) { Tcl_Command cmd = NULL; @@ -6543,7 +6549,7 @@ * search for filters on object mixins */ if (opt && opt->mixins) { - if ((cmd = MixinSearchMethodByName(opt->mixins, name, cl))) { + if ((cmd = MixinSearchMethodByName(INTERP opt->mixins, name, cl))) { return cmd; } } @@ -6555,7 +6561,7 @@ if (startingClass) { NsfClassOpt *opt = startingClass->opt; if (opt && opt->classmixins) { - if ((cmd = MixinSearchMethodByName(opt->classmixins, name, cl))) { + if ((cmd = MixinSearchMethodByName(INTERP opt->classmixins, name, cl))) { return cmd; } } @@ -6576,12 +6582,12 @@ * ok, no filter on obj or mixins -> search class */ if (startingClass) { - *cl = SearchCMethod(startingClass, name, &cmd); + *cl = SearchCMethod(INTERP startingClass, name, &cmd); if (!*cl) { /* * If no filter is found yet -> search the meta-class */ - *cl = SearchCMethod(startingClass->object.cl, name, &cmd); + *cl = SearchCMethod(INTERP startingClass->object.cl, name, &cmd); } } return cmd; @@ -6642,7 +6648,7 @@ */ static void -GuardDel(NsfCmdList *CL) { +GuardDel(INTERP_DECL NsfCmdList *CL) { /*fprintf(stderr, "GuardDel %p clientData = %p\n", CL, CL? CL->clientData : NULL);*/ if (CL && CL->clientData) { @@ -6652,9 +6658,9 @@ } NSF_INLINE static void -GuardAdd(NsfCmdList *CL, Tcl_Obj *guardObj) { +GuardAdd(INTERP_DECL NsfCmdList *CL, Tcl_Obj *guardObj) { if (guardObj) { - GuardDel(CL); + GuardDel(INTERP CL); if (strlen(ObjStr(guardObj)) != 0) { INCR_REF_COUNT2("guardObj", guardObj); CL->clientData = guardObj; @@ -6703,13 +6709,13 @@ } static int -GuardAddFromDefinitionList(NsfCmdList *dest, Tcl_Command interceptorCmd, +GuardAddFromDefinitionList(INTERP_DECL NsfCmdList *dest, Tcl_Command interceptorCmd, NsfCmdList *interceptorDefList) { NsfCmdList *h; if (interceptorDefList) { h = CmdListFindCmdInList(interceptorCmd, interceptorDefList); if (h) { - GuardAdd(dest, (Tcl_Obj *) h->clientData); + GuardAdd(INTERP dest, (Tcl_Obj *) h->clientData); /* * 1 means we have added a guard successfully "interceptorCmd" */ @@ -6739,7 +6745,7 @@ for (ml = object->mixinOrder; ml && !guardAdded; ml = ml->nextPtr) { mixin = NsfGetClassFromCmdPtr(ml->cmdPtr); if (mixin && mixin->opt) { - guardAdded = GuardAddFromDefinitionList(dest, filterCmd, + guardAdded = GuardAddFromDefinitionList(INTERP dest, filterCmd, mixin->opt->classfilters); } } @@ -6748,15 +6754,16 @@ /* search per-object filters */ opt = object->opt; if (!guardAdded && opt && opt->filters) { - guardAdded = GuardAddFromDefinitionList(dest, filterCmd, opt->filters); + guardAdded = GuardAddFromDefinitionList(INTERP dest, filterCmd, + opt->filters); } if (!guardAdded) { /* search per-class filters */ - for (pl = ComputeOrder(object->cl, object->cl->order, Super); !guardAdded && pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP object->cl, object->cl->order, Super); !guardAdded && pl; pl = pl->nextPtr) { NsfClassOpt *clopt = pl->cl->opt; if (clopt) { - guardAdded = GuardAddFromDefinitionList(dest, filterCmd, + guardAdded = GuardAddFromDefinitionList(INTERP dest, filterCmd, clopt->classfilters); } } @@ -6776,7 +6783,7 @@ CmdListFindNameInList(interp, (char *) Tcl_GetCommandName(interp, filterCmd), object->filterOrder); if (registeredFilter) { - GuardAdd(dest, (Tcl_Obj *) registeredFilter->clientData); + GuardAdd(INTERP dest, (Tcl_Obj *) registeredFilter->clientData); } } } @@ -6834,7 +6841,7 @@ NsfFilterregGet(filterregObj, &filterObj, &guardObj); - if (!(cmd = FilterSearch(ObjStr(filterObj), startingObject, startingClass, &cl))) { + if (!(cmd = FilterSearch(INTERP ObjStr(filterObj), startingObject, startingClass, &cl))) { if (startingObject) { return NsfPrintError(interp, "object filter: can't find filterproc '%s' on %s ", ObjStr(filterObj), ObjectName(startingObject)); @@ -6846,12 +6853,12 @@ /*fprintf(stderr, " +++ adding filter %s cl %p\n", ObjStr(nameObj), cl);*/ - new = CmdListAdd(filterList, cmd, cl, /*noDuplicates*/ 1); + new = CmdListAdd(INTERP filterList, cmd, cl, /*noDuplicates*/ 1); if (guardObj) { - GuardAdd(new, guardObj); + GuardAdd(INTERP new, guardObj); } else if (new->clientData) { - GuardDel(new); + GuardDel(INTERP new); } return TCL_OK; @@ -6861,8 +6868,8 @@ * reset the filter order cached in obj->filterOrder */ static void -FilterResetOrder(NsfObject *object) { - CmdListRemoveList(&object->filterOrder, GuardDel); +FilterResetOrder(INTERP_DECL NsfObject *object) { + CmdListRemoveList(INTERP &object->filterOrder, GuardDel); object->filterOrder = NULL; } @@ -6879,16 +6886,16 @@ NsfCmdList *cmdList, *del; NsfClass *cl = NULL; - CmdListRemoveEpoched(filters, GuardDel); + CmdListRemoveEpoched(INTERP filters, GuardDel); for (cmdList = *filters; cmdList; ) { simpleName = (char *) Tcl_GetCommandName(interp, cmdList->cmdPtr); - cmd = FilterSearch(simpleName, startingObject, startingClass, &cl); + cmd = FilterSearch(INTERP simpleName, startingObject, startingClass, &cl); if (cmd == NULL) { del = CmdListRemoveFromList(filters, cmdList); cmdList = cmdList->nextPtr; - CmdListDeleteCmdListEntry(del, GuardDel); + CmdListDeleteCmdListEntry(INTERP del, GuardDel); } else if (cmd != cmdList->cmdPtr) { - CmdListReplaceCmd(cmdList, cmd, cl); + CmdListReplaceCmd(INTERP cmdList, cmd, cl); cmdList = cmdList->nextPtr; } else { cmdList = cmdList->nextPtr; @@ -6911,7 +6918,7 @@ NsfClasses *saved = cl->order, *clPtr, *savePtr; cl->order = NULL; - savePtr = clPtr = ComputeOrder(cl, cl->order, Sub); + savePtr = clPtr = ComputeOrder(INTERP cl, cl->order, Sub); cl->order = saved; for ( ; clPtr; clPtr = clPtr->nextPtr) { @@ -6925,7 +6932,7 @@ } for (; hPtr; hPtr = Tcl_NextHashEntry(&hSrch)) { NsfObject *object = (NsfObject *)Tcl_GetHashKey(&clPtr->cl->instances, hPtr); - FilterResetOrder(object); + FilterResetOrder(INTERP object); object->flags &= ~NSF_FILTER_ORDER_VALID; /* recalculate the commands of all object filter registrations */ @@ -6934,7 +6941,7 @@ } } } - NsfClassListFree(savePtr); + NsfClassListFree(INTERP savePtr); } /* @@ -6944,31 +6951,31 @@ * class cl */ static void -FilterRemoveDependentFilterCmds(NsfClass *cl, NsfClass *removeClass) { +FilterRemoveDependentFilterCmds(INTERP_DECL NsfClass *cl, NsfClass *removeClass) { NsfClasses *saved = cl->order, *clPtr; cl->order = NULL; /*fprintf(stderr, "FilterRemoveDependentFilterCmds cl %p %s, removeClass %p %s\n", cl, ClassName(cl), removeClass, ObjStr(removeClass->object.cmdName));*/ - for (clPtr = ComputeOrder(cl, cl->order, Sub); clPtr; clPtr = clPtr->nextPtr) { + for (clPtr = ComputeOrder(INTERP cl, cl->order, Sub); clPtr; clPtr = clPtr->nextPtr) { Tcl_HashSearch hSrch; Tcl_HashEntry *hPtr = &clPtr->cl->instances ? Tcl_FirstHashEntry(&clPtr->cl->instances, &hSrch) : NULL; NsfClassOpt *opt = clPtr->cl->opt; if (opt) { - CmdListRemoveContextClassFromList(&opt->classfilters, removeClass, GuardDel); + CmdListRemoveContextClassFromList(INTERP &opt->classfilters, removeClass, GuardDel); } for (; hPtr; hPtr = Tcl_NextHashEntry(&hSrch)) { NsfObject *object = (NsfObject *) Tcl_GetHashKey(&clPtr->cl->instances, hPtr); if (object->opt) { - CmdListRemoveContextClassFromList(&object->opt->filters, removeClass, GuardDel); + CmdListRemoveContextClassFromList(INTERP &object->opt->filters, removeClass, GuardDel); } } } - NsfClassListFree(cl->order); + NsfClassListFree(INTERP cl->order); cl->order = saved; } @@ -7070,12 +7077,12 @@ /* * ensure that no epoched command is in the filters list */ - CmdListRemoveEpoched(filters, GuardDel); + CmdListRemoveEpoched(INTERP filters, GuardDel); for (f = *filters; f; f = f->nextPtr) { simpleName = (char *) Tcl_GetCommandName(interp, f->cmdPtr); fcl = f->clorobj; - CmdListAdd(filterList, f->cmdPtr, fcl, /*noDuplicates*/ 0); + CmdListAdd(INTERP filterList, f->cmdPtr, fcl, /*noDuplicates*/ 0); if (fcl && !NsfObjectIsClass(&fcl->object)) { /* get the class from the object for per-object filter */ @@ -7084,15 +7091,15 @@ /* if we have a filter class -> search up the inheritance hierarchy*/ if (fcl) { - pl = ComputeOrder(fcl, fcl->order, Super); + pl = ComputeOrder(INTERP fcl, fcl->order, Super); if (pl && pl->nextPtr) { /* don't search on the start class again */ pl = pl->nextPtr; /* now go up the hierarchy */ for(; pl; pl = pl->nextPtr) { Tcl_Command pi = FindMethod(pl->cl->nsPtr, simpleName); if (pi) { - CmdListAdd(filterList, pi, pl->cl, /*noDuplicates*/ 0); + CmdListAdd(INTERP filterList, pi, pl->cl, /*noDuplicates*/ 0); /* fprintf(stderr, " %s::%s, ", ClassName(pl->cl), simpleName); */ @@ -7115,7 +7122,7 @@ NsfCmdList *filterList = NULL, *next, *checker, *newlist; NsfClasses *pl; - if (object->filterOrder) FilterResetOrder(object); + if (object->filterOrder) FilterResetOrder(INTERP object); /* fprintf(stderr, " List: ", ObjectName(object)); */ @@ -7141,7 +7148,7 @@ FilterComputeOrderFullList(interp, &object->opt->filters, &filterList); } /* append per-class filters */ - for (pl = ComputeOrder(object->cl, object->cl->order, Super); pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP object->cl, object->cl->order, Super); pl; pl = pl->nextPtr) { NsfClassOpt *clopt = pl->cl->opt; if (clopt && clopt->classfilters) { FilterComputeOrderFullList(interp, &clopt->classfilters, &filterList); @@ -7160,7 +7167,7 @@ checker = checker->nextPtr; } if (checker == NULL) { - newlist = CmdListAdd(&object->filterOrder, filterList->cmdPtr, filterList->clorobj, + newlist = CmdListAdd(INTERP &object->filterOrder, filterList->cmdPtr, filterList->clorobj, /*noDuplicates*/ 0); GuardAddInheritedGuards(interp, newlist, object, filterList->cmdPtr); /* @@ -7172,7 +7179,7 @@ } - CmdListDeleteCmdListEntry(filterList, GuardDel); + CmdListDeleteCmdListEntry(INTERP filterList, GuardDel); filterList = next; } @@ -7205,7 +7212,7 @@ * push a filter stack information on this object */ static int -FilterStackPush(NsfObject *object, Tcl_Obj *calledProc) { +FilterStackPush(INTERP_DECL NsfObject *object, Tcl_Obj *calledProc) { register NsfFilterStack *h = NEW(NsfFilterStack); h->currentCmdPtr = NULL; @@ -7220,7 +7227,7 @@ * pop a filter stack information on this object */ static void -FilterStackPop(NsfObject *object) { +FilterStackPop(INTERP_DECL NsfObject *object) { register NsfFilterStack *h = object->filterStack; object->filterStack = h->nextPtr; @@ -7254,7 +7261,7 @@ } /* search per-class filters */ - for (pl = ComputeOrder(object->cl, object->cl->order, Super); pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP object->cl, object->cl->order, Super); pl; pl = pl->nextPtr) { NsfClassOpt *opt = pl->cl->opt; if (opt && opt->classfilters) { if (CmdListFindCmdInList(cmd, opt->classfilters)) { @@ -7324,7 +7331,7 @@ int reversed = 0; int i, j; - filterCheck = ComputeOrder(cl, cl->order, Super); + filterCheck = ComputeOrder(INTERP cl, cl->order, Super); /* * we have to remove all dependent superclass filter referenced * by class or one of its subclasses @@ -7336,7 +7343,7 @@ filterCheck = filterCheck->nextPtr; } for (; filterCheck; filterCheck = filterCheck->nextPtr) { - FilterRemoveDependentFilterCmds(cl, filterCheck->cl); + FilterRemoveDependentFilterCmds(INTERP cl, filterCheck->cl); } /* invalidate all interceptors orders of instances of this @@ -7359,7 +7366,7 @@ for (i = 0; i < oc; i++) { if (reversed) break; for (j = i+1; j < oc; j++) { - NsfClasses *dl = ComputeOrder(scl[j], scl[j]->order, Super); + NsfClasses *dl = ComputeOrder(INTERP scl[j], scl[j]->order, Super); if (reversed) break; dl = NsfClassListFind(dl, scl[i]); if (dl) reversed = 1; @@ -7393,37 +7400,37 @@ osl = NEW(NsfClasses); osl->cl = sc; osl->nextPtr = l; - (void)RemoveSuper(cl, cl->super->cl); + (void)RemoveSuper(INTERP cl, cl->super->cl); } for (i=0; i < oc; i++) { - AddSuper(cl, scl[i]); + AddSuper(INTERP cl, scl[i]); } FREE(NsfClass**, scl); - FlushPrecedencesOnSubclasses(cl); + FlushPrecedencesOnSubclasses(INTERP cl); - if (!ComputeOrder(cl, cl->order, Super)) { + if (!ComputeOrder(INTERP cl, cl->order, Super)) { NsfClasses *l; /* * cycle in the superclass graph, backtrack */ while (cl->super) { - (void)RemoveSuper(cl, cl->super->cl); + (void)RemoveSuper(INTERP cl, cl->super->cl); } for (l = osl; l; l = l->nextPtr) { - AddSuper(cl, l->cl); + AddSuper(INTERP cl, l->cl); } - NsfClassListFree(osl); + NsfClassListFree(INTERP osl); return NsfObjErrType(interp, "superclass", arg, "a cycle-free graph", NULL); } - NsfClassListFree(osl); + NsfClassListFree(INTERP osl); /* if there are no more super classes add the Object class as superclasses */ assert(cl->super); #if 0 if (cl->super == NULL) { fprintf(stderr, "SuperClassAdd super of '%s' is NULL\n", ClassName(cl)); - /*AddSuper(cl, RUNTIME_STATE(interp)->theObject);*/ + /*AddSuper(INTERP cl, RUNTIME_STATE(interp)->theObject);*/ } #endif @@ -7643,17 +7650,19 @@ void NsfProcDeleteProc(ClientData clientData) { NsfProcContext *ctxPtr = (NsfProcContext *)clientData; + INTERP_MEMBER_GET(ctxPtr) + (*ctxPtr->oldDeleteProc)(ctxPtr->oldDeleteData); if (ctxPtr->paramDefs) { /*fprintf(stderr, "free ParamDefs %p\n", ctxPtr->paramDefs);*/ - ParamDefsRefCountDecr(ctxPtr->paramDefs); + ParamDefsRefCountDecr(INTERP ctxPtr->paramDefs); } /*fprintf(stderr, "free %p\n", ctxPtr);*/ FREE(NsfProcContext, ctxPtr); } static Nsf_Param * -ParamsNew(int nr) { +ParamsNew(INTERP_DECL int nr) { Nsf_Param *paramsPtr = NEW_ARRAY(Nsf_Param, nr+1); memset(paramsPtr, 0, sizeof(Nsf_Param)*(nr+1)); return paramsPtr; @@ -7673,7 +7682,7 @@ *---------------------------------------------------------------------- */ static void -ParamFree(Nsf_Param *paramPtr) { +ParamFree(INTERP_DECL Nsf_Param *paramPtr) { /*fprintf(stderr, "ParamFree %p\n", paramPtr);*/ if (paramPtr->name) ckfree(paramPtr->name); if (paramPtr->nameObj) {DECR_REF_COUNT(paramPtr->nameObj);} @@ -7699,12 +7708,12 @@ *---------------------------------------------------------------------- */ static void -ParamsFree(Nsf_Param *paramsPtr) { +ParamsFree(INTERP_DECL Nsf_Param *paramsPtr) { Nsf_Param *paramPtr; /*fprintf(stderr, "ParamsFree %p\n", paramsPtr);*/ for (paramPtr=paramsPtr; paramPtr->name; paramPtr++) { - ParamFree(paramPtr); + ParamFree(INTERP paramPtr); } FREE(Nsf_Param*, paramsPtr); } @@ -7735,7 +7744,7 @@ *---------------------------------------------------------------------- */ static int -ParamDefsStore(Tcl_Command cmd, NsfParamDefs *paramDefs) { +ParamDefsStore(INTERP_DECL Tcl_Command cmd, NsfParamDefs *paramDefs) { Command *cmdPtr = (Command *)cmd; if (cmdPtr->deleteProc != NsfProcDeleteProc) { @@ -7749,6 +7758,8 @@ cmdPtr->deleteProc = NsfProcDeleteProc; ctxPtr->paramDefs = paramDefs; cmdPtr->deleteData = ctxPtr; + INTERP_MEMBER_SET(ctxPtr, interp) + return TCL_OK; } else { /*fprintf(stderr, "ParamDefsStore cmd %p has already NsfProcDeleteProc deleteData %p\n", @@ -7778,7 +7789,7 @@ *---------------------------------------------------------------------- */ static NsfParamDefs * -ParamDefsNew() { +ParamDefsNew(INTERP_DECL1) { NsfParamDefs *paramDefs; paramDefs = NEW(NsfParamDefs); @@ -7805,12 +7816,12 @@ */ static void -ParamDefsFree(NsfParamDefs *paramDefs) { +ParamDefsFree(INTERP_DECL NsfParamDefs *paramDefs) { /*fprintf(stderr, "ParamDefsFree %p slotObj %p returns %p\n", paramDefs, paramDefs->slotObj, paramDefs->returns);*/ if (paramDefs->paramsPtr) { - ParamsFree(paramDefs->paramsPtr); + ParamsFree(INTERP paramDefs->paramsPtr); } if (paramDefs->slotObj) {DECR_REF_COUNT2("paramDefsObj", paramDefs->slotObj);} if (paramDefs->returns) {DECR_REF_COUNT2("paramDefsObj", paramDefs->returns);} @@ -7840,14 +7851,14 @@ static void -ParamDefsRefCountIncr(NsfParamDefs *paramDefs) { +ParamDefsRefCountIncr(INTERP_DECL NsfParamDefs *paramDefs) { paramDefs->refCount ++; } static void -ParamDefsRefCountDecr(NsfParamDefs *paramDefs) { +ParamDefsRefCountDecr(INTERP_DECL NsfParamDefs *paramDefs) { paramDefs->refCount --; if (paramDefs->refCount < 1) { - ParamDefsFree(paramDefs); + ParamDefsFree(INTERP paramDefs); } } @@ -8122,7 +8133,7 @@ */ Tcl_Obj * -NsfParamDefsSyntax(Nsf_Param CONST *paramsPtr) { +NsfParamDefsSyntax(INTERP_DECL Nsf_Param CONST *paramsPtr) { Tcl_Obj *argStringObj = Tcl_NewObj(); Nsf_Param CONST *pPtr; @@ -8151,7 +8162,7 @@ if ((pPtr->flags & NSF_ARG_IS_ENUMERATION)) { Tcl_AppendLimitedToObj(argStringObj, ParamGetDomain(pPtr), -1, INT_MAX, NULL); } else { - Tcl_AppendLimitedToObj(argStringObj, pPtr->name, -1, INT_MAX, NULL); + Tcl_AppendLimitedToObj(argStringObj, pPtr->name, -1, INT_MAX, NULL); // aaaa } } else { Tcl_AppendLimitedToObj(argStringObj, "?", 1, INT_MAX, NULL); @@ -8185,11 +8196,11 @@ *---------------------------------------------------------------------- */ static void -ParsedParamFree(NsfParsedParam *parsedParamPtr) { +ParsedParamFree(INTERP_DECL NsfParsedParam *parsedParamPtr) { /*fprintf(stderr, "ParsedParamFree %p, npargs %p\n", parsedParamPtr, parsedParamPtr->paramDefs);*/ if (parsedParamPtr->paramDefs) { - ParamDefsRefCountDecr(parsedParamPtr->paramDefs); + ParamDefsRefCountDecr(INTERP parsedParamPtr->paramDefs); } FREE(NsfParsedParam, parsedParamPtr); } @@ -8249,7 +8260,7 @@ #if defined(NRE) if ((cscPtr->flags & NSF_CSC_CALL_IS_NRE)) { if (pcPtr) { - ParseContextRelease(pcPtr); + ParseContextRelease(INTERP pcPtr); NsfTclStackFree(interp, pcPtr, "release parse context"); } result = ObjectDispatchFinalize(interp, cscPtr, result /*, "NRE" , methodName*/); @@ -8258,7 +8269,7 @@ } #else if (pcPtr) { - ParseContextRelease(pcPtr); + ParseContextRelease(INTERP pcPtr); } #endif @@ -8297,7 +8308,7 @@ } # endif - ParseContextRelease(pcPtr); + ParseContextRelease(INTERP pcPtr); NsfTclStackFree(interp, pcPtr, "nsf::proc dispatch finialize release parse context"); return result; @@ -8419,12 +8430,12 @@ result = PushProcCallFrame(cp, interp, pcPtr->objc, pcPtr->full_objv, cscPtr); } else { #if defined(NRE) - ParseContextRelease(pcPtr); + ParseContextRelease(INTERP pcPtr); NsfTclStackFree(interp, pcPtr, "parse context (proc prep failed)"); pcPtr = NULL; #else //fprintf(stderr, "error\n"); - ParseContextRelease(pcPtr); + ParseContextRelease(INTERP pcPtr); #endif } } else { @@ -8645,7 +8656,7 @@ assert(cscPtr->cmdPtr == cmd); Tcl_DeleteCommandFromToken(interp, cmd); - NsfCleanupObject(invokeObj, "alias-delete1"); + NsfCleanupObject(INTERP invokeObj, "alias-delete1"); return NsfPrintError(interp, "Trying to dispatch deleted object via method '%s'", methodName); } @@ -8843,7 +8854,7 @@ * cp == NULL && !(Tcl_Command_flags(cmd) & NSF_CMD_NONLEAF_METHOD) * TODO: We could pass cmd==NULL, but is this worth it? */ - CscInit(cscPtr, object, cl, cmd, frameType, flags, methodName); + CscInit(INTERP cscPtr, object, cl, cmd, frameType, flags, methodName); result = MethodDispatchCsc(clientData, interp, objc, objv, cscPtr, methodName, &validCscPtr); @@ -8941,12 +8952,12 @@ if ((flags & NSF_CSC_MIXIN_STACK_PUSHED) && object->mixinStack) { /* fprintf(stderr, "MixinStackPop %s.%s %p %s\n", ObjectName(object), methodName, object->mixinStack, msg);*/ - MixinStackPop(object); + MixinStackPop(INTERP object); } if ((flags & NSF_CSC_FILTER_STACK_PUSHED) && object->filterStack) { /* fprintf(stderr, "FilterStackPop %s.%s %p %s\n", ObjectName(object), methodName, object->filterStack, msg);*/ - FilterStackPop(object); + FilterStackPop(INTERP object); } return result; @@ -8961,7 +8972,7 @@ NsfClasses *p; /*fprintf(stderr, "NsfFindClassMethod %s %s\n", ClassName(cl), methodName);*/ - if (cl->order == NULL) cl->order = TopoOrder(cl, Super); + if (cl->order == NULL) cl->order = TopoOrder(INTERP cl, Super); for(p = cl->order; p; p = p->nextPtr) { NsfClass *currentClass = p->cl; @@ -9074,7 +9085,7 @@ if (!cscPtr1 || (object != cscPtr1->self || (cscPtr1->frameType != NSF_CSC_TYPE_ACTIVE_FILTER))) { - FilterStackPush(object, methodObj); + FilterStackPush(INTERP object, methodObj); flags |= NSF_CSC_FILTER_STACK_PUSHED; cmd = FilterSearchProc(interp, object, &object->filterStack->currentCmdPtr, &cl); @@ -9103,7 +9114,7 @@ * larger. */ - MixinStackPush(object); + MixinStackPush(INTERP object); flags |= NSF_CSC_MIXIN_STACK_PUSHED; if (frameType != NSF_CSC_TYPE_ACTIVE_FILTER) { @@ -9118,7 +9129,7 @@ /*fprintf(stderr, "mixinsearch returned an error for %p %s.%s\n", object, ObjectName(object), methodName);*/ cscPtr = CscAlloc(interp, &csc, NULL); - CscInit(cscPtr, object, cl, NULL, frameType, flags, methodName); + CscInit(INTERP cscPtr, object, cl, NULL, frameType, flags, methodName); goto exit_object_dispatch; } if (cmd) { @@ -9184,7 +9195,7 @@ /* check for a method inherited from a class */ NsfClass *currentClass = object->cl; if (unlikely(currentClass->order == NULL)) { - currentClass->order = TopoOrder(currentClass, Super); + currentClass->order = TopoOrder(INTERP currentClass, Super); } cl = SearchPLMethod(currentClass->order, methodName, &cmd); } @@ -9216,7 +9227,7 @@ * We found the method to dispatch. */ cscPtr = CscAlloc(interp, &csc, cmd); - CscInit(cscPtr, object, cl, cmd, frameType, flags, methodName); + CscInit(INTERP cscPtr, object, cl, cmd, frameType, flags, methodName); if ((cscPtr->frameType == NSF_CSC_TYPE_ACTIVE_FILTER)) { /* run filters not NRE enabled */ @@ -9245,7 +9256,7 @@ * The method to be dispatched is unknown */ cscPtr = CscAlloc(interp, &csc, cmd); - CscInit(cscPtr, object, cl, cmd, frameType, flags, methodName); + CscInit(INTERP cscPtr, object, cl, cmd, frameType, flags, methodName); cscPtr->flags |= NSF_CSC_METHOD_IS_UNKNOWN; if ((flags & NSF_CM_NO_UNKNOWN)) { cscPtr->flags |= NSF_CSC_CALL_NO_UNKNOWN; @@ -9270,7 +9281,7 @@ /*fprintf(stderr, "ObjectDispatch %s.%s returns %d\n", ObjectName(object), methodName, result);*/ - NsfCleanupObject(object, "ObjectDispatch"); + NsfCleanupObject(INTERP object, "ObjectDispatch"); /*fprintf(stderr, "ObjectDispatch call NsfCleanupObject %p DONE\n", object);*/ DECR_REF_COUNT(cmdName); /* must be after last dereferencing of obj */ @@ -9583,7 +9594,7 @@ */ static Tcl_Obj * -AddPrefixToBody(Tcl_Obj *body, int paramDefs, NsfParsedParam *paramPtr) { +AddPrefixToBody(INTERP_DECL Tcl_Obj *body, int paramDefs, NsfParsedParam *paramPtr) { Tcl_Obj *resultBody = Tcl_NewObj(); INCR_REF_COUNT2("resultBody", resultBody); @@ -10707,7 +10718,7 @@ return TCL_OK; param_error: - ParamFree(paramPtr); + ParamFree(INTERP paramPtr); paramPtr->name = NULL; return TCL_ERROR; @@ -10752,7 +10763,7 @@ int i, possibleUnknowns = 0, plainParams = 0, nrNonposArgs = 0; NsfParamDefs *paramDefs; - paramPtr = paramsPtr = ParamsNew(argsc); + paramPtr = paramsPtr = ParamsNew(INTERP argsc); for (i=0; i < argsc; i++, paramPtr++) { result = ParamParse(interp, procNameObj, argsv[i], allowedOptinons, @@ -10763,7 +10774,7 @@ paramPtr->name); } if (result != TCL_OK) { - ParamsFree(paramsPtr); + ParamsFree(INTERP paramsPtr); return result; } /* every parameter must have at least a name set */ @@ -10780,7 +10791,7 @@ * to use the parameter definition structure. */ if (plainParams == argsc && !forceParamdefs) { - ParamsFree(paramsPtr); + ParamsFree(INTERP paramsPtr); return TCL_OK; } /* @@ -10797,7 +10808,7 @@ lastParamPtr->flags &= ~NSF_ARG_REQUIRED; } - paramDefs = ParamDefsNew(); + paramDefs = ParamDefsNew(INTERP1); paramDefs->paramsPtr = paramsPtr; paramDefs->nrParams = paramPtr-paramsPtr; /*fprintf(stderr, "method %s paramDefs %p ifsize %ld, possible unknowns = %d,\n", @@ -10849,10 +10860,10 @@ ov[2] = argList; INCR_REF_COUNT(ov[2]); /*fprintf(stderr, "final arglist = <%s>\n", ObjStr(argList)); */ - ov[3] = AddPrefixToBody(body, 1, &parsedParam); + ov[3] = AddPrefixToBody(INTERP body, 1, &parsedParam); } else { /* no parameter handling needed */ ov[2] = args; - ov[3] = AddPrefixToBody(body, 0, &parsedParam); + ov[3] = AddPrefixToBody(INTERP body, 0, &parsedParam); } Tcl_PushCallFrame(interp, (Tcl_CallFrame *)framePtr, nsPtr, 0); @@ -10883,7 +10894,7 @@ procPtr->cmdPtr->nsPtr = ((Command *)regObject->id)->nsPtr; } - ParamDefsStore((Tcl_Command)procPtr->cmdPtr, parsedParam.paramDefs); + ParamDefsStore(INTERP (Tcl_Command)procPtr->cmdPtr, parsedParam.paramDefs); Tcl_SetObjResult(interp, MethodHandleObj(defObject, withPer_object, methodName)); result = TCL_OK; } @@ -10941,15 +10952,15 @@ NsfAssertionStore *aStore = NULL; if (precondition || postcondition) { if (cl) { - NsfClassOpt *opt = NsfRequireClassOpt(cl); + NsfClassOpt *opt = NsfRequireClassOpt(INTERP cl); if (!opt->assertions) { - opt->assertions = AssertionCreateStore(); + opt->assertions = AssertionCreateStore(INTERP1); } aStore = opt->assertions; } else { - NsfObjectOpt *opt = NsfRequireObjectOpt(defObject); + NsfObjectOpt *opt = NsfRequireObjectOpt(INTERP defObject); if (!opt->assertions) { - opt->assertions = AssertionCreateStore(); + opt->assertions = AssertionCreateStore(INTERP1); } aStore = opt->assertions; } @@ -10996,13 +11007,14 @@ static void NsfProcStubDeleteProc(ClientData clientData) { NsfProcClientData *tcd = clientData; + INTERP_MEMBER_GET(tcd) /*fprintf(stderr, "NsfProcStubDeleteProc received %p\n", clientData); fprintf(stderr, "... procName %s paramDefs %p\n", ObjStr(tcd->procName), tcd->paramDefs);*/ DECR_REF_COUNT2("procNameObj",tcd->procName); if (tcd->cmd) { - NsfCommandRelease(tcd->cmd); + NsfCommandRelease(INTERP tcd->cmd); } /* tcd->paramDefs is freed by NsfProcDeleteProc() */ FREE(NsfProcClientData, tcd); @@ -11054,7 +11066,7 @@ NsfProfileRecordProcData(interp, ObjStr(procNameObj), trt.tv_sec, trt.tv_usec); } # endif - ParseContextRelease(pcPtr); + ParseContextRelease(INTERP pcPtr); NsfTclStackFree(interp, pcPtr, "release parse context"); #else /* @@ -11090,9 +11102,9 @@ /* * ... and update the refCounts */ - NsfCommandRelease(tcd->cmd); + NsfCommandRelease(INTERP tcd->cmd); tcd->cmd = cmd; - NsfCommandPreserve(tcd->cmd); + NsfCommandPreserve(INTERP tcd->cmd); #endif } @@ -11193,7 +11205,7 @@ } else { /*Tcl_Obj *resultObj = Tcl_GetObjResult(interp); fprintf(stderr, "NsfProcStub: incorrect arguments (%s)\n", ObjStr(resultObj));*/ - ParseContextRelease(pcPtr); + ParseContextRelease(INTERP pcPtr); NsfTclStackFree(interp, pcPtr, "release parse context"); } @@ -11260,6 +11272,7 @@ * needed as the inner namespace of the shadowed proc. */ tcd = NEW(NsfProcClientData); + INTERP_MEMBER_SET(tcd, interp) cmd = Tcl_CreateObjCommand(interp, procName, NsfProcStub, tcd, NsfProcStubDeleteProc); if (cmd == NULL) { @@ -11273,7 +11286,7 @@ } cmdNsPtr = Tcl_Command_nsPtr(cmd); - ParamDefsStore(cmd, paramDefs); + ParamDefsStore(INTERP cmd, paramDefs); /*fprintf(stderr, "NsfAddParameterProc procName '%s' define cmd '%s' %p in namespace %s\n", procName, Tcl_GetCommandName(interp, cmd), cmd, cmdNsPtr->fullName);*/ @@ -11348,7 +11361,7 @@ ov[0] = NULL; ov[1] = procNameObj; ov[2] = argList; - ov[3] = AddPrefixToBody(body, 1, parsedParamPtr); + ov[3] = AddPrefixToBody(INTERP body, 1, parsedParamPtr); /*fprintf(stderr, "NsfAddParameterProc define proc %s arglist '%s'\n", ObjStr(ov[1]), ObjStr(ov[2])); */ @@ -11367,7 +11380,7 @@ assert(procCmd); ((Command *)procCmd)->nsPtr = (Namespace *)cmdNsPtr; tcd->cmd = procCmd; - NsfCommandPreserve(tcd->cmd); + NsfCommandPreserve(INTERP tcd->cmd); } else { /* @@ -11444,7 +11457,7 @@ */ /*NsfPrintObjv("actual: ", objc, objv);*/ - ParseContextExtendObjv(pcPtr, paramDefs->nrParams, elts-1, objv + 1 + pcPtr->lastObjc); + ParseContextExtendObjv(INTERP pcPtr, paramDefs->nrParams, elts-1, objv + 1 + pcPtr->lastObjc); } else { /* * A single argument was passed to "args". There is no need to @@ -11478,6 +11491,8 @@ static void ForwardCmdDeleteProc(ClientData clientData) { ForwardCmdClientData *tcd = (ForwardCmdClientData *)clientData; + INTERP_MEMBER_GET(tcd) + if (tcd->cmdName) {DECR_REF_COUNT(tcd->cmdName);} if (tcd->subcommands) {DECR_REF_COUNT(tcd->subcommands);} if (tcd->onerror) {DECR_REF_COUNT(tcd->onerror);} @@ -11505,9 +11520,10 @@ static void SetterCmdDeleteProc(ClientData clientData) { SetterCmdClientData *setterClientData = (SetterCmdClientData *)clientData; + INTERP_MEMBER_GET(setterClientData) if (setterClientData->paramsPtr) { - ParamsFree(setterClientData->paramsPtr); + ParamsFree(INTERP setterClientData->paramsPtr); } FREE(SetterCmdClientData, setterClientData); } @@ -11531,6 +11547,7 @@ static void AliasCmdDeleteProc(ClientData clientData) { AliasCmdClientData *tcd = (AliasCmdClientData *)clientData; + INTERP_MEMBER_GET(tcd) /* * Since we just get the clientData, we have to obtain interp, @@ -11575,7 +11592,7 @@ prevPtr = refPtr; } #endif - NsfCommandRelease(tcd->aliasedCmd); + NsfCommandRelease(INTERP tcd->aliasedCmd); } FREE(AliasCmdClientData, tcd); } @@ -11644,7 +11661,8 @@ tcd = NEW(ForwardCmdClientData); memset(tcd, 0, sizeof(ForwardCmdClientData)); - + INTERP_MEMBER_SET(tcd, interp) + if (withDefault) { Tcl_DString ds, *dsPtr = &ds; DSTRING_INIT(dsPtr); @@ -11851,7 +11869,7 @@ /* * Check, if the entry is from the right type */ - if (type && !IsSubType(childObject->cl, type)) { + if (type && !IsSubType(INTERP childObject->cl, type)) { continue; } @@ -11889,7 +11907,7 @@ } } - return SearchCMethod(object->cl, methodName, &cmd); + return SearchCMethod(INTERP object->cl, methodName, &cmd); } /* @@ -11996,7 +12014,7 @@ if (!*cmdPtr) { NsfClasses *pl; - for (pl = ComputeOrder(object->cl, object->cl->order, Super); *clPtr && pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP object->cl, object->cl->order, Super); *clPtr && pl; pl = pl->nextPtr) { if (pl->cl == *clPtr) { *clPtr = NULL; } @@ -12664,27 +12682,27 @@ if (object->opt) { NsfObjectOpt *opt = object->opt; #if defined(NSF_WITH_ASSERTIONS) - AssertionRemoveStore(opt->assertions); + AssertionRemoveStore(INTERP opt->assertions); opt->assertions = NULL; #endif if (!softrecreate) { /* * Remove this object from all per object mixin lists and clear the mixin list */ - RemoveFromObjectMixinsOf(object->id, opt->mixins); + RemoveFromObjectMixinsOf(INTERP object->id, opt->mixins); - CmdListRemoveList(&opt->mixins, GuardDel); - CmdListRemoveList(&opt->filters, GuardDel); + CmdListRemoveList(INTERP &opt->mixins, GuardDel); + CmdListRemoveList(INTERP &opt->filters, GuardDel); FREE(NsfObjectOpt, opt); opt = object->opt = 0; } } object->flags &= ~NSF_MIXIN_ORDER_VALID; - if (object->mixinOrder) MixinResetOrder(object); + if (object->mixinOrder) MixinResetOrder(INTERP object); object->flags &= ~NSF_FILTER_ORDER_VALID; - if (object->filterOrder) FilterResetOrder(object); + if (object->filterOrder) FilterResetOrder(INTERP object); } /* @@ -12783,10 +12801,10 @@ CleanupDestroyObject(interp, object, 0); while (object->mixinStack) - MixinStackPop(object); + MixinStackPop(INTERP object); while (object->filterStack) - FilterStackPop(object); + FilterStackPop(INTERP object); object->teardown = NULL; if (object->nsPtr) { @@ -12801,7 +12819,7 @@ ObjTrace("ODestroy", object); DECR_REF_COUNT(object->cmdName); - NsfCleanupObject(object, "PrimitiveODestroy"); + NsfCleanupObject(INTERP object, "PrimitiveODestroy"); } @@ -12933,7 +12951,7 @@ nsPtr = NSCheckNamespace(interp, nameString, parentNsPtr); if (nsPtr) { - NSNamespacePreserve(nsPtr); + NSNamespacePreserve(INTERP nsPtr); } #if defined(NRE) object->id = Tcl_NRCreateCommand(interp, nameString, NsfObjDispatch, NsfObjDispatch, @@ -12948,7 +12966,7 @@ PrimitiveOInit(object, interp, nameString, nsPtr, cl); if (nsPtr) { - NSNamespaceRelease(nsPtr); + NSNamespaceRelease(INTERP nsPtr); } object->cmdName = nameObj; @@ -13078,36 +13096,36 @@ * Remove this class from all isClassMixinOf lists and clear the * class mixin list */ - RemoveFromClassMixinsOf(clopt->id, clopt->classmixins); + RemoveFromClassMixinsOf(INTERP clopt->id, clopt->classmixins); - CmdListRemoveList(&clopt->classmixins, GuardDel); + CmdListRemoveList(INTERP &clopt->classmixins, GuardDel); /*MixinInvalidateObjOrders(interp, cl);*/ - CmdListRemoveList(&clopt->classfilters, GuardDel); + CmdListRemoveList(INTERP &clopt->classfilters, GuardDel); /*FilterInvalidateObjOrders(interp, cl);*/ if (!recreate) { /* * Remove this class from all mixin lists and clear the isObjectMixinOf list */ - RemoveFromObjectMixins(clopt->id, clopt->isObjectMixinOf); - CmdListRemoveList(&clopt->isObjectMixinOf, GuardDel); + RemoveFromObjectMixins(INTERP clopt->id, clopt->isObjectMixinOf); + CmdListRemoveList(INTERP &clopt->isObjectMixinOf, GuardDel); /* * Remove this class from all class mixin lists and clear the * isClassMixinOf list */ - RemoveFromClassmixins(clopt->id, clopt->isClassMixinOf); - CmdListRemoveList(&clopt->isClassMixinOf, GuardDel); + RemoveFromClassmixins(INTERP clopt->id, clopt->isClassMixinOf); + CmdListRemoveList(INTERP &clopt->isClassMixinOf, GuardDel); } /* * Remove dependent filters of this class from all subclasses */ - FilterRemoveDependentFilterCmds(cl, cl); + FilterRemoveDependentFilterCmds(INTERP cl, cl); #if defined(NSF_WITH_ASSERTIONS) - AssertionRemoveStore(clopt->assertions); + AssertionRemoveStore(INTERP clopt->assertions); clopt->assertions = NULL; #endif @@ -13165,8 +13183,8 @@ * has a different superclass. So we have to flush the precedence * list on a recreate as well. */ - FlushPrecedencesOnSubclasses(cl); - while (cl->super) (void)RemoveSuper(cl, cl->super->cl); + FlushPrecedencesOnSubclasses(INTERP cl); + while (cl->super) (void)RemoveSuper(INTERP cl, cl->super->cl); if (!softrecreate) { /* @@ -13175,7 +13193,7 @@ while (cl->sub) { NsfClass *subClass = cl->sub->cl; - (void)RemoveSuper(subClass, cl); + (void)RemoveSuper(INTERP subClass, cl); /* * If there are no more super classes add the Object * class as superclasses @@ -13184,10 +13202,10 @@ if (subClass->super == 0 && (cl->object.flags & NSF_IS_ROOT_CLASS) == 0) { /* fprintf(stderr,"subClass %p %s baseClass %p %s\n", cl, ClassName(cl), baseClass, ClassName(baseClass)); */ - AddSuper(subClass, baseClass); + AddSuper(INTERP subClass, baseClass); } } - /*(void)RemoveSuper(cl, cl->super->cl);*/ + /*(void)RemoveSuper(INTERP cl, cl->super->cl);*/ } } @@ -13237,7 +13255,7 @@ /* Look for a configured default superclass */ defaultSuperclass = DefaultSuperClass(interp, cl, cl->object.cl, 0); if (cl != defaultSuperclass) { - AddSuper(cl, defaultSuperclass); + AddSuper(INTERP cl, defaultSuperclass); } cl->color = WHITE; @@ -13358,7 +13376,7 @@ */ nsPtr = NSCheckNamespace(interp, nameString, parentNsPtr); if (nsPtr) { - NSNamespacePreserve(nsPtr); + NSNamespacePreserve(INTERP nsPtr); } #if defined(NRE) object->id = Tcl_NRCreateCommand(interp, nameString, NsfObjDispatch, NsfObjDispatch, @@ -13370,7 +13388,7 @@ PrimitiveOInit(object, interp, nameString, nsPtr, class); if (nsPtr) { - NSNamespaceRelease(nsPtr); + NSNamespaceRelease(INTERP nsPtr); } object->cmdName = nameObj; @@ -13506,7 +13524,7 @@ } } - NsfCleanupObject(object, "obj init"); + NsfCleanupObject(INTERP object, "obj init"); DECR_REF_COUNT(savedObjResult); return result; } @@ -13534,7 +13552,7 @@ } /* is the class a subclass of a meta-class? */ - for (pl = ComputeOrder(cl, cl->order, Super); pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP cl, cl->order, Super); pl; pl = pl->nextPtr) { if (HasMetaProperty(pl->cl)) { return 1; } @@ -13553,8 +13571,8 @@ break; } } - NsfClassListFree(mixinClasses); - NsfClassListFree(checkList); + NsfClassListFree(INTERP mixinClasses); + NsfClassListFree(INTERP checkList); /*fprintf(stderr, "has MC returns %d, mixinClasses = %p\n", hasMCM, mixinClasses);*/ @@ -13566,12 +13584,12 @@ } static int -IsSubType(NsfClass *subcl, NsfClass *cl) { +IsSubType(INTERP_DECL NsfClass *subcl, NsfClass *cl) { assert(cl && subcl); if (cl != subcl) { - return NsfClassListFind(ComputeOrder(subcl, subcl->order, Super), cl) != NULL; + return NsfClassListFind(ComputeOrder(INTERP subcl, subcl->order, Super), cl) != NULL; } return 1; } @@ -13721,24 +13739,24 @@ * obj/cl ClientData setter/getter */ extern void -NsfSetObjClientData(Nsf_Object *object1, ClientData data) { +NsfSetObjClientData(Tcl_Interp *interp, Nsf_Object *object1, ClientData data) { NsfObject *object = (NsfObject *) object1; - NsfObjectOpt *opt = NsfRequireObjectOpt(object); + NsfObjectOpt *opt = NsfRequireObjectOpt(INTERP object); opt->clientData = data; } extern ClientData -NsfGetObjClientData(Nsf_Object *object1) { +NsfGetObjClientData(Tcl_Interp *interp, Nsf_Object *object1) { NsfObject *object = (NsfObject *) object1; return (object && object->opt) ? object->opt->clientData : NULL; } extern void -NsfSetClassClientData(Nsf_Class *cli, ClientData data) { +NsfSetClassClientData(Tcl_Interp *interp, Nsf_Class *cli, ClientData data) { NsfClass *cl = (NsfClass *) cli; - NsfRequireClassOpt(cl); + NsfRequireClassOpt(INTERP cl); cl->opt->clientData = data; } extern ClientData -NsfGetClassClientData(Nsf_Class *cli) { +NsfGetClassClientData(Tcl_Interp *interp, Nsf_Class *cli) { NsfClass *cl = (NsfClass *) cli; return (cl && cl->opt) ? cl->opt->clientData : NULL; } @@ -14493,11 +14511,11 @@ } cmd = GetOriginalCommand(cmd); - NsfCommandRelease(tcd->aliasedCmd); + NsfCommandRelease(INTERP tcd->aliasedCmd); tcd->objProc = Tcl_Command_objProc(cmd); tcd->aliasedCmd = cmd; tcd->clientData = Tcl_Command_objClientData(cmd); - NsfCommandPreserve(tcd->aliasedCmd); + NsfCommandPreserve(INTERP tcd->aliasedCmd); DECR_REF_COUNT(entryObj); /* @@ -14744,7 +14762,7 @@ #include "nsfAPI.h" static void -ArgumentResetRefCounts( struct Nsf_Param CONST *pPtr, Tcl_Obj *valueObj) { +ArgumentResetRefCounts(INTERP_DECL struct Nsf_Param CONST *pPtr, Tcl_Obj *valueObj) { if ((pPtr->flags & NSF_ARG_IS_CONVERTER)) { //fprintf(stderr, "manually decrementing CONVERTER %p\n", valueObj); DECR_REF_COUNT2("valueObj", valueObj); @@ -14789,7 +14807,7 @@ * decrement it here, since we want the valuObj reclaimed when the list * containing the valueObj is freed. */ - ArgumentResetRefCounts(pPtr, elementObjPtr); + ArgumentResetRefCounts(INTERP pPtr, elementObjPtr); } else { Tcl_Obj *resultObj = Tcl_GetObjResult(interp); @@ -14864,7 +14882,7 @@ * the version of this handler building an output list. But first, * we have to reset the refcounts from the first conversion. */ - ArgumentResetRefCounts(pPtr, elementObjPtr); + ArgumentResetRefCounts(INTERP pPtr, elementObjPtr); *flags |= NSF_PC_MUST_DECR; result = ArgumentCheckHelper(interp, objPtr, pPtr, flags, clientData, outObjPtr); break; @@ -15025,7 +15043,7 @@ assert(pPtr->type ? pPtr->defaultValue == NULL : 1); } } else if (pPtr->flags & NSF_ARG_REQUIRED) { - Tcl_Obj *paramDefsObj = NsfParamDefsSyntax(ifd); + Tcl_Obj *paramDefsObj = NsfParamDefsSyntax(INTERP ifd); NsfPrintError(interp, "required argument '%s' is missing, should be:\n\t%s%s%s %s", pPtr->nameObj ? ObjStr(pPtr->nameObj) : pPtr->name, @@ -15083,7 +15101,7 @@ int i, o, flagCount, dashdash = 0, nrDashdash = 0; Nsf_Param CONST *pPtr; - ParseContextInit(pcPtr, nrParams, object, objv[0]); + ParseContextInit(INTERP pcPtr, nrParams, object, objv[0]); #if defined(PARSE_TRACE) fprintf(stderr, "PARAMETER "); @@ -15374,7 +15392,7 @@ Tcl_DStringAppend(dsPtr, "', maybe too many arguments;", -1); NsfArgumentError(interp, Tcl_DStringValue(dsPtr), paramPtr, object ? object->cmdName : NULL, - procNameObj); + procNameObj); // aaaa DSTRING_FREE(dsPtr); return TCL_ERROR; } @@ -15464,7 +15482,7 @@ case NSF_PARAMS_PARAMETER: listObj = ParamDefsFormat(interp, paramsPtr); break; case NSF_PARAMS_LIST: listObj = ParamDefsList(interp, paramsPtr); break; case NSF_PARAMS_NAMES: listObj = ParamDefsNames(interp, paramsPtr); break; - case NSF_PARAMS_SYNTAX: listObj = NsfParamDefsSyntax(paramsPtr); break; + case NSF_PARAMS_SYNTAX: listObj = NsfParamDefsSyntax(INTERP paramsPtr); break; default: listObj = NULL; } @@ -16287,7 +16305,7 @@ if ((childObject = GetObjectFromString(interp, pattern)) && (!classesOnly || NsfObjectIsClass(childObject)) && - (!type || IsSubType(childObject->cl, type)) && + (!type || IsSubType(INTERP childObject->cl, type)) && (Tcl_Command_nsPtr(childObject->id) == object->nsPtr) /* true children */ ) { Tcl_SetObjResult(interp, childObject->cmdName); @@ -16316,7 +16334,7 @@ if ((childObject = NsfGetObjectFromCmdPtr(cmd)) && (!classesOnly || NsfObjectIsClass(childObject)) && - (!type || IsSubType(childObject->cl, type)) && + (!type || IsSubType(INTERP childObject->cl, type)) && (Tcl_Command_nsPtr(childObject->id) == object->nsPtr) /* true children */ ) { Tcl_ListObjAppendElement(interp, list, childObject->cmdName); @@ -16451,13 +16469,13 @@ } if (withClosure) { - NsfClasses *pl = ComputeOrder(cl, cl->order, Super); + NsfClasses *pl = ComputeOrder(INTERP cl, cl->order, Super); if (pl) pl=pl->nextPtr; rc = AppendMatchingElementsFromClasses(interp, pl, patternString, matchObject); } else { - NsfClasses *clSuper = NsfReverseClasses(cl->super); + NsfClasses *clSuper = NsfReverseClasses(INTERP cl->super); rc = AppendMatchingElementsFromClasses(interp, clSuper, patternString, matchObject); - NsfClassListFree(clSuper); + NsfClassListFree(INTERP clSuper); } if (matchObject) { @@ -16564,7 +16582,7 @@ */ /*fprintf(stderr, "remove alias %s to %s\n", Tcl_GetCommandName(interp, cmd), ObjectName(referencedObject));*/ - NsfCleanupObject(referencedObject, "AliasDeleteObjectReference"); + NsfCleanupObject(INTERP referencedObject, "AliasDeleteObjectReference"); Tcl_DeleteCommandFromToken(interp, cmd); return 1; } @@ -16960,10 +16978,10 @@ } */ static int -NsfInvalidateObjectParameterCmd(Tcl_Interp *UNUSED(interp), NsfClass *cl) { +NsfInvalidateObjectParameterCmd(Tcl_Interp *interp, NsfClass *cl) { if (cl->parsedParamPtr) { /*fprintf(stderr, " %s invalidate %p\n", ClassName(cl), cl->parsedParamPtr);*/ - ParsedParamFree(cl->parsedParamPtr); + ParsedParamFree(INTERP cl->parsedParamPtr); cl->parsedParamPtr = NULL; } return TCL_OK; @@ -17105,7 +17123,7 @@ if (newObjProc) { /* add a wrapper */ /*fprintf(stderr, "NsfMethodAliasCmd cmd %p\n", cmd);*/ - NsfCommandPreserve(cmd); + NsfCommandPreserve(INTERP cmd); tcd = NEW(AliasCmdClientData); tcd->cmdName = object->cmdName; tcd->interp = interp; /* just for deleting the associated variable */ @@ -17114,6 +17132,7 @@ tcd->objProc = objProc; tcd->aliasedCmd = cmd; tcd->clientData = Tcl_Command_objClientData(cmd); + objProc = newObjProc; deleteProc = AliasCmdDeleteProc; if (tcd->cmdName) {INCR_REF_COUNT(tcd->cmdName);} @@ -17204,7 +17223,7 @@ case AssertionsubcmdObject_invarIdx: if (arg) { - NsfObjectOpt *opt = NsfRequireObjectOpt(object); + NsfObjectOpt *opt = NsfRequireObjectOpt(INTERP object); AssertionSetInvariants(interp, &opt->assertions, arg); } else { if (object->opt && object->opt->assertions) { @@ -17216,7 +17235,7 @@ case AssertionsubcmdClass_invarIdx: class = (NsfClass *)object; if (arg) { - NsfClassOpt *opt = NsfRequireClassOpt(class); + NsfClassOpt *opt = NsfRequireClassOpt(INTERP class); AssertionSetInvariants(interp, &opt->assertions, arg); } else { if (class->opt && class->opt->assertions) { @@ -17447,8 +17466,8 @@ if (paramDefs == NULL) { /* acquire new paramDefs */ - paramDefs = ParamDefsNew(); - ParamDefsStore(cmd, paramDefs); + paramDefs = ParamDefsNew(INTERP1); + ParamDefsStore(INTERP cmd, paramDefs); /*fprintf(stderr, "new param defs %p for cmd %p %s\n", paramDefs, cmd, methodName);*/ } objPtr = @@ -17524,6 +17543,7 @@ setterClientData = NEW(SetterCmdClientData); setterClientData->object = NULL; setterClientData->paramsPtr = NULL; + INTERP_MEMBER_SET(setterClientData, interp) length = strlen(methodName); for (j=0; jparamsPtr = ParamsNew(1); + setterClientData->paramsPtr = ParamsNew(INTERP 1); result = ParamParse(interp, NsfGlobalObjs[NSF_SETTER], parameter, NSF_DISALLOWED_ARG_SETTER|NSF_ARG_HAS_DEFAULT, setterClientData->paramsPtr, &possibleUnknowns, @@ -17842,7 +17862,7 @@ AddInstance((NsfObject *)theobj, thecls); AddInstance((NsfObject *)thecls, thecls); - AddSuper(thecls, theobj); + AddSuper(INTERP thecls, theobj); if (NSF_DTRACE_OBJECT_ALLOC_ENABLED()) { NSF_DTRACE_OBJECT_ALLOC(ObjectName(((NsfObject *)theobj)), ClassName(((NsfObject *)theobj)->cl)); @@ -18075,7 +18095,7 @@ Tcl_DStringAppendElement(dsPtr, StripBodyPrefix(ObjStr(procPtr->bodyPtr))); #if defined(NSF_WITH_ASSERTIONS) if (procs) { - NsfRequireClassOpt(cl); + NsfRequireClassOpt(INTERP cl); AssertionAppendPrePost(interp, dsPtr, procs); } #endif @@ -18109,7 +18129,7 @@ Tcl_DStringAppendElement(dsPtr, StripBodyPrefix(ObjStr(procPtr->bodyPtr))); #if defined(NSF_WITH_ASSERTIONS) if (procs) { - NsfRequireObjectOpt(object); + NsfRequireObjectOpt(INTERP object); AssertionAppendPrePost(interp, dsPtr, procs); } #endif @@ -18360,7 +18380,7 @@ if (Tcl_ListObjGetElements(interp, valueObj, &oc, &ov) != TCL_OK) { return TCL_ERROR; } - objopt = NsfRequireObjectOpt(object); + objopt = NsfRequireObjectOpt(INTERP object); break; case RelationtypeClass_mixinIdx: @@ -18379,7 +18399,7 @@ if (Tcl_ListObjGetElements(interp, valueObj, &oc, &ov) != TCL_OK) { return TCL_ERROR; } - clopt = NsfRequireClassOpt(cl); + clopt = NsfRequireClassOpt(INTERP cl); break; case RelationtypeSuperclassIdx: @@ -18442,7 +18462,7 @@ for (i = 0; i < oc; i++) { if (MixinAdd(interp, &newMixinCmdList, ov[i], object->cl->object.cl) != TCL_OK) { - CmdListRemoveList(&newMixinCmdList, GuardDel); + CmdListRemoveList(INTERP &newMixinCmdList, GuardDel); return TCL_ERROR; } } @@ -18458,11 +18478,11 @@ /* fprintf(stderr, "Removing object %s from isObjectMixinOf of class %s\n", ObjectName(object), ObjStr(NsfGetClassFromCmdPtr(cmdlist->cmdPtr)->object.cmdName)); */ del = CmdListRemoveFromList(&clopt->isObjectMixinOf, del); - CmdListDeleteCmdListEntry(del, GuardDel); + CmdListDeleteCmdListEntry(INTERP del, GuardDel); } } } - CmdListRemoveList(&objopt->mixins, GuardDel); + CmdListRemoveList(INTERP &objopt->mixins, GuardDel); } object->flags &= ~NSF_MIXIN_ORDER_VALID; @@ -18484,8 +18504,8 @@ if (nObject) { /* fprintf(stderr, "Registering object %s to isObjectMixinOf of class %s\n", ObjectName(object), ObjectName(nObject)); */ - nclopt = NsfRequireClassOpt((NsfClass *)nObject); - CmdListAdd(&nclopt->isObjectMixinOf, object->id, NULL, /*noDuplicates*/ 1); + nclopt = NsfRequireClassOpt(INTERP (NsfClass *)nObject); + CmdListAdd(INTERP &nclopt->isObjectMixinOf, object->id, NULL, /*noDuplicates*/ 1); } /* else fprintf(stderr, "Problem registering %s as a mixinof of %s\n", ObjStr(ov[i]), ClassName(cl)); */ } @@ -18499,7 +18519,7 @@ case RelationtypeObject_filterIdx: if (objopt->filters) { - CmdListRemoveList(&objopt->filters, GuardDel); + CmdListRemoveList(INTERP &objopt->filters, GuardDel); } object->flags &= ~NSF_FILTER_ORDER_VALID; for (i = 0; i < oc; i ++) { @@ -18516,13 +18536,13 @@ for (i = 0; i < oc; i++) { if (MixinAdd(interp, &newMixinCmdList, ov[i], cl->object.cl) != TCL_OK) { - CmdListRemoveList(&newMixinCmdList, GuardDel); + CmdListRemoveList(INTERP &newMixinCmdList, GuardDel); return TCL_ERROR; } } if (clopt->classmixins) { - RemoveFromClassMixinsOf(cl->object.id, clopt->classmixins); - CmdListRemoveList(&clopt->classmixins, GuardDel); + RemoveFromClassMixinsOf(INTERP cl->object.id, clopt->classmixins); + CmdListRemoveList(INTERP &clopt->classmixins, GuardDel); } MixinInvalidateObjOrders(interp, cl); @@ -18542,8 +18562,8 @@ if (nObject) { /* fprintf(stderr, "Registering class %s to isClassMixinOf of class %s\n", ClassName(cl), ObjectName(nObject)); */ - nclopt = NsfRequireClassOpt((NsfClass *) nObject); - CmdListAdd(&nclopt->isClassMixinOf, cl->object.id, NULL, /*noDuplicates*/ 1); + nclopt = NsfRequireClassOpt(INTERP (NsfClass *) nObject); + CmdListAdd(INTERP &nclopt->isClassMixinOf, cl->object.id, NULL, /*noDuplicates*/ 1); } /* else fprintf(stderr, "Problem registering %s as a class-mixin of %s\n", ObjStr(ov[i]), ClassName(cl)); */ } @@ -18553,7 +18573,7 @@ case RelationtypeClass_filterIdx: if (clopt->classfilters) { - CmdListRemoveList(&clopt->classfilters, GuardDel); + CmdListRemoveList(INTERP &clopt->classfilters, GuardDel); } FilterInvalidateObjOrders(interp, cl); for (i = 0; i < oc; i ++) { @@ -18862,6 +18882,7 @@ Nsf_Param *paramPtr; int refCount; int canFree; + INTERP_DECL1; } NsfParamWrapper; static Tcl_DupInternalRepProc ParamDupInteralRep; @@ -18900,9 +18921,10 @@ /* fprintf(stderr, "ParamFreeInternalRep freeing wrapper %p paramPtr %p refCount %dcanFree %d\n", paramWrapperPtr, paramWrapperPtr->paramPtr, paramWrapperPtr->refCount, paramWrapperPtr->canFree);*/ + INTERP_MEMBER_GET(paramWrapperPtr) if (paramWrapperPtr->canFree) { - ParamsFree(paramWrapperPtr->paramPtr); + ParamsFree(INTERP paramWrapperPtr->paramPtr); FREE(NsfParamWrapper, paramWrapperPtr); } else { paramWrapperPtr->refCount--; @@ -18938,9 +18960,10 @@ int result, possibleUnknowns = 0, plainParams = 0, nrNonposArgs = 0; NsfParamWrapper *paramWrapperPtr = NEW(NsfParamWrapper); - paramWrapperPtr->paramPtr = ParamsNew(1); + paramWrapperPtr->paramPtr = ParamsNew(INTERP 1); paramWrapperPtr->refCount = 1; paramWrapperPtr->canFree = 0; + INTERP_MEMBER_SET(paramWrapperPtr, interp) /*fprintf(stderr, "allocating %p\n", paramWrapperPtr->paramPtr);*/ Tcl_AppendLimitedToObj(fullParamObj, ObjStr(objPtr), -1, INT_MAX, NULL); @@ -18978,7 +19001,7 @@ /* * In error cases, free manually memory allocated by this function. */ - ParamsFree(paramWrapperPtr->paramPtr); + ParamsFree(INTERP paramWrapperPtr->paramPtr); FREE(NsfParamWrapper, paramWrapperPtr); } @@ -19073,7 +19096,7 @@ ppDefPtr->possibleUnknowns = parsedParamPtr->possibleUnknowns; class->parsedParamPtr = ppDefPtr; if (ppDefPtr->paramDefs) { - ParamDefsRefCountIncr(ppDefPtr->paramDefs); + ParamDefsRefCountIncr(INTERP ppDefPtr->paramDefs); } } DECR_REF_COUNT(rawConfArgs); @@ -19145,7 +19168,7 @@ if (paramWrapperPtr->refCount == 0) { fprintf(stderr, "#### ParamSetFromAny2 paramPtr %p manual free\n", paramPtr); - ParamsFree(paramWrapperPtr->paramPtr); + ParamsFree(INTERP paramWrapperPtr->paramPtr); FREE(NsfParamWrapper, paramWrapperPtr); } else { paramWrapperPtr->canFree = 1; @@ -19307,7 +19330,7 @@ /* Process the actual arguments based on the parameter definitions */ paramDefs = parsedParam.paramDefs; - ParamDefsRefCountIncr(paramDefs); + ParamDefsRefCountIncr(INTERP paramDefs); result = ProcessMethodArguments(&pc, interp, object, 0, paramDefs, NsfGlobalObjs[NSF_CONFIGURE], objc, objv); @@ -19402,7 +19425,7 @@ Tcl_Interp_varFramePtr(interp) = varFramePtr->callerVarPtr; cscPtr->flags = 0; - CscInit(cscPtr, object, object->cl /*cl*/, NULL /*cmd*/, + CscInit(INTERP cscPtr, object, object->cl /*cl*/, NULL /*cmd*/, NSF_CSC_TYPE_PLAIN, 0, NsfGlobalStrings[NSF_CONFIGURE]); Nsf_PushFrameCsc(interp, cscPtr, framePtr2); @@ -19623,8 +19646,8 @@ configure_exit: - ParamDefsRefCountDecr(paramDefs); - ParseContextRelease(&pc); + ParamDefsRefCountDecr(INTERP paramDefs); + ParseContextRelease(INTERP &pc); return result; } @@ -19713,9 +19736,9 @@ NsfCmdList *h = CmdListFindNameInList(interp, filter, opt->filters); if (h) { if (h->clientData) { - GuardDel((NsfCmdList *) h); + GuardDel(INTERP (NsfCmdList *) h); } - GuardAdd(h, guardObj); + GuardAdd(INTERP h, guardObj); object->flags &= ~NSF_FILTER_ORDER_VALID; return TCL_OK; } @@ -19770,9 +19793,9 @@ NsfCmdList *h = CmdListFindCmdInList(mixinCmd, opt->mixins); if (h) { if (h->clientData) { - GuardDel((NsfCmdList *) h); + GuardDel(INTERP (NsfCmdList *) h); } - GuardAdd(h, guardObj); + GuardAdd(INTERP h, guardObj); object->flags &= ~NSF_MIXIN_ORDER_VALID; return TCL_OK; } @@ -20024,7 +20047,7 @@ vn = NSTail(fullName); if (Tcl_SetVar2(interp, vn, NULL, fullName, 0)) { - NsfObjectOpt *opt = NsfRequireObjectOpt(object); + NsfObjectOpt *opt = NsfRequireObjectOpt(INTERP object); /*fprintf(stderr, "### setting trace for %s on frame %p\n", fullName, Tcl_Interp_varFramePtr(interp)); @@ -20317,9 +20340,9 @@ NsfCmdList *h = CmdListFindNameInList(interp, filter, opt->classfilters); if (h) { if (h->clientData) { - GuardDel(h); + GuardDel(INTERP h); } - GuardAdd(h, guardObj); + GuardAdd(INTERP h, guardObj); FilterInvalidateObjOrders(interp, cl); return TCL_OK; } @@ -20349,9 +20372,9 @@ NsfCmdList *h = CmdListFindCmdInList(mixinCmd, opt->classmixins); if (h) { if (h->clientData) { - GuardDel((NsfCmdList *) h); + GuardDel(INTERP (NsfCmdList *) h); } - GuardAdd(h, guardObj); + GuardAdd(INTERP h, guardObj); MixinInvalidateObjOrders(interp, cl); return TCL_OK; } @@ -20649,7 +20672,7 @@ */ static int NsfObjInfoHasTypeMethod(Tcl_Interp *interp, NsfObject *object, NsfClass *typeClass) { - Tcl_SetBooleanObj(Tcl_GetObjResult(interp), IsSubType(object->cl, typeClass)); + Tcl_SetBooleanObj(Tcl_GetObjResult(interp), IsSubType(INTERP object->cl, typeClass)); return TCL_OK; } @@ -20815,7 +20838,7 @@ } /* append method keys from inheritance order */ - for (pl = ComputeOrder(object->cl, object->cl->order, Super); pl; pl = pl->nextPtr) { + for (pl = ComputeOrder(INTERP object->cl, object->cl->order, Super); pl; pl = pl->nextPtr) { Tcl_HashTable *cmdTablePtr = Tcl_Namespace_cmdTablePtr(pl->cl->nsPtr); if (!MethodSourceMatches(withSource, pl->cl, NULL)) continue; ListMethodKeys(interp, cmdTablePtr, NULL, pattern, methodType, @@ -20868,7 +20891,7 @@ Tcl_DeleteHashTable(&slotTable); MEM_COUNT_FREE("Tcl_InitHashTable", &slotTable); - NsfClassListFree(precendenceList); + NsfClassListFree(INTERP precendenceList); Tcl_SetObjResult(interp, listObj); return TCL_OK; @@ -20987,7 +21010,7 @@ for (pl = precedenceList; pl; pl = pl->nextPtr) { Tcl_ListObjAppendElement(interp, resultObj, pl->cl->object.cmdName); } - NsfClassListFree(precedenceList); + NsfClassListFree(INTERP precedenceList); Tcl_SetObjResult(interp, resultObj); return TCL_OK; @@ -21095,7 +21118,7 @@ Tcl_Obj *resultObj; resultObj = Tcl_NewObj(); - intrinsic = ComputeOrder(cl, cl->order, Super); + intrinsic = ComputeOrder(INTERP cl, cl->order, Super); NsfClassListAddPerClassMixins(interp, cl, &mixinClasses, &checkList); for (pl = mixinClasses; pl; pl = pl->nextPtr) { @@ -21111,8 +21134,8 @@ } } - NsfClassListFree(mixinClasses); - NsfClassListFree(checkList); + NsfClassListFree(INTERP mixinClasses); + NsfClassListFree(INTERP checkList); Tcl_SetObjResult(interp, resultObj); return TCL_OK; @@ -21254,8 +21277,8 @@ AppendMatchingElement(interp, resultObj, clPtr->cl->object.cmdName, patternString); } - NsfClassListFree(checkList); - NsfClassListFree(mixinClasses); + NsfClassListFree(INTERP checkList); + NsfClassListFree(INTERP mixinClasses); } else if (withClosure) { Tcl_HashTable objTable, *commandTable = &objTable; @@ -21414,7 +21437,7 @@ listObj = ParamDefsFormat(interp, paramsPtr); break; case InfoobjectparametersubcmdParametersyntaxIdx: - listObj = NsfParamDefsSyntax(paramsPtr); + listObj = NsfParamDefsSyntax(INTERP paramsPtr); break; } Tcl_SetObjResult(interp, listObj); @@ -21440,7 +21463,7 @@ Tcl_HashTable slotTable; Tcl_ResetResult(interp); - intrinsic = ComputeOrder(class, class->order, Super); + intrinsic = ComputeOrder(INTERP class, class->order, Super); if (withClosure) { NsfClasses *checkList = NULL, *mixinClasses = NULL; @@ -21451,21 +21474,21 @@ for (clPtr = mixinClasses; clPtr; clPtr = clPtr->nextPtr) { if (NsfClassListFind(clPtr->nextPtr, clPtr->cl) == NULL && NsfClassListFind(intrinsic, clPtr->cl) == NULL) { - NsfClassListAdd(&precedenceList, clPtr->cl, NULL); + NsfClassListAdd(INTERP &precedenceList, clPtr->cl, NULL); } } /* * ... followed by the intrinsic classes */ - NsfClassListAdd(&precedenceList, class, NULL); + NsfClassListAdd(INTERP &precedenceList, class, NULL); for (clPtr = intrinsic->nextPtr; clPtr; clPtr = clPtr->nextPtr) { - NsfClassListAdd(&precedenceList, clPtr->cl, NULL); + NsfClassListAdd(INTERP &precedenceList, clPtr->cl, NULL); } - NsfClassListFree(checkList); - NsfClassListFree(mixinClasses); + NsfClassListFree(INTERP checkList); + NsfClassListFree(INTERP mixinClasses); } else { - NsfClassListAdd(&precedenceList, class, NULL); + NsfClassListAdd(INTERP &precedenceList, class, NULL); } /* NsfClassListPrint("precedence", precedenceList);*/ if (withSource == 0) {withSource = 1;} @@ -21486,7 +21509,7 @@ Tcl_DeleteHashTable(&slotTable); MEM_COUNT_FREE("Tcl_InitHashTable", &slotTable); - NsfClassListFree(precedenceList); + NsfClassListFree(INTERP precedenceList); Tcl_SetObjResult(interp, listObj); return TCL_OK; @@ -21506,11 +21529,11 @@ if (withClosure) { NsfClasses *saved = class->order, *subclasses; class->order = NULL; - subclasses = ComputeOrder(class, class->order, Sub); + subclasses = ComputeOrder(INTERP class, class->order, Sub); class->order = saved; rc = AppendMatchingElementsFromClasses(interp, subclasses ? subclasses->nextPtr : NULL, patternString, patternObj); - NsfClassListFree(subclasses); + NsfClassListFree(INTERP subclasses); } else { rc = AppendMatchingElementsFromClasses(interp, class->sub, patternString, patternObj); } @@ -21956,15 +21979,15 @@ #endif FREE(Tcl_Obj**, NsfGlobalObjs); - FREE(NsfRuntimeState, RUNTIME_STATE(interp)); #if defined(TCL_MEM_DEBUG) TclDumpMemoryInfo((ClientData) stderr, 0); Tcl_DumpActiveMemory("./nsfActiveMem"); /* Tcl_GlobalEval(interp, "puts {checkmem to checkmemFile}; checkmem checkmemFile"); */ #endif - MEM_COUNT_DUMP(); + MEM_COUNT_RELEASE(interp); + ckfree(RUNTIME_STATE(interp)); Tcl_Interp_flags(interp) = flags; Tcl_Release(interp); @@ -22036,9 +22059,28 @@ TclDumpMemoryInfo((ClientData) stderr, 0); #endif - MEM_COUNT_INIT(); + /* + * Runtime State stored in the client data of the Interp's global namespace + * in order to avoid global state information. All fields are per default + * set to zero. + */ + runtimeState = ckalloc(sizeof(NsfRuntimeState)); + memset(runtimeState, 0, sizeof(NsfRuntimeState)); +#if USE_ASSOC_DATA + Tcl_SetAssocData(interp, "NsfRuntimeState", NULL, runtimeState); +#else + Tcl_Interp_globalNsPtr(interp)->clientData = runtimeState; +#endif + /* + * If MEM_COUNT is activated, the tables have to be initialized before the + * first call to the MEM_COUNT macros (including e.g. INCR_REF_COUNT), but + * it requires that the runtimeState is already associated with the interp. + */ + MEM_COUNT_INIT(interp); + + /* * Init global variables for Tcl_Obj types */ NsfMutexLock(&initMutex); @@ -22070,20 +22112,7 @@ sizeof(Namespace), sizeof(Command), sizeof(Tcl_HashTable)); */ - /* - * Runtime State stored in the client data of the Interp's global namespace - * in order to avoid global state information. All fields are per default - * set to zero. - */ - runtimeState = NEW(NsfRuntimeState); - memset(runtimeState, 0, sizeof(NsfRuntimeState)); -#if USE_ASSOC_DATA - Tcl_SetAssocData(interp, "NsfRuntimeState", NULL, runtimeState); -#else - Tcl_Interp_globalNsPtr(interp)->clientData = runtimeState; -#endif - #if defined(NSF_PROFILE) NsfProfileInit(interp); #endif Index: generic/nsf.decls =================================================================== diff -u -r58e11ae3135406567181a97b8eac0d88e179a897 -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- generic/nsf.decls (.../nsf.decls) (revision 58e11ae3135406567181a97b8eac0d88e179a897) +++ generic/nsf.decls (.../nsf.decls) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -77,16 +77,16 @@ void NsfStackDump (Tcl_Interp *interp) } declare 16 generic { - void NsfSetObjClientData(Nsf_Object *object, ClientData data) + void NsfSetObjClientData(Tcl_Interp *interp, Nsf_Object *object, ClientData data) } declare 17 generic { - ClientData NsfGetObjClientData(Nsf_Object *object) + ClientData NsfGetObjClientData(Tcl_Interp *interp, Nsf_Object *object) } declare 18 generic { - void NsfSetClassClientData(Nsf_Class *cl, ClientData data) + void NsfSetClassClientData(Tcl_Interp *interp, Nsf_Class *cl, ClientData data) } declare 19 generic { - ClientData NsfGetClassClientData(Nsf_Class *cl) + ClientData NsfGetClassClientData(Tcl_Interp *interp, Nsf_Class *cl) } declare 20 generic { void NsfRequireObjNamespace(Tcl_Interp *interp, Nsf_Object *object) Index: generic/nsfDecls.h =================================================================== diff -u -r6889109b1238e52796b59d0f35b81e00f9f268cf -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- generic/nsfDecls.h (.../nsfDecls.h) (revision 6889109b1238e52796b59d0f35b81e00f9f268cf) +++ generic/nsfDecls.h (.../nsfDecls.h) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -117,23 +117,26 @@ #ifndef NsfSetObjClientData_TCL_DECLARED #define NsfSetObjClientData_TCL_DECLARED /* 16 */ -EXTERN void NsfSetObjClientData(Nsf_Object *object, - ClientData data); +EXTERN void NsfSetObjClientData(Tcl_Interp *interp, + Nsf_Object *object, ClientData data); #endif #ifndef NsfGetObjClientData_TCL_DECLARED #define NsfGetObjClientData_TCL_DECLARED /* 17 */ -EXTERN ClientData NsfGetObjClientData(Nsf_Object *object); +EXTERN ClientData NsfGetObjClientData(Tcl_Interp *interp, + Nsf_Object *object); #endif #ifndef NsfSetClassClientData_TCL_DECLARED #define NsfSetClassClientData_TCL_DECLARED /* 18 */ -EXTERN void NsfSetClassClientData(Nsf_Class *cl, ClientData data); +EXTERN void NsfSetClassClientData(Tcl_Interp *interp, + Nsf_Class *cl, ClientData data); #endif #ifndef NsfGetClassClientData_TCL_DECLARED #define NsfGetClassClientData_TCL_DECLARED /* 19 */ -EXTERN ClientData NsfGetClassClientData(Nsf_Class *cl); +EXTERN ClientData NsfGetClassClientData(Tcl_Interp *interp, + Nsf_Class *cl); #endif #ifndef NsfRequireObjNamespace_TCL_DECLARED #define NsfRequireObjNamespace_TCL_DECLARED @@ -197,10 +200,10 @@ int (*nsfErrInProc) (Tcl_Interp *interp, Tcl_Obj *objName, Tcl_Obj *clName, CONST char *procName); /* 13 */ int (*nsfObjErrType) (Tcl_Interp *interp, CONST char *context, Tcl_Obj *value, CONST char *type, Nsf_Param CONST *pPtr); /* 14 */ void (*nsfStackDump) (Tcl_Interp *interp); /* 15 */ - void (*nsfSetObjClientData) (Nsf_Object *object, ClientData data); /* 16 */ - ClientData (*nsfGetObjClientData) (Nsf_Object *object); /* 17 */ - void (*nsfSetClassClientData) (Nsf_Class *cl, ClientData data); /* 18 */ - ClientData (*nsfGetClassClientData) (Nsf_Class *cl); /* 19 */ + void (*nsfSetObjClientData) (Tcl_Interp *interp, Nsf_Object *object, ClientData data); /* 16 */ + ClientData (*nsfGetObjClientData) (Tcl_Interp *interp, Nsf_Object *object); /* 17 */ + void (*nsfSetClassClientData) (Tcl_Interp *interp, Nsf_Class *cl, ClientData data); /* 18 */ + ClientData (*nsfGetClassClientData) (Tcl_Interp *interp, Nsf_Class *cl); /* 19 */ void (*nsfRequireObjNamespace) (Tcl_Interp *interp, Nsf_Object *object); /* 20 */ int (*nsfCallMethodWithArgs) (Tcl_Interp *interp, Nsf_Object *object, Tcl_Obj *method, Tcl_Obj *arg, int objc, Tcl_Obj *CONST objv[], int flags); /* 21 */ int (*nsfAddObjectMethod) (Tcl_Interp *interp, struct Nsf_Object *object, CONST char *nm, Tcl_ObjCmdProc *proc, ClientData cd, Tcl_CmdDeleteProc *dp, int flags); /* 22 */ Index: generic/nsfError.c =================================================================== diff -u -r9addecef4701fd68a81b54714a370a9de3eb25f3 -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- generic/nsfError.c (.../nsfError.c) (revision 9addecef4701fd68a81b54714a370a9de3eb25f3) +++ generic/nsfError.c (.../nsfError.c) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -12,7 +12,7 @@ */ #include "nsfInt.h" -Tcl_Obj *NsfParamDefsSyntax(Nsf_Param CONST *paramPtr); +Tcl_Obj *NsfParamDefsSyntax(INTERP_DECL Nsf_Param CONST *paramPtr); /* *---------------------------------------------------------------------- @@ -208,7 +208,7 @@ extern int NsfArgumentError(Tcl_Interp *interp, CONST char *errorMsg, Nsf_Param CONST *paramPtr, Tcl_Obj *cmdNameObj, Tcl_Obj *methodObj) { - Tcl_Obj *argStringObj = NsfParamDefsSyntax(paramPtr); + Tcl_Obj *argStringObj = NsfParamDefsSyntax(INTERP paramPtr); NsfObjWrongArgs(interp, errorMsg, cmdNameObj, methodObj, ObjStr(argStringObj)); DECR_REF_COUNT2("paramDefsObj", argStringObj); Index: generic/nsfInt.h =================================================================== diff -u -r9addecef4701fd68a81b54714a370a9de3eb25f3 -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- generic/nsfInt.h (.../nsfInt.h) (revision 9addecef4701fd68a81b54714a370a9de3eb25f3) +++ generic/nsfInt.h (.../nsfInt.h) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -92,27 +92,27 @@ int peak; int count; } NsfMemCounter; -# define MEM_COUNT_ALLOC(id,p) NsfMemCountAlloc(id,p) -# define MEM_COUNT_FREE(id,p) NsfMemCountFree(id,p) -# define MEM_COUNT_INIT() \ - if (nsfMemCountInterpCounter == 0) { \ - extern Tcl_HashTable nsfMemCount; \ - Tcl_InitHashTable(&nsfMemCount, TCL_STRING_KEYS); \ - nsfMemCountInterpCounter = 1; \ - } -# define MEM_COUNT_DUMP() NsfMemCountDump(interp) -# define MEM_COUNT_OPEN_FRAME() -/*if (obj->varTable) noTableBefore = 0*/ -# define MEM_COUNT_CLOSE_FRAME() -/* if (obj->varTable && noTableBefore) \ - NsfMemCountAlloc("obj->varTable",NULL)*/ +# define INTERP interp, +# define INTERP1 interp +# define INTERP_DECL Tcl_Interp *interp, +# define INTERP_DECL1 Tcl_Interp *interp +# define INTERP_MEMBER_GET(ptr) Tcl_Interp *interp = (ptr)->interp; +# define INTERP_MEMBER_SET(ptr, value) (ptr)->interp = (value); +# define MEM_COUNT_ALLOC(id,p) NsfMemCountAlloc(interp, id, p) +# define MEM_COUNT_FREE(id,p) NsfMemCountFree(interp, id, p) +# define MEM_COUNT_INIT(interp) NsfMemCountInit(interp) +# define MEM_COUNT_RELEASE(interp) NsfMemCountRelease(interp) #else +# define INTERP +# define INTERP1 +# define INTERP_DECL +# define INTERP_DECL1 +# define INTERP_MEMBER_GET(ptr) +# define INTERP_MEMBER_SET(ptr, value) # define MEM_COUNT_ALLOC(id,p) # define MEM_COUNT_FREE(id,p) -# define MEM_COUNT_INIT() -# define MEM_COUNT_DUMP() -# define MEM_COUNT_OPEN_FRAME() -# define MEM_COUNT_CLOSE_FRAME() +# define MEM_COUNT_INIT(interp) +# define MEM_COUNT_RELEASE(interp) #endif /* @@ -339,7 +339,7 @@ struct NsfCmdList *nextPtr; } NsfCmdList; -typedef void (NsfFreeCmdListClientData) _ANSI_ARGS_((NsfCmdList*)); +typedef void (NsfFreeCmdListClientData) _ANSI_ARGS_((INTERP_DECL NsfCmdList*)); /* for incr string */ typedef struct NsfStringIncrStruct { @@ -540,6 +540,7 @@ Tcl_Command cmd; NsfParamDefs *paramDefs; int with_ad; + INTERP_DECL1; } NsfProcClientData; typedef enum SystemMethodsIdx { @@ -792,6 +793,9 @@ NsfStringIncrStruct iss; /* used for new to create new symbols */ short guardCount; /* keep track of guard invocations */ ClientData clientData; +#if defined(NSF_MEM_COUNT) + Tcl_HashTable memCountTable; +#endif } NsfRuntimeState; #define NSF_EXITHANDLER_OFF 0 @@ -858,9 +862,9 @@ * MEM Counting */ #ifdef NSF_MEM_COUNT -void NsfMemCountAlloc(char *id, void *); -void NsfMemCountFree(char *id, void *); -void NsfMemCountDump(); +void NsfMemCountAlloc(Tcl_Interp *interp, char *id, void *); +void NsfMemCountFree(Tcl_Interp *interp, char *id, void *); +void NsfMemCountRelease(Tcl_Interp *interp); #endif /* NSF_MEM_COUNT */ /* Index: generic/nsfObj.c =================================================================== diff -u -r9addecef4701fd68a81b54714a370a9de3eb25f3 -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- generic/nsfObj.c (.../nsfObj.c) (revision 9addecef4701fd68a81b54714a370a9de3eb25f3) +++ generic/nsfObj.c (.../nsfObj.c) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -29,6 +29,7 @@ typedef struct { NsfClass *mixin; Tcl_Obj *guardObj; + INTERP_DECL1; } MixinReg; static Tcl_FreeInternalRepProc MixinregFreeInternalRep; @@ -53,6 +54,8 @@ MixinReg *mixinRegPtr = (MixinReg *)objPtr->internalRep.twoPtrValue.ptr1; if (mixinRegPtr != NULL) { + INTERP_MEMBER_GET(mixinRegPtr) + /*fprintf(stderr, "MixinregFreeInternalRep freeing mixinReg %p class %p guard %p\n", mixinRegPtr, mixinRegPtr->class, mixinRegPtr->guardObj);*/ /* @@ -107,15 +110,16 @@ * Allocate structure ... */ mixinRegPtr = NEW(MixinReg); + + mixinRegPtr->mixin = mixin; + mixinRegPtr->guardObj = guardObj; + INTERP_MEMBER_SET(mixinRegPtr, interp) /* * ... and increment refCounts */ NsfObjectRefCountIncr((&mixin->object)); if (guardObj) {INCR_REF_COUNT2("mixinRegPtr->guardObj", guardObj);} - mixinRegPtr->mixin = mixin; - mixinRegPtr->guardObj = guardObj; - /*fprintf(stderr, "MixinregSetFromAny alloc mixinReg %p class %p guard %p\n", mixinRegPtr, mixinRegPtr->mixin, mixinRegPtr->guardObj);*/ @@ -178,6 +182,7 @@ typedef struct { Tcl_Obj *filterObj; Tcl_Obj *guardObj; + INTERP_DECL1; } Filterreg; static Tcl_FreeInternalRepProc FilterregFreeInternalRep; @@ -203,6 +208,8 @@ Filterreg *filterregPtr = (Filterreg *)objPtr->internalRep.twoPtrValue.ptr1; if (filterregPtr != NULL) { + INTERP_MEMBER_GET(filterregPtr) + /*fprintf(stderr, "FilterregFreeInternalRep freeing filterreg %p class %p guard %p\n", filterregPtr, filterregPtr->class, filterregPtr->guardObj);*/ /* @@ -250,15 +257,16 @@ */ filterregPtr = NEW(Filterreg); + filterregPtr->filterObj = filterObj; + filterregPtr->guardObj = guardObj; + INTERP_MEMBER_SET(filterregPtr, interp) + /* * ... and increment refCounts */ INCR_REF_COUNT2("filterregPtr->filterObj", filterObj); if (guardObj) {INCR_REF_COUNT2("filterregPtr->guardObj", guardObj);} - filterregPtr->filterObj = filterObj; - filterregPtr->guardObj = guardObj; - /*fprintf(stderr, "FilterregSetFromAny alloc filterreg %p class %p guard %p\n", filterregPtr, filterregPtr->mixin, filterregPtr->guardObj);*/ Index: generic/nsfStack.c =================================================================== diff -u -race51b03d7e2b835c6867943f49c6ad5fa4c1b65 -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- generic/nsfStack.c (.../nsfStack.c) (revision ace51b03d7e2b835c6867943f49c6ad5fa4c1b65) +++ generic/nsfStack.c (.../nsfStack.c) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -871,7 +871,7 @@ *---------------------------------------------------------------------- */ NSF_INLINE static void -CscInit_(/*@notnull@*/ NsfCallStackContent *cscPtr, NsfObject *object, NsfClass *cl, +CscInit_(INTERP_DECL /*@notnull@*/ NsfCallStackContent *cscPtr, NsfObject *object, NsfClass *cl, Tcl_Command cmd, int frameType, int flags) { #if defined(NSF_PROFILE) struct timeval trt; @@ -913,11 +913,11 @@ * Incremement the namespace ptr in case Tcl tries to delete * this namespace during the invocation */ - NSNamespacePreserve(Tcl_Command_nsPtr(cmd)); + NSNamespacePreserve(INTERP Tcl_Command_nsPtr(cmd)); /*fprintf(stderr, "NSNamespacePreserve %p\n", nsPtr);*/ } - NsfCommandPreserve(cmd); + NsfCommandPreserve(INTERP cmd); } cscPtr->flags |= flags & NSF_CSC_COPY_FLAGS; cscPtr->self = object; @@ -1013,12 +1013,12 @@ /* * Release the Namespace */ - NSNamespaceRelease(Tcl_Command_nsPtr(cscPtr->cmdPtr)); + NSNamespaceRelease(INTERP Tcl_Command_nsPtr(cscPtr->cmdPtr)); } /* * Release the Command */ - NsfCommandRelease(cscPtr->cmdPtr); + NsfCommandRelease(INTERP cscPtr->cmdPtr); } #if defined(NRE) Index: generic/nsfTrace.c =================================================================== diff -u -r9addecef4701fd68a81b54714a370a9de3eb25f3 -rffd5b8ff74134cc891b9715cf1dd949193065b61 --- generic/nsfTrace.c (.../nsfTrace.c) (revision 9addecef4701fd68a81b54714a370a9de3eb25f3) +++ generic/nsfTrace.c (.../nsfTrace.c) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) @@ -75,12 +75,15 @@ void -NsfMemCountAlloc(char *id, void *p) { +NsfMemCountAlloc(Tcl_Interp *interp, char *id, void *p) { int new; NsfMemCounter *entry; - Tcl_HashTable *table = &nsfMemCount; + Tcl_HashTable *tablePtr = &RUNTIME_STATE(interp)->memCountTable; + //Tcl_HashTable *tablePtr = &nsfMemCount; Tcl_HashEntry *hPtr; - hPtr = Tcl_CreateHashEntry(table, id, &new); + + assert(interp); + hPtr = Tcl_CreateHashEntry(tablePtr, id, &new); #ifdef NSF_MEM_TRACE fprintf(stderr, "+++ alloc %s %p\n", id, p); #endif @@ -100,15 +103,17 @@ } void -NsfMemCountFree(char *id, void *p) { +NsfMemCountFree(Tcl_Interp *interp, char *id, void *p) { NsfMemCounter *entry; - Tcl_HashTable *table = &nsfMemCount; + //Tcl_HashTable *tablePtr = &nsfMemCount; + Tcl_HashTable *tablePtr = &RUNTIME_STATE(interp)->memCountTable; Tcl_HashEntry *hPtr; #ifdef NSF_MEM_TRACE fprintf(stderr, "+++ free %s %p\n", id, p); #endif - hPtr = Tcl_FindHashEntry(table, id); + assert(interp); + hPtr = Tcl_FindHashEntry(tablePtr, id); if (!hPtr) { fprintf(stderr, "******** MEM COUNT ALERT: Trying to free %p <%s>, " "but was not allocated\n", p, id); @@ -119,29 +124,42 @@ } void -NsfMemCountDump() { - Tcl_HashTable *table = &nsfMemCount; +NsfMemCountInit(Tcl_Interp *interp) { + Tcl_HashTable *tablePtr = &RUNTIME_STATE(interp)->memCountTable; + + Tcl_InitHashTable(tablePtr, TCL_STRING_KEYS); +#if 0 + extern Tcl_HashTable nsfMemCount; + Tcl_InitHashTable(&nsfMemCount, TCL_STRING_KEYS); +#endif +} + +void +NsfMemCountRelease(Tcl_Interp *interp) { + Tcl_HashTable *tablePtr = &RUNTIME_STATE(interp)->memCountTable; Tcl_HashSearch search; Tcl_HashEntry *hPtr; int count = 0; +#if 0 nsfMemCountInterpCounter--; if (nsfMemCountInterpCounter != 0) { return; } +#endif - fprintf(stderr, "******** XOTcl MEM Count *********\n* count peak\n"); + fprintf(stderr, "******** NSF MEM Count *********\n* count peak\n"); - for (hPtr = Tcl_FirstHashEntry(table, &search); hPtr != NULL; + for (hPtr = Tcl_FirstHashEntry(tablePtr, &search); hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) { - char *id = Tcl_GetHashKey(table, hPtr); + char *id = Tcl_GetHashKey(tablePtr, hPtr); NsfMemCounter *entry = (NsfMemCounter*) Tcl_GetHashValue(hPtr); count += entry->count; fprintf(stderr, "* %4d %6d %s\n", entry->count, entry->peak, id); ckfree ((char*) entry); } - Tcl_DeleteHashTable(table); + Tcl_DeleteHashTable(tablePtr); fprintf(stderr, "******** Count Overall = %d\n", count); }