diff options
-rw-r--r-- | jim-array.c | 4 | ||||
-rw-r--r-- | jim-clock.c | 4 | ||||
-rw-r--r-- | jim-eventloop.c | 3 | ||||
-rw-r--r-- | jim-exec.c | 8 | ||||
-rw-r--r-- | jim-file.c | 4 | ||||
-rw-r--r-- | jim-history.c | 4 | ||||
-rw-r--r-- | jim-interp.c | 4 | ||||
-rw-r--r-- | jim-json.c | 5 | ||||
-rw-r--r-- | jim-namespace.c | 4 | ||||
-rw-r--r-- | jim-pack.c | 5 | ||||
-rw-r--r-- | jim-posix.c | 4 | ||||
-rw-r--r-- | jim-readdir.c | 4 | ||||
-rw-r--r-- | jim-readline.c | 4 | ||||
-rw-r--r-- | jim-redis.c | 4 | ||||
-rw-r--r-- | jim-regexp.c | 4 | ||||
-rw-r--r-- | jim-sdl.c | 4 | ||||
-rw-r--r-- | jim-signal.c | 4 | ||||
-rw-r--r-- | jim-sqlite3.c | 4 | ||||
-rw-r--r-- | jim-syslog.c | 3 | ||||
-rw-r--r-- | jim-tclprefix.c | 5 | ||||
-rw-r--r-- | jim-win32.c | 3 | ||||
-rw-r--r-- | jim-zlib.c | 5 | ||||
-rw-r--r-- | jim.c | 13 | ||||
-rw-r--r-- | jim.h | 8 | ||||
-rw-r--r-- | sqlite3/Makefile | 8 | ||||
-rw-r--r-- | sqlite3/README | 16 | ||||
-rw-r--r-- | sqlite3/jim-sqlite.c (renamed from sqlite3/jim-sqlite3.c) | 6 | ||||
-rw-r--r-- | sqlite3/test-sqlite.tcl (renamed from sqlite3/test-sqlite3.tcl) | 6 |
28 files changed, 62 insertions, 88 deletions
diff --git a/jim-array.c b/jim-array.c index a0ccecd..a21099d 100644 --- a/jim-array.c +++ b/jim-array.c @@ -259,9 +259,7 @@ static const jim_subcmd_type array_command_table[] = { int Jim_arrayInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "array", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "array"); Jim_CreateCommand(interp, "array", Jim_SubCmdProc, (void *)array_command_table, NULL); return JIM_OK; } diff --git a/jim-clock.c b/jim-clock.c index cc24319..0ca3e7b 100644 --- a/jim-clock.c +++ b/jim-clock.c @@ -228,9 +228,7 @@ static const jim_subcmd_type clock_command_table[] = { int Jim_clockInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "clock", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "clock"); Jim_CreateCommand(interp, "clock", Jim_SubCmdProc, (void *)clock_command_table, NULL); return JIM_OK; } diff --git a/jim-eventloop.c b/jim-eventloop.c index 1a97191..91f681a 100644 --- a/jim-eventloop.c +++ b/jim-eventloop.c @@ -794,8 +794,7 @@ int Jim_eventloopInit(Jim_Interp *interp) { Jim_EventLoop *eventLoop; - if (Jim_PackageProvide(interp, "eventloop", "1.0", JIM_ERRMSG)) - return JIM_ERR; + Jim_PackageProvideCheck(interp, "eventloop"); eventLoop = Jim_Alloc(sizeof(*eventLoop)); memset(eventLoop, 0, sizeof(*eventLoop)); @@ -82,9 +82,7 @@ static int Jim_ExecCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_execInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "exec", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "exec"); Jim_CreateCommand(interp, "exec", Jim_ExecCmd, NULL, NULL); return JIM_OK; } @@ -1230,8 +1228,8 @@ static int JimCleanupChildren(Jim_Interp *interp, int numPids, pidtype *pidPtr, int Jim_execInit(Jim_Interp *interp) { struct WaitInfoTable *waitinfo; - if (Jim_PackageProvide(interp, "exec", "1.0", JIM_ERRMSG)) - return JIM_ERR; + + Jim_PackageProvideCheck(interp, "exec"); waitinfo = JimAllocWaitInfoTable(); Jim_CreateCommand(interp, "exec", Jim_ExecCmd, waitinfo, JimFreeWaitInfoTable); @@ -1119,9 +1119,7 @@ static int Jim_PwdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_fileInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "file", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "file"); Jim_CreateCommand(interp, "file", Jim_SubCmdProc, (void *)file_command_table, NULL); Jim_CreateCommand(interp, "pwd", Jim_PwdCmd, NULL, NULL); Jim_CreateCommand(interp, "cd", Jim_CdCmd, NULL, NULL); diff --git a/jim-history.c b/jim-history.c index 1ae63d7..7b00b2f 100644 --- a/jim-history.c +++ b/jim-history.c @@ -113,9 +113,7 @@ static const jim_subcmd_type history_command_table[] = { int Jim_historyInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "history", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "history"); Jim_CreateCommand(interp, "history", Jim_SubCmdProc, (void *)history_command_table, NULL); return JIM_OK; } diff --git a/jim-interp.c b/jim-interp.c index d97d6c5..cf02d5f 100644 --- a/jim-interp.c +++ b/jim-interp.c @@ -169,9 +169,7 @@ static int JimInterpCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_interpInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "interp", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "interp"); Jim_CreateCommand(interp, "interp", JimInterpCommand, NULL, NULL); return JIM_OK; @@ -418,10 +418,7 @@ done: int Jim_jsonInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "json", "1.0", JIM_ERRMSG) != JIM_OK) { - return JIM_ERR; - } - + Jim_PackageProvideCheck(interp, "json"); Jim_CreateCommand(interp, "json::decode", json_decode, NULL, NULL); /* Load the Tcl implementation of the json encoder if possible */ Jim_PackageRequire(interp, "jsonencode", 0); diff --git a/jim-namespace.c b/jim-namespace.c index 9920488..87c4dc8 100644 --- a/jim-namespace.c +++ b/jim-namespace.c @@ -324,9 +324,7 @@ static int JimNamespaceCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_namespaceInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "namespace", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "namespace"); Jim_CreateCommand(interp, "namespace", JimNamespaceCmd, NULL, NULL); Jim_CreateCommand(interp, "variable", JimVariableCmd, NULL, NULL); return JIM_OK; @@ -475,10 +475,7 @@ static int Jim_PackCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_packInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "pack", "1.0", JIM_ERRMSG)) { - return JIM_ERR; - } - + Jim_PackageProvideCheck(interp, "pack"); Jim_CreateCommand(interp, "unpack", Jim_UnpackCmd, NULL, NULL); Jim_CreateCommand(interp, "pack", Jim_PackCmd, NULL, NULL); return JIM_OK; diff --git a/jim-posix.c b/jim-posix.c index a4ba61e..e9d5bc3 100644 --- a/jim-posix.c +++ b/jim-posix.c @@ -137,9 +137,7 @@ static int Jim_PosixUptimeCommand(Jim_Interp *interp, int argc, Jim_Obj *const * int Jim_posixInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "posix", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "posix"); #ifdef HAVE_FORK Jim_CreateCommand(interp, "os.fork", Jim_PosixForkCommand, NULL, NULL); #endif diff --git a/jim-readdir.c b/jim-readdir.c index d7c0e40..07c558e 100644 --- a/jim-readdir.c +++ b/jim-readdir.c @@ -114,9 +114,7 @@ int Jim_ReaddirCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_readdirInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "readdir", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "readdir"); Jim_CreateCommand(interp, "readdir", Jim_ReaddirCmd, NULL, NULL); return JIM_OK; } diff --git a/jim-readline.c b/jim-readline.c index 39051b0..5715b2c 100644 --- a/jim-readline.c +++ b/jim-readline.c @@ -65,9 +65,7 @@ static int JimRlAddHistoryCommand(Jim_Interp *interp, int argc, Jim_Obj *const * int Jim_readlineInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "readline", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "readline"); Jim_CreateCommand(interp, "readline.readline", JimRlReadlineCommand, NULL, NULL); Jim_CreateCommand(interp, "readline.addhistory", JimRlAddHistoryCommand, NULL, NULL); return JIM_OK; diff --git a/jim-redis.c b/jim-redis.c index 8722e9f..3ac07eb 100644 --- a/jim-redis.c +++ b/jim-redis.c @@ -163,9 +163,7 @@ static int jim_redis_cmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_redisInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "redis", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "redis"); Jim_CreateCommand(interp, "redis", jim_redis_cmd, NULL, NULL); return JIM_OK; } diff --git a/jim-regexp.c b/jim-regexp.c index 58671df..1486c3a 100644 --- a/jim-regexp.c +++ b/jim-regexp.c @@ -581,9 +581,7 @@ int Jim_RegsubCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_regexpInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "regexp", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "regexp"); Jim_CreateCommand(interp, "regexp", Jim_RegexpCmd, NULL, NULL); Jim_CreateCommand(interp, "regsub", Jim_RegsubCmd, NULL, NULL); return JIM_OK; @@ -535,9 +535,7 @@ static int JimSdlSurfaceCommand(Jim_Interp *interp, int argc, Jim_Obj *const *ar int Jim_sdlInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "sdl", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "sdl"); Jim_CreateCommand(interp, "sdl.screen", JimSdlSurfaceCommand, NULL, NULL); return JIM_OK; } diff --git a/jim-signal.c b/jim-signal.c index 866119d..b65cf7e 100644 --- a/jim-signal.c +++ b/jim-signal.c @@ -530,9 +530,7 @@ static int Jim_KillCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_signalInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "signal", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "signal"); Jim_CreateCommand(interp, "alarm", Jim_AlarmCmd, 0, 0); Jim_CreateCommand(interp, "kill", Jim_KillCmd, 0, 0); /* Sleep is slightly dubious here */ diff --git a/jim-sqlite3.c b/jim-sqlite3.c index c29230b..0146ed4 100644 --- a/jim-sqlite3.c +++ b/jim-sqlite3.c @@ -288,9 +288,7 @@ static int JimSqliteOpenCommand(Jim_Interp *interp, int argc, Jim_Obj *const *ar int Jim_sqlite3Init(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "sqlite3", "1.0", JIM_ERRMSG)) - return JIM_ERR; - + Jim_PackageProvideCheck(interp, "sqlite3"); Jim_CreateCommand(interp, "sqlite3.open", JimSqliteOpenCommand, NULL, NULL); return JIM_OK; } diff --git a/jim-syslog.c b/jim-syslog.c index 9e279ef..ad8af59 100644 --- a/jim-syslog.c +++ b/jim-syslog.c @@ -172,8 +172,7 @@ int Jim_syslogInit(Jim_Interp *interp) { SyslogInfo *info; - if (Jim_PackageProvide(interp, "syslog", "1.0", JIM_ERRMSG)) - return JIM_ERR; + Jim_PackageProvideCheck(interp, "syslog"); info = Jim_Alloc(sizeof(*info)); diff --git a/jim-tclprefix.c b/jim-tclprefix.c index c492234..c451119 100644 --- a/jim-tclprefix.c +++ b/jim-tclprefix.c @@ -214,10 +214,7 @@ static int Jim_TclPrefixCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const int Jim_tclprefixInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "tclprefix", "1.0", JIM_ERRMSG)) { - return JIM_ERR; - } - + Jim_PackageProvideCheck(interp, "tclprefix"); Jim_CreateCommand(interp, "tcl::prefix", Jim_TclPrefixCoreCommand, NULL, NULL); return JIM_OK; } diff --git a/jim-win32.c b/jim-win32.c index 33e7117..858e49d 100644 --- a/jim-win32.c +++ b/jim-win32.c @@ -506,8 +506,7 @@ Win32_MessageBox(Jim_Interp *interp, int objc, Jim_Obj * const *objv) int Jim_win32Init(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "win32", "1.0", JIM_ERRMSG)) - return JIM_ERR; + Jim_PackageProvideCheck(interp, "win32"); #define CMD(name) \ Jim_CreateCommand(interp, "win32." #name , Win32_ ## name , NULL, NULL) @@ -309,10 +309,7 @@ static int JimZlibCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv) int Jim_zlibInit(Jim_Interp *interp) { - if (Jim_PackageProvide(interp, "zlib", "1.0", JIM_ERRMSG)) { - return JIM_ERR; - } - + Jim_PackageProvideCheck(interp, "zlib"); Jim_CreateCommand(interp, "zlib", JimZlibCmd, 0, 0); return JIM_OK; @@ -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) @@ -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); diff --git a/sqlite3/Makefile b/sqlite3/Makefile index 2b69ae4..3b920cf 100644 --- a/sqlite3/Makefile +++ b/sqlite3/Makefile @@ -1,16 +1,16 @@ # Builds the full sqlite3 extension for Jim Tcl with the sqlite3 amalgamation -all: sqlite3.so +all: sqlite.so SQLITE3_OPTS := -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 \ -DSQLITE_ENABLE_STAT3 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_OMIT_INCRBLOB -sqlite3.so: jim-sqlite3.c sqlite3.c +sqlite.so: jim-sqlite.c sqlite3.c ./build-ext -Wall -o $@ -I.. -L.. $(SQLITE3_OPTS) $(BUILDOPTS) $^ clean: rm -f *.o *.so # Note that this will only work when not cross compiling -test: sqlite3.so - ../jimsh test-sqlite3.tcl +test: sqlite.so + ../jimsh test-sqlite.tcl diff --git a/sqlite3/README b/sqlite3/README index d1094dd..297c3de 100644 --- a/sqlite3/README +++ b/sqlite3/README @@ -13,14 +13,14 @@ Ensure that you have configured and built jim in the source directory, then: $ make -./build-ext -o sqlite3.so -I.. -L.. -DSQLITE_OMIT_LOAD_EXTENSION=1 ... jim-sqlite3.c sqlite3.c -Building sqlite3.so from jim-sqlite3.c sqlite3.c +./build-ext -o sqlite.so -I.. -L.. -DSQLITE_OMIT_LOAD_EXTENSION=1 ... jim-sqlite.c sqlite3.c +Building sqlite.so from jim-sqlite.c sqlite3.c Warning: libjim is static. Dynamic module may not work on some platforms. -Compile: jim-sqlite3.o +Compile: jim-sqlite.o Compile: sqlite3.o -Link: sqlite3.so +Link: sqlite.so Success! @@ -32,17 +32,17 @@ $ make test Installing ---------- -Copy sqlite3.so to your jim library directory, typically /usr/local/lib/jim or +Copy sqlite.so to your jim library directory, typically /usr/local/lib/jim or where $JIMLIB points to. Using ----- -In your Jim Tcl code, ensure that sqlite3.so is in a directory on $auto_path. +In your Jim Tcl code, ensure that sqlite.so is in a directory on $auto_path. Then: - package require sqlite3 + package require sqlite - sqlite3 db test.db + sqlite db test.db ...etc.. Documentation diff --git a/sqlite3/jim-sqlite3.c b/sqlite3/jim-sqlite.c index 8f33d80..06ed7c0 100644 --- a/sqlite3/jim-sqlite3.c +++ b/sqlite3/jim-sqlite.c @@ -2821,10 +2821,8 @@ static int DbMain(Jim_Interp *interp, int objc, Jim_Obj *const*objv){ ** used to open a new SQLite database. See the DbMain() routine above ** for additional information. */ -EXTERN int Jim_sqlite3Init(Jim_Interp *interp){ - Jim_CreateCommand(interp, "sqlite3", DbMain, 0, 0); - Jim_PackageProvide(interp, "sqlite3", PACKAGE_VERSION, 0); +EXTERN int Jim_sqliteInit(Jim_Interp *interp){ + Jim_PackageProvideCheck(interp, "sqlite"); Jim_CreateCommand(interp, "sqlite", DbMain, 0, 0); - Jim_PackageProvide(interp, "sqlite", PACKAGE_VERSION, 0); return JIM_OK; } diff --git a/sqlite3/test-sqlite3.tcl b/sqlite3/test-sqlite.tcl index 3786b09..82cce40 100644 --- a/sqlite3/test-sqlite3.tcl +++ b/sqlite3/test-sqlite.tcl @@ -1,11 +1,11 @@ -# A simple test of the "big" sqlite3 extension +# A simple test of the "big" sqlite extension set auto_path [list . {*}$auto_path] -package require sqlite3 +package require sqlite # Create an in-memory database and add some data -sqlite3 db :memory: +sqlite db :memory: db eval {CREATE TABLE history (type, time, value)} foreach t [range 1 50] { set temp [rand 100] |