Carp/core/Function.carp
Tim Dévé ac4231d005
docs: Expands docs around C function pointers (#1038)
* docs: Generates HTML docs for Function core module

* docs: Adds lifetime information in Function module

* docs: Adds callback section to C Interop

* docs: Corrects typos in Function docs
2020-12-01 10:44:03 +01:00

17 lines
846 B
Plaintext

(defmodule Function
(doc unsafe-ptr "returns a void pointer to the function passed in.
This is unsafe as unsafe-ptr can't check the value passed in is a function.
It is the responsibility of the caller to ensure that the lifetime of the pointer
does not exceed the lifetime of the function it's used on.")
(deftemplate unsafe-ptr (Fn [(Ref a)] (Ptr ())) "void* $NAME($a *fn)" "$DECL { return fn->callback; }")
(doc unsafe-env-ptr "returns void pointer to the environment captured by a lambda.
This is unsafe as unsafe-env-ptr can't check the value passed in is a function.
It is the responsibility of the caller to ensure that the lifetime of the pointer
does not exceed the lifetime of the function it's used on.")
(deftemplate unsafe-env-ptr (Fn [(Ref a)] (Ptr ())) "void* $NAME($a *fn)" "$DECL { return fn->env; }"))