From b7a61963d08e832fb2eecb034dd8ea976414371e Mon Sep 17 00:00:00 2001 From: mescalinum Date: Fri, 11 Nov 2011 14:10:00 +0000 Subject: more changes to the swig interface: - use SWIG_Fail for typemap conversion failures - add another typemap for (int argc, t_atom *argv) svn path=/trunk/externals/loaders/tclpd/; revision=15723 --- tcl.i | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/tcl.i b/tcl.i index 234e9e1..f1fa501 100644 --- a/tcl.i +++ b/tcl.i @@ -52,28 +52,36 @@ %name(outlet_list) EXTERN void outlet_list(t_outlet *x, t_symbol *s, int argc, t_atom_array *argv); %name(outlet_anything) EXTERN void outlet_anything(t_outlet *x, t_symbol *s, int argc, t_atom_array *argv); +%typemap(in) (int argc, t_atom *argv) { + if(Tcl_ListObjLength(tcl_for_pd, $input, &$1) == TCL_ERROR) + return TCL_ERROR; + $2 = (t_atom *)getbytes(sizeof(t_atom) * $1); + int i; + Tcl_Obj *oi; + for(i = 0; i < len; i++) { + oi = Tcl_ListObjIndex(tcl_for_pd, $input, i, &oi); + if(tcl_to_pdatom(oi, $2[i]) == TCL_ERROR) { + SWIG_Fail; + } + } +} + %typemap(in) t_atom * { t_atom *a = (t_atom*)getbytes(sizeof(t_atom)); if(tcl_to_pdatom($input, a) == TCL_ERROR) { -#ifdef DEBUG - post("Tcl SWIG: typemap(in) [t_atom] error"); -#endif - return TCL_ERROR; + SWIG_Fail; } $1 = a; } %typemap(freearg) t_atom * { - freebytes($input sizeof(t_atom)); + freebytes($input, sizeof(t_atom)); } %typemap(out) t_atom * { Tcl_Obj* res_obj; if(pdatom_to_tcl($input, &res_obj) == TCL_ERROR) { -#ifdef DEBUG - post("Tcl SWIG: typemap(out) [t_atom] error"); -#endif - return TCL_ERROR; + SWIG_Fail; } Tcl_SetObjResult(tcl_for_pd, res_obj); } @@ -81,10 +89,7 @@ %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; + SWIG_Fail; } $1 = s; } @@ -92,10 +97,7 @@ %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; + SWIG_Fail; } Tcl_SetObjResult(tcl_for_pd, res_obj); } -- cgit v1.2.1