summaryrefslogtreecommitdiff
path: root/Lib/d/dexception.swg
diff options
context:
space:
mode:
authorDavid Nadlinger <code@klickverbot.at>2010-11-18 00:24:02 +0000
committerDavid Nadlinger <code@klickverbot.at>2010-11-18 00:24:02 +0000
commit03aefbc6e95d094a6de231e1f5264c0946e209a3 (patch)
tree94dff73a4aa3c27366f29f36712bde78317c5776 /Lib/d/dexception.swg
parenta355d2d46af56c655816c37f24bb59fa6bade43f (diff)
downloadswig-03aefbc6e95d094a6de231e1f5264c0946e209a3.tar.gz
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
Diffstat (limited to 'Lib/d/dexception.swg')
-rw-r--r--Lib/d/dexception.swg30
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..f45cf7bfb
--- /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 ($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; %}