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.cr

Class Method Summary

Class Method Detail

def self.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


[View source]
def self.info : TypeDescriptor #

Returns the registered TypeDescriptor for T, initializing it on first access


[View source]
def self.typed_data?(val : Value) : Bool #

Checks if a CRuby Value wraps an instance of T


[View source]
def self.unwrap(val : Value) : T #

Unwraps a CRuby RTypedData Value back into the underlying Crystal instance. Raises TypeException if the value does not wrap type T.


[View source]
def self.unwrap?(val : Value) : T | Nil #

Safely unwraps a CRuby RTypedData Value, returning nil if the type does not match


[View source]
def self.wrap(obj : T) : Value #

Wraps a Crystal object into a CRuby RTypedData Value with zero memory copy


[View source]
def self.wrap_name=(name : String) : Nil #

Sets a custom Ruby class name for this type


[View source]