chiark / gitweb /
map NLopt's C++ exceptions to more Scheme-like equivalents
authorstevenj <stevenj@alum.mit.edu>
Sun, 13 Jun 2010 02:07:45 +0000 (22:07 -0400)
committerstevenj <stevenj@alum.mit.edu>
Sun, 13 Jun 2010 02:07:45 +0000 (22:07 -0400)
darcs-hash:20100613020745-c8de0-0eefd9e80ec3fab27aed5991ee9f1b364b2bae32.gz

swig/nlopt-guile.i

index aea311028f30d1cb2eed3f76f8eac08b8696ef75..8f108d01a961e4f8bbe4fe89288083c656ef4d01 100644 (file)
@@ -1,5 +1,28 @@
 // -*- C++ -*-
 
+%typemap(throws) std::runtime_error %{
+  scm_throw(gh_symbol2scm("runtime-error"), 
+           scm_list_1(scm_from_locale_string(($1).what())));
+%}
+
+%typemap(throws) std::bad_alloc %{
+  scm_throw(gh_symbol2scm("bad-alloc"), 
+           scm_list_1(scm_from_locale_string(($1).what())));
+%}
+
+%typemap(throws) std::invalid_argument %{
+  scm_throw(gh_symbol2scm("invalid-argument"), 
+           scm_list_1(scm_from_locale_string(($1).what())));
+%}
+
+%typemap(throws) nlopt::forced_stop %{
+  scm_throw(gh_symbol2scm("forced-stop"), SCM_EOL);
+%}
+
+%typemap(throws) nlopt::roundoff_limited %{
+  scm_throw(gh_symbol2scm("roundoff-limited"), SCM_EOL);
+%}
+
 %{
 // because our f_data pointer to the Scheme function is stored on the
 // heap, rather than the stack, it may be missed by the Guile garbage