class Candiru::StructScaffolding
- Candiru::StructScaffolding
- Reference
- Object
Overview
Struct scaffolding helps to describe the scaffolding of structs.
This implementation treats structs as arrays with (possibly) different type for each element.
point = StructScaffolding[Int32, Int32]
instance = point.new do |b|
b << 123
b << 456
end
instance.pointer # Pointer(Void)
Included Modules
Defined in:
candiru.crConstructors
-
.new
Initializes an empty struct scaffolding.
Instance Method Summary
-
#<<(type : T.class) forall T
Appends a struct field of the given type.
-
#<<(scaffolding : StructScaffolding)
Appends a pointer to another struct (could be itself, e.g.
-
#[](*args, **options)
Redirected to
#fields
. -
#[](*args, **options, &)
Redirected to
#fields
. -
#bytesize : UInt64
Returns the padded size of this struct, in bytes.
-
#each(*args, **options)
Redirected to
#fields
. -
#each(*args, **options, &)
Redirected to
#fields
. -
#fields : Array(ITypedField)
Returns the array of typed fields in this struct scaffolding.
-
#from_ffi_return_pointer(pointer : Pointer(Void))
Casts pointer, a return value hole from FFI, to this type, and returns its value.
- #matches?(other : StructInstance)
-
#new(&) : StructInstance
Yields a
StructBuilder
which facilitates the creation of an instance of this struct. -
#new(pointer : Pointer(Void))
Makes a struct instance from pointer.
-
#new
Blockless
#new
. -
#size(*args, **options)
Redirected to
#fields
. -
#size(*args, **options, &)
Redirected to
#fields
. -
#to_ffi : FFI::Type
Returns the FFI type corresponding to this value class.
Macro Summary
-
[](*types)
A shorthand for initializing struct scaffolding.
Instance methods inherited from module Candiru::ValueClass(UInt64)
adopt_as_field_value(field : ITypedField, pointer : Pointer(Void)) : FieldValue(T)
adopt_as_field_value,
from_ffi_return_pointer(pointer : Pointer(Void))
from_ffi_return_pointer,
matches?(other : T)
matches?
Instance methods inherited from module Candiru::IValueClassType
adopt_as_field_value(field : ITypedField, pointer : Pointer(Void))
adopt_as_field_value,
from_ffi_return_pointer(pointer : Pointer(Void))
from_ffi_return_pointer,
matches?(other)
matches?,
to_ffi : FFI::Type
to_ffi
Constructor Detail
Instance Method Detail
Appends a pointer to another struct (could be itself, e.g. in a linked list), as described by scaffolding.
Casts pointer, a return value hole from FFI, to this type, and returns its value.
Yields a StructBuilder
which facilitates the creation
of an instance of this struct. Returns the resulting
struct instance.
Makes a struct instance from pointer. Unsafe: does not verify whether the contents of pointer are valid for use under this struct scaffolding.
Returns the FFI type corresponding to this value class.
Int32.to_ffi # FFI::Type.sint32
Macro Detail
A shorthand for initializing struct scaffolding.
StructScaffolding[Int64, Int64]
# Is the same as writing:
scaffolding = StructScaffolding.new
scaffolding << Int64
scaffolding << Int64