module Novika::FFI::ForeignType

Overview

Base type for Novika FFI types.

Direct including types

Defined in:

novika/ffi.cr

Instance Method Summary

Instance Method Detail

abstract def alloc : Pointer(Void) #

Allocates memory for this type. Returns a pointer to that memory.


def from(form : Form) : ForeignValue #

Instantiates a foreign value of this foreign type from the given form.

Dies if conversion is impossible.


def from?(form : Form) : ForeignValue | Nil #

Instantiates a foreign value of this foreign type from the given form.

Returns nil if conversion is impossible.


def matches?(value : ForeignValue) : Bool #

Returns whether this type corresponds to the given value.


def sizeof : UInt64 #

Returns the size of this type, in bytes.


abstract def to_ffi_type : Crystal::FFI::Type #

Returns the corresponding LibFFI type.


abstract def unbox(box : Pointer(Void)) : ForeignValue #

Retrieves ForeignValue of this type from the given void pointer box.