Class: RbSDL2::RWObject::CloseCallback

Inherits:
FFI::Function
  • Object
show all
Defined in:
lib/rb_sdl2/rw_ops/rw_object.rb

Instance Method Summary collapse

Constructor Details

#initializeCloseCallback

Returns a new instance of CloseCallback.



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rb_sdl2/rw_ops/rw_object.rb', line 4

def initialize
  # int (* close) (struct RWops * context);
  super(:int, [:pointer]) do |context|
    yield
    0
  rescue => e
    raise e if $DEBUG
    Error.last_error_message = e.message
    -1
  ensure
    # SDL_RWclose() の仕様により成功、失敗問わずポインターを開放する。
    ::SDL.FreeRW(context)
  end
end