From b961106236fb569dd7b840e90a47c534bd3b179c Mon Sep 17 00:00:00 2001 From: mescalinum Date: Fri, 11 Nov 2011 09:13:54 +0000 Subject: add typemap for t_symbol* (but does not work for return values, like in canvas_getdir()) svn path=/trunk/externals/loaders/tclpd/; revision=15722 --- tcl.i | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'tcl.i') diff --git a/tcl.i b/tcl.i index 6a02761..234e9e1 100644 --- a/tcl.i +++ b/tcl.i @@ -54,9 +54,9 @@ %typemap(in) t_atom * { t_atom *a = (t_atom*)getbytes(sizeof(t_atom)); - if(tcl_to_pd($input, a) == TCL_ERROR) { + if(tcl_to_pdatom($input, a) == TCL_ERROR) { #ifdef DEBUG - post("Tcl SWIG: typemap(in) error"); + post("Tcl SWIG: typemap(in) [t_atom] error"); #endif return TCL_ERROR; } @@ -64,14 +64,36 @@ } %typemap(freearg) t_atom * { - freebytes($1, sizeof(t_atom)); + freebytes($input sizeof(t_atom)); } -%typemap(out) t_atom* { +%typemap(out) t_atom * { Tcl_Obj* res_obj; - if(pd_to_tcl($1, &res_obj) == TCL_ERROR) { + if(pdatom_to_tcl($input, &res_obj) == TCL_ERROR) { #ifdef DEBUG - post("Tcl SWIG: typemap(out) error"); + post("Tcl SWIG: typemap(out) [t_atom] error"); +#endif + return TCL_ERROR; + } + Tcl_SetObjResult(tcl_for_pd, res_obj); +} + +%typemap(in) t_symbol * { + t_symbol *s; + if(tcl_to_pdsymbol($input, &s) == TCL_ERROR) { +#ifdef DEBUG + post("Tcl SWIG: typemap(in) [t_symbol] error"); +#endif + return TCL_ERROR; + } + $1 = s; +} + +%typemap(out) t_symbol * { + Tcl_Obj* res_obj; + if(pdsymbol_to_tcl($input, &res_obj) == TCL_ERROR) { +#ifdef DEBUG + post("Tcl SWIG: typemap(out) [t_symbol] error"); #endif return TCL_ERROR; } -- cgit v1.2.1