2020-11-27 12:17:29 +03:00
|
|
|
(defmodule Function
|
2020-12-01 12:44:03 +03:00
|
|
|
(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.")
|
2020-11-27 12:17:29 +03:00
|
|
|
(deftemplate unsafe-ptr (Fn [(Ref a)] (Ptr ())) "void* $NAME($a *fn)" "$DECL { return fn->callback; }")
|
2020-12-01 12:44:03 +03:00
|
|
|
|
|
|
|
(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.")
|
2020-11-27 12:17:29 +03:00
|
|
|
(deftemplate unsafe-env-ptr (Fn [(Ref a)] (Ptr ())) "void* $NAME($a *fn)" "$DECL { return fn->env; }"))
|