aboutsummaryrefslogtreecommitdiff
path: root/jim.h
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2021-01-10 13:12:36 +1000
committerSteve Bennett <steveb@workware.net.au>2021-01-10 15:33:15 +1000
commit8f3e1ce80995c42a200db98fbfe02e4a60771c26 (patch)
tree79cfcc498292df506fb71660caa3527f03823246 /jim.h
parenta95647743db1816f54368c8b515b6cc6d4c3c745 (diff)
downloadjimtcl-8f3e1ce80995c42a200db98fbfe02e4a60771c26.zip
jimtcl-8f3e1ce80995c42a200db98fbfe02e4a60771c26.tar.gz
jimtcl-8f3e1ce80995c42a200db98fbfe02e4a60771c26.tar.bz2
package: add ABI version checking
jim.h now includes JIM_ABI_VERSION that should be incremented whenever the ABI changes. Then all loadable modules should call Jim_CheckAbiVersion() to make sure they are loaded against the correct version. Add Jim_PackageProvideCheck() that does both Jim_CheckAbiVersion() and Jim_PackageProvide() to simplify the implementation of loadable extensions. Also rename the "big" sqlite3 extension to just sqlite to avoid a naming conflict with the smaller jim-sqlite3 extension. Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'jim.h')
-rw-r--r--jim.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/jim.h b/jim.h
index 4933bdc..8c59876 100644
--- a/jim.h
+++ b/jim.h
@@ -125,6 +125,9 @@ extern "C" {
* Exported defines
* ---------------------------------------------------------------------------*/
+/* Increment this every time the public ABI changes */
+#define JIM_ABI_VERSION 100
+
#define JIM_OK 0
#define JIM_ERR 1
#define JIM_RETURN 2
@@ -891,13 +894,18 @@ JIM_EXPORT void * Jim_GetAssocData(Jim_Interp *interp, const char *key);
JIM_EXPORT int Jim_SetAssocData(Jim_Interp *interp, const char *key,
Jim_InterpDeleteProc *delProc, void *data);
JIM_EXPORT int Jim_DeleteAssocData(Jim_Interp *interp, const char *key);
+JIM_EXPORT int Jim_CheckAbiVersion(Jim_Interp *interp, int abi_version);
/* Packages C API */
+
/* jim-package.c */
JIM_EXPORT int Jim_PackageProvide (Jim_Interp *interp,
const char *name, const char *ver, int flags);
JIM_EXPORT int Jim_PackageRequire (Jim_Interp *interp,
const char *name, int flags);
+#define Jim_PackageProvideCheck(INTERP, NAME) \
+ if (Jim_CheckAbiVersion(INTERP, JIM_ABI_VERSION) == JIM_ERR || Jim_PackageProvide(INTERP, NAME, "1.0", JIM_ERRMSG)) \
+ return JIM_ERR
/* error messages */
JIM_EXPORT void Jim_MakeErrorMessage (Jim_Interp *interp);