summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/OOInitStubs.361
-rw-r--r--generic/tclOO.c2
-rw-r--r--generic/tclOO.h15
-rw-r--r--generic/tclOOStubLib.c2
-rw-r--r--generic/tclStubLib.c13
5 files changed, 86 insertions, 7 deletions
diff --git a/doc/OOInitStubs.3 b/doc/OOInitStubs.3
new file mode 100644
index 0000000..374738d
--- /dev/null
+++ b/doc/OOInitStubs.3
@@ -0,0 +1,61 @@
+'\"
+'\" Copyright (c) 2012 Donal K. Fellows
+'\"
+'\" See the file "license.terms" for information on usage and redistribution
+'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+'\"
+.so man.macros
+.TH Tcl_OOInitStubs 3 1.0 TclOO "TclOO Library Functions"
+.BS
+'\" Note: do not modify the .SH NAME line immediately below!
+.SH NAME
+Tcl_OOInitStubs \- initialize library access to TclOO functionality
+.SH SYNOPSIS
+.nf
+\fB#include <tclOO.h>\fR
+.sp
+const char *
+\fBTcl_OOInitStubs\fR(\fIinterp\fR)
+.fi
+.SH ARGUMENTS
+.AS Tcl_Interp *interp in
+.AP Tcl_Interp *interp in
+The Tcl interpreter that the TclOO API is integrated with and whose C
+interface is going to be used.
+.BE
+.SH DESCRIPTION
+.PP
+When an extension library is going to use the C interface exposed by TclOO,
+and it wants to remain compatible with Tcl 8.6.1 and lower, it
+should use \fBTcl_OOInitStubs\fR to initialize its access to that interface
+from within its \fI*\fB_Init\fR (or \fI*\fB_SafeInit\fR) function, passing in
+the \fIinterp\fR that was passed into that routine as context. If the result
+of calling \fBTcl_OOInitStubs\fR is NULL, the initialization failed and an
+error message will have been left in the interpreter's result. Otherwise, the
+initialization succeeded and the TclOO API may thereafter be used; the
+version of the TclOO API is returned. Starting with Tcl 8.6.2, you can call
+\fBTcl_InitStubs\fR in stead of \fBTcl_OOInitStubs\fR.
+.PP
+When using stubs, the C #define symbol \fBUSE_TCL_STUBS\fR should be defined
+and your library code linked against the Tcl stub library. Calling the
+\fBTcl_InitStubs\fR function is the first thing the extension should do,
+just as any other extension not using TclOO.
+.PP
+If you don't want to use stubs, you can also link to Tcl statically. Then,
+\fBUSE_TCL_STUBS\fR should not be set and calling \fBTcl_InitStubs\fR is
+optional.
+
+.SH "BACKWARD COMPATIBILITY NOTE"
+.PP
+If you are linking against the Tcl 8.5 forward compatibility package for
+TclOO, \fIonly\fR the stub-enabled configuration is supported and you should
+also link against the TclOO independent stub library; that library is an
+integrated part of the main Tcl stub library in Tcl 8.6.
+.SH KEYWORDS
+stubs
+.SH "SEE ALSO"
+Tcl_InitStubs(3)
+.\" Local variables:
+.\" mode: nroff
+.\" fill-column: 78
+.\" End:
diff --git a/generic/tclOO.c b/generic/tclOO.c
index cb22de6..529640f 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -271,7 +271,7 @@ TclOOInit(
return TCL_ERROR;
}
- return Tcl_PkgProvideEx(interp, "TclOO", TCLOO_VERSION,
+ return Tcl_PkgProvideEx(interp, "TclOO", TCLOO_PATCHLEVEL,
(ClientData) &tclOOStubs);
}
diff --git a/generic/tclOO.h b/generic/tclOO.h
index d5ab8a0..fd02bd4 100644
--- a/generic/tclOO.h
+++ b/generic/tclOO.h
@@ -15,18 +15,23 @@
#include "tcl.h"
#ifndef TCLOOAPI
-# if defined(BUILD_tcl) || defined(BUILD_TclOO)
+# if (defined(BUILD_tcl) || defined(BUILD_TclOO)) && !defined(BUILD_STATIC)
# define TCLOOAPI MODULE_SCOPE
# else
# define TCLOOAPI extern
-# undef USE_TCLOO_STUBS
-# define USE_TCLOO_STUBS 1
+# ifdef USE_TCL_STUBS
+# undef USE_TCLOO_STUBS
+# define USE_TCLOO_STUBS 1
+# endif
# endif
#endif
extern const char *TclOOInitializeStubs(
Tcl_Interp *, const char *version);
#define Tcl_OOInitStubs(interp) TclOOInitializeStubs((interp), TCLOO_VERSION)
+#ifndef USE_TCL_STUBS
+# define TclOOInitializeStubs(interp, version) (TCLOO_PATCHLEVEL)
+#endif
/*
* Be careful when it comes to versioning; need to make sure that the
@@ -39,8 +44,8 @@ extern const char *TclOOInitializeStubs(
* win/tclooConfig.sh
*/
-#define TCLOO_VERSION "1.0.1"
-#define TCLOO_PATCHLEVEL TCLOO_VERSION
+#define TCLOO_VERSION "1.0"
+#define TCLOO_PATCHLEVEL "1.0.1"
/*
* These are opaque types.
diff --git a/generic/tclOOStubLib.c b/generic/tclOOStubLib.c
index 921aced..a9fa212 100644
--- a/generic/tclOOStubLib.c
+++ b/generic/tclOOStubLib.c
@@ -27,6 +27,8 @@ const TclOOIntStubs *tclOOIntStubsPtr = NULL;
*----------------------------------------------------------------------
*/
+#undef TclOOInitializeStubs
+
MODULE_SCOPE const char *
TclOOInitializeStubs(
Tcl_Interp *interp,
diff --git a/generic/tclStubLib.c b/generic/tclStubLib.c
index 859cbf9..f4c967a 100644
--- a/generic/tclStubLib.c
+++ b/generic/tclStubLib.c
@@ -11,7 +11,7 @@
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
-#include "tclInt.h"
+#include "tclOOInt.h"
MODULE_SCOPE const TclStubs *tclStubsPtr;
MODULE_SCOPE const TclPlatStubs *tclPlatStubsPtr;
@@ -115,6 +115,17 @@ Tcl_InitStubs(
tclIntPlatStubsPtr = NULL;
}
+ if ((actualVersion[0] > '8')
+ || ((actualVersion[1] == '.') && (actualVersion[2] > '5'))) {
+ stubsPtr->tcl_PkgRequireEx(interp,
+ "TclOO", "1.0", 0, (void *)&tclOOStubsPtr);
+ if (tclOOStubsPtr->hooks) {
+ tclOOIntStubsPtr = tclOOStubsPtr->hooks->tclOOIntStubs;
+ } else {
+ tclOOIntStubsPtr = NULL;
+ }
+ }
+
return actualVersion;
}