Wrapper around the Extism library.
| 6 | * Wrapper around the Extism library. |
| 7 | */ |
| 8 | public interface LibExtism extends Library { |
| 9 | |
| 10 | /** |
| 11 | * Holds the extism library instance. |
| 12 | * Resolves the extism library based on the resolution algorithm defined in {@link com.sun.jna.NativeLibrary}. |
| 13 | */ |
| 14 | LibExtism INSTANCE = Native.load("extism", LibExtism.class); |
| 15 | |
| 16 | interface InternalExtismFunction extends Callback { |
| 17 | void invoke( |
| 18 | Pointer currentPlugin, |
| 19 | ExtismVal inputs, |
| 20 | int nInputs, |
| 21 | ExtismVal outputs, |
| 22 | int nOutputs, |
| 23 | Pointer data |
| 24 | ); |
| 25 | } |
| 26 | |
| 27 | @Structure.FieldOrder({"t", "v"}) |
| 28 | class ExtismVal extends Structure { |
| 29 | public int t; |
| 30 | public ExtismValUnion v; |
| 31 | } |
| 32 | class ExtismValUnion extends Union { |
| 33 | public int i32; |
| 34 | public long i64; |
| 35 | public long ptr; |
| 36 | public float f32; |
| 37 | public double f64; |
| 38 | } |
| 39 | |
| 40 | enum ExtismValType { |
| 41 | I32(0), |
| 42 | I64(1), |
| 43 | // PTR is an alias for I64 |
| 44 | PTR(1), |
| 45 | F32(2), |
| 46 | F64(3), |
| 47 | V128(4), |
| 48 | FuncRef(5), |
| 49 | ExternRef(6); |
| 50 | |
| 51 | public final int v; |
| 52 | |
| 53 | ExtismValType(int value) { |
| 54 | this.v = value; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | Pointer extism_function_new(String name, |
| 59 | int[] inputs, |
| 60 | int nInputs, |
| 61 | int[] outputs, |
| 62 | int nOutputs, |
| 63 | InternalExtismFunction func, |
| 64 | Pointer userData, |
| 65 | Pointer freeUserData); |
no outgoing calls
no test coverage detected