From 76f481fe494afa9ac0ae1aed424fce0ec2705b75 Mon Sep 17 00:00:00 2001 From: stevenj Date: Sat, 12 Jun 2010 22:07:45 -0400 Subject: [PATCH] map NLopt's C++ exceptions to more Scheme-like equivalents darcs-hash:20100613020745-c8de0-0eefd9e80ec3fab27aed5991ee9f1b364b2bae32.gz --- swig/nlopt-guile.i | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/swig/nlopt-guile.i b/swig/nlopt-guile.i index aea3110..8f108d0 100644 --- a/swig/nlopt-guile.i +++ b/swig/nlopt-guile.i @@ -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 -- 2.30.2