Index: generic/xotcl.c =================================================================== diff -u -rfb73930aa9ecf6ce966e512e6f899acb5784ea8c -r5670d611979156a6f4a6654fedc35e9e802e3dee --- generic/xotcl.c (.../xotcl.c) (revision fb73930aa9ecf6ce966e512e6f899acb5784ea8c) +++ generic/xotcl.c (.../xotcl.c) (revision 5670d611979156a6f4a6654fedc35e9e802e3dee) @@ -7827,10 +7827,13 @@ } else { XOTclClass *result; XOTclClasses *sc; - /* check superclasses of metaclass */ + /*fprintf(stderr, "DefaultSuperClass for %s: search in superclasses starting with %p meta %d\n", className(cl), cl->super, isMeta);*/ + /* + * check superclasses of metaclass + */ if (isMeta) { /*fprintf(stderr, " ... is %s already root meta %d\n", className(mcl->object.cl), @@ -7881,17 +7884,19 @@ Tcl_HashSearch hSrch; Tcl_HashEntry *hPtr; XOTclClassOpt *clopt = cl->opt; - XOTclClass *defaultClass = NULL; + XOTclClass *baseClass = NULL; PRINTOBJ("CleanupDestroyClass", (XOTclObject *)cl); assert(softrecreate? recreate == 1 : 1); - /*fprintf(stderr, "CleanupDestroyClass %p softrecreate=%d, recreate=%d, %p\n", cl, - softrecreate, recreate, clopt); */ + /* fprintf(stderr, "CleanupDestroyClass %p %s (ismeta=%d) softrecreate=%d, recreate=%d, %p\n", cl,className(cl),IsMetaClass(interp, cl, 1), + softrecreate, recreate, clopt);*/ - /* do this even with no clopt, since the class might be used as a - superclass of a per object mixin, so it has no clopt... - */ + /* + * Perform the next steps even with clopt == NULL, since the class + * might be used as a superclass of a per object mixin, so it might + * have no clopt... + */ MixinInvalidateObjOrders(interp, cl); FilterInvalidateObjOrders(interp, cl); @@ -7912,19 +7917,20 @@ /* * Remove this class from all mixin lists and clear the isObjectMixinOf list */ - RemoveFromMixins(clopt->id, clopt->isObjectMixinOf); CmdListRemoveList(&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); } - /* remove dependent filters of this class from all subclasses*/ + + /* + * Remove dependent filters of this class from all subclasses + */ FilterRemoveDependentFilterCmds(cl, cl); AssertionRemoveStore(clopt->assertions); clopt->assertions = NULL; @@ -7939,25 +7945,28 @@ /*fprintf(stderr, " CleanupDestroyClass softrecreate %d\n", softrecreate);*/ if (!softrecreate) { - defaultClass = DefaultSuperClass(interp, cl, cl->object.cl, 0); - /* Reclass all instances of the current class the the appropriate - most general class ("baseClass"). The most general class of a - metaclass is the root meta class, the most general class of an - object is the root class. Instances of metaclasses can be only - reset to the root meta class (and not to to the root base class). + /* + * Reclass all instances of the current class the the appropriate + * most general class ("baseClass"). The most general class of a + * metaclass is the root meta class, the most general class of an + * object is the root class. Instances of metaclasses can be only + * reset to the root meta class (and not to to the root base + * class). + */ - We do not have to reclassing in case, cl is a root class - */ + baseClass = DefaultSuperClass(interp, cl, cl->object.cl, + IsMetaClass(interp, cl, 1)); + /* + * We do not have to reclassing in case, cl is a root class + */ if ((cl->object.flags & XOTCL_IS_ROOT_CLASS) == 0) { - XOTclClass *baseClass = IsMetaClass(interp, cl, 1) ? - DefaultSuperClass(interp, cl, cl->object.cl, 1) - : defaultClass; hPtr = &cl->instances ? Tcl_FirstHashEntry(&cl->instances, &hSrch) : 0; for (; hPtr; hPtr = Tcl_NextHashEntry(&hSrch)) { XOTclObject *inst = (XOTclObject*)Tcl_GetHashKey(&cl->instances, hPtr); - /*fprintf(stderr, " inst %p %s flags %.6x id %p\n", inst, objectName(inst), inst->flags, inst->id);*/ + /*fprintf(stderr, " inst %p %s flags %.6x id %p baseClass %p %s\n", + inst, objectName(inst), inst->flags, inst->id,baseClass,className(baseClass));*/ if (inst && inst != (XOTclObject*)cl && !(inst->flags & XOTCL_DURING_DELETE) /*inst->id*/) { if (inst != &(baseClass->object)) { (void)RemoveInstance(inst, cl->object.cl); @@ -7975,10 +7984,11 @@ clopt = cl->opt = 0; } - /* On a recreate, it might be possible that the newly created class - has a different superclass. So we have to flush the precedence list - on a recreate as well. - */ + /* + * On a recreate, it might be possible that the newly created class + * 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); @@ -7990,12 +8000,16 @@ while (cl->sub) { XOTclClass *subClass = cl->sub->cl; (void)RemoveSuper(subClass, cl); - /* if there are no more super classes add the Object + /* + * If there are no more super classes add the Object * class as superclasses * -> don't do that for Object itself! */ - if (subClass->super == 0 && (cl->object.flags & XOTCL_IS_ROOT_CLASS) == 0) - AddSuper(subClass, defaultClass); + if (subClass->super == 0 && (cl->object.flags & XOTCL_IS_ROOT_CLASS) == 0) { + /* fprintf(stderr,"subClass %p %s baseClass %p %s\n", + cl,className(cl),baseClass,className(baseClass)); */ + AddSuper(subClass, baseClass); + } } /*(void)RemoveSuper(cl, cl->super->cl);*/ } @@ -8017,7 +8031,7 @@ #endif /* - * during init of Object and Class the theClass value is not set + * During init of Object and Class the theClass value is not set */ /* if (RUNTIME_STATE(interp)->theClass != 0) Index: tests/object-system.xotcl =================================================================== diff -u -r3f0573cc75724179f416942b974373e5a62ec05e -r5670d611979156a6f4a6654fedc35e9e802e3dee --- tests/object-system.xotcl (.../object-system.xotcl) (revision 3f0573cc75724179f416942b974373e5a62ec05e) +++ tests/object-system.xotcl (.../object-system.xotcl) (revision 5670d611979156a6f4a6654fedc35e9e802e3dee) @@ -63,14 +63,32 @@ ? {c1 ismetaclass} 0 ? {c1 info class} ::C -# destroy meta-class M, reclass meta-class instances to the base meta-class +Class M2 -superclass M +? {Object isobject M2} 1 +? {M2 isclass} 1 +? {M2 ismetaclass} 1 +? {M2 info superclass} ::M +? {M2 info class} ::xotcl::Class + +M2 m2 +? {m2 info superclass} ::xotcl::Object +? {m2 info class} ::M2 + +# destroy meta-class M, reclass meta-class instances to the base +# meta-class and set subclass of M to the root meta-class M destroy ? {Object isobject C} 1 ? {C isclass} 1 ? {C ismetaclass} 0 ? {C info superclass} ::xotcl::Object ? {C info class} ::xotcl::Class +? {M2 ismetaclass} 1 +? {M2 info superclass} ::xotcl::Class +? {m2 info superclass} ::xotcl::Object +? {m2 info class} ::M2 + + # destroy class M, reclass class instances to the base class C destroy ? {Object isobject c1} 1