diff options
Diffstat (limited to 'Lib/d/dexception.swg')
-rw-r--r-- | Lib/d/dexception.swg | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/Lib/d/dexception.swg b/Lib/d/dexception.swg new file mode 100644 index 000000000..1aadbaada --- /dev/null +++ b/Lib/d/dexception.swg @@ -0,0 +1,30 @@ +/* ----------------------------------------------------------------------------- + * 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 ($imdmodule.SwigPendingException.isPending) throw $imdmodule.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; %} |