aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormescalinum <mescalinum@users.sourceforge.net>2011-10-13 23:35:44 +0000
committermescalinum <mescalinum@users.sourceforge.net>2011-10-13 23:35:44 +0000
commit8303218509a59630ec4c3a31aed0b5264e977500 (patch)
tree998978fa7ab2c8a9b43ba8e43978c1c057a21962
parent60160b4fb3576ba38d901ff18976add29e6cd408 (diff)
some binbuf support. dollar-args still not working properly
svn path=/trunk/externals/loaders/tclpd/; revision=15592
-rw-r--r--pdlib.tcl18
-rw-r--r--tcl_extras.h3
-rw-r--r--tcl_typemap.c17
3 files changed, 38 insertions, 0 deletions
diff --git a/pdlib.tcl b/pdlib.tcl
index f490289..4c45cb5 100644
--- a/pdlib.tcl
+++ b/pdlib.tcl
@@ -256,5 +256,23 @@ namespace eval ::pd {
# upload proc
sys_gui "guiproc $name $argz $body\n"
}
+
+ proc get_binbuf {self} {
+ set binbuf [tclpd_get_object_binbuf $self]
+ set len [binbuf_getnatom $binbuf]
+ set result {}
+ for {set i 0} {$i < $len} {incr i} {
+ set atom [tclpd_binbuf_get_atom $binbuf $i]
+ set selector [atom_type_string $atom]
+ set value {?}
+ if {$selector == "float"} {
+ set value [atom_float_value $atom]
+ } elseif {$selector == "symbol"} {
+ set value [atom_symbol_value $atom]
+ }
+ lappend result [list $selector $value]
+ }
+ return $result
+ }
}
diff --git a/tcl_extras.h b/tcl_extras.h
index e2406b9..2ae0116 100644
--- a/tcl_extras.h
+++ b/tcl_extras.h
@@ -47,6 +47,9 @@ extern int Tclpd_SafeInit(Tcl_Interp *interp);
/* tcl_typemap.cxx */
int pd_to_tcl(t_atom* input, Tcl_Obj** output);
int tcl_to_pd(Tcl_Obj* input, t_atom* output);
+const char* atom_type_string(t_atom* a);
+const char* atom_symbol_value(t_atom* a);
+float atom_float_value(t_atom* a);
/* tcl_setup.cxx */
extern Tcl_Interp* tcl_for_pd;
diff --git a/tcl_typemap.c b/tcl_typemap.c
index 4044afb..94c3aa0 100644
--- a/tcl_typemap.c
+++ b/tcl_typemap.c
@@ -28,6 +28,23 @@ int tcl_to_pd(Tcl_Obj *input, t_atom *output) {
return TCL_OK;
}
+const char* atom_type_string(t_atom* a) {
+ switch(a->a_type) {
+ case A_FLOAT: return "float";
+ case A_SYMBOL: return "symbol";
+ case A_POINTER: return "pointer";
+ default: return "???";
+ }
+}
+
+const char* atom_symbol_value(t_atom* a) {
+ return a->a_w.w_symbol->s_name;
+}
+
+float atom_float_value(t_atom* a) {
+ return a->a_w.w_float;
+}
+
int pd_to_tcl(t_atom *input, Tcl_Obj **output) {
Tcl_Obj* tcl_t_atom[2];
#ifdef DEBUG