Class: RbSDL2::RefCountPointer
- Inherits:
-
FFI::AutoPointer
- Object
- FFI::AutoPointer
- RbSDL2::RefCountPointer
show all
- Defined in:
- lib/rb_sdl2/ref_count_pointer.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.dec_ref(ptr) ⇒ Object
10
|
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 10
def dec_ref(ptr) = ::SDL.SDL_AtomicAdd(ptr + offset_of_refcount, -1)
|
.entity_class ⇒ Object
6
|
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 6
def entity_class = raise NotImplementedError
|
.inc_ref(ptr) ⇒ Object
12
|
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 12
def inc_ref(ptr) = ::SDL.SDL_AtomicAdd(ptr + offset_of_refcount, 1)
|
.offset_of_refcount ⇒ Object
8
|
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 8
def offset_of_refcount = entity_class.offset_of(:refcount)
|
.to_ptr(ptr) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 14
def to_ptr(ptr)
obj = new(ptr)
unless ptr.null?
begin
inc_ref(ptr)
rescue => e
obj.autorelease = false
raise e
end
end
obj
end
|
Instance Method Details
#refcount ⇒ Object
33
|
# File 'lib/rb_sdl2/ref_count_pointer.rb', line 33
def refcount = get_int(self.class.offset_of_refcount)
|