aboutsummaryrefslogtreecommitdiff
path: root/tcl_typemap.c
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2011-11-11 09:13:54 +0000
committermescalinum <mescalinum@users.sourceforge.net>2011-11-11 09:13:54 +0000
commitb961106236fb569dd7b840e90a47c534bd3b179c (patch)
tree11600cff710cd883a062d73991cd6d843ec08269 /tcl_typemap.c
parent1f1a3b9aa98917d4bc986eacd11cd1fc47946582 (diff)
add typemap for t_symbol* (but does not work for return values, like in canvas_getdir())
svn path=/trunk/externals/loaders/tclpd/; revision=15722
Diffstat (limited to 'tcl_typemap.c')
-rw-r--r--tcl_typemap.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/tcl_typemap.c b/tcl_typemap.c
index 65f3872..3671025 100644
--- a/tcl_typemap.c
+++ b/tcl_typemap.c
@@ -1,7 +1,7 @@
#include "tcl_extras.h"
#include <string.h>
-int tcl_to_pd(Tcl_Obj *input, t_atom *output) {
+int tcl_to_pdatom(Tcl_Obj *input, t_atom *output) {
int llength;
if(Tcl_ListObjLength(tcl_for_pd, input, &llength) == TCL_ERROR)
return TCL_ERROR;
@@ -28,7 +28,13 @@ int tcl_to_pd(Tcl_Obj *input, t_atom *output) {
return TCL_OK;
}
-const char* atom_type_string(t_atom* a) {
+int tcl_to_pdsymbol(Tcl_Obj *input, t_symbol **output) {
+ char* s = Tcl_GetStringFromObj(input, 0);
+ *output = gensym(s);
+ return TCL_OK;
+}
+
+const char* pdatom_type_string(t_atom* a) {
switch(a->a_type) {
case A_FLOAT:
case A_DEFFLOAT:
@@ -48,7 +54,7 @@ const char* atom_type_string(t_atom* a) {
}
}
-const char* atom_symbol_value(t_atom* a) {
+const char* pdatom_symbol_value(t_atom* a) {
if(a->a_type == A_DOLLAR) {
char buf[6];
snprintf(buf, 6, "$%d", a->a_w.w_index);
@@ -58,14 +64,14 @@ const char* atom_symbol_value(t_atom* a) {
return a->a_w.w_symbol->s_name;
}
-float atom_float_value(t_atom* a) {
+float pdatom_float_value(t_atom* a) {
return a->a_w.w_float;
}
-int pd_to_tcl(t_atom *input, Tcl_Obj **output) {
+int pdatom_to_tcl(t_atom *input, Tcl_Obj **output) {
Tcl_Obj* tcl_t_atom[2];
#ifdef DEBUG
- post("pd_to_tcl: atom type = %d (%s)",
+ post("pdatom_to_tcl: atom type = %d (%s)",
input->a_type, input->a_type == A_FLOAT ? "A_FLOAT" :
input->a_type == A_SYMBOL ? "A_SYMBOL" :
input->a_type == A_POINTER ? "A_POINTER" : "?");
@@ -94,9 +100,19 @@ int pd_to_tcl(t_atom *input, Tcl_Obj **output) {
}
}
#ifdef DEBUG
- post("pd_to_tcl: atom value = \"%s\"", Tcl_GetStringFromObj(tcl_t_atom[1], 0));
+ post("pdatom_to_tcl: atom value = \"%s\"", Tcl_GetStringFromObj(tcl_t_atom[1], 0));
#endif
*output = Tcl_NewListObj(2, &tcl_t_atom[0]);
Tcl_IncrRefCount(*output);
return TCL_OK;
}
+
+int pdsymbol_to_tcl(t_symbol *input, Tcl_Obj **output) {
+ Tcl_Obj* s[2];
+ s[0] = Tcl_NewStringObj("symbol", -1);
+ s[1] = Tcl_NewStringObj(input->s_name, -1);
+ *output = Tcl_NewListObj(2, &s[0]);
+ Tcl_IncrRefCount(*output);
+ return TCL_OK;
+}
+