Object
# File lib/ffi/struct_layout_builder.rb, line 77 def add(name, type, offset = nil) if offset.nil? || offset == -1 offset = @union ? 0 : align(@size, @packed ? [ @packed, type.alignment ].min : [ @min_alignment, type.alignment ].max) end # # If a FFI::Type type was passed in as the field arg, try and convert to a StructLayout::Field instance # field = type.is_a?(StructLayout::Field) ? type : field_for_type(name, offset, type) @fields << field @alignment = [ @alignment, field.alignment ].max unless @packed @size = [ @size, field.size + (@union ? 0 : field.offset) ].max return self end
# File lib/ffi/struct_layout_builder.rb, line 102 def add_array(name, type, count, offset = nil) add(name, Type::Array.new(type, count), offset) end
# File lib/ffi/struct_layout_builder.rb, line 94 def add_field(name, type, offset = nil) add(name, type, offset) end
# File lib/ffi/struct_layout_builder.rb, line 98 def add_struct(name, type, offset = nil) add(name, Type::Struct.new(type), offset) end
# File lib/ffi/struct_layout_builder.rb, line 38 def alignment=(align) @alignment = align if align > @alignment @min_alignment = align end
# File lib/ffi/struct_layout_builder.rb, line 106 def build # Add tail padding if the struct is not packed size = @packed ? @size : align(@size, @alignment) StructLayout.new(@fields, size, @alignment) end
# File lib/ffi/struct_layout_builder.rb, line 51 def packed=(packed) if packed.is_a?(Fixnum) @alignment = packed @packed = packed else @packed = packed ? 1 : 0 end end
# File lib/ffi/struct_layout_builder.rb, line 34 def size=(size) @size = size if size > @size end
Generated with the Darkfish Rdoc Generator 2.