class
Medusa::ValueWrapper
- Medusa::ValueWrapper
- Reference
- Object
Defined in:
medusa/value_wrapper.crConstructors
- .new(context : QuickJS::JSContext, value : QuickJS::JSValue)
- .new(context : QuickJS::JSContext, value : Float64)
- .new(context : QuickJS::JSContext, value : Int32)
- .new(context : QuickJS::JSContext, value : Int64)
- .new(context : QuickJS::JSContext, value : String)
- .new(context : QuickJS::JSContext, value : Bool)
- .new(context : QuickJS::JSContext, value : Hash(String, JSON::Any))
- .new(context : QuickJS::JSContext, values : Array(JSON::Any))
Instance Method Summary
-
#==(other : self) : Bool
Returns
trueif this reference is the same as other. - #[](index : Int32) : ValueWrapper
- #[](key : String) : ValueWrapper
- #[]=(index : Int32, value : ValueWrapper) : ValueWrapper
- #[]=(key : String, value : ValueWrapper) : ValueWrapper
- #[]?(index : Int32) : ValueWrapper | Nil
- #[]?(key : String) : ValueWrapper | Nil
- #array? : Bool
- #as_a : Array(JSON::Any)
- #as_big_int64 : Int64
- #as_bool : Bool
- #as_f64 : Float64
- #as_h : Hash(String, JSON::Any)
- #as_i : Int32
- #as_i64 : Int64
- #as_s : String
- #bool? : Bool
- #call(this_obj : ValueWrapper, args : Array(ValueWrapper) = [] of ValueWrapper) : ValueWrapper
- #call_constructor(args : Array(ValueWrapper) = [] of ValueWrapper) : ValueWrapper
- #constructor? : Bool
- #define_property_value(atom : QuickJS::JSAtom, val : ValueWrapper, flags : Int32 = Constants::JS_PROP_C_W_E) : Nil
- #delete_property(atom : QuickJS::JSAtom, flags : Int32 = 0) : Bool
- #duplicate : QuickJS::JSValue
- #error? : Bool
- #exception? : Bool
-
#finalize
GC finalizer.
- #float64? : Bool
- #free! : Nil
- #from_json(value : JSON::Any) : ValueWrapper
- #function? : Bool
- #get_opaque(class_id : QuickJS::JSClassID) : Pointer(Void)
- #get_opaque2(class_id : QuickJS::JSClassID) : Pointer(Void)
- #get_property(atom : QuickJS::JSAtom) : ValueWrapper
- #has_property?(atom : QuickJS::JSAtom) : Bool
- #int? : Bool
- #null? : Bool
- #number? : Bool
- #object? : Bool
- #prototype : ValueWrapper
- #prototype=(proto : ValueWrapper) : Nil
- #same_value?(other : self) : Bool
- #set_opaque(ptr : Pointer(Void)) : Nil
- #short_big_int? : Bool
- #string? : Bool
- #to_json_any : JSON::Any
-
#to_s(io : IO) : Nil
Appends a short String representation of this object which includes its class name and its object address.
- #to_unsafe : QuickJS::JSValue
- #undefined? : Bool
Constructor Detail
Instance Method Detail
Returns true if this reference is the same as other. Invokes same?.
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.
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>