package wasmer

  1. Overview
  2. Docs

Parameters

module T : StructType

Signature

include module type of struct include DeclareRef(T) end
include module type of struct include DeclareRefBase(T) end
include module type of struct include DeclareOwn(T) end

The base WASM objects, declared in wasm.h as WASM_DECLARE_OWN.

val name : string

The C name of the structure without the _t suffix.

The C unique (abstract) base type for the structure. the structure type is therefore t structure.

The Ctypes definition of the C structure.

This structure maintains an ownership status. See also WasmerBindings.OwnableObject.

include module type of struct include OwnableObject(DeclareRef(T).{O}4) end

Ownable objects are the basic structure that maintains an ownership state on C objects.

The owning structure type.

val make_new : unit -> s

Make a new owning structure from a new pointer.

val make_from_raise : DeclareOwn(T).{O}4.t Ctypes.ptr -> object_state -> s

Make a new owning structure from a pointer. See also WasmerBindings.OwnableObject.make_from_unsafe.

val make_from_unsafe : DeclareOwn(T).{O}4.t Ctypes.ptr -> object_state -> s

Make a new owning structure from a pointer. Does not raise an exception if NULL is given. See also WasmerBindings.OwnableObject.make_from_raise.

Make a new owning structure from a pointer, with an additional data. See also WasmerBindings.OwnableObject.make_from_unsafe_data.

Make a new owning structure from a pointer, with an additional data. Does not raise an exception if NULL is given. See also WasmerBindings.OwnableObject.make_from_raise_data.

val get_state : s -> object_state

Returns the current ownership state.

val lose_ownership : s -> unit

Sets the current ownership state to WasmerBindings.object_state.State_PassedAway. Ignores the current ownership.

val grab_ownership : s -> DeclareOwn(T).{O}4.t Ctypes.ptr

grab_ownership self gives the ownership of the pointed object to the caller code. It is equivalent to let p = get_ptr self in lose_ownership self; p, but with additional checks for the current ownership.

  • returns

    The pointer

val gain_ownership_back : s -> DeclareOwn(T).{O}4.t Ctypes.ptr

Deletes the object if required, then sets the ownership to WasmerBindings.object_state.State_Owned and returns the pointer. This is only to be used in own-out function arguments in the C API or equivalent.

  • returns

    A deleted or given-away pointer.

  • raises Invalid_access

    If the current state is WasmerBindings.object_state.State_Dependent

val is_null : s -> bool

Returns Ctypes.is_null on the underlying pointer, ignoring the current ownership state.

Returns the underlying pointer, requiring a sufficient ownership state.

  • raises Invalid_access

    If the current state is lower than WasmerBindings.object_state.State_RW

val get_ptr_const : s -> DeclareOwn(T).{O}4.t Ctypes.ptr

Returns the underlying pointer, requiring a sufficient ownership state.

  • raises Invalid_access

    If the current state is lower than WasmerBindings.object_state.State_Const

val get_ptr_givenaway : s -> DeclareOwn(T).{O}4.t Ctypes.ptr

Inherently unsafe function that returns a given-away pointer.

  • raises Invalid_access

    If the current state is not WasmerBindings.object_state.State_PassedAway

val delete : s -> unit

Frees the underlying pointer. A side effect is to mark the object as given away.

val duplicate : s -> s
val duplicate_unsafe : s -> s
val same : s -> s -> bool
val get_host_info : s -> unit Ctypes.ptr
val set_host_info : s -> unit Ctypes.ptr -> unit
val set_host_info_with_finalizer : s -> unit Ctypes.ptr -> (unit Ctypes.ptr -> unit) -> unit

Finalizers will not get GC'd (so long as they are called once)

val to_ref : s -> Ref.s
val of_ref : Ref.s -> s
val to_ref_const : s -> Ref.s
val of_ref_const : Ref.s -> s
module S : StructType
module Shared : module type of struct include DeclareOwn(S) end
val to_shared : s -> Shared.s
val of_shared : Store.s -> Shared.s -> s
OCaml

Innovation. Community. Security.