Parent

FFI::Pointer

Constants

SIZE

Public Class Methods

size() click to toggle source

Return the size of a pointer on the current platform, in bytes

# File lib/ffi/pointer.rb, line 27
def self.size
  SIZE
end

Public Instance Methods

read_array_of_type(type, reader, length) click to toggle source
# File lib/ffi/pointer.rb, line 57
def read_array_of_type(type, reader, length)
  ary = []
  size = FFI.type_size(type)
  tmp = self
  length.times { |j|
    ary << tmp.send(reader)
    tmp += size unless j == length-1 # avoid OOB
  }
  ary
end
read_string(len=nil) click to toggle source
# File lib/ffi/pointer.rb, line 31
def read_string(len=nil)
  if len
    get_bytes(0, len)
  else
    get_string(0)
  end
end
read_string_length(len) click to toggle source
# File lib/ffi/pointer.rb, line 39
def read_string_length(len)
  get_bytes(0, len)
end
read_string_to_null() click to toggle source
# File lib/ffi/pointer.rb, line 43
def read_string_to_null
  get_string(0)
end
write_array_of_type(type, writer, ary) click to toggle source
# File lib/ffi/pointer.rb, line 68
def write_array_of_type(type, writer, ary)
  size = FFI.type_size(type)
  tmp = self
  ary.each_with_index {|i, j|
    tmp.send(writer, i)
    tmp += size unless j == ary.length-1 # avoid OOB
  }
  self
end
write_string(str, len=nil) click to toggle source
# File lib/ffi/pointer.rb, line 51
def write_string(str, len=nil)
  len = str.bytesize unless len
  # Write the string data without NUL termination
  put_bytes(0, str, 0, len)
end
write_string_length(str, len) click to toggle source
# File lib/ffi/pointer.rb, line 47
def write_string_length(str, len)
  put_bytes(0, str, 0, len)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.