| Class | FFI::Struct |
| In: |
lib/ffi/struct.rb
|
| Parent: | Object |
| packed | -> | pack |
| aligned | -> | align |
@return [StructLayout] @overload layout
@return [StructLayout] Get struct layout.
@overload layout(*spec)
@param [Array<Symbol, Integer>,Array(Hash)] spec
@return [StructLayout]
Create struct layout from +spec+.
@example Creating a layout from an array +spec+
class MyStruct < Struct
layout :field1, :int,
:field2, :pointer,
:field3, :string
end
@example Creating a layout from an array +spec+ with offset
class MyStructWithOffset < Struct
layout :field1, :int,
:field2, :pointer, 6, # set offset to 6 for this field
:field3, :string
end
@example Creating a layout from a hash +spec+ (Ruby 1.9 only)
class MyStructFromHash < Struct
layout :field1 => :int,
:field2 => :pointer,
:field3 => :string
end
@note Creating a layout from a hash +spec+ is supported only for Ruby 1.9.