Class: FFI::StructLayout::InnerStruct

Inherits:
Field
  • Object
show all
Defined in:
lib/ffi/struct.rb

Instance Method Summary (collapse)

Methods inherited from Field

#alignment, #initialize, #name, #offset, #size, #type

Constructor Details

This class inherits a constructor from FFI::StructLayout::Field

Instance Method Details

- (Object) get(ptr)



74
75
76
# File 'lib/ffi/struct.rb', line 74

def get(ptr)
  type.struct_class.new(ptr.slice(self.offset, self.size))
end

- (Object) put(ptr, value)

Raises:

  • (TypeError)


78
79
80
81
# File 'lib/ffi/struct.rb', line 78

def put(ptr, value)
  raise TypeError, "wrong value type (expected #{type.struct_class})" unless value.is_a?(type.struct_class)
  ptr.slice(self.offset, self.size).__copy_from__(value.pointer, self.size)
end