diff options
author | stanton <stanton> | 1999-03-06 23:07:51 (GMT) |
---|---|---|
committer | stanton <stanton> | 1999-03-06 23:07:51 (GMT) |
commit | 307d14f16b85ccfd297dd1009635376a88d9a74a (patch) | |
tree | b1ab0807300dac4a2ac0a23b54d3f672cf09f9bd /generic | |
parent | e70550a22b9cd29d9438f95c9c7d4c24d993bfdc (diff) | |
download | tk-307d14f16b85ccfd297dd1009635376a88d9a74a.zip tk-307d14f16b85ccfd297dd1009635376a88d9a74a.tar.gz tk-307d14f16b85ccfd297dd1009635376a88d9a74a.tar.bz2 |
Added stub patches
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tk.h | 34 | ||||
-rw-r--r-- | generic/tkMain.c | 33 | ||||
-rw-r--r-- | generic/tkStubLib.c | 90 | ||||
-rw-r--r-- | generic/tkWindow.c | 18 |
4 files changed, 168 insertions, 7 deletions
diff --git a/generic/tk.h b/generic/tk.h index 26dea99..204c46e9 100644 --- a/generic/tk.h +++ b/generic/tk.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: tk.h,v 1.19.4.1 1999/03/06 00:08:01 redman Exp $ + * RCS: @(#) $Id: tk.h,v 1.19.4.2 1999/03/06 23:07:51 stanton Exp $ */ #ifndef _TK @@ -82,9 +82,15 @@ # include <stddef.h> #endif +#undef TCL_STORAGE_CLASS #ifdef BUILD_tk -# undef TCL_STORAGE_CLASS # define TCL_STORAGE_CLASS DLLEXPORT +#else +# ifdef USE_TK_STUBS +# define TCL_STORAGE_CLASS +# else +# define TCL_STORAGE_CLASS DLLIMPORT +# endif #endif /* @@ -1046,6 +1052,30 @@ typedef int (Tk_SelectionProc) _ANSI_ARGS_((ClientData clientData, int offset, char *buffer, int maxBytes)); +/* + * Public functions that are not accessible via the stubs table. + */ + +EXTERN void Tk_Main _ANSI_ARGS_((int argc, char **argv, + Tcl_AppInitProc *appInitProc)); +EXTERN void Tk_MainEx _ANSI_ARGS_((int argc, char **argv, + Tcl_AppInitProc *appInitProc, Tcl_Interp *interp)); + +/* + * Stubs initialization function. This function should be invoked before + * any other Tk functions in a stubs-aware extension. Tk_InitStubs is + * implemented in the stub library, not the main Tk library. In directly + * linked code, this function turns into a call to Tcl_PkgRequire(). + */ + +EXTERN char * Tk_InitStubs _ANSI_ARGS_((Tcl_Interp *interp, + char *version, int exact)); + +#ifndef USE_TK_STUBS +#define Tk_InitStubs(interp, version, exact) \ + Tcl_PkgRequire(interp, "Tk", version, exact) +#endif + #include "tkDecls.h" #endif /* RESOURCE_INCLUDED */ diff --git a/generic/tkMain.c b/generic/tkMain.c index 0583408..ffd9d8b 100644 --- a/generic/tkMain.c +++ b/generic/tkMain.c @@ -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: tkMain.c,v 1.2 1998/09/14 18:23:14 stanton Exp $ + * RCS: @(#) $Id: tkMain.c,v 1.2.4.1 1999/03/06 23:07:51 stanton Exp $ */ #include <ctype.h> @@ -67,7 +67,7 @@ static void StdinProc _ANSI_ARGS_((ClientData clientData, /* *---------------------------------------------------------------------- * - * Tk_Main -- + * Tk_Main, Tk_MainEx -- * * Main program for Wish and most other Tk-based applications. * @@ -92,14 +92,41 @@ Tk_Main(argc, argv, appInitProc) * initialization but before starting * to execute commands. */ { + TkMain(argc, argv, appInitProc, Tcl_CreateInterp()); +} + +void +Tk_MainEx(argc, argv, appInitProc, interp) + int argc; /* Number of arguments. */ + char **argv; /* Array of argument strings. */ + Tcl_AppInitProc *appInitProc; /* Application-specific initialization + * procedure to call after most + * initialization but before starting + * to execute commands. */ + Tcl_Interp *interp; /* Application interpreter. */ +{ char *args, *fileName; char buf[20]; int code; size_t length; Tcl_Channel inChannel, outChannel; + /* + * Make sure that Tcl is present. If using stubs this will initialize the + * stub table pointers. + */ + + if (Tcl_Required (interp, NULL, 0) == NULL) { + abort(); + } + Tcl_FindExecutable(argv[0]); - interp = Tcl_CreateInterp(); + + +#if (defined(__WIN32__) || defined(MAC_TCL)) + TkConsoleCreate(); +#endif + #ifdef TCL_MEM_DEBUG Tcl_InitMemory(interp); #endif diff --git a/generic/tkStubLib.c b/generic/tkStubLib.c new file mode 100644 index 0000000..24342be --- /dev/null +++ b/generic/tkStubLib.c @@ -0,0 +1,90 @@ +/* + * tkStubLib.c -- + * + * Stub object that will be statically linked into extensions that wish + * to access Tk. + * + * Copyright (c) 1998 Paul Duffin. + * Copyright (c) 1998-1999 by Scriptics Corporation. + * + * See the file "license.terms" for information on usage and redistribution + * of this file, and for a DISCLAIMER OF ALL WARRANTIES. + * + * RCS: @(#) $Id: tkStubLib.c,v 1.1.2.1 1999/03/06 23:07:51 stanton Exp $ + */ + +/* + * We need to ensure that we use the stub macros so that this file contains + * no references to any of the stub functions. This will make it possible + * to build an extension that references Tk_InitStubs but doesn't end up + * including the rest of the stub functions. + */ + +#ifndef USE_TK_STUBS +#define USE_TK_STUBS +#endif +#undef USE_TK_STUB_PROCS + +#ifndef USE_TCL_STUBS +#define USE_TCL_STUBS +#endif + +/* + * Ensure that Tk_InitStubs is built as an exported symbol. The other stub + * functions should be built as non-exported symbols. + */ + +#undef TCL_STORAGE_CLASS +#define TCL_STORAGE_CLASS DLLEXPORT + +TkStubs *tkStubsPtr; +TkPlatStubs *tkPlatStubsPtr; +TkIntStubs *tkIntStubsPtr; +TkIntPlatStubs *tkIntPlatStubsPtr; + + +/* + *---------------------------------------------------------------------- + * + * Tk_InitStubs -- + * + * Checks that the correct version of Tk is loaded and that it + * supports stubs. It then initialises the stub table pointers. + * + * Results: + * The actual version of Tk that satisfies the request, or + * NULL to indicate that an error occurred. + * + * Side effects: + * Sets the stub table pointers. + * + *---------------------------------------------------------------------- + */ + +char * +Tk_InitStubs(interp, version, exact) + Tcl_Interp *interp; + char *version; + int exact; +{ + char *actualVersion; + + actualVersion = Tcl_PkgRequireEx(interp, "Tk", version, exact, + (ClientData *) &tkStubsPtr); + if (!actualVersion) { + return NULL; + } + + if (!tkStubsPtr) { + Tcl_SetResult(interp, + "This implementation of Tk does not support stubs", + TCL_STATIC); + return NULL; + } + + tkPlatStubsPtr = tkStubsPtr->hooks->tkPlatStubs; + tkIntStubsPtr = tkStubsPtr->hooks->tkIntStubs; + tkIntPlatStubsPtr = tkStubsPtr->hooks->tkIntPlatStubs; + + return actualVersion; +} diff --git a/generic/tkWindow.c b/generic/tkWindow.c index aeb948b..455b528 100644 --- a/generic/tkWindow.c +++ b/generic/tkWindow.c @@ -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: tkWindow.c,v 1.4.4.1 1999/03/06 02:23:17 redman Exp $ + * RCS: @(#) $Id: tkWindow.c,v 1.4.4.2 1999/03/06 23:07:52 stanton Exp $ */ #include "tkPort.h" @@ -2613,6 +2613,15 @@ Initialize(interp) char buffer[30]; /* + * Ensure that we are getting the matching version of Tcl. This is + * really only an issue when Tk is loaded dynamically. + */ + + if (Tcl_InitStubs(interp, TCL_VERSION, 1) == NULL) { + return TCL_ERROR; + } + + /* * Start by initializing all the static variables to default acceptable * values so that no information is leaked from a previous run of this * code. @@ -2821,7 +2830,12 @@ Initialize(interp) code = TCL_ERROR; goto done; } - code = Tcl_PkgProvide(interp, "Tk", TK_VERSION); + + /* + * Provide Tk and its stub table. + */ + + code = Tcl_PkgProvide(interp, "Tk", TK_VERSION, (ClientData) tkStubsPtr); if (code != TCL_OK) { goto done; } |