Class: Spoon::PointerArray

Inherits:
Object
  • Object
show all
Defined in:
lib/spoon/unix.rb

Instance Method Summary collapse

Constructor Details

#initializePointerArray

Returns a new instance of PointerArray.



110
111
112
# File 'lib/spoon/unix.rb', line 110

def initialize
  @ary = []
end

Instance Method Details

#<<(ptr) ⇒ Object



114
115
116
117
# File 'lib/spoon/unix.rb', line 114

def <<(ptr)
  @ary << ptr
  self
end

#pointerObject



119
120
121
122
123
124
125
126
# File 'lib/spoon/unix.rb', line 119

def pointer
  if @pointer.nil? || (@pointer.size / @pointer.type_size) <= @ary.length
	ptr = FFI::MemoryPointer.new(:pointer, @ary.length + 1)
	ptr.put_array_of_pointer(0, @ary)
	@pointer = ptr
  end
  @pointer
end