Enum Class WasmCallingConvention

java.lang.Object
java.lang.Enum<WasmCallingConvention>
org.apache.ignite.compute.wasm.WasmCallingConvention
All Implemented Interfaces:
Serializable, Comparable<WasmCallingConvention>, Constable

public enum WasmCallingConvention extends Enum<WasmCallingConvention>
WebAssembly calling conventions.
  • Enum Constant Details

    • GENERIC

      public static final WasmCallingConvention GENERIC
      Generic calling convention. Aims to be language-agnostic.
      • Calls _start and/or __wasm_call_ctors for module initialization (if present).
      • Requires alloc and dealloc exports for memory management.
    • RUST_WASM_BINDGEN

      public static final WasmCallingConvention RUST_WASM_BINDGEN
      Rust-specific calling convention that works with modules built using wasm-pack and wasm-bindgen.

      To build a compatible module:

      • cargo install wasm-pack
      • cargo new --lib hello-wasm
      • Add the following to Cargo.toml:
         [lib]
         crate-type = ["cdylib"]
        
         [dependencies]
         wasm-bindgen = "0.2"
         
      • Add the following to src/lib.rs:
         use wasm_bindgen::prelude::*;
        
         #[wasm_bindgen]
         pub fn hello(arg: String) -> String {
             format!("Hello from Rust, {}!", arg)
         }
         
      • Build the module: wasm-pack build
      • Use the generated pkg/hello_wasm_bg.wasm file as the compute module.
    • GO_WASI_REACTOR

      public static final WasmCallingConvention GO_WASI_REACTOR
      Go-specific calling convention that works with modules built using GOOS=wasip1 GOARCH=wasm go build -buildmode=c-shared.

      To build a compatible module:

      • In Go code, use //go:wasmexport to mark functions for export:
         package main
        
         func main() {
         }
        
         //go:wasmexport addOne
         func addOne(x int32) int32 {
             return x + 1
         }
         
      • Build the module: GOOS=wasip1 GOARCH=wasm go build -o addone.wasm -buildmode=c-shared
      • Use the generated addone.wasm file as the compute module.
  • Method Details

    • values

      public static WasmCallingConvention[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static WasmCallingConvention valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null