class

Medusa::ValueWrapper

Inherits Reference < Object

Constructors

new(context : QuickJS::JSContext, value : QuickJS::JSValue)
Source
new(context : QuickJS::JSContext, value : Float64)
Source
new(context : QuickJS::JSContext, value : Int32)
Source
new(context : QuickJS::JSContext, value : Int64)
Source
new(context : QuickJS::JSContext, value : String)
Source
new(context : QuickJS::JSContext, value : Bool)
Source
new(context : QuickJS::JSContext, value : Hash(String, JSON::Any))
Source
new(context : QuickJS::JSContext, values : Array(JSON::Any))
Source

Instance methods

==(other : self) : Bool

Returns true if this reference is the same as other. Invokes same?.

Source
[](index : Int32) : ValueWrapper
Source
[](key : String) : ValueWrapper
Source
[]=(index : Int32, value : ValueWrapper) : ValueWrapper
Source
[]=(key : String, value : ValueWrapper) : ValueWrapper
Source
[]?(index : Int32) : ValueWrapper | Nil
Source
[]?(key : String) : ValueWrapper | Nil
Source
array?
Source
as_a
Source
as_big_int64
Source
as_bool
Source
as_f64
Source
as_h
Source
as_i
Source
as_i64
Source
as_s
Source
bool?
Source
call(this_obj : ValueWrapper, args : Array(ValueWrapper) = [] of ValueWrapper) : ValueWrapper
Source
call_constructor(args : Array(ValueWrapper) = [] of ValueWrapper) : ValueWrapper
Source
constructor?
Source
define_property_value(atom : QuickJS::JSAtom, val : ValueWrapper, flags : Int32 = Constants::JS_PROP_C_W_E) : Nil
Source
delete_property(atom : QuickJS::JSAtom, flags : Int32 = 0) : Bool
Source
duplicate
Source
error?
Source
exception?
Source
finalize

GC finalizer. We intentionally do NOT call FreeValue here.

Boehm GC runs finalizers in non-deterministic order and can trigger them during allocation inside other callbacks. If this ValueWrapper belongs to a sandbox that has already been closed, the context pointer is dangling and FreeValue would segfault.

The trade-off: JSValues with refcounts leak until their Engine is closed, at which point FreeContextAndRuntime drops everything in bulk. During normal long-lived operation (like a GUI event loop), this is fine — QuickJS's own GC handles internal object collection. The Crystal-side wrappers only hold extra refs that prevent QuickJS from collecting; once the engine shuts down, everything is freed.

Source
float64?
Source
free!
Source
from_json(value : JSON::Any) : ValueWrapper
Source
function?
Source
get_opaque(class_id : QuickJS::JSClassID) : Pointer(Void)
Source
get_opaque2(class_id : QuickJS::JSClassID) : Pointer(Void)
Source
get_property(atom : QuickJS::JSAtom) : ValueWrapper
Source
has_property?(atom : QuickJS::JSAtom) : Bool
Source
int?
Source
null?
Source
number?
Source
object?
Source
prototype
Source
prototype=(proto : ValueWrapper) : Nil
Source
same_value?(other : self) : Bool
Source
set_opaque(ptr : Pointer(Void)) : Nil
Source
short_big_int?
Source
string?
Source
to_json_any
Source
to_s(io : IO) : Nil

Appends a short String representation of this object which includes its class name and its object address.

class Person
  def initialize(@name : String, @age : Int32)
  end
end

Person.new("John", 32).to_s # => #<Person:0x10a199f20>
Source
to_unsafe
Source
undefined?
Source

Nested types