From af98737169abfbf0de440053b3d63e0f888ed1ab Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Wed, 12 Mar 2003 20:33:38 +0000 Subject: [PATCH] Non typemap code git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4522 626c5289-ae23-0410-ae9c-e8d60b6d4f22 --- SWIG/Lib/csharp/csharphead.swg | 68 ++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 SWIG/Lib/csharp/csharphead.swg diff --git a/SWIG/Lib/csharp/csharphead.swg b/SWIG/Lib/csharp/csharphead.swg new file mode 100644 index 000000000..bcc603db9 --- /dev/null +++ b/SWIG/Lib/csharp/csharphead.swg @@ -0,0 +1,68 @@ +/* ----------------------------------------------------------------------------- + * csharphead.swg + * + * CSharp support code + * ----------------------------------------------------------------------------- */ + +%insert(runtime) %{ + +#include +#include +#ifdef WIN32 +# define DllExport __declspec( dllexport ) +#else +# define DllExport +#endif +%} + +#if 0 +%insert(runtime) %{ +/* Support for throwing CSharp exceptions */ +typedef enum { + SWIG_JavaOutOfMemoryError = 1, + SWIG_JavaIOException, + SWIG_JavaRuntimeException, + SWIG_JavaIndexOutOfBoundsException, + SWIG_JavaArithmeticException, + SWIG_JavaIllegalArgumentException, + SWIG_JavaNullPointerException, + SWIG_JavaUnknownError +} SWIG_JavaExceptionCodes; + +typedef struct { + SWIG_JavaExceptionCodes code; + const char *java_exception; +} SWIG_JavaExceptions_t; + +#if defined(SWIG_NOINCLUDE) +void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg); +#else +%} +%insert(runtime) { +void SWIG_JavaThrowException(JNIEnv *jenv, SWIG_JavaExceptionCodes code, const char *msg) { + jclass excep; + static const SWIG_JavaExceptions_t java_exceptions[] = { + { SWIG_JavaOutOfMemoryError, "java/lang/OutOfMemoryError" }, + { SWIG_JavaIOException, "java/io/IOException" }, + { SWIG_JavaRuntimeException, "java/lang/RuntimeException" }, + { SWIG_JavaIndexOutOfBoundsException, "java/lang/IndexOutOfBoundsException" }, + { SWIG_JavaArithmeticException, "java/lang/ArithmeticException" }, + { SWIG_JavaIllegalArgumentException, "java/lang/IllegalArgumentException" }, + { SWIG_JavaNullPointerException, "java/lang/NullPointerException" }, + { SWIG_JavaUnknownError, "java/lang/UnknownError" }, + { (SWIG_JavaExceptionCodes)0, "java/lang/UnknownError" } }; + const SWIG_JavaExceptions_t *except_ptr = java_exceptions; + + while (except_ptr->code != code && except_ptr->code) + except_ptr++; + + JCALL0(ExceptionClear, jenv); + excep = JCALL1(FindClass, jenv, except_ptr->java_exception); + if (excep) + JCALL2(ThrowNew, jenv, excep, msg); +} +} +%insert(runtime) %{ +#endif +%} +#endif