summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvincentdarley <vincentdarley>2002-07-22 16:51:47 (GMT)
committervincentdarley <vincentdarley>2002-07-22 16:51:47 (GMT)
commitdf9190aa43ec6f65886c402aa9d5ade8a57cd6be (patch)
tree30941e07aec5369bc98f08402bcba7684f40d889
parent27070d54f1091210791f5ec8bd0c2474b5531f6d (diff)
downloadtcl-df9190aa43ec6f65886c402aa9d5ade8a57cd6be.zip
tcl-df9190aa43ec6f65886c402aa9d5ade8a57cd6be.tar.gz
tcl-df9190aa43ec6f65886c402aa9d5ade8a57cd6be.tar.bz2
removed load-related clientData, made filesystem static
-rw-r--r--ChangeLog15
-rw-r--r--doc/FileSystem.319
-rw-r--r--generic/tcl.decls4
-rw-r--r--generic/tcl.h7
-rw-r--r--generic/tclDecls.h6
-rw-r--r--generic/tclIOUtil.c39
-rw-r--r--generic/tclInt.h3
-rw-r--r--generic/tclLoad.c16
8 files changed, 64 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index 6e34532..46bd625 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2002-07-22 Vince Darley <vincentdarley@users.sourceforge.net>
+
+ * generic/tclIOUtil.c: made tclNativeFilesystem static
+ (since 07-19 changes removed its usage elsewhere), and
+ added comments about its usage.
+ * generic/tclLoad.c:
+ * generic/tcl.h:
+ * generic/tcl.decls:
+ * doc/FileSystem.3: converted last load-related ClientData
+ parameter to Tcl_LoadHandle opaque structure, removing a
+ couple of casts in the process.
+
+ * generic/tclInt.h: removed tclNativeFilesystem declaration
+ since it is now static again.
+
2002-07-22 Donal K. Fellows <fellowsd@cs.man.ac.uk>
* tests/expr.test (expr-22.*): Added tests to help detect the
diff --git a/doc/FileSystem.3 b/doc/FileSystem.3
index d4f4c25..2af7768 100644
--- a/doc/FileSystem.3
+++ b/doc/FileSystem.3
@@ -4,7 +4,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: FileSystem.3,v 1.29 2002/07/08 12:08:34 vincentdarley Exp $
+'\" RCS: @(#) $Id: FileSystem.3,v 1.30 2002/07/22 16:51:47 vincentdarley Exp $
'\"
.so man.macros
.TH Filesystem 3 8.4 Tcl "Tcl Library Procedures"
@@ -58,7 +58,7 @@ int
\fBTcl_FSEvalFile\fR(\fIinterp, pathPtr\fR)
.sp
int
-\fBTcl_FSLoadFile\fR(\fIinterp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, clientDataPtr, unloadProcPtr\fR)
+\fBTcl_FSLoadFile\fR(\fIinterp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr, handlePtr, unloadProcPtr\fR)
.sp
int
\fBTcl_FSMatchInDirectory\fR(\fIinterp, result, pathPtr, pattern, types\fR)
@@ -1278,22 +1278,17 @@ entirely.
typedef int Tcl_FSLoadFileProc(
Tcl_Interp * \fIinterp\fR,
Tcl_Obj *\fIpathPtr\fR,
- CONST char * \fIsym1\fR,
- CONST char * \fIsym2\fR,
- Tcl_PackageInitProc ** \fIproc1Ptr\fR,
- Tcl_PackageInitProc ** \fIproc2Ptr\fR,
- ClientData * \fIclientDataPtr\fR,
+ Tcl_LoadHandle * \fIhandlePtr\fR,
Tcl_FSUnloadFileProc * \fIunloadProcPtr\fR);
.CE
.PP
Returns a standard Tcl completion code. If an error occurs, an error
message is left in the interp's result. The function dynamically loads
-a binary code file into memory and returns the addresses of two
-procedures within that file, if they are defined. On a successful
-load, the \fIclientDataPtr\fR should be filled with a token for
+a binary code file into memory. On a successful
+load, the \fIhandlePtr\fR should be filled with a token for
the dynamically loaded file, and the \fIunloadProcPtr\fR should be
filled in with the address of a procedure. The procedure will be
-called with the given clientData as its only parameter when Tcl
+called with the given Tcl_LoadHandle as its only parameter when Tcl
needs to unload the file.
.SH UNLOADFILEPROC
.PP
@@ -1303,7 +1298,7 @@ cleanup action required.
.PP
.CS
typedef void Tcl_FSUnloadFileProc(
- ClientData \fIclientData\fR);
+ Tcl_LoadHandle \fIloadHandle\fR);
.CE
.SH GETCWDPROC
.PP
diff --git a/generic/tcl.decls b/generic/tcl.decls
index 69ebc9c..6e0f5f5 100644
--- a/generic/tcl.decls
+++ b/generic/tcl.decls
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: tcl.decls,v 1.90 2002/06/21 14:22:28 vincentdarley Exp $
+# RCS: @(#) $Id: tcl.decls,v 1.91 2002/07/22 16:51:47 vincentdarley Exp $
library tcl
@@ -1569,7 +1569,7 @@ declare 444 generic {
Tcl_Obj *pathPtr, CONST char * sym1, CONST char * sym2,
Tcl_PackageInitProc ** proc1Ptr,
Tcl_PackageInitProc ** proc2Ptr,
- ClientData * clientDataPtr,
+ Tcl_LoadHandle * handlePtr,
Tcl_FSUnloadFileProc **unloadProcPtr)
}
declare 445 generic {
diff --git a/generic/tcl.h b/generic/tcl.h
index 38219b7..4fc6592 100644
--- a/generic/tcl.h
+++ b/generic/tcl.h
@@ -13,7 +13,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tcl.h,v 1.135 2002/07/18 16:26:02 vincentdarley Exp $
+ * RCS: @(#) $Id: tcl.h,v 1.136 2002/07/22 16:51:47 vincentdarley Exp $
*/
#ifndef _TCL
@@ -1618,10 +1618,7 @@ typedef Tcl_Obj* (Tcl_FSLinkProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
Tcl_Obj *toPtr, int linkType));
typedef int (Tcl_FSLoadFileProc) _ANSI_ARGS_((Tcl_Interp * interp,
Tcl_Obj *pathPtr,
- CONST char * sym1, CONST char * sym2,
- Tcl_PackageInitProc ** proc1Ptr,
- Tcl_PackageInitProc ** proc2Ptr,
- ClientData * clientDataPtr,
+ Tcl_LoadHandle *handlePtr,
Tcl_FSUnloadFileProc **unloadProcPtr));
typedef int (Tcl_FSPathInFilesystemProc) _ANSI_ARGS_((Tcl_Obj *pathPtr,
ClientData *clientDataPtr));
diff --git a/generic/tclDecls.h b/generic/tclDecls.h
index 0a4df01..19687a3 100644
--- a/generic/tclDecls.h
+++ b/generic/tclDecls.h
@@ -8,7 +8,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclDecls.h,v 1.90 2002/06/22 00:06:23 dkf Exp $
+ * RCS: @(#) $Id: tclDecls.h,v 1.91 2002/07/22 16:51:48 vincentdarley Exp $
*/
#ifndef _TCLDECLS
@@ -1407,7 +1407,7 @@ EXTERN int Tcl_FSLoadFile _ANSI_ARGS_((Tcl_Interp * interp,
CONST char * sym2,
Tcl_PackageInitProc ** proc1Ptr,
Tcl_PackageInitProc ** proc2Ptr,
- ClientData * clientDataPtr,
+ Tcl_LoadHandle * handlePtr,
Tcl_FSUnloadFileProc ** unloadProcPtr));
/* 445 */
EXTERN int Tcl_FSMatchInDirectory _ANSI_ARGS_((
@@ -2059,7 +2059,7 @@ typedef struct TclStubs {
int (*tcl_FSCopyDirectory) _ANSI_ARGS_((Tcl_Obj * srcPathPtr, Tcl_Obj * destPathPtr, Tcl_Obj ** errorPtr)); /* 441 */
int (*tcl_FSCreateDirectory) _ANSI_ARGS_((Tcl_Obj * pathPtr)); /* 442 */
int (*tcl_FSDeleteFile) _ANSI_ARGS_((Tcl_Obj * pathPtr)); /* 443 */
- int (*tcl_FSLoadFile) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * pathPtr, CONST char * sym1, CONST char * sym2, Tcl_PackageInitProc ** proc1Ptr, Tcl_PackageInitProc ** proc2Ptr, ClientData * clientDataPtr, Tcl_FSUnloadFileProc ** unloadProcPtr)); /* 444 */
+ int (*tcl_FSLoadFile) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * pathPtr, CONST char * sym1, CONST char * sym2, Tcl_PackageInitProc ** proc1Ptr, Tcl_PackageInitProc ** proc2Ptr, Tcl_LoadHandle * handlePtr, Tcl_FSUnloadFileProc ** unloadProcPtr)); /* 444 */
int (*tcl_FSMatchInDirectory) _ANSI_ARGS_((Tcl_Interp * interp, Tcl_Obj * result, Tcl_Obj * pathPtr, CONST char * pattern, Tcl_GlobTypeData * types)); /* 445 */
Tcl_Obj * (*tcl_FSLink) _ANSI_ARGS_((Tcl_Obj * pathPtr, Tcl_Obj * toPtr, int linkAction)); /* 446 */
int (*tcl_FSRemoveDirectory) _ANSI_ARGS_((Tcl_Obj * pathPtr, int recursive, Tcl_Obj ** errorPtr)); /* 447 */
diff --git a/generic/tclIOUtil.c b/generic/tclIOUtil.c
index c419727..27f32b4 100644
--- a/generic/tclIOUtil.c
+++ b/generic/tclIOUtil.c
@@ -17,7 +17,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIOUtil.c,v 1.62 2002/07/21 17:03:00 dgp Exp $
+ * RCS: @(#) $Id: tclIOUtil.c,v 1.63 2002/07/22 16:51:48 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -372,8 +372,15 @@ Tcl_FSUnloadFileProc TclpUnloadFile;
Tcl_FSLinkProc TclpObjLink;
Tcl_FSListVolumesProc TclpObjListVolumes;
-/* Define the native filesystem dispatch table */
-Tcl_Filesystem tclNativeFilesystem = {
+/*
+ * Define the native filesystem dispatch table. If necessary, it
+ * is ok to make this non-static, but it should only be accessed
+ * by the functions actually listed within it (or perhaps other
+ * helper functions of them). Anything which is not part of this
+ * 'native filesystem implementation' should not be delving inside
+ * here!
+ */
+static Tcl_Filesystem tclNativeFilesystem = {
"native",
sizeof(Tcl_Filesystem),
TCL_FILESYSTEM_VERSION_1,
@@ -406,7 +413,7 @@ Tcl_Filesystem tclNativeFilesystem = {
&TclpObjRenameFile,
&TclpObjCopyDirectory,
&TclpObjLstat,
- &TclpLoadFile,
+ &TclpDlopen,
&TclpObjGetCwd,
&TclpObjChdir
};
@@ -578,7 +585,7 @@ FsReleaseIterator(void) {
* Clean up the filesystem. After this, calls to all Tcl_FS...
* functions will fail.
*
- * Note that, since 'TclFinalizedLoad' may unload extensions
+ * Note that, since 'TclFinalizeLoad' may unload extensions
* which implement other filesystems, and which may therefore
* contain a 'freeProc' for those filesystems, at this stage
* we _must_ have freed all objects of "path" type, or we may
@@ -2491,7 +2498,7 @@ Tcl_FSChdir(pathPtr)
int
Tcl_FSLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
- clientDataPtr, unloadProcPtr)
+ handlePtr, unloadProcPtr)
Tcl_Interp *interp; /* Used for error reporting. */
Tcl_Obj *pathPtr; /* Name of the file containing the desired
* code. */
@@ -2500,7 +2507,7 @@ Tcl_FSLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
Tcl_PackageInitProc **proc1Ptr, **proc2Ptr;
/* Where to return the addresses corresponding
* to sym1 and sym2. */
- ClientData *clientDataPtr; /* Filled with token for dynamically loaded
+ Tcl_LoadHandle *handlePtr; /* Filled with token for dynamically loaded
* file which will be passed back to
* (*unloadProcPtr)() to unload the file. */
Tcl_FSUnloadFileProc **unloadProcPtr;
@@ -2512,9 +2519,15 @@ Tcl_FSLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
if (fsPtr != NULL) {
Tcl_FSLoadFileProc *proc = fsPtr->loadFileProc;
if (proc != NULL) {
- int retVal = (*proc)(interp, pathPtr, sym1, sym2,
- proc1Ptr, proc2Ptr, clientDataPtr,
- unloadProcPtr);
+ int retVal = (*proc)(interp, pathPtr, handlePtr, unloadProcPtr);
+ if (retVal != TCL_OK) {
+ return retVal;
+ }
+ if (*handlePtr == NULL) {
+ return TCL_ERROR;
+ }
+ *proc1Ptr = TclpFindSymbol(interp, *handlePtr, sym1);
+ *proc2Ptr = TclpFindSymbol(interp, *handlePtr, sym2);
return retVal;
} else {
Tcl_Filesystem *copyFsPtr;
@@ -2573,7 +2586,7 @@ Tcl_FSLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
retVal = Tcl_FSLoadFile(interp, copyToPtr, sym1, sym2,
proc1Ptr, proc2Ptr,
- (ClientData*)&newLoadHandle,
+ &newLoadHandle,
&newUnloadProcPtr);
if (retVal != TCL_OK) {
/* The file didn't load successfully */
@@ -2588,7 +2601,7 @@ Tcl_FSLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
*/
if (Tcl_FSDeleteFile(copyToPtr) == TCL_OK) {
Tcl_DecrRefCount(copyToPtr);
- (*clientDataPtr) = NULL;
+ (*handlePtr) = NULL;
(*unloadProcPtr) = NULL;
return TCL_OK;
}
@@ -2621,7 +2634,7 @@ Tcl_FSLoadFile(interp, pathPtr, sym1, sym2, proc1Ptr, proc2Ptr,
tvdlPtr->divertedFileNativeRep = Tcl_FSGetInternalRep(copyToPtr,
copyFsPtr);
copyToPtr = NULL;
- (*clientDataPtr) = (ClientData) tvdlPtr;
+ (*handlePtr) = (Tcl_LoadHandle) tvdlPtr;
(*unloadProcPtr) = &FSUnloadTempFile;
return retVal;
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 05780ed..8fad788 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.107 2002/07/19 12:31:10 dkf Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.108 2002/07/22 16:51:48 vincentdarley Exp $
*/
#ifndef _TCLINT
@@ -1613,7 +1613,6 @@ extern char * tclDefaultEncodingDir;
extern Tcl_ChannelType tclFileChannelType;
extern char * tclMemDumpFileName;
extern TclPlatformType tclPlatform;
-extern Tcl_Filesystem tclNativeFilesystem;
/*
* Variables denoting the Tcl object types defined in the core.
diff --git a/generic/tclLoad.c b/generic/tclLoad.c
index 75dec1b..959fd7b 100644
--- a/generic/tclLoad.c
+++ b/generic/tclLoad.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclLoad.c,v 1.7 2002/01/09 19:09:28 kennykb Exp $
+ * RCS: @(#) $Id: tclLoad.c,v 1.8 2002/07/22 16:51:48 vincentdarley Exp $
*/
#include "tclInt.h"
@@ -32,7 +32,7 @@ typedef struct LoadedPackage {
* properly capitalized (first letter UC,
* others LC), no "_", as in "Net".
* Malloc-ed. */
- ClientData clientData; /* Token for the loaded file which should be
+ Tcl_LoadHandle loadHandle; /* Token for the loaded file which should be
* passed to (*unLoadProcPtr)() when the file
* is no longer needed. If fileName is NULL,
* then this field is irrelevant. */
@@ -124,7 +124,7 @@ Tcl_LoadObjCmd(dummy, interp, objc, objv)
InterpPackage *ipFirstPtr, *ipPtr;
int code, namesMatch, filesMatch;
char *p, *fullFileName, *packageName;
- ClientData clientData;
+ Tcl_LoadHandle loadHandle;
Tcl_FSUnloadFileProc *unLoadProcPtr = NULL;
Tcl_UniChar ch;
int offset;
@@ -340,7 +340,7 @@ Tcl_LoadObjCmd(dummy, interp, objc, objv)
Tcl_MutexLock(&packageMutex);
code = Tcl_FSLoadFile(interp, objv[1], Tcl_DStringValue(&initName),
Tcl_DStringValue(&safeInitName), &initProc, &safeInitProc,
- &clientData,&unLoadProcPtr);
+ &loadHandle,&unLoadProcPtr);
Tcl_MutexUnlock(&packageMutex);
if (code != TCL_OK) {
goto done;
@@ -349,7 +349,7 @@ Tcl_LoadObjCmd(dummy, interp, objc, objv)
Tcl_AppendResult(interp, "couldn't find procedure ",
Tcl_DStringValue(&initName), (char *) NULL);
if (unLoadProcPtr != NULL) {
- (*unLoadProcPtr)(clientData);
+ (*unLoadProcPtr)(loadHandle);
}
code = TCL_ERROR;
goto done;
@@ -366,7 +366,7 @@ Tcl_LoadObjCmd(dummy, interp, objc, objv)
pkgPtr->packageName = (char *) ckalloc((unsigned)
(Tcl_DStringLength(&pkgName) + 1));
strcpy(pkgPtr->packageName, Tcl_DStringValue(&pkgName));
- pkgPtr->clientData = clientData;
+ pkgPtr->loadHandle = loadHandle;
pkgPtr->unLoadProcPtr = unLoadProcPtr;
pkgPtr->initProc = initProc;
pkgPtr->safeInitProc = safeInitProc;
@@ -490,7 +490,7 @@ Tcl_StaticPackage(interp, pkgName, initProc, safeInitProc)
pkgPtr->packageName = (char *) ckalloc((unsigned)
(strlen(pkgName) + 1));
strcpy(pkgPtr->packageName, pkgName);
- pkgPtr->clientData = NULL;
+ pkgPtr->loadHandle = NULL;
pkgPtr->initProc = initProc;
pkgPtr->safeInitProc = safeInitProc;
Tcl_MutexLock(&packageMutex);
@@ -667,7 +667,7 @@ TclFinalizeLoad()
if (pkgPtr->fileName[0] != '\0') {
Tcl_FSUnloadFileProc *unLoadProcPtr = pkgPtr->unLoadProcPtr;
if (unLoadProcPtr != NULL) {
- (*unLoadProcPtr)(pkgPtr->clientData);
+ (*unLoadProcPtr)(pkgPtr->loadHandle);
}
}
#endif