class Medusa::Engine

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.cr

Constant Summary

Log = ::Log.for(self)

Constructors

Instance Method Summary

Constructor Detail

def self.new #

[View source]
def self.new(*, raw : Bool) #

[View source]

Instance Method Detail

def call(function : ValueWrapper, this_obj : ValueWrapper, arguments : Array(ValueWrapper) = [] of ValueWrapper, same_thread : Bool = true) : ValueWrapper #

[View source]
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.


[View source]
def closed? : Bool #

[View source]
def context : Context #

[View source]
def create_value(value) : ValueWrapper #

[View source]
def drain_jobs : Int32 #

[View source]
def eval_string(input : String, eval_flag : QuickJS::EvalFlag = QuickJS::EvalFlag::STRICT, etag : String = "<input>", same_thread : Bool = true) : ValueWrapper #

[View source]
def eval_this(this_obj : ValueWrapper, input : String, eval_flag : QuickJS::EvalFlag = QuickJS::EvalFlag::STRICT, etag : String = "<input>", same_thread : Bool = true) : ValueWrapper #

[View source]
def finalize #

[View source]
def runtime : Runtime #

[View source]