Class PanamaComponentTypedFunc
java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaComponentTypedFunc
- All Implemented Interfaces:
ai.tegmentum.wasmtime4j.component.ComponentTypedFunc,AutoCloseable
public final class PanamaComponentTypedFunc
extends Object
implements ai.tegmentum.wasmtime4j.component.ComponentTypedFunc
Panama FFI implementation of typed WebAssembly Component Model function calls.
This class provides zero-cost typed function calls by caching type information and avoiding runtime type checking on each invocation. This is a significant performance optimization for frequently called Component Model functions with known signatures.
ComponentTypedFunc wraps a regular ComponentFunc with compile-time type information, enabling:
- Zero-cost abstraction - no runtime type checking overhead
- Direct primitive parameter passing without ComponentVal boxing
- Optimized parameter/result marshalling for common type combinations
- Type safety through signature validation at creation time
Supported signatures use Component Model type names:
- "s32" = signed 32-bit integer
- "s64" = signed 64-bit integer
- "f32" = 32-bit float
- "f64" = 64-bit float
- "string" = UTF-8 string
- "bool" = boolean
- "void" = no value
Example usage:
ComponentFunc func = instance.getFunc("add");
PanamaComponentTypedFunc typedAdd = new PanamaComponentTypedFunc(func, "s32,s32->s32");
int result = typedAdd.callS32S32ToS32(10, 20); // Returns 30
- Since:
- 1.0.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface ai.tegmentum.wasmtime4j.component.ComponentTypedFunc
ai.tegmentum.wasmtime4j.component.ComponentTypedFunc.TypedComponentFunctionSupport -
Constructor Summary
ConstructorsConstructorDescriptionPanamaComponentTypedFunc(ai.tegmentum.wasmtime4j.component.ComponentFunc func, String signature) Creates a typed component function wrapper from a regular component function. -
Method Summary
Modifier and TypeMethodDescriptionbooleancallBoolToBool(boolean param) floatcallF32F32F32ToF32(float param1, float param2, float param3) floatcallF32F32ToF32(float param1, float param2) floatcallF32ToF32(float param) doublecallF64F64F64ToF64(double param1, double param2, double param3) doublecallF64F64ToF64(double param1, double param2) doublecallF64ToF64(double param) intcallS32S32S32ToS32(int param1, int param2, int param3) intcallS32S32ToS32(int param1, int param2) longcallS32S32ToS64(int param1, int param2) voidcallS32S32ToVoid(int param1, int param2) intcallS32ToS32(int param) voidcallS32ToVoid(int param) longcallS64S64S64ToS64(long param1, long param2, long param3) longcallS64S64ToS64(long param1, long param2) voidcallS64S64ToVoid(long param1, long param2) intcallS64ToS32(long param) longcallS64ToS64(long param) voidcallS64ToVoid(long param) callStringStringToString(String param1, String param2) callStringToString(String param) voidcallStringToVoid(String param) booleanvoidvoidclose()ai.tegmentum.wasmtime4j.component.ComponentFunctoString()Ensures the typed function is not closed.
-
Constructor Details
-
PanamaComponentTypedFunc
public PanamaComponentTypedFunc(ai.tegmentum.wasmtime4j.component.ComponentFunc func, String signature) Creates a typed component function wrapper from a regular component function.The signature string encodes parameter and return types using Component Model names:
- "s8", "s16", "s32", "s64" = signed integers
- "u8", "u16", "u32", "u64" = unsigned integers
- "f32", "f64" = floating point
- "bool" = boolean
- "string" = string
- "void" or empty = no value
Format: "params->results", e.g., "s32,s32->s32" for (s32, s32) -> s32
- Parameters:
func- the component function to wrap with type informationsignature- the signature string encoding parameter and return types- Throws:
IllegalArgumentException- if function or signature is invalid
-
-
Method Details
-
callVoidToVoid
public void callVoidToVoid() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
callVoidToVoidin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS32ToVoid
public void callS32ToVoid(int param) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS32ToVoidin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS32S32ToVoid
public void callS32S32ToVoid(int param1, int param2) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS32S32ToVoidin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS64ToVoid
public void callS64ToVoid(long param) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS64ToVoidin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS64S64ToVoid
public void callS64S64ToVoid(long param1, long param2) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS64S64ToVoidin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callStringToVoid
- Specified by:
callStringToVoidin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS32ToS32
public int callS32ToS32(int param) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS32ToS32in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS32S32ToS32
public int callS32S32ToS32(int param1, int param2) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS32S32ToS32in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS32S32S32ToS32
public int callS32S32S32ToS32(int param1, int param2, int param3) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS32S32S32ToS32in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS64ToS32
public int callS64ToS32(long param) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS64ToS32in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS64ToS64
public long callS64ToS64(long param) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS64ToS64in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS64S64ToS64
public long callS64S64ToS64(long param1, long param2) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS64S64ToS64in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS64S64S64ToS64
public long callS64S64S64ToS64(long param1, long param2, long param3) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS64S64S64ToS64in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callS32S32ToS64
public long callS32S32ToS64(int param1, int param2) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callS32S32ToS64in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callF32ToF32
public float callF32ToF32(float param) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callF32ToF32in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callF32F32ToF32
public float callF32F32ToF32(float param1, float param2) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callF32F32ToF32in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callF32F32F32ToF32
public float callF32F32F32ToF32(float param1, float param2, float param3) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callF32F32F32ToF32in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callF64ToF64
public double callF64ToF64(double param) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callF64ToF64in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callF64F64ToF64
public double callF64F64ToF64(double param1, double param2) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callF64F64ToF64in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callF64F64F64ToF64
public double callF64F64F64ToF64(double param1, double param2, double param3) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callF64F64F64ToF64in interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callVoidToString
- Specified by:
callVoidToStringin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callStringToString
-
callStringStringToString
-
callVoidToBool
public boolean callVoidToBool() throws ai.tegmentum.wasmtime4j.exception.WasmException- Specified by:
callVoidToBoolin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
callBoolToBool
public boolean callBoolToBool(boolean param) throws ai.tegmentum.wasmtime4j.exception.WasmException - Specified by:
callBoolToBoolin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc- Throws:
ai.tegmentum.wasmtime4j.exception.WasmException
-
getSignature
- Specified by:
getSignaturein interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc
-
getFunction
public ai.tegmentum.wasmtime4j.component.ComponentFunc getFunction()- Specified by:
getFunctionin interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceai.tegmentum.wasmtime4j.component.ComponentTypedFunc
-
toString
Ensures the typed function is not closed.- Overrides:
toStringin classObject- Throws:
IllegalStateException- if closed
-