aboutsummaryrefslogtreecommitdiff
path: root/tclpd.c
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2011-11-13 22:52:33 +0000
committermescalinum <mescalinum@users.sourceforge.net>2011-11-13 22:52:33 +0000
commitc80ad601728139c16c4903f5ed08680f7e5f203c (patch)
treeab8d9484489355b9877eecf05e859a02d8bb7e14 /tclpd.c
parent8dd16881e82ee2b655049367968ebd8d28d1d9cc (diff)
0.3.0 - typemaps support complete
svn path=/trunk/externals/loaders/tclpd/; revision=15738
Diffstat (limited to 'tclpd.c')
-rw-r--r--tclpd.c51
1 files changed, 31 insertions, 20 deletions
diff --git a/tclpd.c b/tclpd.c
index 0440952..6925852 100644
--- a/tclpd.c
+++ b/tclpd.c
@@ -1,13 +1,13 @@
-#include "tcl_extras.h"
+#include "tclpd.h"
#include <stdlib.h>
#include <unistd.h>
#include <limits.h>
#include <m_imp.h>
-Tcl_Interp *tcl_for_pd = NULL;
+Tcl_Interp *tclpd_interp = NULL;
void tclpd_setup(void) {
- if(tcl_for_pd) {
+ if(tclpd_interp) {
return;
}
@@ -16,41 +16,52 @@ void tclpd_setup(void) {
proxyinlet_setup();
- tcl_for_pd = Tcl_CreateInterp();
- Tcl_Init(tcl_for_pd);
- Tclpd_SafeInit(tcl_for_pd);
+ tclpd_interp = Tcl_CreateInterp();
+ Tcl_Init(tclpd_interp);
+ Tclpd_SafeInit(tclpd_interp);
- Tcl_Eval(tcl_for_pd, "package provide Tclpd " TCLPD_VERSION);
+ Tcl_Eval(tclpd_interp, "package provide Tclpd " TCLPD_VERSION);
- t_class* foo_class = class_new(gensym("tclpd_init"), 0, 0, 0, 0, 0);
+ t_class *foo_class = class_new(gensym("tclpd_init"), 0, 0, 0, 0, 0);
char buf[PATH_MAX];
-
snprintf(buf, PATH_MAX, "%s/tclpd.tcl", foo_class->c_externdir->s_name);
- if(Tcl_EvalFile(tcl_for_pd, buf) != TCL_OK) {
- error("tclpd loader: error loading %s", buf);
+ verbose(-1, "tclpd: trying to load %s...", buf);
+ int result = Tcl_EvalFile(tclpd_interp, buf);
+ switch(result) {
+ case TCL_ERROR:
+ error("tclpd: error loading %s", buf);
+ break;
+ case TCL_RETURN:
+ error("tclpd: warning: %s exited with code return", buf);
+ break;
+ case TCL_BREAK:
+ case TCL_CONTINUE:
+ error("tclpd: warning: %s exited with code break/continue", buf);
+ break;
}
+ verbose(-1, "tclpd: loaded %s", buf);
sys_register_loader(tclpd_do_load_lib);
}
-void tclpd_interp_error(t_tcl* x, int result) {
- error("tclpd error: %s", Tcl_GetStringResult(tcl_for_pd));
+void tclpd_interp_error(t_tcl *x, int result) {
+ error("tclpd error: %s", Tcl_GetStringResult(tclpd_interp));
- logpost(x, 3, "------------------- Tcl error: -------------------\n");
+ logpost(x, 3, "------------------- Tcl error: -------------------");
// Tcl_GetReturnOptions and Tcl_DictObjGet only available in Tcl >= 8.5
#if ((TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION >= 5) || (TCL_MAJOR_VERSION > 8))
- Tcl_Obj* dict = Tcl_GetReturnOptions(tcl_for_pd, result);
- Tcl_Obj* errorInfo = NULL;
- Tcl_Obj* errorInfoK = Tcl_NewStringObj("-errorinfo", -1);
+ Tcl_Obj *dict = Tcl_GetReturnOptions(tclpd_interp, result);
+ Tcl_Obj *errorInfo = NULL;
+ Tcl_Obj *errorInfoK = Tcl_NewStringObj("-errorinfo", -1);
Tcl_IncrRefCount(errorInfoK);
- Tcl_DictObjGet(tcl_for_pd, dict, errorInfoK, &errorInfo);
+ Tcl_DictObjGet(tclpd_interp, dict, errorInfoK, &errorInfo);
Tcl_DecrRefCount(errorInfoK);
logpost(x, 3, "%s\n", Tcl_GetStringFromObj(errorInfo, 0));
#else
- logpost(x, 3, "Backtrace not available in Tcl < 8.5. Please upgrade Tcl.\n");
+ logpost(x, 3, "Backtrace not available in Tcl < 8.5. Please upgrade Tcl.");
#endif
- logpost(x, 3, "--------------------------------------------------\n");
+ logpost(x, 3, "--------------------------------------------------");
}