class Wasmer::ImportObject
- Wasmer::ImportObject
- Reference
- Object
Overview
ImportObject contains all of the import data used when instantiating a WebAssembly module.
Defined in:
wasmer/import.crConstructors
Instance Method Summary
-
#contains_namespace?(name : String) : Bool
Returns true if the
ImportObject
contains the given namespace (or module name)imports = ImportObject.new imports.contains_namespace?("env")
- #externs : Hash(String, Hash(String, WithExtern))
-
#register(ns_name : String, ns : Hash(String, WithExtern)) : Nil
Registers a namespace (or module name) in the
ImportObject
.
Constructor Detail
Instance Method Detail
def contains_namespace?(name : String) : Bool
#
Returns true if the ImportObject
contains the given namespace (or module name)
imports = ImportObject.new
imports.contains_namespace?("env")
def register(ns_name : String, ns : Hash(String, WithExtern)) : Nil
#
Registers a namespace (or module name) in the ImportObject
.
It takes two arguments: the namespace name and a hash with imports names as key and externs as value
Note: An extern is anything implementing WithExtern
: Function
, Global
, Memory
, Table
imports = ImportObject.new
imports.register("env", {"host_function" => host_function, "host_global" => host_global})
Note: The namespace (or module name) may be empty:
imports = ImportObject.new
imports.register("", {"host_function" => host_function, "host_global" => host_global})