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 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 function
      name - the function name
      functionType - 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:
      call in interface ai.tegmentum.wasmtime4j.WasmFunction
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getFunctionType

      public ai.tegmentum.wasmtime4j.type.FunctionType getFunctionType()
      Specified by:
      getFunctionType in interface ai.tegmentum.wasmtime4j.WasmFunction
    • getName

      public String getName()
      Specified by:
      getName in interface ai.tegmentum.wasmtime4j.WasmFunction
    • asTyped

      public ai.tegmentum.wasmtime4j.func.TypedFunc asTyped(String signature)
      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:
      asTyped in interface ai.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:
      callAsync in interface ai.tegmentum.wasmtime4j.WasmFunction
    • callVoid

      public void callVoid() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      callVoid in interface ai.tegmentum.wasmtime4j.WasmFunction
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • callI32ToI32

      public int callI32ToI32(int arg) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      callI32ToI32 in interface ai.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:
      callI32I32ToI32 in interface ai.tegmentum.wasmtime4j.WasmFunction
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • callI64ToI64

      public long callI64ToI64(long arg) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      callI64ToI64 in interface ai.tegmentum.wasmtime4j.WasmFunction
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • callF64ToF64

      public double callF64ToF64(double arg) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      callF64ToF64 in interface ai.tegmentum.wasmtime4j.WasmFunction
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • callToI32

      public int callToI32() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      callToI32 in interface ai.tegmentum.wasmtime4j.WasmFunction
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • toRawFuncRef

      public long toRawFuncRef() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      toRawFuncRef in interface ai.tegmentum.wasmtime4j.WasmFunction
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • close

      public void close()
      Closes the function and releases resources.