Temporary buffer for an SDL 2 event exposing the pseudo-class hierarchy metadata

An instance of this class should be used to call poll_event and to_event.

Introduced properties

fun is_keydown: Bool

sdl2 :: SDLEventBuffer :: is_keydown

Is this a key presse event?
fun is_keyup: Bool

sdl2 :: SDLEventBuffer :: is_keyup

Is this a key release event?
fun is_mouse_button_down: Bool

sdl2 :: SDLEventBuffer :: is_mouse_button_down

Is this a mouse button down event?
fun is_mouse_button_up: Bool

sdl2 :: SDLEventBuffer :: is_mouse_button_up

Is this a mouse button up event?
fun is_mouse_motion: Bool

sdl2 :: SDLEventBuffer :: is_mouse_motion

Is this a mouse motion event?
fun is_mouse_wheel: Bool

sdl2 :: SDLEventBuffer :: is_mouse_wheel

Is this a mouse wheel event?
fun is_quit: Bool

sdl2 :: SDLEventBuffer :: is_quit

Is this a quit event?
fun is_window: Bool

sdl2 :: SDLEventBuffer :: is_window

Is this a window event?
init malloc: SDLEventBuffer

sdl2 :: SDLEventBuffer :: malloc

Allocate memory for a new SDLEventBuffer
fun poll_event: Bool

sdl2 :: SDLEventBuffer :: poll_event

Poll and event into self
fun to_event: SDLEvent

sdl2 :: SDLEventBuffer :: to_event

Get a reference to the data at self as a precise SDLEvent
fun to_keydown: SDLKeyboardDownEvent

sdl2 :: SDLEventBuffer :: to_keydown

Get a reference to data at self as a SDLKeyboardDownEvent
fun to_keyup: SDLKeyboardUpEvent

sdl2 :: SDLEventBuffer :: to_keyup

Get a reference to data at self as a SDLKeyboardUpEvent
fun to_mouse_button_down: SDLMouseButtonDownEvent

sdl2 :: SDLEventBuffer :: to_mouse_button_down

Get a reference to data at self as a SDLMouseButtonDownEvent
fun to_mouse_button_up: SDLMouseButtonUpEvent

sdl2 :: SDLEventBuffer :: to_mouse_button_up

Get a reference to data at self as a SDLMouseButtonUpEvent
fun to_mouse_motion: SDLMouseMotionEvent

sdl2 :: SDLEventBuffer :: to_mouse_motion

Get a reference to data at self as a SDLMouseMotionEvent
fun to_mouse_wheel: SDLMouseWheelEvent

sdl2 :: SDLEventBuffer :: to_mouse_wheel

Get a reference to data at self as a SDLMouseWheelEvent
fun to_quit: SDLQuitEvent

sdl2 :: SDLEventBuffer :: to_quit

Get a reference to data at self as a SDLQuitEvent
fun to_window: SDLWindowEvent

sdl2 :: SDLEventBuffer :: to_window

Get a reference to data at self as a SDLWindowEvent

Redefined properties

redef type SELF: SDLEventBuffer

sdl2 $ SDLEventBuffer :: SELF

Type of this instance, automatically specialized in every class

All properties

fun !=(other: nullable Object): Bool

core :: Object :: !=

Have self and other different values?
fun ==(other: nullable Object): Bool

core :: Object :: ==

Have self and other the same value?
type CLASS: Class[SELF]

core :: Object :: CLASS

The type of the class of self.
type SELF: Object

core :: Object :: SELF

Type of this instance, automatically specialized in every class
fun address_is_null: Bool

core :: Pointer :: address_is_null

Is the address behind this Object at NULL?
protected fun class_factory(name: String): CLASS

core :: Object :: class_factory

Implementation used by get_class to create the specific class.
fun class_name: String

core :: Object :: class_name

The class name of the object.
fun free

core :: Pointer :: free

Free the memory pointed by this pointer
fun get_class: CLASS

core :: Object :: get_class

The meta-object representing the dynamic type of self.
fun hash: Int

core :: Object :: hash

The hash code of the object.
init init

core :: Object :: init

fun inspect: String

core :: Object :: inspect

Developer readable representation of self.
protected fun inspect_head: String

core :: Object :: inspect_head

Return "CLASSNAME:#OBJECTID".
fun is_keydown: Bool

sdl2 :: SDLEventBuffer :: is_keydown

Is this a key presse event?
fun is_keyup: Bool

sdl2 :: SDLEventBuffer :: is_keyup

