Skip to main content

Interface: DlopenSymbol

Describes a native symbol for use with dlopen.

An entry with type declares a data symbol (a global variable); any other entry declares a function.

The key an entry is listed under is the JS property name it binds to, and by default also the C symbol resolved; name separates the two.

Properties

args?

optional args?: TypeOrAlias[]

Argument types. Defaults to [] (no arguments) if omitted.


fixed?

optional fixed?: number

Number of fixed arguments for variadic functions.


name?

optional name?: string

C symbol to resolve. Defaults to the key the entry is listed under.

Set it to bind one C symbol more than once — a variadic function needs a binding per arity — or to expose a C name under a friendlier one.


optional?

optional optional?: boolean

When true, a symbol that cannot be resolved is left out of symbols instead of making the whole dlopen throw — use 'foo' in symbols to find out whether this build of the library has it. Only resolution is affected; any other failure still throws.


returns?

optional returns?: TypeOrAlias

Return type. Defaults to 'void' if omitted.


type?

optional type?: TypeOrAlias

Type of a global variable. The symbol binds to a level-1 Pointer at the variable's address instead of a callable, so symbols.foo.deref() reads it. A global with a deeper indirection is reached by rebuilding the pointer: new Pointer(symbols.foo.addr, 2, type).

Mutually exclusive with args and returns; an entry carrying both throws a TypeError.