swig/Lib/d/dexception.swg
David Nadlinger 03aefbc6e9 Added support for the D programming languge.
It is still a bit rough around some edges, particularly with regard to multi-threading and operator overloading, and there are some documentation bits missing, but it should be fine for basic use.

The test-suite should build and run fine with the current versions of DMD, LDC and Tango (at least) on Linux x86_64 and Mac OS X 10.6.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12299 626c5289-ae23-0410-ae9c-e8d60b6d4f22
2010-11-18 00:24:02 +00:00

30 lines
1.2 KiB
Text

/* -----------------------------------------------------------------------------
* dexception.swg
*
* Typemaps used for propagating C++ exceptions to D.
* ----------------------------------------------------------------------------- */
// Code which is inserted into the dout typemaps and class constructors via
// excode if exceptions can be thrown.
%define SWIGEXCODE "\n if ($wrapdmodule.SwigPendingException.isPending) throw $wrapdmodule.SwigPendingException.retrieve();" %enddef
%typemap(throws, canthrow=1) int,
long,
short,
unsigned int,
unsigned long,
unsigned short
%{ char error_msg[256];
sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
SWIG_DSetPendingException(SWIG_DException, error_msg);
return $null; %}
%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY],
enum SWIGTYPE, const enum SWIGTYPE &
%{ (void)$1;
SWIG_DSetPendingException(SWIG_DException, "C++ $1_type exception thrown");
return $null; %}
%typemap(throws, canthrow=1) char *
%{ SWIG_DSetPendingException(SWIG_DException, $1);
return $null; %}