Class: GirFFI::ArgHelper::ObjectStore
- Inherits:
-
Object
- Object
- GirFFI::ArgHelper::ObjectStore
- 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
- #fetch(ptr) ⇒ Object
-
#initialize ⇒ ObjectStore
constructor
A new instance of ObjectStore.
- #store(ptr, obj) ⇒ Object
Constructor Details
#initialize ⇒ ObjectStore
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 |