From e1e75297077642fd8bb402bd444ce2c70548f288 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 14 Nov 2011 05:40:12 +0000 Subject: before trying to load an object, set the Tcl auto_path to include the object's dir, so that object can use a local package of shared code svn path=/trunk/externals/loaders/tclpd/; revision=15741 --- tcl_loader.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tcl_loader.c b/tcl_loader.c index a1b1f16..8d07bf7 100644 --- a/tcl_loader.c +++ b/tcl_loader.c @@ -7,7 +7,7 @@ void source_table_add(const char *object_name, const char *source_path); extern int tclpd_do_load_lib(t_canvas *canvas, char *objectname) { - char filename[MAXPDSTRING], dirbuf[MAXPDSTRING], + char filename[MAXPDSTRING], dirbuf[MAXPDSTRING], buf[MAXPDSTRING], *classname, *nameptr; int fd; @@ -59,6 +59,12 @@ found: verbose(-1, "tclpd loader: init namespace for class %s", classname); tclpd_class_namespace_init(classname); + // add current dir to the Tcl auto_path so objects can use local packages + Tcl_Eval(tclpd_interp, "set current_auto_path $auto_path"); + snprintf(buf, MAXPDSTRING, "set auto_path \"{%s} $auto_path\"", dirbuf); + Tcl_Eval(tclpd_interp, buf); + verbose(0, buf); + // load tcl external: verbose(-1, "tclpd loader: loading tcl file %s", filename); result = Tcl_EvalFile(tclpd_interp, filename); @@ -70,6 +76,8 @@ found: tclpd_interp_error(NULL, result); return 0; } + // reset auto_path + Tcl_Eval(tclpd_interp, "set auto_path $current_auto_path"); #ifdef TCLPD_CALL_SETUP // call the setup method: -- cgit v1.2.1