Class: RbSDL2::RefCountPointer
- Inherits:
-
FFI::AutoPointer
- Object
- FFI::AutoPointer
- RbSDL2::RefCountPointer
- Defined in:
- lib/rb_sdl2/ref_count_pointer.rb
Direct Known Subclasses
Palette::PalettePointer, Surface::PixelFormat::PixelFormatPointer, Surface::SurfacePointer
Class Method Summary collapse
Instance Method Summary collapse
-
#refcount ⇒ Object
for debug.
Class Method Details
.entity_class ⇒ Object
4 5 6 |
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 4 def entity_class raise NotImplementedError end |
.to_ptr(ptr) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 8 def to_ptr(ptr) raise ArgumentError, 'Invalid pointer, ptr is NULL' if ptr.null? # refcount の増加を AutoPointer 化する前に成功させる必要がある。 # AutoPointer になった後に失敗すると、GC に回収されたとき refcount が実際の参照数より少なくなる。 entity_class.new(ptr)[:refcount] += 1 new(ptr) end |
Instance Method Details
#refcount ⇒ Object
for debug
18 |
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 18 def refcount = self.class.entity_class.new(self)[:refcount] |