aboutsummaryrefslogtreecommitdiff
path: root/jim.c
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.c
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.c')
-rw-r--r--jim.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/jim.c b/jim.c
index 0de2f3e..7c54628 100644
--- a/jim.c
+++ b/jim.c
@@ -16206,6 +16206,19 @@ void Jim_SetResultFormatted(Jim_Interp *interp, const char *format, ...)
}
}
+/* Should be called as the first thing in a loadable module to verify
+ * that the interpeter ABI is compatible with the ABI that the module was compiled against.
+ * Returns JIM_ERR and sets an error if mismatch.
+ */
+int Jim_CheckAbiVersion(Jim_Interp *interp, int abi_version)
+{
+ if (abi_version != JIM_ABI_VERSION) {
+ Jim_SetResultString(interp, "ABI version mismatch", -1);
+ return JIM_ERR;
+ }
+ return JIM_OK;
+}
+
/* stubs */
#ifndef jim_ext_package
int Jim_PackageProvide(Jim_Interp *interp, const char *name, const char *ver, int flags)