| 1 | package io.gomatcha.bridge; |
| 2 | |
| 3 | public class GoValue { |
| 4 | static { |
| 5 | System.loadLibrary("gojni"); |
| 6 | |
| 7 | matchaInit(Tracker.singleton()); |
| 8 | } |
| 9 | |
| 10 | private static native void matchaInit(Object tracker); |
| 11 | |
| 12 | protected long goRef; |
| 13 | |
| 14 | protected GoValue(long goref, boolean empty) { |
| 15 | this.goRef = goref; |
| 16 | } |
| 17 | public GoValue(Object v) { |
| 18 | this(matchaGoForeign(Tracker.singleton().track(v)), false); |
| 19 | } |
| 20 | |
| 21 | public GoValue(boolean v) { |
| 22 | this(matchaGoBool(v), false); |
| 23 | } |
| 24 | public GoValue(long v) { |
| 25 | this(matchaGoLong(v), false); |
| 26 | } |
| 27 | public GoValue(double v) { |
| 28 | this(matchaGoDouble(v), false); |
| 29 | } |
| 30 | public GoValue(String v) { |
| 31 | this(matchaGoString(v), false); |
| 32 | } |
| 33 | public GoValue(byte[] v) { |
| 34 | this(matchaGoByteArray(v), false); |
| 35 | } |
| 36 | public GoValue(GoValue[] v) { |
| 37 | this(makeGoArray(v), false); |
| 38 | } |
| 39 | public static GoValue withFunc(String v) { |
| 40 | return new GoValue(matchaGoFunc(v), false); |
| 41 | } |
| 42 | public static GoValue withType(String v) { |
| 43 | return new GoValue(matchaGoType(v), false); |
| 44 | } |
| 45 | private static long makeGoArray(GoValue[] v) { |
| 46 | long[] array = new long[v.length]; |
| 47 | for (int i = 0; i < v.length; i++) { |
| 48 | array[i] = v[i].goRef; |
| 49 | } |
| 50 | return matchaGoArray(array); |
| 51 | } |
| 52 | |
| 53 | private static native long matchaGoForeign(long a); |
| 54 | private static native long matchaGoBool(boolean a); |
| 55 | private static native long matchaGoLong(long a); |
| 56 | private static native long matchaGoDouble(double a); |
| 57 | private static native long matchaGoString(String a); |
| 58 | private static native long matchaGoByteArray(byte[] v); |
| 59 | private static native long matchaGoArray(long[] v); |
| 60 | private static native long matchaGoFunc(String a); |
nothing calls this directly
no test coverage detected