Class: Extism::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/extism/wasm.rb

Overview

Represents a host function. This is mostly for internal use and you should try to use HostEnvironment instead

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(name, params, returns, func_proc, user_data: nil, on_free: nil) ⇒ Function

Create a new host function

Parameters:

  • name (String)

    Must match the import name in Wasm. Doesn’t include namespace. All extism host functions are in the env name space

  • params (Array[Extism::ValType])

    An array of val types matching the import’s params

  • returns (Array[Extism::ValType])

    An array of val types matching the import returns

  • func_proc (Proc)

    A proc that will be executed when the host function is executed

  • user_data (Object) (defaults to: nil)

    Any reference to object you want to be passed back to you when the func is invoked

  • on_free (Proc) (defaults to: nil)

    A proc triggered when this function is freed by the runtime. Not guaranteed to trigger.



75
76
77
78
79
80
81
82
# File 'lib/extism/wasm.rb', line 75

def initialize(name, params, returns, func_proc, user_data: nil, on_free: nil)
  @name = name
  @params = params
  @returns = returns
  @func = func_proc
  @user_data = user_data
  @on_free = on_free
end