Class: GirFFI::ArgHelper::ObjectStore

Inherits:
Object
  • Object
show all
Defined in:
lib/gir_ffi/arg_helper.rb

Overview

Helper class for storing objects for later retrieval. Used to store user data arguments.

Instance Method Summary collapse

Constructor Details

#initializeObjectStore

Returns a new instance of ObjectStore.



12
13
14
# File 'lib/gir_ffi/arg_helper.rb', line 12

def initialize
  @store = {}
end

Instance Method Details

#fetch(ptr) ⇒ Object



20
21
22
23
24
25
26
27
28
# File 'lib/gir_ffi/arg_helper.rb', line 20

def fetch ptr
  return if ptr.null?
  key = ptr.address
  if @store.has_key? key
    @store[key]
  else
    ptr
  end
end

#store(ptr, obj) ⇒ Object



16
17
18
# File 'lib/gir_ffi/arg_helper.rb', line 16

def store ptr, obj
  @store[ptr.address] = obj
end