class Wasmer::ImportObject

Overview

ImportObject contains all of the import data used when instantiating a WebAssembly module.

Defined in:

wasmer/import.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]

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")

[View source]
def externs : Hash(String, Hash(String, WithExtern)) #

[View source]
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})

[View source]