struct Candiru::StructInstance

Overview

Represents a live struct instance, pointed to by #pointer and described by #scaffolding.

point_struct = StructScaffolding[Int32, Int32]
point = point_struct.new { |s| s << 12; s << 34 }

# point : StructInstance

puts point.sum(&.value.raw) # 46

Included Modules

Extended Modules

Defined in:

candiru.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Candiru::ValueInstance(UInt64)

raw : T raw

Instance methods inherited from module Candiru::IValueInstanceType

to_ffi_argument_pointer : Pointer(Void) to_ffi_argument_pointer

Constructor Detail

def self.new(scaffolding : StructScaffolding, pointer : Pointer(Void)) #

[View source]

Class Method Detail

def self.to_ffi : FFI::Type #

[View source]

Instance Method Detail

def clone #

[View source]
def copy_with(scaffolding _scaffolding = @scaffolding, pointer _pointer = @pointer) #

[View source]
def pointer : Pointer(Void) #

def raw : UInt64 #
Description copied from module Candiru::ValueInstance(UInt64)

Returns raw content of this value instance.


[View source]
def scaffolding : StructScaffolding #

def size #
Description copied from module Indexable(Candiru::IValueInstanceType)

Returns the number of elements in this container.


[View source]
def to_ffi_argument_pointer : Pointer(Void) #
Description copied from module Candiru::IValueInstanceType

Returns an FFI argument pointer for this value instance.


[View source]
def to_s(io) #

[View source]
def unsafe_fetch(index : Int) #
Description copied from module Indexable(Candiru::IValueInstanceType)

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.


[View source]