Class PanamaMemoryType

java.lang.Object
ai.tegmentum.wasmtime4j.panama.type.PanamaMemoryType
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.type.MemoryType, ai.tegmentum.wasmtime4j.type.WasmType

public final class PanamaMemoryType extends Object implements ai.tegmentum.wasmtime4j.type.MemoryType
Panama implementation of MemoryType interface.

This class provides type introspection capabilities for WebAssembly memory types using Panama Foreign Function Interface bindings to the native Wasmtime library.

Since:
1.0.0
  • Constructor Details

    • PanamaMemoryType

      public PanamaMemoryType(long minimum, Long maximum, boolean is64Bit, boolean isShared)
      Creates a new PanamaMemoryType instance with just the type values.

      This constructor is used when the type information is already known and no native handle is needed for further operations.

      Parameters:
      minimum - the minimum number of memory pages
      maximum - the maximum number of memory pages (null if unlimited)
      is64Bit - true if this is 64-bit addressable memory
      isShared - true if this is shared memory
    • PanamaMemoryType

      public PanamaMemoryType(long minimum, Long maximum, boolean is64Bit, boolean isShared, int pageSizeLog2)
      Creates a new PanamaMemoryType instance with just the type values including page size.
      Parameters:
      minimum - the minimum number of memory pages
      maximum - the maximum number of memory pages (null if unlimited)
      is64Bit - true if this is 64-bit addressable memory
      isShared - true if this is shared memory
      pageSizeLog2 - the log2 of the page size (e.g. 16 for 65536 bytes)
    • PanamaMemoryType

      public PanamaMemoryType(long minimum, Long maximum, boolean is64Bit, boolean isShared, Arena arena, MemorySegment nativeHandle)
      Creates a new PanamaMemoryType instance with native handle and default page size.
      Parameters:
      minimum - the minimum number of memory pages
      maximum - the maximum number of memory pages (null if unlimited)
      is64Bit - true if this is 64-bit addressable memory
      isShared - true if this is shared memory
      arena - the memory arena for resource management
      nativeHandle - the native handle to the memory type
    • PanamaMemoryType

      public PanamaMemoryType(long minimum, Long maximum, boolean is64Bit, boolean isShared, int pageSizeLog2, Arena arena, MemorySegment nativeHandle)
      Creates a new PanamaMemoryType instance with native handle.
      Parameters:
      minimum - the minimum number of memory pages
      maximum - the maximum number of memory pages (null if unlimited)
      is64Bit - true if this is 64-bit addressable memory
      isShared - true if this is shared memory
      pageSizeLog2 - the log2 of the page size (e.g. 16 for 65536 bytes)
      arena - the memory arena for resource management
      nativeHandle - the native handle to the memory type
  • Method Details

    • fromNative

      public static PanamaMemoryType fromNative(MemorySegment nativeHandle, Arena arena)
      Creates a PanamaMemoryType from native memory type information.
      Parameters:
      nativeHandle - the native handle to the memory type
      arena - the memory arena for resource management
      Returns:
      the PanamaMemoryType instance
      Throws:
      IllegalArgumentException - if nativeHandle is invalid
    • getMinimum

      public long getMinimum()
      Specified by:
      getMinimum in interface ai.tegmentum.wasmtime4j.type.MemoryType
    • getMaximum

      public Optional<Long> getMaximum()
      Specified by:
      getMaximum in interface ai.tegmentum.wasmtime4j.type.MemoryType
    • is64Bit

      public boolean is64Bit()
      Specified by:
      is64Bit in interface ai.tegmentum.wasmtime4j.type.MemoryType
    • isShared

      public boolean isShared()
      Specified by:
      isShared in interface ai.tegmentum.wasmtime4j.type.MemoryType
    • getPageSize

      public long getPageSize()
      Specified by:
      getPageSize in interface ai.tegmentum.wasmtime4j.type.MemoryType
    • getPageSizeLog2

      public int getPageSizeLog2()
      Specified by:
      getPageSizeLog2 in interface ai.tegmentum.wasmtime4j.type.MemoryType
    • getKind

      public ai.tegmentum.wasmtime4j.type.WasmTypeKind getKind()
      Specified by:
      getKind in interface ai.tegmentum.wasmtime4j.type.MemoryType
      Specified by:
      getKind in interface ai.tegmentum.wasmtime4j.type.WasmType
    • getNativeHandle

      public MemorySegment getNativeHandle()
      Gets the native handle for this memory type.
      Returns:
      the native handle
    • getArena

      public Arena getArena()
      Gets the memory arena used by this memory type.
      Returns:
      the memory arena
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object