PageRenderTime 836ms CodeModel.GetById 199ms RepoModel.GetById 7ms app.codeStats 0ms

/tags/rel-1-3-29/SWIG/Lib/std_except.i

#
Swig | 58 lines | 28 code | 7 blank | 23 comment | 0 complexity | b99891cc8edffc673aa99ad1dc2ceb68 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * See the LICENSE file for information on copyright, usage and redistribution
  3. * of SWIG, and the README file for authors - http://www.swig.org/release.html.
  4. *
  5. * std_except.i
  6. *
  7. * SWIG library file with typemaps to handle and throw STD exceptions in a
  8. * language and STL independent way, i.e., the target language doesn't
  9. * require to support STL but only the 'exception.i' mechanism.
  10. *
  11. * These typemaps are used when methods are declared with an STD
  12. * exception specification, such as
  13. *
  14. * size_t at() const throw (std::out_of_range);
  15. *
  16. * The typemaps here are based on the language independent
  17. * 'exception.i' library. If that is working in your target language,
  18. * this file will work.
  19. *
  20. * If the target language doesn't implement a robust 'exception.i'
  21. * mechanism, or you prefer other ways to map the STD exceptions, write
  22. * a new std_except.i file in the target library directory.
  23. * ----------------------------------------------------------------------------- */
  24. #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL)
  25. #error "This version of std_except.i should not be used"
  26. #endif
  27. %{
  28. #include <stdexcept>
  29. %}
  30. %include <exception.i>
  31. %define %std_exception_map(Exception, Code)
  32. %typemap(throws,noblock=1) Exception {
  33. SWIG_exception(Code, $1.what());
  34. }
  35. %ignore Exception;
  36. struct Exception {
  37. };
  38. %enddef
  39. namespace std {
  40. %std_exception_map(bad_exception, SWIG_SystemError);
  41. %std_exception_map(domain_error, SWIG_ValueError);
  42. %std_exception_map(exception, SWIG_SystemError);
  43. %std_exception_map(invalid_argument, SWIG_ValueError);
  44. %std_exception_map(length_error, SWIG_IndexError);
  45. %std_exception_map(logic_error, SWIG_RuntimeError);
  46. %std_exception_map(out_of_range, SWIG_IndexError);
  47. %std_exception_map(overflow_error, SWIG_OverflowError);
  48. %std_exception_map(range_error, SWIG_OverflowError);
  49. %std_exception_map(runtime_error, SWIG_RuntimeError);
  50. %std_exception_map(underflow_error, SWIG_OverflowError);
  51. }