class Medusa::Engine

Overview

Manages a QuickJS runtime and context for executing JavaScript code. Provides methods to evaluate JavaScript strings and call JavaScript functions, with support for same-thread execution and safer multithreaded handling.

Defined in:

medusa/engine.cr

Constant Summary

Log = ::Log.for(self)

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Initializes the engine with a new runtime and context.


[View source]

Instance Method Detail

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

Calls a JavaScript function with the given arguments and this context.


[View source]
def context : Context #

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

Creates a ValueWrapper for a given value, encapsulating context access.


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

Evaluates a JavaScript string and returns the result as a ValueWrapper.


[View source]
def finalize #

Finalizes the engine, freeing the context and runtime.


[View source]
def runtime : Runtime #

[View source]