myplugin/core
turi-eval-autolink-hint
(turi-eval-autolink-hint :int)
emit build hints for the libturi linker and headers.
0 (side-effect: injects -lturi and turi/eval.h into the build).
Since: Phase S2
Env/new
(Env/new :ptr<void>)
create a new unrestricted evaluation environment.
Opaque TuriEnv handle as ptr<void>.
(let [env (Env/new)] ... (Env/free env))
Since: Phase S2
Env/new-sandboxed
(Env/new-sandboxed :ptr<void>)
create a sandboxed environment with I/O and FFI disabled.
Opaque TuriEnv handle as ptr<void>.
Since: Phase S2
Env/free
(Env/free [env :ptr<void>] :void)
free all resources owned by an environment.
| env | TuriEnv handle returned by Env/new or Env/new-sandboxed |
Since: Phase S2
eval
(eval [env :ptr<void> src :cstr] :ptr<void>)
evaluate a Turmeric source string and return a boxed result.
| env | TuriEnv evaluation environment | |
| src | Turmeric source code string |
Boxed TuriValue as ptr<void>; free with eval-free when done.
(eval env "(+ 40 2)")
Since: Phase S2
eval-file
(eval-file [env :ptr<void> path :cstr] :ptr<void>)
evaluate a file's contents in the given environment.
| env | TuriEnv evaluation environment | |
| path | path to the .tur file to evaluate |
Boxed TuriValue as ptr<void>; free with eval-free when done.
Since: Phase S2
eval!
(eval! [env :ptr<void> src :cstr] :ptr<void>)
evaluate a source string and panic on error.
| env | TuriEnv evaluation environment | |
| src | Turmeric source code string |
Boxed TuriValue as ptr<void>; free with eval-free when done.
Since: Phase S2
eval-free
(eval-free [result :ptr<void>] :void)
free a boxed TuriValue returned by eval or eval-file.
| result | ptr<void> previously returned by eval, eval-file, or eval! |
Since: Phase S2
eval-ok?
(eval-ok? [result :ptr<void>] :bool)
return true if the eval result is not an error.
| result | boxed TuriValue |
true if the result has a non-error tag.
(when (eval-ok? r) (eval-as-int r))
Since: Phase S2
eval-err?
(eval-err? [result :ptr<void>] :bool)
return true if the eval result is an error.
| result | boxed TuriValue |
true if the result has the TURI_ERROR tag or is NULL.
Since: Phase S2
eval-err-msg
(eval-err-msg [result :ptr<void>] :cstr)
extract the error message from an error result.
| result | boxed TuriValue (should satisfy eval-err?) |
Error message string, or "<not-an-error>" if result is not an error.
Since: Phase S2
eval-as-int
(eval-as-int [result :ptr<void>] :int)
extract the integer value from a TURI_INT result.
| result | boxed TuriValue with TURI_INT tag |
Integer value, or 0 if result is not TURI_INT.
(eval-as-int (eval env "(+ 40 2)")) ; => 42
Since: Phase S2
eval-as-bool
(eval-as-bool [result :ptr<void>] :bool)
extract the boolean value from a TURI_BOOL result.
| result | boxed TuriValue with TURI_BOOL tag |
Boolean value, or false if result is not TURI_BOOL.
Since: Phase S2
eval-as-cstr
(eval-as-cstr [result :ptr<void>] :cstr)
extract the string value from a TURI_CSTR result.
| result | boxed TuriValue with TURI_CSTR tag |
C string value, or "" if result is not TURI_CSTR.
Since: Phase S2
eval-tag
(eval-tag [result :ptr<void>] :int)
return the numeric tag of a TuriValue result.
| result | boxed TuriValue |
Integer tag: 0=nil 1=bool 2=int 3=float 4=cstr 5=closure 6=error.
Since: Phase S2