diff options
author | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-11-14 05:40:12 +0000 |
---|---|---|
committer | Hans-Christoph Steiner <eighthave@users.sourceforge.net> | 2011-11-14 05:40:12 +0000 |
commit | e1e75297077642fd8bb402bd444ce2c70548f288 (patch) | |
tree | 806b0b47621d4fee65a2626a6f6199646a49d889 | |
parent | 4ba75f7cabfad8ae7fe378eda0f6ec6b275b15c2 (diff) |
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
-rw-r--r-- | tcl_loader.c | 10 |
1 files changed, 9 insertions, 1 deletions
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: |