class Medusa::Context

Defined in:

medusa/context.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(runtime : QuickJS::JSRuntime) #

Creates a full context with std/os modules via the C++ bridge.


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

Creates a raw context — no intrinsics loaded. Call add_intrinsic_* as needed.


[View source]

Class Method Detail

def self.new_class_id : QuickJS::JSClassID #

[View source]

Instance Method Detail

def add_all_intrinsics : Nil #

Adds all standard intrinsics at once (convenience for raw contexts).


[View source]
def add_intrinsic_base_objects : Nil #

[View source]
def add_intrinsic_date : Nil #

[View source]
def add_intrinsic_eval : Nil #

[View source]
def add_intrinsic_json : Nil #

[View source]
def add_intrinsic_map_set : Nil #

[View source]
def add_intrinsic_promise : Nil #

[View source]
def add_intrinsic_proxy : Nil #

[View source]
def add_intrinsic_regexp : Nil #

[View source]
def add_intrinsic_regexp_compiler : Nil #

[View source]
def add_intrinsic_string_normalize : Nil #

[View source]
def add_intrinsic_typed_arrays : Nil #

[View source]
def add_intrinsic_weak_ref : Nil #

[View source]
def bind_crystal_function(procedure : Proc(QuickJS::JSContext, QuickJS::JSValue, LibC::Int, Pointer(QuickJS::JSValue), QuickJS::JSValue), name : String, length : LibC::Int) : ValueWrapper #

Binds a Crystal Proc as a QuickJS function. Returns a ValueWrapper for the JS function object. Each binding is independent — no shared state.


[View source]
def detect_module?(input : String) : Bool #

Detects whether a string looks like an ES module.


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

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

[View source]
def finalize : Nil #

[View source]
def freed? : Bool #

[View source]
def get_class_proto(class_id : QuickJS::JSClassID) : ValueWrapper #

[View source]
def get_exception : ValueWrapper #

[View source]
def global_object : ValueWrapper #

[View source]
def has_exception? : Bool #

[View source]
def json_stringify(obj : ValueWrapper) : String #

[View source]
def mark_freed! : Nil #

[View source]
def new_c_function2(function_pointer : QuickJS::JSCFunction, name : String, length : LibC::Int, cproto : QuickJS::CFunctionEnum = QuickJS::CFunctionEnum::GENERIC, magic : LibC::Int = 0) : ValueWrapper #

Low-level: create a QuickJS function from a raw C function pointer.


[View source]
def opaque : Pointer(Void) #

[View source]
def opaque=(ptr : Pointer(Void)) : Nil #

[View source]
def parse_json(input : String, filename : String = "<json>") : ValueWrapper #

[View source]
def read_object(buf : Bytes, flags : QuickJS::ReadObjFlag = QuickJS::ReadObjFlag::BYTECODE) : ValueWrapper #

[View source]
def runtime : QuickJS::JSRuntime #

[View source]
def set_class_proto(class_id : QuickJS::JSClassID, obj : ValueWrapper) : Nil #

[View source]
def to_unsafe : QuickJS::JSContext #

[View source]
def write_object(obj : ValueWrapper, flags : QuickJS::WriteObjFlag = QuickJS::WriteObjFlag::BYTECODE) : Bytes #

[View source]