PageRenderTime 165ms CodeModel.GetById 15ms RepoModel.GetById 2ms app.codeStats 0ms

/trunk/Lib/typemaps/std_except.swg

#
Unknown | 96 lines | 79 code | 17 blank | 0 comment | 0 complexity | be1e4d0275c3c5f51e405c1065575e36 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. %include <typemaps/exception.swg>
  2. %include <std/std_except.i>
  3. /*
  4. Mark all of std exception classes as "exception classes" via
  5. the "exceptionclass" feature.
  6. If needed, you can disable it by using %noexceptionclass.
  7. */
  8. %define %std_exception_map(Exception, Code)
  9. %exceptionclass Exception;
  10. #if !defined(SWIG_STD_EXCEPTIONS_AS_CLASSES)
  11. %typemap(throws,noblock=1) Exception {
  12. SWIG_exception_fail(Code, $1.what());
  13. }
  14. %ignore Exception;
  15. struct Exception {
  16. };
  17. #endif
  18. %enddef
  19. namespace std {
  20. %std_exception_map(bad_exception, SWIG_SystemError);
  21. %std_exception_map(domain_error, SWIG_ValueError);
  22. %std_exception_map(exception, SWIG_SystemError);
  23. %std_exception_map(invalid_argument, SWIG_ValueError);
  24. %std_exception_map(length_error, SWIG_IndexError);
  25. %std_exception_map(logic_error, SWIG_RuntimeError);
  26. %std_exception_map(out_of_range, SWIG_IndexError);
  27. %std_exception_map(overflow_error, SWIG_OverflowError);
  28. %std_exception_map(range_error, SWIG_OverflowError);
  29. %std_exception_map(runtime_error, SWIG_RuntimeError);
  30. %std_exception_map(underflow_error, SWIG_OverflowError);
  31. }
  32. #if defined(SWIG_STD_EXCEPTIONS_AS_CLASSES)
  33. namespace std {
  34. struct exception
  35. {
  36. virtual ~exception() throw();
  37. virtual const char* what() const throw();
  38. };
  39. struct bad_exception : exception
  40. {
  41. };
  42. struct logic_error : exception
  43. {
  44. logic_error(const string& msg);
  45. };
  46. struct domain_error : logic_error
  47. {
  48. domain_error(const string& msg);
  49. };
  50. struct invalid_argument : logic_error
  51. {
  52. invalid_argument(const string& msg);
  53. };
  54. struct length_error : logic_error
  55. {
  56. length_error(const string& msg);
  57. };
  58. struct out_of_range : logic_error
  59. {
  60. out_of_range(const string& msg);
  61. };
  62. struct runtime_error : exception
  63. {
  64. runtime_error(const string& msg);
  65. };
  66. struct range_error : runtime_error
  67. {
  68. range_error(const string& msg);
  69. };
  70. struct overflow_error : runtime_error
  71. {
  72. overflow_error(const string& msg);
  73. };
  74. struct underflow_error : runtime_error
  75. {
  76. underflow_error(const string& msg);
  77. };
  78. }
  79. #endif