From: <ai...@us...> - 2011-04-13 05:24:08
|
Revision: 11701 http://plplot.svn.sourceforge.net/plplot/?rev=11701&view=rev Author: airwin Date: 2011-04-13 05:24:00 +0000 (Wed, 13 Apr 2011) Log Message: ----------- Initial styling (done automatically with recently revised scripts/style_source.sh) for swig *.i configuration files. This cleans up bad styling issues that appeared in these files before, and the results of the test_diff_psc target continue to be good with these changes. Modified Paths: -------------- trunk/bindings/java/plplotjavac.i trunk/bindings/lua/plplotluac.i trunk/bindings/octave/plplot_octave.i trunk/bindings/python/plplotcmodule.i trunk/bindings/swig-support/plplotcapi.i Modified: trunk/bindings/java/plplotjavac.i =================================================================== --- trunk/bindings/java/plplotjavac.i 2011-04-13 05:20:14 UTC (rev 11700) +++ trunk/bindings/java/plplotjavac.i 2011-04-13 05:24:00 UTC (rev 11701) @@ -1,38 +1,38 @@ -/* -Copyright (C) 2002 Gary Bishop -Copyright (C) 2002, 2004 Alan W. Irwin -Copyright (C) 2004-2010 Andrew Ross -This file is part of PLplot. +// +//Copyright (C) 2002 Gary Bishop +//Copyright (C) 2002, 2004 Alan W. Irwin +//Copyright (C) 2004-2010 Andrew Ross +//This file is part of PLplot. +// +//PLplot is free software; you can redistribute it and/or modify +//it under the terms of the GNU Library General Public License as published by +//the Free Software Foundation; version 2 of the License. +// +//PLplot is distributed in the hope that it will be useful, +//but WITHOUT ANY WARRANTY; without even the implied warranty of +//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//GNU Library General Public License for more details. +// +//You should have received a copy of the GNU Library General Public License +//along with the file PLplot; if not, write to the Free Software +//Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// -PLplot is free software; you can redistribute it and/or modify -it under the terms of the GNU Library General Public License as published by -the Free Software Foundation; version 2 of the License. - -PLplot is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU Library General Public License for more details. - -You should have received a copy of the GNU Library General Public License -along with the file PLplot; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -/* -A SWIG interface to PLplot for Java. This wrapper does the following: - - 1) it strictly provides the C-API with the usual change of not - requiring lengths for arrays, - - 2) it attempts to provide the entire API *excluding* callbacks for - plcont and plshade(s) (for now). - - 3) it works both with the single and double-precision versions of the - PLplot library. - -This is known to work with swig-1.3.21. - -*/ +// +//A SWIG interface to PLplot for Java. This wrapper does the following: +// +// 1) it strictly provides the C-API with the usual change of not +// requiring lengths for arrays, +// +// 2) it attempts to provide the entire API *excluding* callbacks for +// plcont and plshade(s) (for now). +// +// 3) it works both with the single and double-precision versions of the +// PLplot library. +// +//This is known to work with swig-1.3.21. +// +// %module plplotjavac %include typemaps.i @@ -41,1798 +41,1919 @@ %} #ifdef PL_DOUBLE_INTERFACE -typedef double PLFLT; +typedef double PLFLT; #else -typedef float PLFLT; +typedef float PLFLT; #endif -/* This assumes that C int is 32-bit - swig doesn't know about int32_t */ -/* Ideally we should have a typemap for it */ -typedef int PLINT; -typedef unsigned int PLUNICODE; -typedef PLINT PLBOOL; +// This assumes that C int is 32-bit - swig doesn't know about int32_t +// Ideally we should have a typemap for it +typedef int PLINT; +typedef unsigned int PLUNICODE; +typedef PLINT PLBOOL; -/* Set jni version and cache JVM - needed for callbacks */ +// Set jni version and cache JVM - needed for callbacks %{ -static JavaVM *cached_jvm = NULL; - -SWIGEXPORT JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *jvm, void *reserved) { - cached_jvm = jvm; - return JNI_VERSION_1_2; -} -%} + static JavaVM *cached_jvm = NULL; -/* Simple (input) PLBOOL arguments */ -/* Use macro style similar to INPUT_TYPEMAP defined in typemaps.i, but - * actually follow what is done in java.swg for bool C type except - * change action of typemap(in) from "? true : false;" to "? 1 : 0;" to - * be consistent with actual C type of PLBOOL which is PLINT. If C type - * of PLBOOL ever changed to bool, none of this would be necessary, but - * such a change would demand using the c99 standard for PLplot which is - * not widely implemented yet. - */ -%define PLBOOL_INPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JNIDESC) -%typemap(jni) TYPE "JNITYPE" -%typemap(jtype) TYPE "JTYPE" -%typemap(jstype) TYPE "JTYPE" + SWIGEXPORT JNIEXPORT jint JNICALL JNI_OnLoad( JavaVM *jvm, void *reserved ) + { + cached_jvm = jvm; + return JNI_VERSION_1_2; + } +%} -%typemap(in) TYPE -%{ $1 = $input ? 1 : 0; %} +// Simple (input) PLBOOL arguments +// Use macro style similar to INPUT_TYPEMAP defined in typemaps.i, but +// actually follow what is done in java.swg for bool C type except +// change action of typemap(in) from "? true : false;" to "? 1 : 0;" to +// be consistent with actual C type of PLBOOL which is PLINT. If C type +// of PLBOOL ever changed to bool, none of this would be necessary, but +// such a change would demand using the c99 standard for PLplot which is +// not widely implemented yet. +// +%define PLBOOL_INPUT_TYPEMAP( TYPE, JNITYPE, JTYPE, JNIDESC ) +%typemap( jni ) TYPE "JNITYPE" +%typemap( jtype ) TYPE "JTYPE" +%typemap( jstype ) TYPE "JTYPE" -%typemap(javadirectorin) TYPE "$jniinput" -%typemap(javadirectorout) TYPE "$javacall" +%typemap( in ) TYPE +%{ + $1 = $input ? 1 : 0; +%} -%typemap(directorin,descriptor=JNIDESC) TYPE -%{$input = (JNITYPE *) $1; %} +%typemap( javadirectorin ) TYPE "$jniinput" +%typemap( javadirectorout ) TYPE "$javacall" -%typemap(javain) TYPE "$javainput" +%typemap( directorin, descriptor = JNIDESC ) TYPE +%{ + $input = (JNITYPE *) $1; +%} + +%typemap( javain ) TYPE "$javainput" %enddef -PLBOOL_INPUT_TYPEMAP(PLBOOL, jboolean, boolean, "Z"); +PLBOOL_INPUT_TYPEMAP( PLBOOL, jboolean, boolean, "Z" ); -/* This renamed macro copied exactly from OUTPUT_TYPEMAP macro - * in typemaps.i which handles *OUTPUT types. */ +// This renamed macro copied exactly from OUTPUT_TYPEMAP macro +// in typemaps.i which handles *OUTPUT types. -%define PLBOOL_OUTPUT_TYPEMAP(TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE) -%typemap(jni) TYPE *OUTPUT, TYPE &OUTPUT %{JNITYPE##Array%} -%typemap(jtype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]" -%typemap(jstype) TYPE *OUTPUT, TYPE &OUTPUT "JTYPE[]" -%typemap(javain) TYPE *OUTPUT, TYPE &OUTPUT "$javainput" -%typemap(javadirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$jniinput" -%typemap(javadirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$javacall" +%define PLBOOL_OUTPUT_TYPEMAP( TYPE, JNITYPE, JTYPE, JAVATYPE, JNIDESC, TYPECHECKTYPE ) +%typemap( jni ) TYPE * OUTPUT, TYPE & OUTPUT +%{ + JNITYPE ## Array +%} +%typemap( jtype ) TYPE * OUTPUT, TYPE & OUTPUT "JTYPE[]" +%typemap( jstype ) TYPE * OUTPUT, TYPE & OUTPUT "JTYPE[]" +%typemap( javain ) TYPE * OUTPUT, TYPE & OUTPUT "$javainput" +%typemap( javadirectorin ) TYPE * OUTPUT, TYPE & OUTPUT "$jniinput" +%typemap( javadirectorout ) TYPE * OUTPUT, TYPE & OUTPUT "$javacall" -%typemap(in) TYPE *OUTPUT($*1_ltype temp), TYPE &OUTPUT($*1_ltype temp) +%typemap( in ) TYPE * OUTPUT( $*1_ltype temp ), TYPE &OUTPUT( $*1_ltype temp ) %{ - if (!$input) { - SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "array null"); - return $null; - } - if (JCALL1(GetArrayLength, jenv, $input) == 0) { - SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element"); - return $null; - } - $1 = &temp; + if ( !$input ) + { + SWIG_JavaThrowException( jenv, SWIG_JavaNullPointerException, "array null" ); + return $null; + } + if ( JCALL1( GetArrayLength, jenv, $input ) == 0 ) + { + SWIG_JavaThrowException( jenv, SWIG_JavaIndexOutOfBoundsException, "Array must contain at least 1 element" ); + return $null; + } + $1 = &temp; %} -%typemap(directorin,descriptor=JNIDESC) TYPE &OUTPUT -%{ *(($&1_ltype) $input) = &$1; %} +%typemap( directorin, descriptor = JNIDESC ) TYPE & OUTPUT +%{ + *( ( $&1_ltype )$input ) = &$1; +%} -%typemap(directorin,descriptor=JNIDESC,warning="Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown") TYPE *OUTPUT +%typemap( directorin, descriptor = JNIDESC, warning = "Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown" ) TYPE * OUTPUT %{ %} -%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT "" +%typemap( freearg ) TYPE * OUTPUT, TYPE & OUTPUT "" -%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT +%typemap( argout ) TYPE * OUTPUT, TYPE & OUTPUT %{ - JNITYPE jvalue = (JNITYPE)temp$argnum; - JCALL4(Set##JAVATYPE##ArrayRegion, jenv, $input, 0, 1, &jvalue); + JNITYPE jvalue = (JNITYPE) temp$argnum; + JCALL4( Set ## JAVATYPE ## ArrayRegion, jenv, $input, 0, 1, &jvalue ); %} -%typemap(typecheck) TYPE *INOUT = TYPECHECKTYPE; -%typemap(typecheck) TYPE &INOUT = TYPECHECKTYPE; +%typemap( typecheck ) TYPE * INOUT = TYPECHECKTYPE; +%typemap( typecheck ) TYPE &INOUT = TYPECHECKTYPE; %enddef -/* Copy what is done for C bool type, only use PLBOOL instead. */ -PLBOOL_OUTPUT_TYPEMAP(PLBOOL, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray); +// Copy what is done for C bool type, only use PLBOOL instead. +PLBOOL_OUTPUT_TYPEMAP( PLBOOL, jboolean, boolean, Boolean, "[Ljava/lang/Boolean;", jbooleanArray ); -/*************************** - A trick for docstrings -****************************/ +//************************** +// A trick for docstrings +//*************************** -%define DOC(func, string) -%wrapper %{#define _doc_ ## func string %} +%define DOC( func, string ) +%wrapper +%{ + # define _doc_ ## func string +%} %enddef -/* Infrastructure for handling swig compatible plplot API definitions. */ +// Infrastructure for handling swig compatible plplot API definitions. #ifdef PL_DOUBLE_INTERFACE -#define setup_array_1d_PLFLT setup_array_1d_d -#define setup_array_2d_PLFLT setup_array_2d_d -#define jPLFLTArray "jdoubleArray" -#define jPLFLTbracket "double[]" -#define jPLFLTbracket2 "double[][]" -#define GetPLFLTArrayElements GetDoubleArrayElements -#define ReleasePLFLTArrayElements ReleaseDoubleArrayElements -#define jPLFLT jdouble +#define setup_array_1d_PLFLT setup_array_1d_d +#define setup_array_2d_PLFLT setup_array_2d_d +#define jPLFLTArray "jdoubleArray" +#define jPLFLTbracket "double[]" +#define jPLFLTbracket2 "double[][]" +#define GetPLFLTArrayElements GetDoubleArrayElements +#define ReleasePLFLTArrayElements ReleaseDoubleArrayElements +#define jPLFLT jdouble #else -#define setup_array_1d_PLFLT setup_array_1d_f -#define setup_array_2d_PLFLT setup_array_2d_f -#define jPLFLTArray "jfloatArray" -#define jPLFLTbracket "float[]" -#define jPLFLTbracket2 "float[][]" -#define GetPLFLTArrayElements GetFloatArrayElements -#define ReleasePLFLTArrayElements ReleaseFloatArrayElements -#define jPLFLT jfloat +#define setup_array_1d_PLFLT setup_array_1d_f +#define setup_array_2d_PLFLT setup_array_2d_f +#define jPLFLTArray "jfloatArray" +#define jPLFLTbracket "float[]" +#define jPLFLTbracket2 "float[][]" +#define GetPLFLTArrayElements GetFloatArrayElements +#define ReleasePLFLTArrayElements ReleaseFloatArrayElements +#define jPLFLT jfloat #endif %{ -/*--------------------------------------------------------------------------- - * Array allocation & copy helper routines. Note because of swig limitations - * it is necessary to release the java array memory right after calling these - * routines. Thus it is necessary to allocate and copy the arrays even if - * the java and plplot arrays are of the same type. Note, because of this - * change to Geoffrey's original versions, caller must always free memory - * afterwards. Thus, the must_free_buffers logic is gone as well. - *---------------------------------------------------------------------------*/ +//-------------------------------------------------------------------------- +// Array allocation & copy helper routines. Note because of swig limitations +// it is necessary to release the java array memory right after calling these +// routines. Thus it is necessary to allocate and copy the arrays even if +// the java and plplot arrays are of the same type. Note, because of this +// change to Geoffrey's original versions, caller must always free memory +// afterwards. Thus, the must_free_buffers logic is gone as well. +//-------------------------------------------------------------------------- -/* 1d array of jbooleans */ +// 1d array of jbooleans -static void -setup_array_1d_b( PLBOOL **pa, jboolean *adat, int n ) -{ - int i; - *pa = (PLBOOL *) malloc( n * sizeof(PLBOOL) ); - for( i=0; i < n; i++ ) { - (*pa)[i] = adat[i] ? 1 : 0; - } -} + static void + setup_array_1d_b( PLBOOL **pa, jboolean *adat, int n ) + { + int i; + *pa = (PLBOOL *) malloc( n * sizeof ( PLBOOL ) ); + for ( i = 0; i < n; i++ ) + { + ( *pa )[i] = adat[i] ? 1 : 0; + } + } -/* 1d array of jints */ +// 1d array of jints -static void -setup_array_1d_i( PLINT **pa, jint *adat, int n ) -{ - int i; - *pa = (PLINT *) malloc( n * sizeof(PLINT) ); - for( i=0; i < n; i++ ) { - (*pa)[i] = adat[i]; - } -} + static void + setup_array_1d_i( PLINT **pa, jint *adat, int n ) + { + int i; + *pa = (PLINT *) malloc( n * sizeof ( PLINT ) ); + for ( i = 0; i < n; i++ ) + { + ( *pa )[i] = adat[i]; + } + } -/* 1d array of jfloats */ +// 1d array of jfloats -static void -setup_array_1d_f( PLFLT **pa, jfloat *adat, int n ) -{ - int i; - *pa = (PLFLT *) malloc( n * sizeof(PLFLT) ); - for( i=0; i < n; i++ ) { - (*pa)[i] = adat[i]; - } -} + static void + setup_array_1d_f( PLFLT **pa, jfloat *adat, int n ) + { + int i; + *pa = (PLFLT *) malloc( n * sizeof ( PLFLT ) ); + for ( i = 0; i < n; i++ ) + { + ( *pa )[i] = adat[i]; + } + } -/* 1d array of jdoubles */ +// 1d array of jdoubles -static void -setup_array_1d_d( PLFLT **pa, jdouble *adat, int n ) -{ - int i; - *pa = (PLFLT *) malloc( n * sizeof(PLFLT) ); - for( i=0; i < n; i++ ) { - (*pa)[i] = adat[i]; - } -} + static void + setup_array_1d_d( PLFLT **pa, jdouble *adat, int n ) + { + int i; + *pa = (PLFLT *) malloc( n * sizeof ( PLFLT ) ); + for ( i = 0; i < n; i++ ) + { + ( *pa )[i] = adat[i]; + } + } -/* 2d array of floats */ -/* Here caller must free(a[0]) and free(a) (in that order) afterward */ +// 2d array of floats +// Here caller must free(a[0]) and free(a) (in that order) afterward -static void -setup_array_2d_f( PLFLT ***pa, jfloat **adat, int nx, int ny ) -{ - int i, j; + static void + setup_array_2d_f( PLFLT ***pa, jfloat **adat, int nx, int ny ) + { + int i, j; - *pa = (PLFLT **) malloc( nx * sizeof(PLFLT *) ); - (*pa)[0] = (PLFLT *) malloc( nx * ny * sizeof(PLFLT) ); + *pa = (PLFLT **) malloc( nx * sizeof ( PLFLT * ) ); + ( *pa )[0] = (PLFLT *) malloc( nx * ny * sizeof ( PLFLT ) ); - for( i=0; i < nx; i++ ) - { - (*pa)[i] = (*pa)[0] + i*ny; - for( j=0; j < ny; j++ ) - (*pa)[i][j] = adat[i][j]; - } + for ( i = 0; i < nx; i++ ) + { + ( *pa )[i] = ( *pa )[0] + i * ny; + for ( j = 0; j < ny; j++ ) + ( *pa )[i][j] = adat[i][j]; + } + } -} +// 2d array of doubles +// Here caller must free(a[0]) and free(a) (in that order) afterward -/* 2d array of doubles */ -/* Here caller must free(a[0]) and free(a) (in that order) afterward */ + static void + setup_array_2d_d( PLFLT ***pa, jdouble **adat, int nx, int ny ) + { + int i, j; -static void -setup_array_2d_d( PLFLT ***pa, jdouble **adat, int nx, int ny ) -{ - int i, j; + *pa = (PLFLT **) malloc( nx * sizeof ( PLFLT * ) ); + ( *pa )[0] = (PLFLT *) malloc( nx * ny * sizeof ( PLFLT ) ); - *pa = (PLFLT **) malloc( nx * sizeof(PLFLT *) ); - (*pa)[0] = (PLFLT *) malloc( nx * ny * sizeof(PLFLT) ); + for ( i = 0; i < nx; i++ ) + { + ( *pa )[i] = ( *pa )[0] + i * ny; + for ( j = 0; j < ny; j++ ) + ( *pa )[i][j] = adat[i][j]; + } + } - for( i=0; i < nx; i++ ) - { - (*pa)[i] = (*pa)[0] + i*ny; - for( j=0; j < ny; j++ ) - (*pa)[i][j] = adat[i][j]; - } +// Setup java arrays (for callback functions) -} - -/* Setup java arrays (for callback functions) */ - -/* Create a jdoubleArray and fill it from the C PLFLT array dat */ -static jdoubleArray -setup_java_array_1d_PLFLT( JNIEnv *jenv, PLFLT *dat, PLINT n) -{ - double *x; - jdoubleArray jadat; +// Create a jdoubleArray and fill it from the C PLFLT array dat + static jdoubleArray + setup_java_array_1d_PLFLT( JNIEnv *jenv, PLFLT *dat, PLINT n ) + { + double *x; + jdoubleArray jadat; #ifdef PL_DOUBLE - x = (double *) dat; + x = (double *) dat; #else - x = (double *) malloc( n * sizeof(double) ); - for (i=0;i<n;i++) { - x[i] = (double) dat[i]; - } + x = (double *) malloc( n * sizeof ( double ) ); + for ( i = 0; i < n; i++ ) + { + x[i] = (double) dat[i]; + } #endif - jadat = (*jenv)->NewDoubleArray(jenv, n); - (*jenv)->SetDoubleArrayRegion(jenv, jadat, 0, n, x); + jadat = ( *jenv )->NewDoubleArray( jenv, n ); + ( *jenv )->SetDoubleArrayRegion( jenv, jadat, 0, n, x ); #ifndef PL_DOUBLE - free(x); + free( x ); #endif - return jadat; -} + return jadat; + } -/* Copy back data from jdoubleArray to C PLFLT array then release java array */ -static void -release_java_array_1d_PLFLT(JNIEnv *jenv, jdoubleArray jadat, PLFLT *dat, PLINT n) -{ - PLINT i; - jdouble *jdata = (*jenv)->GetDoubleArrayElements( jenv, jadat, 0 ); - for (i=0;i<n;i++) { - dat[i] = (PLFLT) jdata[i]; - } - (*jenv)->ReleaseDoubleArrayElements( jenv, jadat, jdata, 0 ); -} +// Copy back data from jdoubleArray to C PLFLT array then release java array + static void + release_java_array_1d_PLFLT( JNIEnv *jenv, jdoubleArray jadat, PLFLT *dat, PLINT n ) + { + PLINT i; + jdouble *jdata = ( *jenv )->GetDoubleArrayElements( jenv, jadat, 0 ); + for ( i = 0; i < n; i++ ) + { + dat[i] = (PLFLT) jdata[i]; + } + ( *jenv )->ReleaseDoubleArrayElements( jenv, jadat, jdata, 0 ); + } %} -/* I hate global variables but this is the best way I can think of to manage consistency - checking among function arguments. */ +// I hate global variables but this is the best way I can think of to manage consistency +// checking among function arguments. %{ - static PLINT Alen = 0; - static PLINT Xlen = 0, Ylen = 0; - static PLFLT **xg; - static PLFLT **yg; - %} + static PLINT Alen = 0; + static PLINT Xlen = 0, Ylen = 0; + static PLFLT **xg; + static PLFLT **yg; +%} -/* The following typemaps take care of marshaling values into and out of PLplot functions. The -Array rules are trickly because of the need for length checking. These rules manage -some global variables (above) to handle consistency checking amoung parameters. +// The following typemaps take care of marshaling values into and out of PLplot functions. The +//Array rules are trickly because of the need for length checking. These rules manage +//some global variables (above) to handle consistency checking amoung parameters. +// +//Naming rules: +// Array (sets Alen to dim[0]) +// ArrayCk (tests that dim[0] == Alen) +// ArrayCkNull (tests that dim[0] == Alen or array is null) +// ArrayX (sets Xlen to dim[0] +// ArrayCkX (tests dim[0] == Xlen) +// ArrayY (sets Ylen to dim[1]) +// ArrayCkY (tests dim[1] == Ylen) +// Matrix (sets Xlen to dim[0], Ylen to dim[1]) +// MatrixCk (test Xlen == dim[0] && Ylen == dim[1]) +// -Naming rules: - Array (sets Alen to dim[0]) - ArrayCk (tests that dim[0] == Alen) - ArrayCkNull (tests that dim[0] == Alen or array is null) - ArrayX (sets Xlen to dim[0] - ArrayCkX (tests dim[0] == Xlen) - ArrayY (sets Ylen to dim[1]) - ArrayCkY (tests dim[1] == Ylen) - Matrix (sets Xlen to dim[0], Ylen to dim[1]) - MatrixCk (test Xlen == dim[0] && Ylen == dim[1]) -*/ +//-------------------------------------------------------------------------- +// PLINT arrays +//-------------------------------------------------------------------------- -/********************************************************************************** - PLINT arrays -**********************************************************************************/ - -/* with preceding count */ -%typemap(in) (PLINT n, const PLINT *Array) { - jint *jxdata = (*jenv)->GetIntArrayElements( jenv, $input, 0 ); - $1 = (*jenv)->GetArrayLength( jenv, $input); - Alen = $1; - setup_array_1d_i( &$2, jxdata, Alen); - /* Could find no easy way to do this as part of freearg so I modified - * the previous function so it ALWAYS mallocs and copies so that - * the java array can be released immediately. */ - (*jenv)->ReleaseIntArrayElements( jenv, $input, jxdata, 0 ); +// with preceding count +%typemap( in ) ( PLINT n, const PLINT * Array ) +{ + jint *jxdata = ( *jenv )->GetIntArrayElements( jenv, $input, 0 ); + $1 = ( *jenv )->GetArrayLength( jenv, $input ); + Alen = $1; + setup_array_1d_i( &$2, jxdata, Alen ); + // Could find no easy way to do this as part of freearg so I modified + // the previous function so it ALWAYS mallocs and copies so that + // the java array can be released immediately. + ( *jenv )->ReleaseIntArrayElements( jenv, $input, jxdata, 0 ); } -%typemap(freearg) (PLINT n, const PLINT *Array) { - free($2); +%typemap( freearg ) ( PLINT n, const PLINT * Array ) +{ + free( $2 ); } -%typemap(jni) (PLINT n, const PLINT *Array) "jintArray" -%typemap(jtype) (PLINT n, const PLINT *Array) "int[]" -%typemap(jstype) (PLINT n, const PLINT *Array) "int[]" -%typemap(javain) (PLINT n, const PLINT *Array) "$javainput" -%typemap(javaout) (PLINT n, const PLINT *Array) { - return $jnicall; +%typemap( jni ) ( PLINT n, const PLINT * Array ) "jintArray" +%typemap( jtype ) ( PLINT n, const PLINT * Array ) "int[]" +%typemap( jstype ) ( PLINT n, const PLINT * Array ) "int[]" +%typemap( javain ) ( PLINT n, const PLINT * Array ) "$javainput" +%typemap( javaout ) ( PLINT n, const PLINT * Array ) +{ + return $jnicall; } -/* Trailing count and check consistency with previous*/ -%typemap(in) (const PLINT *ArrayCk, PLINT n) { - jint *jydata = (*jenv)->GetIntArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) != Alen) { - printf("Vectors must be same length.\n"); - return; - } - $2 = (*jenv)->GetArrayLength( jenv, $input ); - setup_array_1d_i( &$1, jydata, Alen); - (*jenv)->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); +// Trailing count and check consistency with previous +%typemap( in ) ( const PLINT * ArrayCk, PLINT n ) +{ + jint *jydata = ( *jenv )->GetIntArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) != Alen ) + { + printf( "Vectors must be same length.\n" ); + return; + } + $2 = ( *jenv )->GetArrayLength( jenv, $input ); + setup_array_1d_i( &$1, jydata, Alen ); + ( *jenv )->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) (const PLINT *ArrayCk, PLINT n) { - free($1); +%typemap( freearg ) ( const PLINT * ArrayCk, PLINT n ) +{ + free( $1 ); } -%typemap(jni) (const PLINT *ArrayCk, PLINT n) "jintArray" -%typemap(jtype) (const PLINT *ArrayCk, PLINT n) "int[]" -%typemap(jstype) (const PLINT *ArrayCk, PLINT n) "int[]" -%typemap(javain) (const PLINT *ArrayCk, PLINT n) "$javainput" -%typemap(javaout) (const PLINT *ArrayCk, PLINT n) { - return $jnicall; +%typemap( jni ) ( const PLINT * ArrayCk, PLINT n ) "jintArray" +%typemap( jtype ) ( const PLINT * ArrayCk, PLINT n ) "int[]" +%typemap( jstype ) ( const PLINT * ArrayCk, PLINT n ) "int[]" +%typemap( javain ) ( const PLINT * ArrayCk, PLINT n ) "$javainput" +%typemap( javaout ) ( const PLINT * ArrayCk, PLINT n ) +{ + return $jnicall; } -/* no count but check consistency with previous */ -%typemap(in) const PLINT *ArrayCk { - jint *jydata = (*jenv)->GetIntArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) != Alen) { - printf("Vectors must be same length.\n"); - return; - } - setup_array_1d_i( &$1, jydata, Alen); - (*jenv)->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); +// no count but check consistency with previous +%typemap( in ) const PLINT * ArrayCk { + jint *jydata = ( *jenv )->GetIntArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) != Alen ) + { + printf( "Vectors must be same length.\n" ); + return; + } + setup_array_1d_i( &$1, jydata, Alen ); + ( *jenv )->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) const PLINT *ArrayCk { - free($1); +%typemap( freearg ) const PLINT * ArrayCk { + free( $1 ); } -%typemap(jni) const PLINT *ArrayCk "jintArray" -%typemap(jtype) const PLINT *ArrayCk "int[]" -%typemap(jstype) const PLINT *ArrayCk "int[]" -%typemap(javain) const PLINT *ArrayCk "$javainput" -%typemap(javaout) const PLINT *ArrayCk { - return $jnicall; +%typemap( jni ) const PLINT * ArrayCk "jintArray" +%typemap( jtype ) const PLINT * ArrayCk "int[]" +%typemap( jstype ) const PLINT * ArrayCk "int[]" +%typemap( javain ) const PLINT * ArrayCk "$javainput" +%typemap( javaout ) const PLINT * ArrayCk { + return $jnicall; } -/* no count but check consistency with previous or is null */ -%typemap(in) const PLINT *ArrayCkNull { - if ( $input != NULL ) { - jint *jydata = (*jenv)->GetIntArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) != Alen) { - printf("Vectors must be same length.\n"); - return; - } - setup_array_1d_i( &$1, jydata, Alen); - (*jenv)->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); - } - else { - $1 == NULL; - } +// no count but check consistency with previous or is null +%typemap( in ) const PLINT * ArrayCkNull { + if ( $input != NULL ) + { + jint *jydata = ( *jenv )->GetIntArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) != Alen ) + { + printf( "Vectors must be same length.\n" ); + return; + } + setup_array_1d_i( &$1, jydata, Alen ); + ( *jenv )->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); + } + else + { + $1 == NULL; + } } -%typemap(freearg) const PLINT *ArrayCkNull { - if ($1 != NULL) - free($1); +%typemap( freearg ) const PLINT * ArrayCkNull { + if ( $1 != NULL ) + free( $1 ); } -%typemap(jni) const PLINT *ArrayCkNull "jintArray" -%typemap(jtype) const PLINT *ArrayCkNull "int[]" -%typemap(jstype) const PLINT *ArrayCkNull "int[]" -%typemap(javain) const PLINT *ArrayCkNull "$javainput" -%typemap(javaout) const PLINT *ArrayCkNull { - return $jnicall; +%typemap( jni ) const PLINT * ArrayCkNull "jintArray" +%typemap( jtype ) const PLINT * ArrayCkNull "int[]" +%typemap( jstype ) const PLINT * ArrayCkNull "int[]" +%typemap( javain ) const PLINT * ArrayCkNull "$javainput" +%typemap( javaout ) const PLINT * ArrayCkNull { + return $jnicall; } -/* Weird case to allow argument to be one shorter than others */ -/* This case is used both for PLBOOL and PLINT. Define PLBOOL version - * first. (AWI thinks this may be necessary because of the above - * typedef PLINT PLBOOL;) - * Also add version which must be one shorter than others or null. - */ -%typemap(in) const PLBOOL *ArrayCkMinus1 { - jboolean *jydata = (*jenv)->GetBooleanArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) < Alen-1) { - printf("Vector must be at least length of others minus 1.\n"); - return; - } - setup_array_1d_b( &$1, jydata, Alen); - (*jenv)->ReleaseBooleanArrayElements( jenv, $input, jydata, 0 ); +// Weird case to allow argument to be one shorter than others +// This case is used both for PLBOOL and PLINT. Define PLBOOL version +// first. (AWI thinks this may be necessary because of the above +// typedef PLINT PLBOOL;) +// Also add version which must be one shorter than others or null. +// +%typemap( in ) const PLBOOL * ArrayCkMinus1 { + jboolean *jydata = ( *jenv )->GetBooleanArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) < Alen - 1 ) + { + printf( "Vector must be at least length of others minus 1.\n" ); + return; + } + setup_array_1d_b( &$1, jydata, Alen ); + ( *jenv )->ReleaseBooleanArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) const PLBOOL *ArrayCkMinus1 { - free($1); +%typemap( freearg ) const PLBOOL * ArrayCkMinus1 { + free( $1 ); } -%typemap(jni) const PLBOOL *ArrayCkMinus1 "jbooleanArray" -%typemap(jtype) const PLBOOL *ArrayCkMinus1 "boolean[]" -%typemap(jstype) const PLBOOL *ArrayCkMinus1 "boolean[]" -%typemap(javain) const PLBOOL *ArrayCkMinus1 "$javainput" -%typemap(javaout) const PLBOOL *ArrayCkMinus1 { - return $jnicall; +%typemap( jni ) const PLBOOL * ArrayCkMinus1 "jbooleanArray" +%typemap( jtype ) const PLBOOL * ArrayCkMinus1 "boolean[]" +%typemap( jstype ) const PLBOOL * ArrayCkMinus1 "boolean[]" +%typemap( javain ) const PLBOOL * ArrayCkMinus1 "$javainput" +%typemap( javaout ) const PLBOOL * ArrayCkMinus1 { + return $jnicall; } -%typemap(in) const PLBOOL *ArrayCkMinus1Null { - if ($input != NULL) { - jboolean *jydata = (*jenv)->GetBooleanArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) < Alen-1) { - printf("Vector must be at least length of others minus 1.\n"); - return; - } - setup_array_1d_b( &$1, jydata, Alen); - (*jenv)->ReleaseBooleanArrayElements( jenv, $input, jydata, 0 ); - } - else { - $1 = NULL; - } +%typemap( in ) const PLBOOL * ArrayCkMinus1Null { + if ( $input != NULL ) + { + jboolean *jydata = ( *jenv )->GetBooleanArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) < Alen - 1 ) + { + printf( "Vector must be at least length of others minus 1.\n" ); + return; + } + setup_array_1d_b( &$1, jydata, Alen ); + ( *jenv )->ReleaseBooleanArrayElements( jenv, $input, jydata, 0 ); + } + else + { + $1 = NULL; + } } -%typemap(freearg) const PLBOOL *ArrayCkMinus1Null { - if ($1 != NULL) - free($1); +%typemap( freearg ) const PLBOOL * ArrayCkMinus1Null { + if ( $1 != NULL ) + free( $1 ); } -%typemap(jni) const PLBOOL *ArrayCkMinus1Null "jbooleanArray" -%typemap(jtype) const PLBOOL *ArrayCkMinus1Null "boolean[]" -%typemap(jstype) const PLBOOL *ArrayCkMinus1Null "boolean[]" -%typemap(javain) const PLBOOL *ArrayCkMinus1Null "$javainput" -%typemap(javaout) const PLBOOL *ArrayCkMinus1Null { - return $jnicall; +%typemap( jni ) const PLBOOL * ArrayCkMinus1Null "jbooleanArray" +%typemap( jtype ) const PLBOOL * ArrayCkMinus1Null "boolean[]" +%typemap( jstype ) const PLBOOL * ArrayCkMinus1Null "boolean[]" +%typemap( javain ) const PLBOOL * ArrayCkMinus1Null "$javainput" +%typemap( javaout ) const PLBOOL * ArrayCkMinus1Null { + return $jnicall; } -%typemap(in) const PLINT *ArrayCkMinus1 { - jint *jydata = (*jenv)->GetIntArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) < Alen-1) { - printf("Vector must be at least length of others minus 1.\n"); - return; - } - setup_array_1d_i( &$1, jydata, Alen); - (*jenv)->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); +%typemap( in ) const PLINT * ArrayCkMinus1 { + jint *jydata = ( *jenv )->GetIntArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) < Alen - 1 ) + { + printf( "Vector must be at least length of others minus 1.\n" ); + return; + } + setup_array_1d_i( &$1, jydata, Alen ); + ( *jenv )->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) const PLINT *ArrayCkMinus1 { - free($1); +%typemap( freearg ) const PLINT * ArrayCkMinus1 { + free( $1 ); } -%typemap(jni) const PLINT *ArrayCkMinus1 "jintArray" -%typemap(jtype) const PLINT *ArrayCkMinus1 "int[]" -%typemap(jstype) const PLINT *ArrayCkMinus1 "int[]" -%typemap(javain) const PLINT *ArrayCkMinus1 "$javainput" -%typemap(javaout) const PLINT *ArrayCkMinus1 { - return $jnicall; +%typemap( jni ) const PLINT * ArrayCkMinus1 "jintArray" +%typemap( jtype ) const PLINT * ArrayCkMinus1 "int[]" +%typemap( jstype ) const PLINT * ArrayCkMinus1 "int[]" +%typemap( javain ) const PLINT * ArrayCkMinus1 "$javainput" +%typemap( javaout ) const PLINT * ArrayCkMinus1 { + return $jnicall; } -%typemap(in) const PLINT *ArrayCkMinus1Null { - if ($input != NULL) { - jint *jydata = (*jenv)->GetIntArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) < Alen-1) { - printf("Vector must be at least length of others minus 1.\n"); - return; - } - setup_array_1d_i( &$1, jydata, Alen); - (*jenv)->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); - } - else { - $1 = NULL; - } +%typemap( in ) const PLINT * ArrayCkMinus1Null { + if ( $input != NULL ) + { + jint *jydata = ( *jenv )->GetIntArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) < Alen - 1 ) + { + printf( "Vector must be at least length of others minus 1.\n" ); + return; + } + setup_array_1d_i( &$1, jydata, Alen ); + ( *jenv )->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); + } + else + { + $1 = NULL; + } } -%typemap(freearg) const PLINT *ArrayCkMinus1Null { - if ($1 != NULL) - free($1); +%typemap( freearg ) const PLINT * ArrayCkMinus1Null { + if ( $1 != NULL ) + free( $1 ); } -%typemap(jni) const PLINT *ArrayCkMinus1Null "jintArray" -%typemap(jtype) const PLINT *ArrayCkMinus1Null "int[]" -%typemap(jstype) const PLINT *ArrayCkMinus1Null "int[]" -%typemap(javain) const PLINT *ArrayCkMinus1Null "$javainput" -%typemap(javaout) const PLINT *ArrayCkMinus1Null { - return $jnicall; +%typemap( jni ) const PLINT * ArrayCkMinus1Null "jintArray" +%typemap( jtype ) const PLINT * ArrayCkMinus1Null "int[]" +%typemap( jstype ) const PLINT * ArrayCkMinus1Null "int[]" +%typemap( javain ) const PLINT * ArrayCkMinus1Null "$javainput" +%typemap( javaout ) const PLINT * ArrayCkMinus1Null { + return $jnicall; } -/* No length but remember size to check others */ -%typemap(in) const PLINT *Array { - jint *jydata = (*jenv)->GetIntArrayElements( jenv, $input, 0 ); - Alen = (*jenv)->GetArrayLength( jenv, $input); - setup_array_1d_i( &$1, jydata, Alen); - (*jenv)->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); +// No length but remember size to check others +%typemap( in ) const PLINT * Array { + jint *jydata = ( *jenv )->GetIntArrayElements( jenv, $input, 0 ); + Alen = ( *jenv )->GetArrayLength( jenv, $input ); + setup_array_1d_i( &$1, jydata, Alen ); + ( *jenv )->ReleaseIntArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) const PLINT *Array { - free($1); +%typemap( freearg ) const PLINT * Array { + free( $1 ); } -%typemap(jni) const PLINT *Array "jintArray" -%typemap(jtype) const PLINT *Array "int[]" -%typemap(jstype) const PLINT *Array "int[]" -%typemap(javain) const PLINT *Array "$javainput" -%typemap(javaout) const PLINT *Array { - return $jnicall; +%typemap( jni ) const PLINT * Array "jintArray" +%typemap( jtype ) const PLINT * Array "int[]" +%typemap( jstype ) const PLINT * Array "int[]" +%typemap( javain ) const PLINT * Array "$javainput" +%typemap( javaout ) const PLINT * Array { + return $jnicall; } -/****************************************************************************** - PLFLT Arrays -******************************************************************************/ +//-------------------------------------------------------------------------- +// PLFLT Arrays +//-------------------------------------------------------------------------- //temporary #if 0 #ifndef PL_DOUBLE -%wrapper %{ -/* some really twisted stuff to allow calling a single precision library from python */ -PyArrayObject* myArray_ContiguousFromObject(PyObject* in, int type, int mindims, int maxdims) -{ - PyArrayObject* tmp = (PyArrayObject*)PyArray_ContiguousFromObject(in, PyArray_FLOAT, - mindims, maxdims); - if (!tmp) { - /* could be an incoming double array which can't be "safely" converted, do it anyway */ - if(PyArray_Check(in)) { - PyErr_Clear(); - tmp = (PyArrayObject*)PyArray_Cast((PyArrayObject*)in, PyArray_FLOAT); +%wrapper +%{ +// some really twisted stuff to allow calling a single precision library from python + PyArrayObject* myArray_ContiguousFromObject( PyObject* in, int type, int mindims, int maxdims ) + { + PyArrayObject* tmp = (PyArrayObject*) PyArray_ContiguousFromObject( in, PyArray_FLOAT, + mindims, maxdims ); + if ( !tmp ) + { + // could be an incoming double array which can't be "safely" converted, do it anyway + if ( PyArray_Check( in ) ) + { + PyErr_Clear(); + tmp = (PyArrayObject*) PyArray_Cast( (PyArrayObject*) in, PyArray_FLOAT ); + } + } + return tmp; } - } - return tmp; -} - %} +%} #else -%wrapper %{ -#define myArray_ContiguousFromObject PyArray_ContiguousFromObject - %} +%wrapper +%{ +#define myArray_ContiguousFromObject PyArray_ContiguousFromObject +%} #endif -/* temporary*/ +// temporary #endif -/* with preceding count */ -%typemap(in) (PLINT n, const PLFLT *Array) { - jPLFLT *jxdata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - $1 = (*jenv)->GetArrayLength( jenv, $input); - Alen = $1; - setup_array_1d_PLFLT( &$2, jxdata, Alen ); - /* Could find no easy way to do this as part of freearg so I modified - * the previous function so it ALWAYS mallocs and copies so that - * the java array can be released immediately. */ - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); +// with preceding count +%typemap( in ) ( PLINT n, const PLFLT * Array ) +{ + jPLFLT *jxdata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + $1 = ( *jenv )->GetArrayLength( jenv, $input ); + Alen = $1; + setup_array_1d_PLFLT( &$2, jxdata, Alen ); + // Could find no easy way to do this as part of freearg so I modified + // the previous function so it ALWAYS mallocs and copies so that + // the java array can be released immediately. + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); } -%typemap(freearg) (PLINT n, const PLFLT *Array) { - free($2); +%typemap( freearg ) ( PLINT n, const PLFLT * Array ) +{ + free( $2 ); } -%typemap(jni) (PLINT n, const PLFLT *Array) jPLFLTArray -%typemap(jtype) (PLINT n, const PLFLT *Array) jPLFLTbracket -%typemap(jstype) (PLINT n, const PLFLT *Array) jPLFLTbracket -%typemap(javain) (PLINT n, const PLFLT *Array) "$javainput" -%typemap(javaout) (PLINT n, const PLFLT *Array) { - return $jnicall; +%typemap( jni ) ( PLINT n, const PLFLT * Array ) jPLFLTArray +%typemap( jtype ) ( PLINT n, const PLFLT * Array ) jPLFLTbracket +%typemap( jstype ) ( PLINT n, const PLFLT * Array ) jPLFLTbracket +%typemap( javain ) ( PLINT n, const PLFLT * Array ) "$javainput" +%typemap( javaout ) ( PLINT n, const PLFLT * Array ) +{ + return $jnicall; } -/* trailing count, and check consistency with previous */ -%typemap(in) (const PLFLT *ArrayCk, PLINT n) { - jPLFLT *jydata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - $2 = (*jenv)->GetArrayLength( jenv, $input ); - if((*jenv)->GetArrayLength( jenv, $input ) != Alen) { - printf("Vectors must be same length.\n"); - return; - } - setup_array_1d_PLFLT( &$1, jydata, Alen ); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); +// trailing count, and check consistency with previous +%typemap( in ) ( const PLFLT * ArrayCk, PLINT n ) +{ + jPLFLT *jydata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + $2 = ( *jenv )->GetArrayLength( jenv, $input ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) != Alen ) + { + printf( "Vectors must be same length.\n" ); + return; + } + setup_array_1d_PLFLT( &$1, jydata, Alen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) (const PLFLT *ArrayCk, PLINT n) { - free($1); +%typemap( freearg ) ( const PLFLT * ArrayCk, PLINT n ) +{ + free( $1 ); } -%typemap(jni) (const PLFLT *ArrayCk, PLINT n) jPLFLTArray -%typemap(jtype) (const PLFLT *ArrayCk, PLINT n) jPLFLTbracket -%typemap(jstype) (const PLFLT *ArrayCk, PLINT n) jPLFLTbracket -%typemap(javain) (const PLFLT *ArrayCk, PLINT n) "$javainput" -%typemap(javaout) (const PLFLT *ArrayCk, PLINT n){ - return $jnicall; +%typemap( jni ) ( const PLFLT * ArrayCk, PLINT n ) jPLFLTArray +%typemap( jtype ) ( const PLFLT * ArrayCk, PLINT n ) jPLFLTbracket +%typemap( jstype ) ( const PLFLT * ArrayCk, PLINT n ) jPLFLTbracket +%typemap( javain ) ( const PLFLT * ArrayCk, PLINT n ) "$javainput" +%typemap( javaout ) ( const PLFLT * ArrayCk, PLINT n ) +{ + return $jnicall; } -/* no count, but check consistency with previous */ -%typemap(in) const PLFLT *ArrayCk { - jPLFLT *jydata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) != Alen) { - printf("Vectors must be same length.\n"); - return; - } - setup_array_1d_PLFLT( &$1, jydata, Alen ); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); +// no count, but check consistency with previous +%typemap( in ) const PLFLT * ArrayCk { + jPLFLT *jydata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) != Alen ) + { + printf( "Vectors must be same length.\n" ); + return; + } + setup_array_1d_PLFLT( &$1, jydata, Alen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) const PLFLT *ArrayCk { - free($1); +%typemap( freearg ) const PLFLT * ArrayCk { + free( $1 ); } -%typemap(jni) const PLFLT *ArrayCk jPLFLTArray -%typemap(jtype) const PLFLT *ArrayCk jPLFLTbracket -%typemap(jstype) const PLFLT *ArrayCk jPLFLTbracket -%typemap(javain) const PLFLT *ArrayCk "$javainput" -%typemap(javaout) const PLFLT *ArrayCk{ - return $jnicall; +%typemap( jni ) const PLFLT * ArrayCk jPLFLTArray +%typemap( jtype ) const PLFLT * ArrayCk jPLFLTbracket +%typemap( jstype ) const PLFLT * ArrayCk jPLFLTbracket +%typemap( javain ) const PLFLT * ArrayCk "$javainput" +%typemap( javaout ) const PLFLT * ArrayCk { + return $jnicall; } -/* no count, but check consistency with previous or NULL */ -%typemap(in) const PLFLT *ArrayCkNull { - if ( $input != NULL ) { - jPLFLT *jydata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) != Alen) { - printf("Vectors must be same length.\n"); - return; - } - setup_array_1d_PLFLT( &$1, jydata, Alen ); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); - } - else { - $1 = NULL; - } +// no count, but check consistency with previous or NULL +%typemap( in ) const PLFLT * ArrayCkNull { + if ( $input != NULL ) + { + jPLFLT *jydata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) != Alen ) + { + printf( "Vectors must be same length.\n" ); + return; + } + setup_array_1d_PLFLT( &$1, jydata, Alen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); + } + else + { + $1 = NULL; + } } -%typemap(freearg) const PLFLT *ArrayCkNull { - if ($1 != NULL) - free($1); +%typemap( freearg ) const PLFLT * ArrayCkNull { + if ( $1 != NULL ) + free( $1 ); } -%typemap(jni) const PLFLT *ArrayCkNull jPLFLTArray -%typemap(jtype) const PLFLT *ArrayCkNull jPLFLTbracket -%typemap(jstype) const PLFLT *ArrayCkNull jPLFLTbracket -%typemap(javain) const PLFLT *ArrayCkNull "$javainput" -%typemap(javaout) const PLFLT *ArrayCkNull{ - return $jnicall; +%typemap( jni ) const PLFLT * ArrayCkNull jPLFLTArray +%typemap( jtype ) const PLFLT * ArrayCkNull jPLFLTbracket +%typemap( jstype ) const PLFLT * ArrayCkNull jPLFLTbracket +%typemap( javain ) const PLFLT * ArrayCkNull "$javainput" +%typemap( javaout ) const PLFLT * ArrayCkNull { + return $jnicall; } -/* set X length for later consistency checking */ -%typemap(in) (const PLFLT *ArrayX, PLINT nx) { - jPLFLT *jxdata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - Xlen = (*jenv)->GetArrayLength( jenv, $input); - $2 = Xlen; - setup_array_1d_PLFLT( &$1, jxdata, Xlen); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); +// set X length for later consistency checking +%typemap( in ) ( const PLFLT * ArrayX, PLINT nx ) +{ + jPLFLT *jxdata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + Xlen = ( *jenv )->GetArrayLength( jenv, $input ); + $2 = Xlen; + setup_array_1d_PLFLT( &$1, jxdata, Xlen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); } -%typemap(freearg) (const PLFLT *ArrayX, PLINT nx) { - free($1); +%typemap( freearg ) ( const PLFLT * ArrayX, PLINT nx ) +{ + free( $1 ); } -%typemap(jni) (const PLFLT *ArrayX, PLINT nx) jPLFLTArray -%typemap(jtype) (const PLFLT *ArrayX, PLINT nx) jPLFLTbracket -%typemap(jstype) (const PLFLT *ArrayX, PLINT nx) jPLFLTbracket -%typemap(javain) (const PLFLT *ArrayX, PLINT nx) "$javainput" -%typemap(javaout) (const PLFLT *ArrayX, PLINT nx) { - return $jnicall; +%typemap( jni ) ( const PLFLT * ArrayX, PLINT nx ) jPLFLTArray +%typemap( jtype ) ( const PLFLT * ArrayX, PLINT nx ) jPLFLTbracket +%typemap( jstype ) ( const PLFLT * ArrayX, PLINT nx ) jPLFLTbracket +%typemap( javain ) ( const PLFLT * ArrayX, PLINT nx ) "$javainput" +%typemap( javaout ) ( const PLFLT * ArrayX, PLINT nx ) +{ + return $jnicall; } -%typemap(in) const PLFLT *ArrayX { - jPLFLT *jxdata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - Xlen = (*jenv)->GetArrayLength( jenv, $input); - setup_array_1d_PLFLT( &$1, jxdata, Xlen); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); +%typemap( in ) const PLFLT * ArrayX { + jPLFLT *jxdata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + Xlen = ( *jenv )->GetArrayLength( jenv, $input ); + setup_array_1d_PLFLT( &$1, jxdata, Xlen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); } -%typemap(freearg) const PLFLT *ArrayX { - free($1); +%typemap( freearg ) const PLFLT * ArrayX { + free( $1 ); } -%typemap(jni) const PLFLT *ArrayX jPLFLTArray -%typemap(jtype) const PLFLT *ArrayX jPLFLTbracket -%typemap(jstype) const PLFLT *ArrayX jPLFLTbracket -%typemap(javain) const PLFLT *ArrayX "$javainput" -%typemap(javaout) const PLFLT *ArrayX { - return $jnicall; +%typemap( jni ) const PLFLT * ArrayX jPLFLTArray +%typemap( jtype ) const PLFLT * ArrayX jPLFLTbracket +%typemap( jstype ) const PLFLT * ArrayX jPLFLTbracket +%typemap( javain ) const PLFLT * ArrayX "$javainput" +%typemap( javaout ) const PLFLT * ArrayX { + return $jnicall; } -/* set Y length for later consistency checking */ -%typemap(in) (const PLFLT *ArrayY, PLINT ny) { - jPLFLT *jydata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - Ylen = (*jenv)->GetArrayLength( jenv, $input); - $2 = Ylen; - setup_array_1d_PLFLT( &$1, jydata, Ylen); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); +// set Y length for later consistency checking +%typemap( in ) ( const PLFLT * ArrayY, PLINT ny ) +{ + jPLFLT *jydata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + Ylen = ( *jenv )->GetArrayLength( jenv, $input ); + $2 = Ylen; + setup_array_1d_PLFLT( &$1, jydata, Ylen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) (const PLFLT *ArrayY, PLINT ny) { - free($1); +%typemap( freearg ) ( const PLFLT * ArrayY, PLINT ny ) +{ + free( $1 ); } -%typemap(jni) (const PLFLT *ArrayY, PLINT ny) jPLFLTArray -%typemap(jtype) (const PLFLT *ArrayY, PLINT ny) jPLFLTbracket -%typemap(jstype) (const PLFLT *ArrayY, PLINT ny) jPLFLTbracket -%typemap(javain) (const PLFLT *ArrayY, PLINT ny) "$javainput" -%typemap(javaout) (const PLFLT *ArrayY, PLINT ny) { - return $jnicall; +%typemap( jni ) ( const PLFLT * ArrayY, PLINT ny ) jPLFLTArray +%typemap( jtype ) ( const PLFLT * ArrayY, PLINT ny ) jPLFLTbracket +%typemap( jstype ) ( const PLFLT * ArrayY, PLINT ny ) jPLFLTbracket +%typemap( javain ) ( const PLFLT * ArrayY, PLINT ny ) "$javainput" +%typemap( javaout ) ( const PLFLT * ArrayY, PLINT ny ) +{ + return $jnicall; } -%typemap(in) const PLFLT *ArrayY { - jPLFLT *jydata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - Ylen = (*jenv)->GetArrayLength( jenv, $input); - setup_array_1d_PLFLT( &$1, jydata, Ylen); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); +%typemap( in ) const PLFLT * ArrayY { + jPLFLT *jydata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + Ylen = ( *jenv )->GetArrayLength( jenv, $input ); + setup_array_1d_PLFLT( &$1, jydata, Ylen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) const PLFLT *ArrayY { - free($1); +%typemap( freearg ) const PLFLT * ArrayY { + free( $1 ); } -%typemap(jni) const PLFLT *ArrayY jPLFLTArray -%typemap(jtype) const PLFLT *ArrayY jPLFLTbracket -%typemap(jstype) const PLFLT *ArrayY jPLFLTbracket -%typemap(javain) const PLFLT *ArrayY "$javainput" -%typemap(javaout) const PLFLT *ArrayY { - return $jnicall; +%typemap( jni ) const PLFLT * ArrayY jPLFLTArray +%typemap( jtype ) const PLFLT * ArrayY jPLFLTbracket +%typemap( jstype ) const PLFLT * ArrayY jPLFLTbracket +%typemap( javain ) const PLFLT * ArrayY "$javainput" +%typemap( javaout ) const PLFLT * ArrayY { + return $jnicall; } -/* with trailing count */ -%typemap(in) (const PLFLT *Array, PLINT n) { - jPLFLT *jxdata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - $2 = (*jenv)->GetArrayLength( jenv, $input ); - setup_array_1d_PLFLT( &$1, jxdata, $2); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); +// with trailing count +%typemap( in ) ( const PLFLT * Array, PLINT n ) +{ + jPLFLT *jxdata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + $2 = ( *jenv )->GetArrayLength( jenv, $input ); + setup_array_1d_PLFLT( &$1, jxdata, $2 ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); } -%typemap(freearg) (const PLFLT *Array, PLINT n) { - free($1); +%typemap( freearg ) ( const PLFLT * Array, PLINT n ) +{ + free( $1 ); } -%typemap(jni) (const PLFLT *Array, PLINT n) jPLFLTArray -%typemap(jtype) (const PLFLT *Array, PLINT n) jPLFLTbracket -%typemap(jstype) (const PLFLT *Array, PLINT n) jPLFLTbracket -%typemap(javain) (const PLFLT *Array, PLINT n) "$javainput" -%typemap(javaout) (const PLFLT *Array, PLINT n) { - return $jnicall; +%typemap( jni ) ( const PLFLT * Array, PLINT n ) jPLFLTArray +%typemap( jtype ) ( const PLFLT * Array, PLINT n ) jPLFLTbracket +%typemap( jstype ) ( const PLFLT * Array, PLINT n ) jPLFLTbracket +%typemap( javain ) ( const PLFLT * Array, PLINT n ) "$javainput" +%typemap( javaout ) ( const PLFLT * Array, PLINT n ) +{ + return $jnicall; } -/* with no trailing count */ -%typemap(in) const PLFLT *Array { - jPLFLT *jxdata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - Alen = (*jenv)->GetArrayLength( jenv, $input ); - setup_array_1d_PLFLT( &$1, jxdata, Alen); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); +// with no trailing count +%typemap( in ) const PLFLT * Array { + jPLFLT *jxdata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + Alen = ( *jenv )->GetArrayLength( jenv, $input ); + setup_array_1d_PLFLT( &$1, jxdata, Alen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); } -%typemap(freearg) const PLFLT *Array { - free($1); +%typemap( freearg ) const PLFLT * Array { + free( $1 ); } -%typemap(jni) const PLFLT *Array jPLFLTArray -%typemap(jtype) const PLFLT *Array jPLFLTbracket -%typemap(jstype) const PLFLT *Array jPLFLTbracket -%typemap(javain) const PLFLT *Array "$javainput" -%typemap(javaout) const PLFLT *Array { - return $jnicall; +%typemap( jni ) const PLFLT * Array jPLFLTArray +%typemap( jtype ) const PLFLT * Array jPLFLTbracket +%typemap( jstype ) const PLFLT * Array jPLFLTbracket +%typemap( javain ) const PLFLT * Array "$javainput" +%typemap( javaout ) const PLFLT * Array { + return $jnicall; } -/* check consistency with X dimension of previous */ -%typemap(in) const PLFLT *ArrayCkX { - jPLFLT *jxdata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) != Xlen) { - printf("Vectors must be same length.\n"); - return; - } - setup_array_1d_PLFLT( &$1, jxdata, Xlen ); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); +// check consistency with X dimension of previous +%typemap( in ) const PLFLT * ArrayCkX { + jPLFLT *jxdata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) != Xlen ) + { + printf( "Vectors must be same length.\n" ); + return; + } + setup_array_1d_PLFLT( &$1, jxdata, Xlen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jxdata, 0 ); } -%typemap(freearg) const PLFLT *ArrayCkX { - free($1); +%typemap( freearg ) const PLFLT * ArrayCkX { + free( $1 ); } -%typemap(jni) const PLFLT *ArrayCkX jPLFLTArray -%typemap(jtype) const PLFLT *ArrayCkX jPLFLTbracket -%typemap(jstype) const PLFLT *ArrayCkX jPLFLTbracket -%typemap(javain) const PLFLT *ArrayCkX "$javainput" -%typemap(javaout) const PLFLT *ArrayCkX{ - return $jnicall; +%typemap( jni ) const PLFLT * ArrayCkX jPLFLTArray +%typemap( jtype ) const PLFLT * ArrayCkX jPLFLTbracket +%typemap( jstype ) const PLFLT * ArrayCkX jPLFLTbracket +%typemap( javain ) const PLFLT * ArrayCkX "$javainput" +%typemap( javaout ) const PLFLT * ArrayCkX { + return $jnicall; } -/* check consistency with Y dimension of previous */ -%typemap(in) const PLFLT *ArrayCkY { - jPLFLT *jydata = (*jenv)->GetPLFLTArrayElements( jenv, $input, 0 ); - if((*jenv)->GetArrayLength( jenv, $input ) != Ylen) { - printf("Vectors must be same length.\n"); - return; - } - setup_array_1d_PLFLT( &$1, jydata, Ylen ); - (*jenv)->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); +// check consistency with Y dimension of previous +%typemap( in ) const PLFLT * ArrayCkY { + jPLFLT *jydata = ( *jenv )->GetPLFLTArrayElements( jenv, $input, 0 ); + if ( ( *jenv )->GetArrayLength( jenv, $input ) != Ylen ) + { + printf( "Vectors must be same length.\n" ); + return; + } + setup_array_1d_PLFLT( &$1, jydata, Ylen ); + ( *jenv )->ReleasePLFLTArrayElements( jenv, $input, jydata, 0 ); } -%typemap(freearg) const PLFLT *ArrayCkY { - free($1); +%typemap( freearg ) const PLFLT * ArrayCkY { + free( $1 ); } -%typemap(jni) const PLFLT *ArrayCkY jPLFLTArray -%typemap(jtype) const PLFLT *ArrayCkY jPLFLTbracket -%typemap(jstype) const PLFLT *ArrayCkY jPLFLTbracket -%typemap(javain) const PLFLT *ArrayCkY "$javainput" -%typemap(javaout) const PLFLT *ArrayCkY{ - return $jnicall; +%typemap( jni ) const PLFLT * ArrayCkY jPLFLTArray +%typemap( jtype ) const PLFLT * ArrayCkY jPLFLTbracket +%typemap( jstype ) const PLFLT * ArrayCkY jPLFLTbracket +%typemap( javain ) const PLFLT * ArrayCkY "$javainput" +%typemap( javaout ) const PLFLT * ArrayCkY { + return $jnicall; } -/* 2D array with trailing dimensions, check consistency with previous */ -%typemap(in) (const PLFLT **MatrixCk, PLINT nx, PLINT ny) { - jPLFLT **adat; - jobject *ai; - int nx = (*jenv)->GetArrayLength( jenv, $input ); - int ny = -1; - int i, j; - ai = (jobject *) malloc( nx * sizeof(jobject) ); - adat = (jPLFLT **) malloc( nx * sizeof(jPLFLT *) ); +// 2D array with trailing dimensions, check consistency with previous +%typemap( in ) ( const PLFLT * *MatrixCk, PLINT nx, PLINT ny ) +{ + jPLFLT **adat; + jobject *ai; + int nx = ( *jenv )->GetArrayLength( jenv, $input ); + int ny = -1; + int i, j; + ai = (jobject *) malloc( nx * sizeof ( jobject ) ); + adat = (jPLFLT **) malloc( nx * sizeof ( jPLFLT * ) ); - (*jenv)->EnsureLocalCapacity( jenv, nx ); + ( *jenv )->EnsureLocalCapacity( jenv, nx ); - for( i=0; i < nx; i++ ) - { - ai[i] = (*jenv)->GetObjectArrayElement( jenv, $input, i ); - adat[i] = (*jenv)->GetPLFLTArrayElements( jenv, ai[i], 0 ); + for ( i = 0; i < nx; i++ ) + { + ai[i] = ( *jenv )->GetObjectArrayElement( jenv, $input, i ); + adat[i] = ( *jenv )->GetPLFLTArrayElements( jenv, ai[i], 0 ); - if (ny == -1) - ny = (*jenv)->GetArrayLength( jenv, ai[i] ); - else if (ny != (*jenv)->GetArrayLength( jenv, ai[i] )) { - printf( "Misshapen a array.\n" ); - for( j=0; j <= i; j++ ) - (*jenv)->ReleasePLFLTArrayElements( jenv, ai[j], adat[j], 0 ); - free(adat); - free(ai); - return; - } - } + if ( ny == -1 ) + ny = ( *jenv )->GetArrayLength( jenv, ai[i] ); + else if ( ny != ( *jenv )->GetArrayLength( jenv, ai[i] ) ) + { + printf( "Misshapen a array.\n" ); + for ( j = 0; j <= i; j++ ) + ( *jenv )->ReleasePLFLTArrayElements( jenv, ai[j], adat[j], 0 ); + free( adat ); + free( ai ); + return; + } + } - if( nx != Xlen || ny != Ylen ) { - printf( "Vectors must match matrix.\n" ); - for( i=0; i < nx; i++ ) - (*jenv)->ReleasePLFLTArrayElements( jenv, ai[i], adat[i], 0 ); - free(adat); - free(ai); - return; - } - setup_array_2d_PLFLT( &$1, adat, nx, ny ); - $2 = nx; - $3 = ny; - for( i=0; i < nx; i++ ) { - (*jenv)->ReleasePLFLTArrayElements( jenv, ai[i], adat[i], 0 ); - (*jenv)->DeleteLocalRef(jenv, ai[i]); - } - + if ( nx != Xlen || ny != Ylen ) + { + printf( "Vectors must match matrix.\n" ); + for ( i = 0; i < nx; i++ ) + ( *jenv )->ReleasePLFLTArrayElements( jenv, ai[i], adat[i], 0 ); + free( adat ); + free( ai ); + return; + } + setup_array_2d_PLFLT( &$1, adat, nx, ny ); + $2 = nx; + $3 = ny; + for ( i = 0; i < nx; i++ ) + { + ( *jenv )->ReleasePLFLTArrayElements( jenv, ai[i], adat[i], 0 ); + ( *jenv )->DeleteLocalRef( jenv, ai[i] ); + } - free(adat); - free(ai); + free( adat ); + free( ai ); } -%typemap(freearg) (const PLFLT **MatrixCk, PLINT nx, PLINT ny) { - free($1[0]); - free($1); +%typemap( freearg ) ( const PLFLT * *MatrixCk, PLINT nx, P... [truncated message content] |