View Source Orb.Import (Orb v0.1.0)

Define an interface to be imported into WebAssembly.

Each function declaration is turned into an (import) WebAssembly instruction.

defmodule Log do
  use Orb.Import, name: :log

  defw logi32(value: I32)
  defw logi64(value: I64)
end

defmodule Time do
  use Orb.Import, name: :time

  defw get_unix_time(), I64
end

defmodule Example do
  use Orb

  Orb.Import.register(Log)
  Orb.Import.register(Time)

  defw example() do
    Log.logi32(99)

    Log.logi64(Time.get_unix_time())
  end
end

Summary

Functions

Register an import module under namespace.

Functions

Link to this macro

register(module)

View Source (since 0.0.46) (macro)

Register an import module under namespace.

The module is defined via use Orb.Import. The namespace is the local name the import is registered under.

For each function defined within module an (import) instruction is defined in the outputted WebAssembly:

(module $example
  (import "namespace" "function1" (func $function1 (param $a i32) (result i32)))
  (import "namespace" "function2" (func $function2 (param $a i32) (result i32)))
  (import "namespace" "function3" (func $function3 (param $a i32) (result i32)))
)