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 @example Creating a layout with pointers to functions class MyFunctionTable < Struct layout :function1, callback([:int, :int], :int), :function2, callback([:pointer], :void), :field3, :string end @note Creating a layout from a hash +spec+ is supported only for Ruby 1.9.