module
Rubellite::TypedData(T)
Overview
Coordinates zero-copy object wrapping between Crystal classes/structs and CRuby RTypedData. Guarantees dual-GC safety by pinning Crystal objects in Boehm GC on creation, and unpinning them via the CRuby dfree callback when the Ruby object is swept.
Defined in:
rubellite/typed_data.crClass Method Summary
-
.def_method(method_name : String, &block : T, Array(Value) -> Value) : Nil
Defines an instance method on the CRuby class that receives the unwrapped Crystal self
-
.info : TypeDescriptor
Returns the registered TypeDescriptor for T, initializing it on first access
-
.typed_data?(val : Value) : Bool
Checks if a CRuby Value wraps an instance of T
-
.unwrap(val : Value) : T
Unwraps a CRuby RTypedData Value back into the underlying Crystal instance.
-
.unwrap?(val : Value) : T | Nil
Safely unwraps a CRuby RTypedData Value, returning nil if the type does not match
-
.wrap(obj : T) : Value
Wraps a Crystal object into a CRuby RTypedData Value with zero memory copy
-
.wrap_name=(name : String) : Nil
Sets a custom Ruby class name for this type
Class Method Detail
Defines an instance method on the CRuby class that receives the unwrapped Crystal self
Returns the registered TypeDescriptor for T, initializing it on first access
Checks if a CRuby Value wraps an instance of T
Unwraps a CRuby RTypedData Value back into the underlying Crystal instance.
Raises TypeException if the value does not wrap type T.
Safely unwraps a CRuby RTypedData Value, returning nil if the type does not match
Wraps a Crystal object into a CRuby RTypedData Value with zero memory copy
Sets a custom Ruby class name for this type