ffi.bind()
Builds a callable native signature.
Signature
ffi.bind(library, name, parameters, result[, fixed_count])
Parameters
Open library, string symbol, array of up to 254 descriptors, return descriptor and optional signed number of fixed arguments, from 1 through one fewer than the parameter count.
Returns
Atom function.
Behavior
Uses the host default ABI and installs the function under that name on the library handle. Calls use the exact descriptor count.
Errors
Missing symbol, unsupported ABI shape, invalid variadic signature, bad values or invocation after close.
Example
Build the native C fixture and pass its shared library path after --.
use ffi
use os
lib = ffi.load(os.args[0])
try:
twice = ffi.bind(lib, 'twice', [i32], i32)
assert(twice(7) == 14)
finally:
ffi.close(lib)