From: stevenj Date: Sun, 13 Jun 2010 02:07:45 +0000 (-0400) Subject: map NLopt's C++ exceptions to more Scheme-like equivalents X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=76f481fe494afa9ac0ae1aed424fce0ec2705b75;p=nlopt.git map NLopt's C++ exceptions to more Scheme-like equivalents darcs-hash:20100613020745-c8de0-0eefd9e80ec3fab27aed5991ee9f1b364b2bae32.gz --- 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