Is this a key release event?
fun is_mouse_button_down: Bool

sdl2 :: SDLEventBuffer :: is_mouse_button_down

Is this a mouse button down event?
fun is_mouse_button_up: Bool

sdl2 :: SDLEventBuffer :: is_mouse_button_up

Is this a mouse button up event?
fun is_mouse_motion: Bool

sdl2 :: SDLEventBuffer :: is_mouse_motion

Is this a mouse motion event?
fun is_mouse_wheel: Bool

sdl2 :: SDLEventBuffer :: is_mouse_wheel

Is this a mouse wheel event?
fun is_quit: Bool

sdl2 :: SDLEventBuffer :: is_quit

Is this a quit event?
intern fun is_same_instance(other: nullable Object): Bool

core :: Object :: is_same_instance

Return true if self and other are the same instance (i.e. same identity).
fun is_same_serialized(other: nullable Object): Bool

core :: Object :: is_same_serialized

Is self the same as other in a serialization context?
intern fun is_same_type(other: Object): Bool

core :: Object :: is_same_type

Return true if self and other have the same dynamic type.
fun is_window: Bool

sdl2 :: SDLEventBuffer :: is_window

Is this a window event?
init malloc: SDLEventBuffer

sdl2 :: SDLEventBuffer :: malloc

Allocate memory for a new SDLEventBuffer
init nul: Pointer

core :: Pointer :: nul

C NULL pointer
intern fun object_id: Int

core :: Object :: object_id

An internal hash code for the object based on its identity.
fun output

core :: Object :: output

Display self on stdout (debug only).
intern fun output_class_name

core :: Object :: output_class_name

Display class name on stdout (debug only).
fun poll_event: Bool

sdl2 :: SDLEventBuffer :: poll_event

Poll and event into self
fun serialization_hash: Int

core :: Object :: serialization_hash

Hash value use for serialization
intern fun sys: Sys

core :: Object :: sys

Return the global sys object, the only instance of the Sys class.
fun to_event: SDLEvent

sdl2 :: SDLEventBuffer :: to_event

Get a reference to the data at self as a precise SDLEvent
abstract fun to_jvalue(env: JniEnv): JValue

core :: Object :: to_jvalue

fun to_keydown: SDLKeyboardDownEvent

sdl2 :: SDLEventBuffer :: to_keydown

Get a reference to data at self as a SDLKeyboardDownEvent
fun to_keyup: SDLKeyboardUpEvent

sdl2 :: SDLEventBuffer :: to_keyup

Get a reference to data at self as a SDLKeyboardUpEvent
fun to_mouse_button_down: SDLMouseButtonDownEvent

sdl2 :: SDLEventBuffer :: to_mouse_button_down

Get a reference to data at self as a SDLMouseButtonDownEvent
fun to_mouse_button_up: SDLMouseButtonUpEvent

sdl2 :: SDLEventBuffer :: to_mouse_button_up

Get a reference to data at self as a SDLMouseButtonUpEvent
fun to_mouse_motion: SDLMouseMotionEvent

sdl2 :: SDLEventBuffer :: to_mouse_motion

Get a reference to data at self as a SDLMouseMotionEvent
fun to_mouse_wheel: SDLMouseWheelEvent

sdl2 :: SDLEventBuffer :: to_mouse_wheel

Get a reference to data at self as a SDLMouseWheelEvent
fun to_quit: SDLQuitEvent

sdl2 :: SDLEventBuffer :: to_quit

Get a reference to data at self as a SDLQuitEvent
fun to_s: String

core :: Object :: to_s

User readable representation of self.
fun to_window: SDLWindowEvent

sdl2 :: SDLEventBuffer :: to_window

Get a reference to data at self as a SDLWindowEvent
package_diagram sdl2::SDLEventBuffer SDLEventBuffer core::Pointer Pointer sdl2::SDLEventBuffer->core::Pointer core::Object Object core::Pointer->core::Object ...core::Object ... ...core::Object->core::Object

Ancestors

interface Object

core :: Object

The root of the class hierarchy.

Parents

extern class Pointer

core :: Pointer

Pointer classes are used to manipulate extern C structures.

Class definitions

