abstract struct Novika::FFI::StructView
- Novika::FFI::StructView
- Struct
- Value
- Object
Overview
Base type of the value side of structs.
Implements Indexable
and Indexable::Mutable
over the fields in
the struct, allowing you to iterate, read, and change them (with
some casting from and to ForeignValue
though.)
Included Modules
- Indexable(Novika::FFI::ForeignValue)
- Indexable::Mutable(Novika::FFI::ForeignValue)
- Novika::FFI::ForeignValue
Direct Known Subclasses
Defined in:
novika/ffi.crConstructors
Instance Method Summary
- #==(other : StructView)
-
#[](id : String)
Returns the value of a field with the given identifier.
-
#[]=(id : String, value : ForeignValue)
Assigns value to a field with the given identifier.
-
#[]?(id : String)
Returns the value of a field with the given identifier, or nil if there is no such field.
-
#address(*args, **options)
Returns the pointer address of the struct this view refers to.
-
#address(*args, **options, &)
Returns the pointer address of the struct this view refers to.
-
#has_field?(*args, **options)
See
StructLayout
. -
#has_field?(*args, **options, &)
See
StructLayout
. -
#hash(hasher)
See
Object#hash(hasher)
-
#layout : StructLayout
Returns this view's struct layout.
-
#size
Returns the number of elements in this container.
-
#to_form? : Form | Nil
Determines the best form type to represent this foreign value, then builds and returns a form of that type.
- #to_s(io)
-
#unsafe_fetch(index : Int)
Returns the element at the given index, without doing any bounds check.
-
#unsafe_put(index : Int, value : ForeignValue)
Sets the element at the given index to value, without doing any bounds check.
Instance methods inherited from module Novika::FFI::ForeignValue
box : Pointer(Void)
box,
must_be_of(type : ForeignType)
must_be_of,
to_form? : Form | Nil
to_form?,
write_to!(base : Pointer(Void)) : Pointer(Void)
write_to!
Constructor Detail
Instance Method Detail
Returns the value of a field with the given identifier. Dies if there is no such field.
Returns the value of a field with the given identifier, or nil if there is no such field.
See Object#hash(hasher)
Returns the number of elements in this container.
Determines the best form type to represent this foreign value, then builds and returns a form of that type.
Returns nil if value is nothing.
Returns the element at the given index, without doing any bounds check.
Indexable
makes sure to invoke this method with index in 0...size
,
so converting negative indices to positive ones is not needed here.
Clients never invoke this method directly. Instead, they access
elements with #[](index)
and #[]?(index)
.
This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.
Sets the element at the given index to value, without doing any bounds check.
Indexable::Mutable
makes sure to invoke this method with index in
0...size
, so converting negative indices to positive ones is not needed
here.
Clients never invoke this method directly. Instead, they modify elements
with #[]=(index, value)
.
This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.