class Box(T)
inherits Reference
¶
A Box allows turning any object to a Void* and back.
A Box's purpose is passing data to C as a Void* and then converting that
back to the original data type.
For an example usage, see Proc's explanation about sending Procs to C.
Class methods¶
.box(r : Reference?) : Pointer(Void)
¶
(r : Reference?) : Pointer(Void)
Creates a Box for a reference type (or nil) and returns the same pointer (or NULL)
.unbox(pointer : Pointer(Void)) : T
¶
(pointer : Pointer(Void)) : T
Unboxes a Void* into an object of type T. Note that for this you must
specify T: Box(T).unbox(data).
.new(object : T)
¶
(object : T)
Creates a Box with the given object.
This method isn't usually used directly. Instead, Box.box is used.