dl.eh

Dynamic loading support. More...

use "dl.eh"

Types

type Library < Any;

Functions

def buildlibrary(input: IStream): Library;
def Library.getfunc(signature: String): Function;
def loadlibrary(name: String): Library;

Description

This header provides support to open libraries and load functions from them at runtime. The common case for this is writing plugins.
var lib = loadlibrary("/lib/libcore.3.so")
var fun = cast ( (Double):Double ) lib.getfunc("sin")
println(fun(PI))    // outputs 0.0

Type details

type Library < Any;
Represents instance of dynamically loaded library.

Function details

def loadlibrary(name: String): Library;
Loads and returns function library. If given name contains slash characters then it is used as path to the library. If not, then library named libname.so is searched in directories listed in environment variable LIBPATH (which is "/lib" by default). If function fails to load library it returns null.

def buildlibrary(input: IStream): Library;
Reads and constructs Ether library from the input stream.

def Library.getfunc(signature: String): Function;
Loads function with given signature from a library. If the library does not have a function with given signature then null is returned. Since type of the function is not known at compile time, you should explicitly cast function to appropriate type to use it.