Skip to content

Commit b8384e0

Browse files
Allow to pass NULL for the boolean[], int[], float[] and double[] parameters (#18)
Co-authored-by: Jonathan Schilling <[email protected]>
1 parent c63517f commit b8384e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6004
-4265
lines changed

arpack/src/main/native/jni.c

Lines changed: 292 additions & 292 deletions
Large diffs are not rendered by default.

blas/src/main/native/jni.c

Lines changed: 215 additions & 215 deletions
Large diffs are not rendered by default.

generator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -168,45 +168,45 @@ def __init__(self, name):
168168
self.name = name
169169
self.native_type_and_name = "int *{name}".format(name=name)
170170
self.java_type_and_name = [a.format(name=name) for a in ["jbooleanArray {name}", "jint offset{name}"]]
171-
self.native_argument = "__n{name} + offset{name}".format(name=name)
171+
self.native_argument = "__n{name} ? __n{name} + offset{name} : NULL".format(name=name)
172172
self.native_local = "int *__n{name} = NULL; jboolean *__j{name} = NULL;".format(name=name)
173-
self.prolog = """if (!(__j{name} = (*env)->GetPrimitiveArrayCritical(env, {name}, NULL))) {{ __failed = TRUE; goto done; }}
173+
self.prolog = """if ({name}) {{ if (!(__j{name} = (*env)->GetPrimitiveArrayCritical(env, {name}, NULL))) {{ __failed = TRUE; goto done; }}
174174
do {{
175175
int __length = (*env)->GetArrayLength(env, {name});
176176
if (__length <= 0) {{ __failed = TRUE; goto done; }}
177177
if (!(__n{name} = malloc(sizeof(int) * __length))) {{ __failed = TRUE; goto done; }}
178178
for (int i = 0; i < __length; i++) {{ __n{name}[i] = __j{name}[i]; }}
179-
}} while(0);""".format(name=name)
179+
}} while(0); }}""".format(name=name)
180180
self.epilog = "if (__n{name}) {{ free(__n{name}); }} if (__j{name}) (*env)->ReleasePrimitiveArrayCritical(env, {name}, __n{name}, JNI_ABORT);".format(name=name)
181181
class JIntArray:
182182
def __init__(self, name, mode = "0"):
183183
self.idx = 1
184184
self.name = name
185185
self.native_type_and_name = "int *{name}".format(name=name)
186186
self.java_type_and_name = [a.format(name=name) for a in ["jintArray {name}", "jint offset{name}"]]
187-
self.native_argument = "__n{name} + offset{name}".format(name=name)
187+
self.native_argument = "__n{name} ? __n{name} + offset{name} : NULL".format(name=name)
188188
self.native_local = "int *__n{name} = NULL;".format(name=name)
189-
self.prolog = "if (!(__n{name} = (*env)->GetPrimitiveArrayCritical(env, {name}, NULL))) {{ __failed = TRUE; goto done; }}".format(name=name)
189+
self.prolog = "if ({name}) {{ if (!(__n{name} = (*env)->GetPrimitiveArrayCritical(env, {name}, NULL))) {{ __failed = TRUE; goto done; }} }}".format(name=name)
190190
self.epilog = "if (__n{name}) (*env)->ReleasePrimitiveArrayCritical(env, {name}, __n{name}, {mode});".format(name=name, mode=("JNI_ABORT" if mode == "JNI_ABORT" else ("__failed ? JNI_ABORT : %s" % mode)))
191191
class JFloatArray:
192192
def __init__(self, name, mode = "0"):
193193
self.idx = 1
194194
self.name = name
195195
self.native_type_and_name = "float *{name}".format(name=name)
196196
self.java_type_and_name = [a.format(name=name) for a in ["jfloatArray {name}", "jint offset{name}"]]
197-
self.native_argument = "__n{name} + offset{name}".format(name=name)
197+
self.native_argument = "__n{name} ? __n{name} + offset{name} : NULL".format(name=name)
198198
self.native_local = "float *__n{name} = NULL;".format(name=name)
199-
self.prolog = "if (!(__n{name} = (*env)->GetPrimitiveArrayCritical(env, {name}, NULL))) {{ __failed = TRUE; goto done; }}".format(name=name)
199+
self.prolog = "if ({name}) {{ if (!(__n{name} = (*env)->GetPrimitiveArrayCritical(env, {name}, NULL))) {{ __failed = TRUE; goto done; }} }}".format(name=name)
200200
self.epilog = "if (__n{name}) (*env)->ReleasePrimitiveArrayCritical(env, {name}, __n{name}, {mode});".format(name=name, mode=("JNI_ABORT" if mode == "JNI_ABORT" else ("__failed ? JNI_ABORT : %s" % mode)))
201201
class JDoubleArray:
202202
def __init__(self, name, mode = "0"):
203203
self.idx = 1
204204
self.name = name
205205
self.native_type_and_name = "double *{name}".format(name=name)
206206
self.java_type_and_name = [a.format(name=name) for a in ["jdoubleArray {name}", "jint offset{name}"]]
207-
self.native_argument = "__n{name} + offset{name}".format(name=name)
207+
self.native_argument = "__n{name} ? __n{name} + offset{name} : NULL".format(name=name)
208208
self.native_local = "double *__n{name} = NULL;".format(name=name)
209-
self.prolog = "if (!(__n{name} = (*env)->GetPrimitiveArrayCritical(env, {name}, NULL))) {{ __failed = TRUE; goto done; }}".format(name=name)
209+
self.prolog = "if ({name}) {{ if (!(__n{name} = (*env)->GetPrimitiveArrayCritical(env, {name}, NULL))) {{ __failed = TRUE; goto done; }} }}".format(name=name)
210210
self.epilog = "if (__n{name}) (*env)->ReleasePrimitiveArrayCritical(env, {name}, __n{name}, {mode});".format(name=name, mode=("JNI_ABORT" if mode == "JNI_ABORT" else ("__failed ? JNI_ABORT : %s" % mode)))
211211

212212
class RoutineR:

lapack/src/main/native/jni.c

Lines changed: 3749 additions & 3749 deletions
Large diffs are not rendered by default.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020, 2022, Ludovic Henry
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
* Please contact [email protected] or visit ludovic.dev if you need additional
23+
* information or have any questions.
24+
*/
25+
26+
package dev.ludovic.netlib.lapack;
27+
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.params.ParameterizedTest;
30+
import org.junit.jupiter.params.provider.MethodSource;
31+
import static org.junit.jupiter.api.Assertions.*;
32+
33+
public class DisnanTest extends LAPACKTest {
34+
35+
@ParameterizedTest
36+
@MethodSource("LAPACKImplementations")
37+
void testSanity(LAPACK lapack) {
38+
org.junit.jupiter.api.Assumptions.assumeTrue(false);
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020, 2022, Ludovic Henry
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
* Please contact [email protected] or visit ludovic.dev if you need additional
23+
* information or have any questions.
24+
*/
25+
26+
package dev.ludovic.netlib.lapack;
27+
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.params.ParameterizedTest;
30+
import org.junit.jupiter.params.provider.MethodSource;
31+
import static org.junit.jupiter.api.Assertions.*;
32+
33+
public class DlaisnanTest extends LAPACKTest {
34+
35+
@ParameterizedTest
36+
@MethodSource("LAPACKImplementations")
37+
void testSanity(LAPACK lapack) {
38+
org.junit.jupiter.api.Assumptions.assumeTrue(false);
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020, 2022, Ludovic Henry
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
* Please contact [email protected] or visit ludovic.dev if you need additional
23+
* information or have any questions.
24+
*/
25+
26+
package dev.ludovic.netlib.lapack;
27+
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.params.ParameterizedTest;
30+
import org.junit.jupiter.params.provider.MethodSource;
31+
import static org.junit.jupiter.api.Assertions.*;
32+
33+
public class Dlamc3Test extends LAPACKTest {
34+
35+
@ParameterizedTest
36+
@MethodSource("LAPACKImplementations")
37+
void testSanity(LAPACK lapack) {
38+
org.junit.jupiter.api.Assumptions.assumeTrue(false);
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020, 2022, Ludovic Henry
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
* Please contact [email protected] or visit ludovic.dev if you need additional
23+
* information or have any questions.
24+
*/
25+
26+
package dev.ludovic.netlib.lapack;
27+
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.params.ParameterizedTest;
30+
import org.junit.jupiter.params.provider.MethodSource;
31+
import static org.junit.jupiter.api.Assertions.*;
32+
33+
public class DlamchTest extends LAPACKTest {
34+
35+
@ParameterizedTest
36+
@MethodSource("LAPACKImplementations")
37+
void testSanity(LAPACK lapack) {
38+
org.junit.jupiter.api.Assumptions.assumeTrue(false);
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020, 2022, Ludovic Henry
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
* Please contact [email protected] or visit ludovic.dev if you need additional
23+
* information or have any questions.
24+
*/
25+
26+
package dev.ludovic.netlib.lapack;
27+
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.params.ParameterizedTest;
30+
import org.junit.jupiter.params.provider.MethodSource;
31+
import static org.junit.jupiter.api.Assertions.*;
32+
33+
public class DlanegTest extends LAPACKTest {
34+
35+
@ParameterizedTest
36+
@MethodSource("LAPACKImplementations")
37+
void testSanity(LAPACK lapack) {
38+
org.junit.jupiter.api.Assumptions.assumeTrue(false);
39+
}
40+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2020, 2022, Ludovic Henry
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
* Please contact [email protected] or visit ludovic.dev if you need additional
23+
* information or have any questions.
24+
*/
25+
26+
package dev.ludovic.netlib.lapack;
27+
28+
import org.junit.jupiter.api.Test;
29+
import org.junit.jupiter.params.ParameterizedTest;
30+
import org.junit.jupiter.params.provider.MethodSource;
31+
import static org.junit.jupiter.api.Assertions.*;
32+
33+
public class DlangbTest extends LAPACKTest {
34+
35+
@ParameterizedTest
36+
@MethodSource("LAPACKImplementations")
37+
void testSanity(LAPACK lapack) {
38+
org.junit.jupiter.api.Assumptions.assumeTrue(false);
39+
}
40+
}

0 commit comments

Comments
 (0)