diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-07-05 12:12:13 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-07-05 12:12:13 (GMT) |
commit | 7e70c520097e7bd507cf88be353d4cd21d4ac0f3 (patch) | |
tree | 171a87e1227b4bd4cb8273784f97dc5eeb297684 | |
parent | dc2e004dcb78418bd5b3e2389dc44d6efee0e4d9 (diff) | |
parent | 4d6c5fd3acdad15b867c6a66bc53ba9ecf46e7a4 (diff) | |
download | tcl-7e70c520097e7bd507cf88be353d4cd21d4ac0f3.zip tcl-7e70c520097e7bd507cf88be353d4cd21d4ac0f3.tar.gz tcl-7e70c520097e7bd507cf88be353d4cd21d4ac0f3.tar.bz2 |
Merge 8.7
-rw-r--r-- | doc/Class.3 | 18 | ||||
-rw-r--r-- | generic/tclCmdAH.c | 18 | ||||
-rw-r--r-- | generic/tclIOUtil.c | 10 | ||||
-rw-r--r-- | unix/tclUnixFCmd.c | 4 |
4 files changed, 32 insertions, 18 deletions
diff --git a/doc/Class.3 b/doc/Class.3 index 9e968cd..12658ce 100644 --- a/doc/Class.3 +++ b/doc/Class.3 @@ -79,7 +79,9 @@ The number of elements in the \fIobjv\fR array. The arguments to the command to create the instance of the class. .AP int skip in The number of arguments at the start of the argument array, \fIobjv\fR, that -are not arguments to any constructors. +are not arguments to any constructors. This allows the generation of correct +error messages even when complicated calling patterns are used (e.g., via the +\fBnext\fR command). .AP Tcl_ObjectMetadataType *metaTypePtr in The type of \fImetadata\fR being set with \fBTcl_ClassSetMetadata\fR or retrieved with \fBTcl_ClassGetMetadata\fR. @@ -109,7 +111,9 @@ may be retrieved using the \fBTcl_GetObjectCommand\fR function, the name of the object (and hence the name of the command) with \fBTcl_GetObjectName\fR, and the namespace may be retrieved using the \fBTcl_GetObjectNamespace\fR function. Note that the Tcl_Obj reference returned by \fBTcl_GetObjectName\fR -is a shared reference. +is a shared reference. You can also get whether the object has been marked for +deletion with \fBTcl_ObjectDeleted\fR (it returns true if deletion of the +object has begun); this can be useful during the processing of methods. .PP Instances of classes are created using \fBTcl_NewObjectInstance\fR, which creates an object from any class (and which is internally called by both @@ -121,6 +125,16 @@ created object, or NULL if the creation failed (when an error message will be left in the interpreter result). In addition, objects may be copied by using \fBTcl_CopyObjectInstance\fR which creates a copy of an object without running any constructors. +.PP +Note that the lifetime management of objects is handled internally within +TclOO, and does not use \fBTcl_Preserve\fR. \fIIt is not safe to put a +Tcl_Object handle in a C structure with a lifespan different to the object;\fR +you should use the object's command name (as retrieved with +\fBTcl_GetObjectName\fR) instead. It is safe to use a Tcl_Object handle for +the lifespan of a call of a method on that object; handles do not become +invalid while there is an outstanding call on their object (even if the only +operation guaranteed to be safe on them is \fBTcl_ObjectDeleted\fR; the other +operations are only guaranteed to work on non-deleted objects). .SH "OBJECT AND CLASS METADATA" .PP Every object and every class may have arbitrary amounts of metadata attached diff --git a/generic/tclCmdAH.c b/generic/tclCmdAH.c index 68c0eb4..cf10e9b 100644 --- a/generic/tclCmdAH.c +++ b/generic/tclCmdAH.c @@ -1002,7 +1002,7 @@ FileAttrAccessTimeCmd( } #if defined(_WIN32) /* We use a value of 0 to indicate the access time not available */ - if (buf.st_atime == 0) { + if (Tcl_GetAccessTimeFromStat(&buf) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "could not get access time for file \"%s\"", TclGetString(objv[1]))); @@ -1023,7 +1023,7 @@ FileAttrAccessTimeCmd( } tval.actime = newTime; - tval.modtime = buf.st_mtime; + tval.modtime = Tcl_GetModificationTimeFromStat(&buf); if (Tcl_FSUtime(objv[1], &tval) != 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( @@ -1043,7 +1043,7 @@ FileAttrAccessTimeCmd( } } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((long) buf.st_atime)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tcl_GetAccessTimeFromStat(&buf))); return TCL_OK; } @@ -1084,7 +1084,7 @@ FileAttrModifyTimeCmd( } #if defined(_WIN32) /* We use a value of 0 to indicate the modification time not available */ - if (buf.st_mtime == 0) { + if (Tcl_GetModificationTimeFromStat(&buf) == 0) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( "could not get modification time for file \"%s\"", TclGetString(objv[1]))); @@ -1103,7 +1103,7 @@ FileAttrModifyTimeCmd( return TCL_ERROR; } - tval.actime = buf.st_atime; + tval.actime = Tcl_GetAccessTimeFromStat(&buf); tval.modtime = newTime; if (Tcl_FSUtime(objv[1], &tval) != 0) { @@ -1123,7 +1123,7 @@ FileAttrModifyTimeCmd( } } - Tcl_SetObjResult(interp, Tcl_NewWideIntObj((long) buf.st_mtime)); + Tcl_SetObjResult(interp, Tcl_NewWideIntObj(Tcl_GetModificationTimeFromStat(&buf))); return TCL_OK; } @@ -2154,9 +2154,9 @@ StoreStatData( #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE STORE_ARY("blksize", Tcl_NewWideIntObj((long)statPtr->st_blksize)); #endif - STORE_ARY("atime", Tcl_NewWideIntObj((long)statPtr->st_atime)); - STORE_ARY("mtime", Tcl_NewWideIntObj((long)statPtr->st_mtime)); - STORE_ARY("ctime", Tcl_NewWideIntObj((long)statPtr->st_ctime)); + STORE_ARY("atime", Tcl_NewWideIntObj(Tcl_GetAccessTimeFromStat(statPtr))); + STORE_ARY("mtime", Tcl_NewWideIntObj(Tcl_GetModificationTimeFromStat(statPtr))); + STORE_ARY("ctime", Tcl_NewWideIntObj(Tcl_GetChangeTimeFromStat(statPtr))); mode = (unsigned short) statPtr->st_mode; STORE_ARY("mode", Tcl_NewWideIntObj(mode)); STORE_ARY("type", Tcl_NewStringObj(GetTypeFromMode(mode), -1)); diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c index f18c20c..705d89e 100644 --- a/generic/tclIOUtil.c +++ b/generic/tclIOUtil.c @@ -327,9 +327,9 @@ Tcl_Stat( oldStyleBuf->st_uid = buf.st_uid; oldStyleBuf->st_gid = buf.st_gid; oldStyleBuf->st_size = (off_t) buf.st_size; - oldStyleBuf->st_atime = buf.st_atime; - oldStyleBuf->st_mtime = buf.st_mtime; - oldStyleBuf->st_ctime = buf.st_ctime; + oldStyleBuf->st_atime = Tcl_GetAccessTimeFromStat(&buf); + oldStyleBuf->st_mtime = Tcl_GetModificationTimeFromStat(&buf); + oldStyleBuf->st_ctime = Tcl_GetChangeTimeFromStat(&buf); #ifdef HAVE_STRUCT_STAT_ST_BLKSIZE oldStyleBuf->st_blksize = buf.st_blksize; #endif @@ -4423,8 +4423,8 @@ TclCrossFilesystemCopy( */ if (Tcl_FSLstat(source, &sourceStatBuf) == 0) { - tval.actime = sourceStatBuf.st_atime; - tval.modtime = sourceStatBuf.st_mtime; + tval.actime = Tcl_GetAccessTimeFromStat(&sourceStatBuf); + tval.modtime = Tcl_GetModificationTimeFromStat(&sourceStatBuf); Tcl_FSUtime(target, &tval); } diff --git a/unix/tclUnixFCmd.c b/unix/tclUnixFCmd.c index f36aecd..db49024 100644 --- a/unix/tclUnixFCmd.c +++ b/unix/tclUnixFCmd.c @@ -1313,8 +1313,8 @@ CopyFileAtts( } } - tval.actime = statBufPtr->st_atime; - tval.modtime = statBufPtr->st_mtime; + tval.actime = Tcl_GetAccessTimeFromStat(statBufPtr); + tval.modtime = Tcl_GetModificationTimeFromStat(statBufPtr); if (utime(dst, &tval)) { /* INTL: Native. */ return TCL_ERROR; |