Class FFI::StructLayoutBuilder
In: lib/ffi/struct_layout_builder.rb
Parent: Object

Build a {StructLayout struct layout}.

Methods

add   add_array   add_field   add_struct   alignment=   build   new   packed=   size=   union=   union?  

Constants

NUMBER_TYPES = [ Type::INT8, Type::UINT8, Type::INT16, Type::UINT16, Type::INT32, Type::UINT32, Type::LONG, Type::ULONG, Type::INT64, Type::UINT64, Type::FLOAT32, Type::FLOAT64, Type::LONGDOUBLE, Type::BOOL, ]   List of number types

Attributes

alignment  [R] 
size  [R] 

Public Class methods

Public Instance methods

@param [String, Symbol] name name of the field @param [Array, DataConverter, Struct, StructLayout::Field, Symbol, Type] type type of the field @param [Numeric, nil] offset @return [self] Add a field to the builder. @note Setting offset to nil or +-1+ is equivalent to +0+.

@param name (see add) @param type (see add) @param [Numeric] count array length @param offset (see add) @return (see add) Add an array as a field to the builder.

@param (see add) @return (see add) Same as {add}. @see add

@param (see add) @return (see add) Add a struct as a field to the builder.

@param [Numeric] alignment Set alignment attribute with alignment only if it is greater than attribute value.

@return [StructLayout] Build and return the struct layout.

Set packed attribute @overload packed=(packed)

 @param [Fixnum] packed
 @return [packed]
 Set alignment and packed attributes to +packed+.

@overload packed=(packed)

 @param packed
 @return [0,1]
 Set packed attribute.

@param [Numeric] size Set size attribute with size only if size is greater than attribute value.

@param [Boolean] is_union @return [is_union] Set union attribute. Set to true to build a {Union} instead of a {Struct}.

@return [Boolean] Building a {Union} or a {Struct} ?

[Validate]