summaryrefslogtreecommitdiffstats
path: root/generic/tclOO.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2019-11-15 20:11:10 (GMT)
committerdgp <dgp@users.sourceforge.net>2019-11-15 20:11:10 (GMT)
commitfc5da6d413b6981ebe7235f63d505f3290cc6c5c (patch)
tree83bafd6100aad31a41316ed1d27d88bd6452dc87 /generic/tclOO.c
parent521b33f6ec17381c19722e73043934c1dc81bea4 (diff)
parent12a22416413a587980cbb7d9c9bc361db5f3e419 (diff)
downloadtcl-fc5da6d413b6981ebe7235f63d505f3290cc6c5c.zip
tcl-fc5da6d413b6981ebe7235f63d505f3290cc6c5c.tar.gz
tcl-fc5da6d413b6981ebe7235f63d505f3290cc6c5c.tar.bz2
merge 8.6
Diffstat (limited to 'generic/tclOO.c')
-rw-r--r--generic/tclOO.c44
1 files changed, 29 insertions, 15 deletions
diff --git a/generic/tclOO.c b/generic/tclOO.c
index 1ba262b..af5ea50 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -175,7 +175,7 @@ MODULE_SCOPE const TclOOStubs tclOOStubs;
* ROOT_CLASS respectively.
*/
-#define Deleted(oPtr) ((oPtr)->flags & OBJECT_DELETED)
+#define Destructing(oPtr) ((oPtr)->flags & OBJECT_DESTRUCTING)
#define IsRootObject(ocPtr) ((ocPtr)->flags & ROOT_OBJECT)
#define IsRootClass(ocPtr) ((ocPtr)->flags & ROOT_CLASS)
#define IsRoot(ocPtr) ((ocPtr)->flags & (ROOT_OBJECT|ROOT_CLASS))
@@ -840,7 +840,7 @@ ObjectRenamedTrace(
* 2950259].
*/
- if (!Deleted(oPtr)) {
+ if (!Destructing(oPtr)) {
Tcl_DeleteNamespace(oPtr->namespacePtr);
}
oPtr->command = NULL;
@@ -880,7 +880,7 @@ TclOODeleteDescendants(
* clsPtr
*/
- if (!Deleted(mixinSubclassPtr->thisPtr)
+ if (!Destructing(mixinSubclassPtr->thisPtr)
&& !(mixinSubclassPtr->thisPtr->flags & DONT_DELETE)) {
Tcl_DeleteCommandFromToken(interp,
mixinSubclassPtr->thisPtr->command);
@@ -900,7 +900,7 @@ TclOODeleteDescendants(
if (clsPtr->subclasses.num > 0) {
while (clsPtr->subclasses.num > 0) {
subclassPtr = clsPtr->subclasses.list[clsPtr->subclasses.num - 1];
- if (!Deleted(subclassPtr->thisPtr) && !IsRoot(subclassPtr)
+ if (!Destructing(subclassPtr->thisPtr) && !IsRoot(subclassPtr)
&& !(subclassPtr->thisPtr->flags & DONT_DELETE)) {
Tcl_DeleteCommandFromToken(interp,
subclassPtr->thisPtr->command);
@@ -926,7 +926,7 @@ TclOODeleteDescendants(
* This condition also covers the case where instancePtr == oPtr
*/
- if (!Deleted(instancePtr) && !IsRoot(instancePtr) &&
+ if (!Destructing(instancePtr) && !IsRoot(instancePtr) &&
!(instancePtr->flags & DONT_DELETE)) {
Tcl_DeleteCommandFromToken(interp, instancePtr->command);
}
@@ -968,7 +968,7 @@ TclOOReleaseClassContents(
* Sanity check!
*/
- if (!Deleted(oPtr)) {
+ if (!Destructing(oPtr)) {
if (IsRootClass(oPtr)) {
Tcl_Panic("deleting class structure for non-deleted %s",
"::oo::class");
@@ -1087,7 +1087,7 @@ TclOOReleaseClassContents(
ckfree(clsPtr->privateVariables.list);
}
- if (IsRootClass(oPtr) && !Deleted(fPtr->objectCls->thisPtr)) {
+ if (IsRootClass(oPtr) && !Destructing(fPtr->objectCls->thisPtr)) {
Tcl_DeleteCommandFromToken(interp, fPtr->objectCls->thisPtr->command);
}
}
@@ -1120,7 +1120,7 @@ ObjectNamespaceDeleted(
Tcl_Interp *interp = oPtr->fPtr->interp;
int i;
- if (Deleted(oPtr)) {
+ if (Destructing(oPtr)) {
/*
* TODO: Can ObjectNamespaceDeleted ever be called twice? If not,
* this guard could be removed.
@@ -1135,7 +1135,7 @@ ObjectNamespaceDeleted(
* records. This is the flag that
*/
- oPtr->flags |= OBJECT_DELETED;
+ oPtr->flags |= OBJECT_DESTRUCTING;
/*
* Let the dominoes fall!
@@ -1280,7 +1280,7 @@ ObjectNamespaceDeleted(
* sometimes not go away automatically; we force it here. [Bug 2962664]
*/
- if (IsRootObject(oPtr) && !Deleted(fPtr->classCls->thisPtr)
+ if (IsRootObject(oPtr) && !Destructing(fPtr->classCls->thisPtr)
&& !Tcl_InterpDeleted(interp)) {
Tcl_DeleteCommandFromToken(interp, fPtr->classCls->thisPtr->command);
}
@@ -1331,6 +1331,20 @@ TclOODecrRefCount(
/*
* ----------------------------------------------------------------------
*
+ * TclOOObjectDestroyed --
+ *
+ * Returns TCL_OK if an object is entirely deleted, i.e. the destruction
+ * sequence has completed.
+ *
+ * ----------------------------------------------------------------------
+ */
+int TclOOObjectDestroyed(Object *oPtr) {
+ return (oPtr->namespacePtr == NULL);
+}
+
+/*
+ * ----------------------------------------------------------------------
+ *
* TclOORemoveFromInstances --
*
* Utility function to remove an object from the list of instances within
@@ -1473,7 +1487,7 @@ TclOOAddToSubclasses(
* is assumed that the class is not already
* present as a subclass in the superclass. */
{
- if (Deleted(superPtr->thisPtr)) {
+ if (Destructing(superPtr->thisPtr)) {
return;
}
if (superPtr->subclasses.num >= superPtr->subclasses.size) {
@@ -1538,7 +1552,7 @@ TclOOAddToMixinSubs(
* is assumed that the class is not already
* present as a subclass in the superclass. */
{
- if (Deleted(superPtr->thisPtr)) {
+ if (Destructing(superPtr->thisPtr)) {
return;
}
if (superPtr->mixinSubs.num >= superPtr->mixinSubs.size) {
@@ -1847,7 +1861,7 @@ FinalizeAlloc(
* want to lose errors by accident. [Bug 2903011]
*/
- if (result != TCL_ERROR && Deleted(oPtr)) {
+ if (result != TCL_ERROR && Destructing(oPtr)) {
Tcl_SetObjResult(interp, Tcl_NewStringObj(
"object deleted in constructor", -1));
Tcl_SetErrorCode(interp, "TCL", "OO", "STILLBORN", NULL);
@@ -1862,7 +1876,7 @@ FinalizeAlloc(
* command before we delete it. [Bug 9dd1bd7a74]
*/
- if (!Deleted(oPtr)) {
+ if (!Destructing(oPtr)) {
(void) TclOOObjectName(interp, oPtr);
Tcl_DeleteCommandFromToken(interp, oPtr->command);
}
@@ -2007,7 +2021,7 @@ Tcl_CopyObjectInstance(
*/
o2Ptr->flags = oPtr->flags & ~(
- OBJECT_DELETED | ROOT_OBJECT | ROOT_CLASS | FILTER_HANDLING);
+ OBJECT_DESTRUCTING | ROOT_OBJECT | ROOT_CLASS | FILTER_HANDLING);
/*
* Copy the object's metadata.