Class: SGC::Memory::MemoryPointer

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

Overview

A memory pointer class. TODO: To use #write_pointer() when FFI fix the use of FIX2INT().

Instance Method Summary (collapse)

Constructor Details

- (Object) initialize(addr = nil)



37
38
39
40
# File 'lib/memory/pointer.rb', line 37

def initialize(addr = nil)
    @p = FFI::MemoryPointer.new(:pointer)
    @p.write_long(addr.to_i)
end

Instance Method Details

- (MemoryPointer) offset(index)



59
60
61
# File 'lib/memory/pointer.rb', line 59

def offset(index)
    MemoryPointer.new(@p.read_pointer.to_i + index)
end

- (Object) ptr



44
45
46
# File 'lib/memory/pointer.rb', line 44

def ptr
    @p.read_pointer
end

- (Object) ptr=(addr)

Set this pointer to point to memory address addr.



52
53
54
# File 'lib/memory/pointer.rb', line 52

def ptr=(addr)
    @p.write_long(addr.to_i)
end

- (Object) ref



65
66
67
# File 'lib/memory/pointer.rb', line 65

def ref
    @p
end