Module: NDAV::FFI::MemoryPointer::ToNDAV

Defined in:
lib/ndav/ffi.rb

Instance Method Summary collapse

Instance Method Details

#to_ndav(format: TYPE_SIZE_TO_FORMAT[type_size], lifetime: self) ⇒ Object



21
22
23
24
25
26
# File 'lib/ndav/ffi.rb', line 21

def to_ndav(format: TYPE_SIZE_TO_FORMAT[type_size], lifetime: self, **)
  shape = [size / type_size]
  byte_size = shape.reduce(ITEM_SIZES[format], :*)
  ptr = ::Fiddle::Pointer.new(address, byte_size)
  ::NDAV.new(ptr, shape:, format:, lifetime:, **)
end