sdl2 $ SDLEventBuffer
# Temporary buffer for an SDL 2 event exposing the pseudo-class hierarchy metadata
#
# An instance of this class should be used to call `poll_event` and `to_event`.
extern class SDLEventBuffer `{SDL_Event *`}
	# Allocate memory for a new `SDLEventBuffer`
	new malloc `{ return malloc(sizeof(SDL_Event)); `}

	# Poll and event into `self`
	#
	# Returns `true` if an event was available.
	fun poll_event: Bool `{ return SDL_PollEvent(self); `}

	# Get a reference to the data at `self` as a precise `SDLEvent`
	#
	# Returns `null` if the event is unknown.
	#
	# Note: The returned `SDLEvent` is just a different Nit instance pointing to the same data.
	# A call to `poll_event` will invalidate any instances returned previously by `to_event`.
	fun to_event: SDLEvent
	do
		if is_quit then return to_quit
		if is_mouse_motion then return to_mouse_motion
		if is_mouse_button_down then return to_mouse_button_down
		if is_mouse_button_up then return to_mouse_button_up
		if is_mouse_wheel then return to_mouse_wheel
		if is_keydown then return to_keydown
		if is_keyup then return to_keyup
		if is_window then return to_window
		return to_event_direct
	end

	private fun to_event_direct: SDLEvent `{ return self; `}

	# Is this a quit event?
	fun is_quit: Bool `{ return self->type == SDL_QUIT; `}

	# Get a reference to data at `self` as a `SDLQuitEvent`
	#
	# Require: `is_quit`
	fun to_quit: SDLQuitEvent `{ return self; `}

	# Is this a mouse motion event?
	fun is_mouse_motion: Bool `{ return self->type == SDL_MOUSEMOTION; `}

	# Get a reference to data at `self` as a `SDLMouseMotionEvent`
	#
	# Require: `is_mouse_motion`
	fun to_mouse_motion: SDLMouseMotionEvent `{ return self; `}

	# Is this a mouse button down event?
	fun is_mouse_button_down: Bool `{ return self->type == SDL_MOUSEBUTTONDOWN; `}

	# Get a reference to data at `self` as a `SDLMouseButtonDownEvent`
	#
	# Require: `is_mouse_button_down`
	fun to_mouse_button_down: SDLMouseButtonDownEvent `{ return self; `}

	# Is this a mouse button up event?
	fun is_mouse_button_up: Bool `{ return self->type == SDL_MOUSEBUTTONUP; `}

	# Get a reference to data at `self` as a `SDLMouseButtonUpEvent`
	#
	# Require: `is_mouse_button_up`
	fun to_mouse_button_up: SDLMouseButtonUpEvent `{ return self; `}

	# Is this a mouse wheel event?
	fun is_mouse_wheel: Bool `{ return self->type == SDL_MOUSEWHEEL; `}

	# Get a reference to data at `self` as a `SDLMouseWheelEvent`
	#
	# Require: `is_mouse_wheel`
	fun to_mouse_wheel: SDLMouseWheelEvent `{ return self; `}

	# Is this a key presse event?
	fun is_keydown: Bool `{ return self->type == SDL_KEYDOWN; `}

	# Get a reference to data at `self` as a `SDLKeyboardDownEvent`
	#
	# Require: `is_keydown`
	fun to_keydown: SDLKeyboardDownEvent `{ return self; `}

	#  Is this a key release event?
	fun is_keyup: Bool `{ return self->type == SDL_KEYUP; `}

	# Get a reference to data at `self` as a `SDLKeyboardUpEvent`
	#
	# Require: `is_keyup`
	fun to_keyup: SDLKeyboardUpEvent `{ return self; `}

	#  Is this a window event?
	fun is_window: Bool `{ return self->type == SDL_WINDOWEVENT; `}

	# Get a reference to data at `self` as a `SDLWindowEvent`
	#
	# Require: `is_window`
	fun to_window: SDLWindowEvent `{ return self; `}

	# TODO other SDL events:
	#
	# SDL_CommonEvent common
	# SDL_WindowEvent window
	# SDL_TextEditingEvent edit
	# SDL_TextInputEvent text
	# SDL_JoyAxisEvent jaxis
	# SDL_JoyBallEvent jball
	# SDL_JoyHatEvent jhat;
	# SDL_JoyButtonEvent jbutton
	# SDL_JoyDeviceEvent jdevice
	# SDL_ControllerAxisEvent caxis
	# SDL_ControllerButtonEvent cbutton
	# SDL_ControllerDeviceEvent cdevice
	# SDL_UserEvent user
	# SDL_SysWMEvent syswm
	# SDL_TouchFingerEvent tfinger
	# SDL_MultiGestureEvent mgesture
	# SDL_DollarGestureEvent dgesture
	# SDL_DropEvent drop
end
lib/sdl2/events.nit:26,1--143,3