Carp/core/Function.carp
Tim Dévé 36f41e39a7
Adds Function.unsafe-ptr & Function.unsafe-env-ptr (#1026)
This functions are useful with binding callback based C APIs
2020-11-27 10:17:29 +01:00

8 lines
584 B
Plaintext

(defmodule Function
(doc unsafe-ptr "returns void pointer to the function passed in."
"This is unsafe as unsafe-ptr can't check the value passed in is a function.")
(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.")
(deftemplate unsafe-env-ptr (Fn [(Ref a)] (Ptr ())) "void* $NAME($a *fn)" "$DECL { return fn->env; }"))