Foreign Function Interface

The Foreign Function Interface (FFI) provides a powerful and simple way to connect external code to the Wolfram Language, enabling high-speed and memory-efficient execution. It does this by allowing C-compatible dynamic libraries to be directly loaded into the Wolfram Language kernel so that functions in the libraries can be immediately called from the Wolfram Language. The code required to connect to these libraries is entirely done in the Wolfram Language. This interface allows exchanging arbitrary data with the linked library: integers, reals, pointers, structs and function callbacks.

ForeignFunctionLoad load a function from a dynamic library

ForeignPointerLookup get the pointer to a function in a dynamic library

ForeignFunction a function that calls into a dynamic library

CreateForeignCallback create a foreign callback function

ForeignCallback a function that can be called from external libraries

RawMemoryAllocate allocate raw memory of a given type

RawMemoryFree free raw memory

RawMemoryRead read values from raw memory

RawMemoryWrite write values to raw memory

RawMemoryImport import raw memory in various formats

RawMemoryExport export expressions as raw memory

CreateManagedObject create a memory-managed object

ManagedObject represent a memory-managed object

UnmanageObject deactivate a managed object

RawPointer a raw pointer to a typed memory address

OpaqueRawPointer a raw pointer to an untyped memory address

NullRawPointerQ test whether a pointer is a null pointer