1/* -----------------------------------------------------------------------------
2 * dexception.swg
3 *
4 * Typemaps used for propagating C++ exceptions to D.
5 * ----------------------------------------------------------------------------- */
6
7// Code which is inserted into the dout typemaps and class constructors via
8// excode if exceptions can be thrown.
9%define SWIGEXCODE "\n  if ($imdmodule.SwigPendingException.isPending) throw $imdmodule.SwigPendingException.retrieve();" %enddef
10
11%typemap(throws, canthrow=1) int,
12                 long,
13                 short,
14                 unsigned int,
15                 unsigned long,
16                 unsigned short
17%{ char error_msg[256];
18   sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
19   SWIG_DSetPendingException(SWIG_DException, error_msg);
20   return $null; %}
21
22%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY],
23  enum SWIGTYPE, const enum SWIGTYPE &
24%{ (void)$1;
25   SWIG_DSetPendingException(SWIG_DException, "C++ $1_type exception thrown");
26   return $null; %}
27
28%typemap(throws, canthrow=1) char *
29%{ SWIG_DSetPendingException(SWIG_DException, $1);
30   return $null; %}
31