Permalink
Browse files

use more handy SWIG macros

git-svn-id: https://pure-data.svn.sourceforge.net/svnroot/pure-data/trunk@15749 df7eb9d6-776f-4174-a42d-0ffd8d5d5b5d
  • Loading branch information...
1 parent 6376af8 commit 73209d02e12a1a6f6a690f1eaeb6a3e4ed6551e7 mescalinum committed Nov 15, 2011
Showing with 15 additions and 32 deletions.
  1. +15 −32 externals/loaders/tclpd/tclpd.i
@@ -26,20 +26,17 @@ void name_setitem(type *ary, int index, type value)
%typemap(in) (int argc, t_atom *argv) {
if(Tcl_ListObjLength(interp, $input, &$1) == TCL_ERROR) {
- SWIG_exception(SWIG_RuntimeError, "failed to get list length");
- SWIG_fail;
+ SWIG_exception_fail(SWIG_RuntimeError, "failed to get list length");
}
$2 = (t_atom *)getbytes(sizeof(t_atom) * $1);
int i;
Tcl_Obj *oi;
for(i = 0; i < $1; i++) {
if(Tcl_ListObjIndex(interp, $input, i, &oi) == TCL_ERROR) {
- SWIG_exception(SWIG_RuntimeError, "failed to access list element");
- SWIG_fail;
+ SWIG_exception_fail(SWIG_RuntimeError, "failed to access list element");
}
if(tcl_to_pdatom(oi, &$2[i]) == TCL_ERROR) {
- SWIG_exception(SWIG_RuntimeError, "failed tcl_to_pdatom conversion");
- SWIG_fail;
+ SWIG_exception_fail(SWIG_RuntimeError, "failed tcl_to_pdatom conversion");
}
}
}
@@ -51,8 +48,7 @@ void name_setitem(type *ary, int index, type value)
%typemap(in) t_atom * {
$1 = (t_atom *)getbytes(sizeof(t_atom));
if(tcl_to_pdatom($input, $1) == TCL_ERROR) {
- SWIG_exception(SWIG_RuntimeError, "failed tcl_to_pdatom conversion");
- SWIG_fail;
+ SWIG_exception_fail(SWIG_RuntimeError, "failed tcl_to_pdatom conversion");
}
}
@@ -63,62 +59,49 @@ void name_setitem(type *ary, int index, type value)
%typemap(out) t_atom * {
Tcl_Obj *lst;
if(pdatom_to_tcl($1, &lst) == TCL_ERROR) {
- SWIG_exception(SWIG_RuntimeError, "failed pdatom_to_tcl conversion");
- SWIG_fail;
+ SWIG_exception_fail(SWIG_RuntimeError, "failed pdatom_to_tcl conversion");
}
Tcl_SetObjResult(interp, lst);
}
%typemap(in) t_symbol * {
if(tcl_to_pdsymbol($input, &$1) == TCL_ERROR) {
- SWIG_exception(SWIG_RuntimeError, "failed tcl_to_pdsymbol conversion");
- SWIG_fail;
+ SWIG_exception_fail(SWIG_RuntimeError, "failed tcl_to_pdsymbol conversion");
}
}
%typemap(out) t_symbol * {
Tcl_Obj *lst;
if(pdsymbol_to_tcl($1, &lst) == TCL_ERROR) {
- SWIG_exception(SWIG_RuntimeError, "failed pdsymbol_to_tcl conversion");
- SWIG_fail;
+ SWIG_exception_fail(SWIG_RuntimeError, "failed pdsymbol_to_tcl conversion");
}
Tcl_SetObjResult(interp, lst);
}
%typemap(in) t_tcl * {
const char *str = Tcl_GetStringFromObj($input, NULL);
$1 = object_table_get(str);
- if(!$1) {
- SWIG_exception(SWIG_RuntimeError, "not a t_tcl * instance");
- SWIG_fail;
+ SWIG_contract_assert($1, "not a t_tcl * instance");
}
}
-%typemap(in) t_text * {
+%typemap(in) t_pd * {
const char *str = Tcl_GetStringFromObj($input, NULL);
$1 = object_table_get(str);
- if(!$1) {
- SWIG_exception(SWIG_RuntimeError, "not a t_text * instance");
- SWIG_fail;
- }
+ SWIG_contract_assert($1, "not a t_pd * instance");
}
-%typemap(in) t_pd * {
+%typemap(in) t_text * {
const char *str = Tcl_GetStringFromObj($input, NULL);
- $1 = object_table_get(str);
- if(!$1) {
- SWIG_exception(SWIG_RuntimeError, "not a t_pd * instance");
- SWIG_fail;
- }
+ t_tcl *x = object_table_get(str);
+ SWIG_contract_assert(x, "not a t_text * instance");
+ $1 = &x->o;
}
%typemap(in) t_object * {
const char *str = Tcl_GetStringFromObj($input, NULL);
t_tcl *x = object_table_get(str);
- if(!x) {
- SWIG_exception(SWIG_RuntimeError, "not a t_tcl * instance");
- SWIG_fail;
- }
+ SWIG_contract_assert(x, "not a t_object * instance");
$1 = &x->o;
}

0 comments on commit 73209d0

Please sign in to comment.