From 3f8ed3e65030937f8984b59f73b9f3c3c9373fd1 Mon Sep 17 00:00:00 2001 From: Marcelo Matus Date: Sat, 29 May 2004 23:19:01 +0000 Subject: [PATCH] more fixes for exceptions git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@5944 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Lib/python/pyswigtype.swg | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/SWIG/Lib/python/pyswigtype.swg b/SWIG/Lib/python/pyswigtype.swg index 5f99cae18..b8fcc459f 100644 --- a/SWIG/Lib/python/pyswigtype.swg +++ b/SWIG/Lib/python/pyswigtype.swg @@ -226,9 +226,8 @@ SWIG_fail; } -/* This doesn't work, and not sure if it is needed... */ -#if 0 -%typecheck(throws) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] { + +%typemap(throws) SWIGTYPE * { if ($1_descriptor->clientdata) { PyErr_SetObject((PyObject *) ($1_descriptor->clientdata), SWIG_NewPointerObj($1,$1_descriptor,1)); } else { @@ -236,5 +235,22 @@ } SWIG_fail; } -#endif + +%typemap(throws) SWIGTYPE [ANY] { + if ($1_descriptor->clientdata) { + PyErr_SetObject((PyObject *) ($1_descriptor->clientdata), SWIG_NewPointerObj($1,$1_descriptor,1)); + } else { + PyErr_SetString(PyExc_RuntimeError,"$1_type"); + } + SWIG_fail; +} + +%typemap(throws) SWIGTYPE & { + if ($1_descriptor->clientdata) { + PyErr_SetObject((PyObject *) ($1_descriptor->clientdata), SWIG_NewPointerObj(&($1),$1_descriptor,1)); + } else { + PyErr_SetString(PyExc_RuntimeError,"$1_type"); + } + SWIG_fail; +}