From 3bf9df6b2785fa6d951086978a3e66f49427166a Mon Sep 17 00:00:00 2001 From: FluorescentCIAAfricanAmerican <0934gj3049fk@protonmail.com> Date: Wed, 22 Apr 2020 12:56:21 -0400 Subject: 1 --- devtools/swigwin-1.3.34/Lib/java/arrays_java.i | 391 +++++++++++++++++++++++++ 1 file changed, 391 insertions(+) create mode 100644 devtools/swigwin-1.3.34/Lib/java/arrays_java.i (limited to 'devtools/swigwin-1.3.34/Lib/java/arrays_java.i') diff --git a/devtools/swigwin-1.3.34/Lib/java/arrays_java.i b/devtools/swigwin-1.3.34/Lib/java/arrays_java.i new file mode 100644 index 0000000..95510c3 --- /dev/null +++ b/devtools/swigwin-1.3.34/Lib/java/arrays_java.i @@ -0,0 +1,391 @@ +/* ----------------------------------------------------------------------------- + * See the LICENSE file for information on copyright, usage and redistribution + * of SWIG, and the README file for authors - http://www.swig.org/release.html. + * + * arrays_java.i + * + * These typemaps give more natural support for arrays. The typemaps are not efficient + * as there is a lot of copying of the array values whenever the array is passed to C/C++ + * from Java and vice versa. The Java array is expected to be the same size as the C array. + * An exception is thrown if they are not. + * + * Example usage: + * Wrapping: + * + * %include + * %inline %{ + * short FiddleSticks[3]; + * %} + * + * Use from Java like this: + * + * short[] fs = new short[] {10, 11, 12}; + * example.setFiddleSticks(fs); + * fs = example.getFiddleSticks(); + * ----------------------------------------------------------------------------- */ + +/* Primitive array support is a combination of SWIG macros and functions in order to reduce + * code bloat and aid maintainability. The SWIG preprocessor expands the macros into functions + * for inclusion in the generated code. */ + +/* Array support functions declarations macro */ +%define JAVA_ARRAYS_DECL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME) +%{ +int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input); +void SWIG_JavaArrayArgout##JFUNCNAME (JNIEnv *jenv, JNITYPE *jarr, CTYPE *carr, JNITYPE##Array input); +JNITYPE##Array SWIG_JavaArrayOut##JFUNCNAME (JNIEnv *jenv, CTYPE *result, jsize sz); +%} +%enddef + +/* Array support functions macro */ +%define JAVA_ARRAYS_IMPL(CTYPE, JNITYPE, JAVATYPE, JFUNCNAME) +%{ +/* CTYPE[] support */ +int SWIG_JavaArrayIn##JFUNCNAME (JNIEnv *jenv, JNITYPE **jarr, CTYPE **carr, JNITYPE##Array input) { + int i; + jsize sz; + if (!input) { + SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "null array"); + return 0; + } + sz = JCALL1(GetArrayLength, jenv, input); + *jarr = JCALL2(Get##JAVATYPE##ArrayElements, jenv, input, 0); + if (!*jarr) + return 0; %} +#ifdef __cplusplus +%{ *carr = new CTYPE[sz]; %} +#else +%{ *carr = (CTYPE*) calloc(sz, sizeof(CTYPE)); %} +#endif +%{ if (!*carr) { + SWIG_JavaThrowException(jenv, SWIG_JavaOutOfMemoryError, "array memory allocation failed"); + return 0; + } + for (i=0; i