The great merge
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4141 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
6fcc22a1f8
commit
516036631c
1508 changed files with 125983 additions and 44037 deletions
84
SWIG/Lib/java/javahead.swg
Normal file
84
SWIG/Lib/java/javahead.swg
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* javahead.swg
|
||||
*
|
||||
* Java support code
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
||||
/* JNI function calls require different calling conventions for C and C++. These JCALL macros are used so
|
||||
* that the same typemaps can be used for generating code for both C and C++. The SWIG preprocessor can expand
|
||||
* the macros thereby generating the correct calling convention. It is thus essential that all typemaps that
|
||||
* use the macros are not within %{ %} brackets as they won't be run through the SWIG preprocessor. */
|
||||
#ifdef __cplusplus
|
||||
# define JCALL0(func, jenv) jenv->func()
|
||||
# define JCALL1(func, jenv, ar1) jenv->func(ar1)
|
||||
# define JCALL2(func, jenv, ar1, ar2) jenv->func(ar1, ar2)
|
||||
# define JCALL3(func, jenv, ar1, ar2, ar3) jenv->func(ar1, ar2, ar3)
|
||||
# define JCALL4(func, jenv, ar1, ar2, ar3, ar4) jenv->func(ar1, ar2, ar3, ar4)
|
||||
#else
|
||||
# define JCALL0(func, jenv) (*jenv)->func(jenv)
|
||||
# define JCALL1(func, jenv, ar1) (*jenv)->func(jenv, ar1)
|
||||
# define JCALL2(func, jenv, ar1, ar2) (*jenv)->func(jenv, ar1, ar2)
|
||||
# define JCALL3(func, jenv, ar1, ar2, ar3) (*jenv)->func(jenv, ar1, ar2, ar3)
|
||||
# define JCALL4(func, jenv, ar1, ar2, ar3, ar4) (*jenv)->func(jenv, ar1, ar2, ar3, ar4)
|
||||
#endif
|
||||
|
||||
%insert(runtime) %{
|
||||
#if defined(__GNUC__)
|
||||
typedef long long __int64; /*For gcc on Windows */
|
||||
#endif
|
||||
#include <jni.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
%}
|
||||
|
||||
%insert(runtime) %{
|
||||
/* Support for throwing Java 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
|
||||
%}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue