Liking cljdoc? Tell your friends :D

coffi.ffi

Functions for creating handles to native functions and loading native libraries.

Functions for creating handles to native functions and loading native libraries.
raw docstring

cfnclj

(cfn symbol args ret)

Constructs a Clojure function to call the native function referenced by symbol.

The function returned will serialize any passed arguments into the args types, and deserialize the return to the ret type.

If your args and ret are constants, then it is more efficient to call make-downcall followed by make-serde-wrapper because the latter has an inline definition which will result in less overhead from serdes.

Constructs a Clojure function to call the native function referenced by `symbol`.

The function returned will serialize any passed arguments into the `args`
types, and deserialize the return to the `ret` type.

If your `args` and `ret` are constants, then it is more efficient to
call [[make-downcall]] followed by [[make-serde-wrapper]] because the latter
has an inline definition which will result in less overhead from serdes.
sourceraw docstring

constclj

(const symbol-or-addr type)

Gets the value of a constant stored in symbol-or-addr.

Gets the value of a constant stored in `symbol-or-addr`.
sourceraw docstring

defcfncljmacro

(defcfn name docstring? attr-map? symbol arg-types ret-type)
(defcfn name docstring? attr-map? symbol arg-types ret-type native-fn & fn-tail)

Defines a Clojure function which maps to a native function.

name is the symbol naming the resulting var. symbol is a symbol or string naming the library symbol to link against. arg-types is a vector of qualified keywords representing the argument types. ret-type is a single qualified keyword representing the return type. fn-tail is the body of the function (potentially with multiple arities) which wraps the native one. Inside the function, native-fn is bound to a function that will serialize its arguments, call the native function, and deserialize its return type. If any body is present, you must call this function in order to call the native code.

If no fn-tail is provided, then the resulting function will simply serialize the arguments according to arg-types, call the native function, and deserialize the return value.

The number of args in the fn-tail need not match the number of arg-types for the native function. It need only call the native wrapper function with the correct arguments.

See [[serialize]], [[deserialize]], make-downcall.

Defines a Clojure function which maps to a native function.

`name` is the symbol naming the resulting var.
`symbol` is a symbol or string naming the library symbol to link against.
`arg-types` is a vector of qualified keywords representing the argument types.
`ret-type` is a single qualified keyword representing the return type.
`fn-tail` is the body of the function (potentially with multiple arities)
which wraps the native one. Inside the function, `native-fn` is bound to a
function that will serialize its arguments, call the native function, and
deserialize its return type. If any body is present, you must call this
function in order to call the native code.

If no `fn-tail` is provided, then the resulting function will simply serialize
the arguments according to `arg-types`, call the native function, and
deserialize the return value.

The number of args in the `fn-tail` need not match the number of `arg-types`
for the native function. It need only call the native wrapper function with
the correct arguments.

See [[serialize]], [[deserialize]], [[make-downcall]].
sourceraw docstring

defconstcljmacro

(defconst symbol docstring? symbol-or-addr type)

Defines a var named by symbol to be the value of the given type from symbol-or-addr.

Defines a var named by `symbol` to be the value of the given `type` from `symbol-or-addr`.
sourceraw docstring

defvarcljmacro

(defvar symbol docstring? symbol-or-addr type)

Defines a var named by symbol to be a reference to the native memory from symbol-or-addr.

Defines a var named by `symbol` to be a reference to the native memory from `symbol-or-addr`.
sourceraw docstring

ensure-symbolclj

(ensure-symbol symbol-or-addr)

Returns the argument if it is a [[MemorySegment]], otherwise calls find-symbol on it.

Returns the argument if it is a [[MemorySegment]], otherwise
calls [[find-symbol]] on it.
sourceraw docstring

find-symbolclj

(find-symbol sym)

Gets the [[MemorySegment]] of a symbol from the loaded libraries.

Gets the [[MemorySegment]] of a symbol from the loaded libraries.
sourceraw docstring

freset!clj

(freset! static-var newval)

Sets the value of static-var to newval, running it through [[serialize]].

Sets the value of `static-var` to `newval`, running it through [[serialize]].
sourceraw docstring

fswap!clj

(fswap! static-var f & args)

Non-atomically runs the function f over the value stored in static-var.

The value is deserialized before passing it to f, and serialized before putting the value into static-var.

Non-atomically runs the function `f` over the value stored in `static-var`.

The value is deserialized before passing it to `f`, and serialized before
putting the value into `static-var`.
sourceraw docstring

load-libraryclj

(load-library path)

Loads the library at path.

Loads the library at `path`.
sourceraw docstring

load-system-libraryclj

(load-system-library libname)

Loads the library named libname from the system's load path.

Loads the library named `libname` from the system's load path.
sourceraw docstring

make-downcallclj

(make-downcall symbol-or-addr args ret)

Constructs a downcall function reference to symbol-or-addr with the given args and ret types.

The function returned takes only arguments whose types match exactly the [[java-layout]] for that type, and returns an argument with exactly the [[java-layout]] of the ret type. This function will perform no serialization or deserialization of arguments or the return type.

If the ret type is non-primitive, then the returned function will take a first argument of a [[SegmentAllocator]].

Constructs a downcall function reference to `symbol-or-addr` with the given `args` and `ret` types.

The function returned takes only arguments whose types match exactly
the [[java-layout]] for that type, and returns an argument with exactly
the [[java-layout]] of the `ret` type. This function will perform no
serialization or deserialization of arguments or the return type.

If the `ret` type is non-primitive, then the returned function will take a
first argument of a [[SegmentAllocator]].
sourceraw docstring

make-serde-varargs-wrapperclj

(make-serde-varargs-wrapper varargs-factory required-args ret-type)

Constructs a wrapper function for the varargs-factory which produces functions that serialize the arguments and deserialize the return value.

Constructs a wrapper function for the `varargs-factory` which produces
functions that serialize the arguments and deserialize the return value.
sourceraw docstring

make-serde-wrapperclj

(make-serde-wrapper downcall arg-types ret-type)

Constructs a wrapper function for the downcall which serializes the arguments and deserializes the return value.

Constructs a wrapper function for the `downcall` which serializes the arguments
and deserializes the return value.
sourceraw docstring

make-varargs-factoryclj

(make-varargs-factory symbol required-args ret)

Returns a function for constructing downcalls with additional types for arguments.

The required-args are the types of the first arguments passed to the downcall handle, and the values passed to the returned function are only the varargs types.

The returned function is memoized, so that only one downcall function will be generated per combination of argument types.

See make-downcall.

Returns a function for constructing downcalls with additional types for arguments.

The `required-args` are the types of the first arguments passed to the
downcall handle, and the values passed to the returned function are only the
varargs types.

The returned function is memoized, so that only one downcall function will be
generated per combination of argument types.

See [[make-downcall]].
sourceraw docstring

reify-libspecclj

(reify-libspec libspec)

Loads all the symbols specified in the libspec.

The value of each key of the passed map is transformed as by reify-symbolspec.

Loads all the symbols specified in the `libspec`.

The value of each key of the passed map is transformed as
by [[reify-symbolspec]].
sourceraw docstring

reify-symbolspeccljmultimethod

Takes a spec for a symbol reference and returns a live value for that type.

Takes a spec for a symbol reference and returns a live value for that type.
sourceraw docstring

static-variableclj

(static-variable symbol-or-addr type)

Constructs a reference to a mutable value stored in symbol-or-addr.

The returned value can be dereferenced, and has metadata.

See freset!, fswap!.

Constructs a reference to a mutable value stored in `symbol-or-addr`.

The returned value can be dereferenced, and has metadata.

See [[freset!]], [[fswap!]].
sourceraw docstring

static-variable-segmentclj

(static-variable-segment static-var)

Gets the backing [[MemorySegment]] from static-var.

This is primarily useful when you need to pass the static variable's address to a native function which takes an [[Addressable]].

Gets the backing [[MemorySegment]] from `static-var`.

This is primarily useful when you need to pass the static variable's address
to a native function which takes an [[Addressable]].
sourceraw docstring

vacfn-factoryclj

(vacfn-factory symbol required-args ret)

Constructs a varargs factory to call the native function referenced by symbol.

The function returned takes any number of type arguments and returns a specialized Clojure function for calling the native function with those arguments.

Constructs a varargs factory to call the native function referenced by `symbol`.

The function returned takes any number of type arguments and returns a
specialized Clojure function for calling the native function with those
arguments.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close