Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

271 lines
7.1 KiB

  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. * exception.i
  6. *
  7. * SWIG library file providing language independent exception handling
  8. * ----------------------------------------------------------------------------- */
  9. #if defined(SWIGUTL)
  10. #error "This version of exception.i should not be used"
  11. #endif
  12. %insert("runtime") "swigerrors.swg"
  13. #ifdef SWIGPHP
  14. %{
  15. #if PHP_MAJOR_VERSION < 5
  16. # define SWIG_exception(code, msg) { zend_error(E_ERROR, msg); }
  17. #else
  18. # include "zend_exceptions.h"
  19. # define SWIG_exception(code, msg) { zend_throw_exception(NULL, (char*)msg, code TSRMLS_CC); }
  20. #endif
  21. %}
  22. #endif
  23. #ifdef SWIGGUILE
  24. %{
  25. SWIGINTERN void SWIG_exception_ (int code, const char *msg,
  26. const char *subr) {
  27. #define ERROR(scmerr) \
  28. scm_error(gh_symbol2scm((char *) (scmerr)), \
  29. (char *) subr, (char *) msg, \
  30. SCM_EOL, SCM_BOOL_F)
  31. #define MAP(swigerr, scmerr) \
  32. case swigerr: \
  33. ERROR(scmerr); \
  34. break
  35. switch (code) {
  36. MAP(SWIG_MemoryError, "swig-memory-error");
  37. MAP(SWIG_IOError, "swig-io-error");
  38. MAP(SWIG_RuntimeError, "swig-runtime-error");
  39. MAP(SWIG_IndexError, "swig-index-error");
  40. MAP(SWIG_TypeError, "swig-type-error");
  41. MAP(SWIG_DivisionByZero, "swig-division-by-zero");
  42. MAP(SWIG_OverflowError, "swig-overflow-error");
  43. MAP(SWIG_SyntaxError, "swig-syntax-error");
  44. MAP(SWIG_ValueError, "swig-value-error");
  45. MAP(SWIG_SystemError, "swig-system-error");
  46. default:
  47. ERROR("swig-error");
  48. }
  49. #undef ERROR
  50. #undef MAP
  51. }
  52. #define SWIG_exception(a,b) SWIG_exception_(a, b, FUNC_NAME)
  53. %}
  54. #endif
  55. #ifdef SWIGMZSCHEME
  56. %{
  57. SWIGINTERN void SWIG_exception_ (int code, const char *msg) {
  58. #define ERROR(errname) \
  59. scheme_signal_error(errname " (%s)", msg);
  60. #define MAP(swigerr, errname) \
  61. case swigerr: \
  62. ERROR(errname); \
  63. break
  64. switch (code) {
  65. MAP(SWIG_MemoryError, "swig-memory-error");
  66. MAP(SWIG_IOError, "swig-io-error");
  67. MAP(SWIG_RuntimeError, "swig-runtime-error");
  68. MAP(SWIG_IndexError, "swig-index-error");
  69. MAP(SWIG_TypeError, "swig-type-error");
  70. MAP(SWIG_DivisionByZero, "swig-division-by-zero");
  71. MAP(SWIG_OverflowError, "swig-overflow-error");
  72. MAP(SWIG_SyntaxError, "swig-syntax-error");
  73. MAP(SWIG_ValueError, "swig-value-error");
  74. MAP(SWIG_SystemError, "swig-system-error");
  75. default:
  76. ERROR("swig-error");
  77. }
  78. #undef ERROR
  79. #undef MAP
  80. }
  81. #define SWIG_exception(a,b) SWIG_exception_(a, b)
  82. %}
  83. #endif
  84. #ifdef SWIGJAVA
  85. %{
  86. SWIGINTERN void SWIG_JavaException(JNIEnv *jenv, int code, const char *msg) {
  87. SWIG_JavaExceptionCodes exception_code = SWIG_JavaUnknownError;
  88. switch(code) {
  89. case SWIG_MemoryError:
  90. exception_code = SWIG_JavaOutOfMemoryError;
  91. break;
  92. case SWIG_IOError:
  93. exception_code = SWIG_JavaIOException;
  94. break;
  95. case SWIG_SystemError:
  96. case SWIG_RuntimeError:
  97. exception_code = SWIG_JavaRuntimeException;
  98. break;
  99. case SWIG_OverflowError:
  100. case SWIG_IndexError:
  101. exception_code = SWIG_JavaIndexOutOfBoundsException;
  102. break;
  103. case SWIG_DivisionByZero:
  104. exception_code = SWIG_JavaArithmeticException;
  105. break;
  106. case SWIG_SyntaxError:
  107. case SWIG_ValueError:
  108. case SWIG_TypeError:
  109. exception_code = SWIG_JavaIllegalArgumentException;
  110. break;
  111. case SWIG_UnknownError:
  112. default:
  113. exception_code = SWIG_JavaUnknownError;
  114. break;
  115. }
  116. SWIG_JavaThrowException(jenv, exception_code, msg);
  117. }
  118. %}
  119. #define SWIG_exception(code, msg)\
  120. { SWIG_JavaException(jenv, code, msg); return $null; }
  121. #endif // SWIGJAVA
  122. #ifdef SWIGOCAML
  123. %{
  124. #define OCAML_MSG_BUF_LEN 1024
  125. SWIGINTERN void SWIG_exception_(int code, const char *msg) {
  126. char msg_buf[OCAML_MSG_BUF_LEN];
  127. sprintf( msg_buf, "Exception(%d): %s\n", code, msg );
  128. failwith( msg_buf );
  129. }
  130. #define SWIG_exception(a,b) SWIG_exception_((a),(b))
  131. %}
  132. #endif
  133. #ifdef SWIGCHICKEN
  134. %{
  135. SWIGINTERN void SWIG_exception_(int code, const char *msg) {
  136. C_word *a;
  137. C_word scmmsg;
  138. C_word list;
  139. a = C_alloc (C_SIZEOF_STRING (strlen (msg)) + C_SIZEOF_LIST(2));
  140. scmmsg = C_string2 (&a, (char *) msg);
  141. list = C_list(&a, 2, C_fix(code), scmmsg);
  142. SWIG_ThrowException(list);
  143. }
  144. #define SWIG_exception(a,b) SWIG_exception_((a),(b))
  145. %}
  146. #endif
  147. #ifdef SWIGCSHARP
  148. %{
  149. SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
  150. if (code == SWIG_ValueError) {
  151. SWIG_CSharpExceptionArgumentCodes exception_code = SWIG_CSharpArgumentOutOfRangeException;
  152. SWIG_CSharpSetPendingExceptionArgument(exception_code, msg, 0);
  153. } else {
  154. SWIG_CSharpExceptionCodes exception_code = SWIG_CSharpApplicationException;
  155. switch(code) {
  156. case SWIG_MemoryError:
  157. exception_code = SWIG_CSharpOutOfMemoryException;
  158. break;
  159. case SWIG_IndexError:
  160. exception_code = SWIG_CSharpIndexOutOfRangeException;
  161. break;
  162. case SWIG_DivisionByZero:
  163. exception_code = SWIG_CSharpDivideByZeroException;
  164. break;
  165. case SWIG_IOError:
  166. exception_code = SWIG_CSharpIOException;
  167. break;
  168. case SWIG_OverflowError:
  169. exception_code = SWIG_CSharpOverflowException;
  170. break;
  171. case SWIG_RuntimeError:
  172. case SWIG_TypeError:
  173. case SWIG_SyntaxError:
  174. case SWIG_SystemError:
  175. case SWIG_UnknownError:
  176. default:
  177. exception_code = SWIG_CSharpApplicationException;
  178. break;
  179. }
  180. SWIG_CSharpSetPendingException(exception_code, msg);
  181. }
  182. }
  183. %}
  184. #define SWIG_exception(code, msg)\
  185. { SWIG_CSharpException(code, msg); return $null; }
  186. #endif // SWIGCSHARP
  187. #ifdef SWIGLUA
  188. %{
  189. #define SWIG_exception(a,b)\
  190. { lua_pushfstring(L,"%s:%s",#a,b);SWIG_fail; }
  191. %}
  192. #endif // SWIGLUA
  193. #ifdef __cplusplus
  194. /*
  195. You can use the SWIG_CATCH_STDEXCEPT macro with the %exception
  196. directive as follows:
  197. %exception {
  198. try {
  199. $action
  200. }
  201. catch (my_except& e) {
  202. ...
  203. }
  204. SWIG_CATCH_STDEXCEPT // catch std::exception
  205. catch (...) {
  206. SWIG_exception(SWIG_UnknownError, "Unknown exception");
  207. }
  208. }
  209. */
  210. %{
  211. #include <stdexcept>
  212. %}
  213. %define SWIG_CATCH_STDEXCEPT
  214. /* catching std::exception */
  215. catch (std::invalid_argument& e) {
  216. SWIG_exception(SWIG_ValueError, e.what() );
  217. } catch (std::domain_error& e) {
  218. SWIG_exception(SWIG_ValueError, e.what() );
  219. } catch (std::overflow_error& e) {
  220. SWIG_exception(SWIG_OverflowError, e.what() );
  221. } catch (std::out_of_range& e) {
  222. SWIG_exception(SWIG_IndexError, e.what() );
  223. } catch (std::length_error& e) {
  224. SWIG_exception(SWIG_IndexError, e.what() );
  225. } catch (std::runtime_error& e) {
  226. SWIG_exception(SWIG_RuntimeError, e.what() );
  227. } catch (std::exception& e) {
  228. SWIG_exception(SWIG_SystemError, e.what() );
  229. }
  230. %enddef
  231. %define SWIG_CATCH_UNKNOWN
  232. catch (std::exception& e) {
  233. SWIG_exception(SWIG_SystemError, e.what() );
  234. }
  235. catch (...) {
  236. SWIG_exception(SWIG_UnknownError, "unknown exception");
  237. }
  238. %enddef
  239. /* rethrow the unknown exception */
  240. %typemap(throws,noblock=1) (...) {
  241. SWIG_exception(SWIG_RuntimeError,"unknown exception");
  242. }
  243. #endif /* __cplusplus */
  244. /* exception.i ends here */