Class PanamaFunction
java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaFunction
- All Implemented Interfaces:
ai.tegmentum.wasmtime4j.func.TypedFunc.TypedFunctionSupport,ai.tegmentum.wasmtime4j.WasmFunction
public final class PanamaFunction
extends Object
implements ai.tegmentum.wasmtime4j.WasmFunction, ai.tegmentum.wasmtime4j.func.TypedFunc.TypedFunctionSupport
Panama FFI implementation of WebAssembly Function.
- Since:
- 1.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionPanamaFunction(PanamaInstance instance, String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType) Creates a new Panama function that delegates to an instance. -
Method Summary
Modifier and TypeMethodDescriptionai.tegmentum.wasmtime4j.func.TypedFuncCreates a typed function wrapper with the specified signature.ai.tegmentum.wasmtime4j.WasmValue[]call(ai.tegmentum.wasmtime4j.WasmValue... params) CompletableFuture<ai.tegmentum.wasmtime4j.WasmValue[]> callAsync(ai.tegmentum.wasmtime4j.WasmValue... params) doublecallF64ToF64(double arg) intcallI32I32ToI32(int arg1, int arg2) intcallI32ToI32(int arg) longcallI64ToI64(long arg) intvoidcallVoid()voidclose()Closes the function and releases resources.ai.tegmentum.wasmtime4j.type.FunctionTypegetName()longMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ai.tegmentum.wasmtime4j.WasmFunction
callSingleAsync, callUnchecked, getNativeHandle, matchesFuncType, matchesType, typed
-
Constructor Details
-
PanamaFunction
public PanamaFunction(PanamaInstance instance, String name, ai.tegmentum.wasmtime4j.type.FunctionType functionType) Creates a new Panama function that delegates to an instance.- Parameters:
instance- the instance containing this functionname- the function namefunctionType- the function type signature
-
-
Method Details
-
call
public ai.tegmentum.wasmtime4j.WasmValue[] call(ai.tegmentum.wasmtime4j.WasmValue... params) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callin interfaceai.tegmentum.wasmtime4j.WasmFunction- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
getFunctionType
public ai.tegmentum.wasmtime4j.type.FunctionType getFunctionType()- Specified by:
getFunctionTypein interfaceai.tegmentum.wasmtime4j.WasmFunction
-
getName
- Specified by:
getNamein interfaceai.tegmentum.wasmtime4j.WasmFunction
-
asTyped
Creates a typed function wrapper with the specified signature.This method provides zero-cost typed function calls by eliminating runtime type checking overhead. The signature string encodes parameter and return types in a compact format.
- Specified by:
asTypedin interfaceai.tegmentum.wasmtime4j.func.TypedFunc.TypedFunctionSupport- Parameters:
signature- the signature string (e.g., "ii->i" for (i32, i32) -> i32)- Returns:
- a new TypedFunc instance wrapping this function
- Throws:
IllegalArgumentException- if signature is invalid
-
callAsync
public CompletableFuture<ai.tegmentum.wasmtime4j.WasmValue[]> callAsync(ai.tegmentum.wasmtime4j.WasmValue... params) - Specified by:
callAsyncin interfaceai.tegmentum.wasmtime4j.WasmFunction
-
callVoid
public void callVoid() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
callVoidin interfaceai.tegmentum.wasmtime4j.WasmFunction- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callI32ToI32
public int callI32ToI32(int arg) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callI32ToI32in interfaceai.tegmentum.wasmtime4j.WasmFunction- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callI32I32ToI32
public int callI32I32ToI32(int arg1, int arg2) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callI32I32ToI32in interfaceai.tegmentum.wasmtime4j.WasmFunction- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callI64ToI64
public long callI64ToI64(long arg) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callI64ToI64in interfaceai.tegmentum.wasmtime4j.WasmFunction- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callF64ToF64
public double callF64ToF64(double arg) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callF64ToF64in interfaceai.tegmentum.wasmtime4j.WasmFunction- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callToI32
public int callToI32() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
callToI32in interfaceai.tegmentum.wasmtime4j.WasmFunction- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
toRawFuncRef
public long toRawFuncRef() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
toRawFuncRefin interfaceai.tegmentum.wasmtime4j.WasmFunction- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
close
public void close()Closes the function and releases resources.
-