Class: OnnxRuntime::Pointer

Inherits:
Object
  • Object
show all
Defined in:
lib/onnxruntime/pointer.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(free = nil) ⇒ Pointer

Returns a new instance of Pointer.



5
6
7
8
# File 'lib/onnxruntime/pointer.rb', line 5

def initialize(free = nil)
  @ref = ::FFI::MemoryPointer.new(:pointer)
  ObjectSpace.define_finalizer(self, self.class.finalize(@ref, free)) if free
end

Instance Attribute Details

#refObject (readonly)

Returns the value of attribute ref.



3
4
5
# File 'lib/onnxruntime/pointer.rb', line 3

def ref
  @ref
end

Class Method Details

.finalize(ref, free) ⇒ Object



10
11
12
13
14
15
# File 'lib/onnxruntime/pointer.rb', line 10

def self.finalize(ref, free)
  proc do
    ptr = ref.read_pointer
    free.(ptr) unless ptr.null?
  end
end

Instance Method Details

#read_array_of_pointerObject



25
26
27
# File 'lib/onnxruntime/pointer.rb', line 25

def read_array_of_pointer(...)
  to_ptr.read_array_of_pointer(...)
end

#read_stringObject



21
22
23
# File 'lib/onnxruntime/pointer.rb', line 21

def read_string(...)
  to_ptr.read_string(...)
end

#to_ptrObject



17
18
19
# File 'lib/onnxruntime/pointer.rb', line 17

def to_ptr
  @ref.read_pointer
end