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.

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

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

Set packed attribute @overload packed=(packed) Set alignment and packed attributes to

  +packed+.

  @param [Fixnum] packed

  @return [packed]

@overload packed=(packed) Set packed attribute.

  @param packed

  @return [0,1]

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

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

Building a {Union} or a {Struct} ?

@return [Boolean]

[Validate]