Class: RbSDL2::EventPointer

Inherits:
FFI::MemoryPointer
  • Object
show all
Defined in:
lib/rb_sdl2/event/event_pointer.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.copy(ptr) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rb_sdl2/event/event_pointer.rb', line 4

def copy(ptr)
  obj = malloc
  ::SDL.memcpy(obj, ptr, size)
  type = obj.type
  if ::SDL::DROPFILE == type || ::SDL::DROPTEXT == type
    ref = obj + ::SDL::DropEvent.offset_of(:file)
    str = ::SDL.strdup(ref.read_pointer)
    raise NoMemoryError if str.null?
    ref.write_pointer(str)
  end
  obj
end

.mallocObject



17
# File 'lib/rb_sdl2/event/event_pointer.rb', line 17

def malloc = new(0)

.new(type) ⇒ Object



19
# File 'lib/rb_sdl2/event/event_pointer.rb', line 19

def new(type) = super(size).write_uint32(type)

.sizeObject



21
# File 'lib/rb_sdl2/event/event_pointer.rb', line 21

def size = ::SDL::Event.size

Instance Method Details

#typeObject



24
# File 'lib/rb_sdl2/event/event_pointer.rb', line 24

def type = read_uint32