Index: ChangeLog =================================================================== diff -u -r91e9b1a3b1c3e60a8538156b4aa37d5a664d5133 -r6cea71632dc3d32fabb894f5de7c803145261102 --- ChangeLog (.../ChangeLog) (revision 91e9b1a3b1c3e60a8538156b4aa37d5a664d5133) +++ ChangeLog (.../ChangeLog) (revision 6cea71632dc3d32fabb894f5de7c803145261102) @@ -63,6 +63,10 @@ C c1 ;# c1 has no no default value for "a", before it had ====== +2009-06-27 + - changed method name "instdestroy" into "dealloc" + - new file: tclAPI.h + 2009-06-25 - new command: Index: generic/tclAPI.h =================================================================== diff -u --- generic/tclAPI.h (revision 0) +++ generic/tclAPI.h (revision 6cea71632dc3d32fabb894f5de7c803145261102) @@ -0,0 +1,123 @@ + +enum { + /* Object method definitions (1) */ + XOTclOAutonameMethodIdx, + XOTclOCheckMethodIdx, + XOTclOCleanupMethodIdx, + XOTclOConfigureMethodIdx, + XOTclODestroyMethodIdx, + XOTclOExistsMethodIdx, + XOTclOFilterGuardMethodIdx, + XOTclOFilterSearchMethodIdx, + XOTclOInstVarMethodIdx, + XOTclOInvariantsMethodIdx, + XOTclOIsClassMethodIdx, + XOTclOIsMetaClassMethodIdx, + XOTclOIsObjectMethodIdx, + XOTclOIsTypeMethodIdx, + XOTclOIsMixinMethodIdx, + XOTclOMixinGuardMethodIdx, + XOTclONextMethodIdx, + XOTclONoinitMethodIdx, + XOTclCParameterCmdMethodIdx, + XOTclOProcMethodIdx, + XOTclOProcSearchMethodIdx, + XOTclORequireNamespaceMethodIdx, + XOTclOSetMethodIdx, /***??**/ + XOTclOSetvaluesMethodIdx, + XOTclOForwardMethodIdx, + XOTclOUplevelMethodIdx, + XOTclOUpvarMethodIdx, + XOTclOVolatileMethodIdx, + XOTclOVwaitMethodIdx, + + /* Class method definitions (2) */ + XOTclCAllocMethodIdx, + XOTclCCreateMethodIdx, + XOTclCDeallocMethodIdx, + XOTclCNewMethodIdx, + XOTclCInstFilterGuardMethodIdx, + XOTclCInvariantsMethodIdx, + XOTclCInstMixinGuardMethodIdx, + XOTclCInstParameterCmdMethodIdx, + XOTclCInstProcMethodIdx, + XOTclCInstProcMethodCIdx, + XOTclCInstForwardMethodIdx, + XOTclCRecreateMethodIdx, + XOTclCUnknownMethodIdx, + + /* Check method definitions (3) */ + XOTclCheckRequiredArgsIdx, + /*XOTclCheckBooleanArgsIdx, for boolean and switch, we use the same checker */ + XOTclCheckBooleanArgsIdx, + + /* Object info definitions (4) */ + XOTclObjInfoArgsMethodIdx, + XOTclObjInfoBodyMethodIdx, + XOTclObjInfoClassMethodIdx, + XOTclObjInfoCommandsMethodIdx, + XOTclObjInfoChildrenMethodIdx, + XOTclObjInfoCheckMethodIdx, + XOTclObjInfoDefaultMethodIdx, + XOTclObjInfoFilterMethodIdx, + XOTclObjInfoFilterguardMethodIdx, + XOTclObjInfoForwardMethodIdx, + XOTclObjInfoHasnamespaceMethodIdx, + XOTclObjInfoInvarMethodIdx, + XOTclObjInfoMethodsMethodIdx, + XOTclObjInfoMixinMethodIdx, + XOTclObjInfoMixinguardMethodIdx, + XOTclObjInfoNonposargsMethodIdx, + XOTclObjInfoParentMethodIdx, + XOTclObjInfoParametercmdMethodIdx, + XOTclObjInfoPostMethodIdx, + XOTclObjInfoPreMethodIdx, + XOTclObjInfoProcsMethodIdx, + XOTclObjInfoPrecedenceMethodIdx, + XOTclObjInfoSlotObjectsMethodIdx, + XOTclObjInfoVarsMethodIdx, + + /* Class info definitions (5) */ + XOTclClassInfoHeritageMethodIdx, + XOTclClassInfoInstancesMethodIdx, + XOTclClassInfoInstargsMethodIdx, + XOTclClassInfoInstbodyMethodIdx, + XOTclClassInfoInstcommandsMethodIdx, + XOTclClassInfoInstdefaultMethodIdx, + XOTclClassInfoInstfilterMethodIdx, + XOTclClassInfoInstfilterguardMethodIdx, + XOTclClassInfoInstforwardMethodIdx, + XOTclClassInfoInstinvarMethodIdx, + XOTclClassInfoInstmixinMethodIdx, + XOTclClassInfoInstmixinguardMethodIdx, + XOTclClassInfoInstmixinofMethodIdx, + XOTclClassInfoInstprocsMethodIdx, + XOTclClassInfoInstnonposargsMethodIdx, + XOTclClassInfoInstparametercmdMethodIdx, + XOTclClassInfoInstpreMethodIdx, + XOTclClassInfoInstpostMethodIdx, + XOTclClassInfoMixinofMethodIdx, + XOTclClassInfoParameterMethodIdx, + XOTclClassInfoSubclassMethodIdx, + XOTclClassInfoSuperclassMethodIdx, + XOTclClassInfoSlotsMethodIdx, + + methodIdxEND +} XOTclMethods; + +static interfaceDefinition methodDefinitions[methodIdxEND]; + +interfaceDefinition xxx = { + {"class", 1,0, "class"}, + {"-closure"}, + {"pattern", 0,0, "objpattern"} +}; + +methodDefinitions[XOTclClassInfoInstancesMethodIdx] = xxx; +/* +methodDefinitions[XOTclClassInfoInstancesMethodIdx] = { + {"class", 1,0, "class"}, + {"-closure"}, + {"pattern", 0,0, "objpattern"} +}; +*/ Index: generic/xotcl.c =================================================================== diff -u -rad28c74f8adeff33ff86faf9e678642d35b7a6ee -r6cea71632dc3d32fabb894f5de7c803145261102 --- generic/xotcl.c (.../xotcl.c) (revision ad28c74f8adeff33ff86faf9e678642d35b7a6ee) +++ generic/xotcl.c (.../xotcl.c) (revision 6cea71632dc3d32fabb894f5de7c803145261102) @@ -5442,7 +5442,7 @@ } */ /* The order of the check is important, since obj might be already - freed in case the call was a instdestroy */ + freed in case the call was a "dealloc" */ if (!rst->callIsDestroy && obj->opt) { co = obj->opt->checkoptions; if ((co & CHECK_INVAR) && @@ -8161,7 +8161,7 @@ object is ::xotcl::Object. Instances of metaclasses can be only reset to ::xotcl::Class (and not to ::xotcl::Object as in earlier versions), since otherwise their instances can't be - deleted, because ::xotcl::Object has no method "instdestroy". + deleted, because ::xotcl::Object has no method "dealloc". We do not have to reclassing in case, cl == ::xotcl::Object */ @@ -8669,10 +8669,10 @@ PRINTOBJ("XOTclODestroyMethod", obj); /* - * call instdestroy for [self] + * call dealloc for [self] */ return XOTclCallMethodWithArgs((ClientData)obj->cl, interp, - XOTclGlobalObjects[XOTE_INSTDESTROY], obj->cmdName, + XOTclGlobalObjects[XOTE_DEALLOC], obj->cmdName, objc, objv+1, 0); } @@ -11457,7 +11457,7 @@ */ static int -XOTclCInstDestroyMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { +XOTclCDeallocMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { XOTclClass *cl = XOTclObjectToClass(clientData); XOTclObject *delobj; int rc; @@ -11471,7 +11471,7 @@ ObjStr(objv[1]), " that does not exist.", (char *) NULL); - /* fprintf(stderr,"instdestroy obj=%s, opt=%p\n", objectName(delobj), delobj->opt);*/ + /* fprintf(stderr,"dealloc obj=%s, opt=%p\n", objectName(delobj), delobj->opt);*/ rc = freeUnsetTraceVariable(interp, delobj); if (rc != TCL_OK) { return rc; @@ -11482,7 +11482,7 @@ */ delobj->flags |= XOTCL_DESTROY_CALLED; RUNTIME_STATE(interp)->callIsDestroy = 1; - /*fprintf(stderr,"instDestroy %s : setting callIsDestroy = 1\n", ObjStr(objv[1]));*/ + /*fprintf(stderr,"dealloc %s : setting callIsDestroy = 1\n", ObjStr(objv[1]));*/ if (RUNTIME_STATE(interp)->exitHandlerDestroyRound != XOTCL_EXITHANDLER_ON_SOFT_DESTROY) { CallStackDestroyObject(interp, delobj); @@ -11945,20 +11945,15 @@ int required; int nrargs; char *type; + char *defaultValue; } argDefinition; -typedef struct { - int flags; - argDefinition args[10]; -} interfaceDefinition; +typedef argDefinition interfaceDefinition[10]; interfaceDefinition d = { - parseMatchObject, - { {"class", 1,0, "class"}, {"-closure"}, {"pattern"} - } }; typedef struct { @@ -11969,22 +11964,16 @@ entry entries[] = { { "dummy", { - parseMatchObject, - { {"class", 1, 0, "class"}, {"-closure"}, {"pattern"} - } } }, { "dummy2", { - parseMatchObject, - { {"class", 1, 0, "class"}, {"-closure"}, {"pattern"} - } } }, }; @@ -12077,11 +12066,11 @@ parse2(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[], interfaceDefinition *ifdPtr, struct parseContext *pc) { int i, o, args, flagCount = 0, nrReq = 0, nrOpt = 0; - argDefinition *aPtr, *bPtr, *argsPtr = ifdPtr->args; + argDefinition *aPtr, *bPtr; memset(pc, 0, sizeof(struct parseContext)); - for (i=0, o=1, aPtr=argsPtr; aPtr->name && oname && oname,o);*/ if (*aPtr->name == '-') { /* the interface defintion has switches,switches can be given in @@ -12095,7 +12084,7 @@ found = 0; for (bPtr = aPtr; *bPtr->name == '-'; bPtr ++) { if (strcmp(objStr,bPtr->name) == 0) { - pc->clientData[bPtr-argsPtr] = (ClientData)1; + pc->clientData[bPtr-ifdPtr[0]] = (ClientData)1; flagCount++; found = 1; } @@ -12137,8 +12126,8 @@ /*fprintf(stderr, "objc = %d, args = %d, nrReq %d, nrReq + nrOpt = %d\n", objc,args,nrReq,nrReq + nrOpt);*/ if (args < nrReq || args > nrReq + nrOpt) { Tcl_Obj *msg = Tcl_NewStringObj("", 0); - for (aPtr=argsPtr; aPtr->name; aPtr++) { - if (aPtr != argsPtr) { + for (aPtr=ifdPtr[0]; aPtr->name; aPtr++) { + if (aPtr != ifdPtr[0]) { Tcl_AppendToObj(msg, " ", 1); } if (aPtr->required) { @@ -12175,15 +12164,15 @@ return 0; } +#include "tclApi.h" + static int XOTclClassInfoInstancesMethod(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { struct parseContext pc; interfaceDefinition d = { - parseMatchObject, { {"class", 1,0, "class"}, {"-closure"}, {"pattern", 0,0, "objpattern"} - } }; if (parse2(clientData, interp, objc, objv, &d, &pc) != TCL_OK) { @@ -12916,7 +12905,6 @@ name = ObjStr(objv[1 + incr]); if ((cl->object.flags & XOTCL_IS_ROOT_CLASS && isDestroyString(name)) || - (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isInstDestroyString(name)) || (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isDeallocString(name)) || (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isAllocString(name)) || (cl->object.flags & XOTCL_IS_ROOT_META_CLASS && isCreateString(name))) @@ -14477,6 +14465,7 @@ typedef struct methodDefinition { char *methodName; Tcl_ObjCmdProc *proc; + int pos; } methodDefinition; char *namespace_names[] = { @@ -14486,6 +14475,7 @@ "::xotcl::cmd::ObjectInfo", "::xotcl::cmd::ClassInfo" }; + methodDefinition definitions1[] = { {"autoname", XOTclOAutonameMethod}, {"check", XOTclOCheckMethod}, @@ -14502,12 +14492,8 @@ {"isobject", XOTclOIsObjectMethod}, {"istype", XOTclOIsTypeMethod}, {"ismixin", XOTclOIsMixinMethod}, -#ifdef XOTCL_METADATA - {"metadata", XOTclOMetaDataMethod}, -#endif {"mixinguard", XOTclOMixinGuardMethod}, {"__next", XOTclONextMethod}, - /* {"next", XOTclONextMethod2},*/ {"noinit", XOTclONoinitMethod}, {"parametercmd", XOTclCParameterCmdMethod}, {"proc", XOTclOProcMethod}, @@ -14525,9 +14511,8 @@ methodDefinition definitions2[] = { {"alloc", XOTclCAllocMethod}, {"create", XOTclCCreateMethod}, - {"dealloc", XOTclCInstDestroyMethod}, + {"dealloc", XOTclCDeallocMethod}, {"new", XOTclCNewMethod}, - {"instdestroy", XOTclCInstDestroyMethod}, {"instfilterguard", XOTclCInstFilterGuardMethod}, {"instinvar", XOTclCInvariantsMethod}, {"instmixinguard", XOTclCInstMixinGuardMethod}, @@ -14538,6 +14523,7 @@ {"recreate", XOTclCRecreateMethod}, {"unknown", XOTclCUnknownMethod} }; + methodDefinition definitions3[] = { {"type=required", XOTclCheckRequiredArgs}, {"type=switch", XOTclCheckBooleanArgs}, /* for boolean and switch, we use the same checker */ @@ -14559,7 +14545,6 @@ {"methods", XOTclObjInfoMethodsMethod}, {"mixin", XOTclObjInfoMixinMethod}, {"mixinguard", XOTclObjInfoMixinguardMethod}, - {"methods", XOTclObjInfoMethodsMethod}, {"nonposargs", XOTclObjInfoNonposargsMethod}, {"parent", XOTclObjInfoParentMethod}, {"parametercmd", XOTclObjInfoParametercmdMethod}, Index: generic/xotclInt.h =================================================================== diff -u -r91e9b1a3b1c3e60a8538156b4aa37d5a664d5133 -r6cea71632dc3d32fabb894f5de7c803145261102 --- generic/xotclInt.h (.../xotclInt.h) (revision 91e9b1a3b1c3e60a8538156b4aa37d5a664d5133) +++ generic/xotclInt.h (.../xotclInt.h) (revision 6cea71632dc3d32fabb894f5de7c803145261102) @@ -135,10 +135,6 @@ #define isDestroyString(m) (\ *m == 'd' && m[1] == 'e' && m[2] == 's' && m[3] == 't' && \ m[4] == 'r' && m[5] == 'o' && m[6] == 'y' && m[7] == '\0') -#define isInstDestroyString(m) (\ - *m == 'i' && m[1] == 'n' && m[2] == 's' && m[3] == 't' && \ - m[4] == 'd' && m[5] == 'e' && m[6] == 's' && m[7] == 't' && \ - m[8] == 'r' && m[9] == 'o' && m[10] == 'y' && m[11] == '\0') #define isInitString(m) (\ *m == 'i' && m[1] == 'n' && m[2] == 'i' && m[3] == 't' && \ m[4] == '\0') @@ -544,7 +540,7 @@ and Strings - otherwise these "constants" would have to be built every time they are used; now they are built once in XOTcl_Init */ typedef enum { - XOTE_EMPTY, XOTE_UNKNOWN, XOTE_CREATE, XOTE_DESTROY, XOTE_INSTDESTROY, + XOTE_EMPTY, XOTE_UNKNOWN, XOTE_CREATE, XOTE_DESTROY, XOTE_DEALLOC, XOTE_ALLOC, XOTE_INIT, XOTE_INSTVAR, XOTE_INTERP, XOTE_AUTONAMES, XOTE_ZERO, XOTE_ONE, XOTE_MOVE, XOTE_SELF, XOTE_CLASS, XOTE_RECREATE, XOTE_SELF_CLASS, XOTE_SELF_PROC, @@ -564,7 +560,7 @@ extern char *XOTclGlobalStrings[]; #else char *XOTclGlobalStrings[] = { - "", "unknown", "create", "destroy", "instdestroy", + "", "unknown", "create", "destroy", "dealloc", "alloc", "init", "instvar", "interp", "__autonames", "0", "1", "move", "self", "class", "recreate", "self class", "self proc",