class
Medusa::Engine
- Medusa::Engine
- Reference
- Object
Overview
Manages a QuickJS runtime and context for executing JavaScript code.
IMPORTANT: Always call #close when done. Do not rely solely on GC
finalization — Boehm GC runs finalizers in non-deterministic order.
Defined in:
medusa/engine.crConstant Summary
-
Log =
::Log.for(self)
Constructors
Instance Method Summary
- #call(function : ValueWrapper, this_obj : ValueWrapper, arguments : Array(ValueWrapper) = [] of ValueWrapper, same_thread : Bool = true) : ValueWrapper
-
#close : Nil
Shuts down the engine.
- #closed? : Bool
- #context : Context
- #create_value(value) : ValueWrapper
- #drain_jobs : Int32
- #eval_string(input : String, eval_flag : QuickJS::EvalFlag = QuickJS::EvalFlag::STRICT, etag : String = "<input>", same_thread : Bool = true) : ValueWrapper
- #eval_this(this_obj : ValueWrapper, input : String, eval_flag : QuickJS::EvalFlag = QuickJS::EvalFlag::STRICT, etag : String = "<input>", same_thread : Bool = true) : ValueWrapper
- #finalize
- #runtime : Runtime
Constructor Detail
Instance Method Detail
def call(function : ValueWrapper, this_obj : ValueWrapper, arguments : Array(ValueWrapper) = [] of ValueWrapper, same_thread : Bool = true) : ValueWrapper
#
def close : Nil
#
Shuts down the engine. The C++ FreeContextAndRuntime handles the QuickJS gc_obj_list assertion issue caused by Crystal ValueWrappers that haven't been GC'd yet.
def eval_string(input : String, eval_flag : QuickJS::EvalFlag = QuickJS::EvalFlag::STRICT, etag : String = "<input>", same_thread : Bool = true) : ValueWrapper
#
def eval_this(this_obj : ValueWrapper, input : String, eval_flag : QuickJS::EvalFlag = QuickJS::EvalFlag::STRICT, etag : String = "<input>", same_thread : Bool = true) : ValueWrapper
#