Class: OnnxRuntime::Pointer
- Inherits:
-
Object
- Object
- OnnxRuntime::Pointer
- Defined in:
- lib/onnxruntime/pointer.rb
Instance Attribute Summary collapse
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(free = nil) ⇒ Pointer
constructor
A new instance of Pointer.
- #read_array_of_pointer ⇒ Object
- #read_string ⇒ Object
- #to_ptr ⇒ Object
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
#ref ⇒ Object (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_pointer ⇒ Object
25 26 27 |
# File 'lib/onnxruntime/pointer.rb', line 25 def read_array_of_pointer(...) to_ptr.read_array_of_pointer(...) end |
#read_string ⇒ Object
21 22 23 |
# File 'lib/onnxruntime/pointer.rb', line 21 def read_string(...) to_ptr.read_string(...) end |
#to_ptr ⇒ Object
17 18 19 |
# File 'lib/onnxruntime/pointer.rb', line 17 def to_ptr @ref.read_pointer end |