class FFI::Struct
def layout(*spec)
- Note: - Creating a layout from a hash +spec+ is supported only for Ruby 1.9.
Other tags:
- Example: Creating a layout with pointers to functions -
Example: Creating a layout from a hash +spec+ (Ruby 1.9 only) -
Example: Creating a layout from an array +spec+ with offset -
Example: Creating a layout from an array +spec+ -
Returns:
-
(StructLayout)- -
(StructLayout)- -
(StructLayout)-
Parameters:
-
spec(Array) --, Array(Hash)
Overloads:
-
layout(*spec) -
layout
def layout(*spec) #raise RuntimeError, "struct layout already defined for #{self.inspect}" if defined?(@layout) return @layout if spec.size == 0 builder = StructLayoutBuilder.new builder.union = self < Union builder.packed = @packed if defined?(@packed) builder.alignment = @min_alignment if defined?(@min_alignment) if spec[0].kind_of?(Hash) hash_layout(builder, spec) else array_layout(builder, spec) end builder.size = @size if defined?(@size) && @size > builder.size cspec = builder.build @layout = cspec unless self == Struct @size = cspec.size return cspec end