Skip to content

Commit 8fda99e

Browse files
Merge pull request #4 from suve/enums-as-seperate-integer-types-instead-of-aliases
Enums as seperate integer types instead of aliases
2 parents 85c2771 + 408a13e commit 8fda99e

File tree

9 files changed

+719
-713
lines changed

9 files changed

+719
-713
lines changed

sdl2.pas

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,9 @@ function SDL_WINDOWPOS_ISCENTERED(X: Variant): Variant;
431431

432432
//from "sdl_events.h"
433433

434-
function SDL_GetEventState(type_: UInt32): UInt8;
434+
function SDL_GetEventState(evType: TSDL_EventType): UInt8;
435435
begin
436-
Result := SDL_EventState(type_, SDL_QUERY);
436+
Result := SDL_EventState(evType, SDL_QUERY);
437437
end;
438438

439439
// from "sdl_timer.h"

sdlblendmode.inc

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,40 @@
66

77
type
88
PSDL_BlendMode = ^TSDL_BlendMode;
9-
TSDL_BlendMode = DWord;
9+
TSDL_BlendMode = type DWord;
1010

1111
const
12-
SDL_BLENDMODE_NONE = $00000000; {**< No blending *}
13-
SDL_BLENDMODE_BLEND = $00000001; {**< dst = (src * A) + (dst * (1-A)) *}
14-
SDL_BLENDMODE_ADD = $00000002; {**< dst = (src * A) + dst *}
15-
SDL_BLENDMODE_MOD = $00000004; {**< dst = src * dst *}
12+
SDL_BLENDMODE_NONE = TSDL_BlendMode($00000000); {**< No blending *}
13+
SDL_BLENDMODE_BLEND = TSDL_BlendMode($00000001); {**< dst = (src * A) + (dst * (1-A)) *}
14+
SDL_BLENDMODE_ADD = TSDL_BlendMode($00000002); {**< dst = (src * A) + dst *}
15+
SDL_BLENDMODE_MOD = TSDL_BlendMode($00000004); {**< dst = src * dst *}
1616

1717
type
1818
PSDL_BlendOperation = ^TSDL_BlendOperation;
19-
TSDL_BlendOperation = DWord;
19+
TSDL_BlendOperation = type DWord;
2020

2121
const
22-
SDL_BLENDOPERATION_ADD = $1; {**< dst + src: supported by all renderers *}
23-
SDL_BLENDOPERATION_SUBTRACT = $2; {**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES}
24-
SDL_BLENDOPERATION_REV_SUBTRACT = $3; {**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES}
25-
SDL_BLENDOPERATION_MINIMUM = $4; {**< min(dst, src) : supported by D3D11 *}
26-
SDL_BLENDOPERATION_MAXIMUM = $5; {**< max(dst, src) : supported by D3D11 *}
22+
SDL_BLENDOPERATION_ADD = TSDL_BlendOperation($1); {**< dst + src: supported by all renderers *}
23+
SDL_BLENDOPERATION_SUBTRACT = TSDL_BlendOperation($2); {**< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES}
24+
SDL_BLENDOPERATION_REV_SUBTRACT = TSDL_BlendOperation($3); {**< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES}
25+
SDL_BLENDOPERATION_MINIMUM = TSDL_BlendOperation($4); {**< min(dst, src) : supported by D3D11 *}
26+
SDL_BLENDOPERATION_MAXIMUM = TSDL_BlendOperation($5); {**< max(dst, src) : supported by D3D11 *}
2727

2828
type
2929
PSDL_BlendFactor = ^TSDL_BlendFactor;
30-
TSDL_BlendFactor = DWord;
30+
TSDL_BlendFactor = type DWord;
3131

3232
const
33-
SDL_BLENDFACTOR_ZERO = $1; {**< 0, 0, 0, 0 *}
34-
SDL_BLENDFACTOR_ONE = $2; {**< 1, 1, 1, 1 *}
35-
SDL_BLENDFACTOR_SRC_COLOR = $3; {**< srcR, srcG, srcB, srcA *}
36-
SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = $4; {**< 1-srcR, 1-srcG, 1-srcB, 1-srcA *}
37-
SDL_BLENDFACTOR_SRC_ALPHA = $5; {**< srcA, srcA, srcA, srcA *}
38-
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = $6; {**< 1-srcA, 1-srcA, 1-srcA, 1-srcA *}
39-
SDL_BLENDFACTOR_DST_COLOR = $7; {**< dstR, dstG, dstB, dstA *}
40-
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = $8; {**< 1-dstR, 1-dstG, 1-dstB, 1-dstA *}
41-
SDL_BLENDFACTOR_DST_ALPHA = $9; {**< dstA, dstA, dstA, dstA *}
42-
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = $A; {**< 1-dstA, 1-dstA, 1-dstA, 1-dstA *}
33+
SDL_BLENDFACTOR_ZERO = TSDL_BlendFactor($1); {**< 0, 0, 0, 0 *}
34+
SDL_BLENDFACTOR_ONE = TSDL_BlendFactor($2); {**< 1, 1, 1, 1 *}
35+
SDL_BLENDFACTOR_SRC_COLOR = TSDL_BlendFactor($3); {**< srcR, srcG, srcB, srcA *}
36+
SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR = TSDL_BlendFactor($4); {**< 1-srcR, 1-srcG, 1-srcB, 1-srcA *}
37+
SDL_BLENDFACTOR_SRC_ALPHA = TSDL_BlendFactor($5); {**< srcA, srcA, srcA, srcA *}
38+
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA = TSDL_BlendFactor($6); {**< 1-srcA, 1-srcA, 1-srcA, 1-srcA *}
39+
SDL_BLENDFACTOR_DST_COLOR = TSDL_BlendFactor($7); {**< dstR, dstG, dstB, dstA *}
40+
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR = TSDL_BlendFactor($8); {**< 1-dstR, 1-dstG, 1-dstB, 1-dstA *}
41+
SDL_BLENDFACTOR_DST_ALPHA = TSDL_BlendFactor($9); {**< dstA, dstA, dstA, dstA *}
42+
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA = TSDL_BlendFactor($A); {**< 1-dstA, 1-dstA, 1-dstA, 1-dstA *}
4343

4444
{**
4545
* \brief Create a custom blend mode, which may or may not be supported by a given renderer

sdlevents.inc

Lines changed: 89 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,131 @@
11
//from "sdl_events.h"
22

3+
type
4+
PSDL_EventType = ^TSDL_EventType;
5+
TSDL_EventType = type UInt32;
6+
37
{**
48
* The types of events that can be delivered.
59
*}
6-
710
const
811

912
{ General keyboard/mouse state definitions }
1013
SDL_RELEASED = 0;
1114
SDL_PRESSED = 1;
1215

13-
SDL_FIRSTEVENT = 0; // Unused (do not remove) (needed in pascal?)
16+
SDL_FIRSTEVENT = TSDL_EventType(0); // Unused (do not remove) (needed in pascal?)
1417

15-
SDL_COMMONEVENT = 1; //added for pascal-compatibility
18+
SDL_COMMONEVENT = TSDL_EventType(1); //added for pascal-compatibility
1619

1720
{ Application events }
18-
SDL_QUITEV = $100; // User-requested quit (originally SDL_QUIT, but changed, cause theres a method called SDL_QUIT)
19-
20-
21-
{* These application events have special meaning on iOS, see README.iOS for details *}
22-
SDL_APP_TERMINATING = $101; {**< The application is being terminated by the OS
23-
Called on iOS in applicationWillTerminate()
24-
Called on Android in onDestroy()
25-
*}
26-
SDL_APP_LOWMEMORY = $102; {**< The application is low on memory, free memory if possible.
27-
Called on iOS in applicationDidReceiveMemoryWarning()
28-
Called on Android in onLowMemory()
29-
*}
30-
SDL_APP_WILLENTERBACKGROUND = $103; {**< The application is about to enter the background
31-
Called on iOS in applicationWillResignActive()
32-
Called on Android in onPause()
33-
*}
34-
SDL_APP_DIDENTERBACKGROUND = $104; {**< The application did enter the background and may not get CPU for some time
35-
Called on iOS in applicationDidEnterBackground()
36-
Called on Android in onPause()
37-
*}
38-
SDL_APP_WILLENTERFOREGROUND = $105; {**< The application is about to enter the foreground
39-
Called on iOS in applicationWillEnterForeground()
40-
Called on Android in onResume()
41-
*}
42-
SDL_APP_DIDENTERFOREGROUND = $106; {**< The application is now interactive
43-
Called on iOS in applicationDidBecomeActive()
44-
Called on Android in onResume()
45-
*}
21+
SDL_QUITEV = TSDL_EventType($100); // User-requested quit (originally SDL_QUIT, but changed, cause theres a method called SDL_QUIT)
22+
23+
24+
{ These application events have special meaning on iOS, see README.iOS for details *}
25+
26+
{* The application is being terminated by the OS. *
27+
* Called on iOS in applicationWillTerminate() *
28+
* Called on Android in onDestroy() *}
29+
SDL_APP_TERMINATING = TSDL_EventType($101);
30+
31+
{* The application is low on memory, free memory if possible. *
32+
* Called on iOS in applicationDidReceiveMemoryWarning() *
33+
* Called on Android in onLowMemory() *}
34+
SDL_APP_LOWMEMORY = TSDL_EventType($102);
35+
36+
{* The application is about to enter the background. *
37+
* Called on iOS in applicationWillResignActive() *
38+
* Called on Android in onPause() *}
39+
SDL_APP_WILLENTERBACKGROUND = TSDL_EventType($103);
40+
41+
{* The application did enter the background and may not get CPU for some time. *
42+
* Called on iOS in applicationDidEnterBackground() *
43+
* Called on Android in onPause() *}
44+
SDL_APP_DIDENTERBACKGROUND = TSDL_EventType($104);
45+
46+
{* The application is about to enter the foreground. *
47+
* Called on iOS in applicationWillEnterForeground() *
48+
* Called on Android in onResume() *}
49+
SDL_APP_WILLENTERFOREGROUND = TSDL_EventType($105);
50+
51+
{* The application is now interactive. *
52+
* Called on iOS in applicationDidBecomeActive() *
53+
* Called on Android in onResume() *}
54+
SDL_APP_DIDENTERFOREGROUND = TSDL_EventType($106);
55+
4656

4757
{ Window events }
48-
SDL_WINDOWEVENT = $200; // Window state change
49-
SDL_SYSWMEVENT = $201; // System specific event
58+
SDL_WINDOWEVENT = TSDL_EventType($200); // Window state change
59+
SDL_SYSWMEVENT = TSDL_EventType($201); // System specific event
5060

5161
{ Keyboard events }
52-
SDL_KEYDOWN = $300; // Key pressed
53-
SDL_KEYUP = $301; // Key released
54-
SDL_TEXTEDITING = $302; // Keyboard text editing (composition)
55-
SDL_TEXTINPUT = $303; // Keyboard text input
56-
SDL_KEYMAPCHANGED = $304; // Keymap changed due to a system event such as an
57-
// input language or keyboard layout change.
62+
SDL_KEYDOWN = TSDL_EventType($300); // Key pressed
63+
SDL_KEYUP = TSDL_EventType($301); // Key released
64+
SDL_TEXTEDITING = TSDL_EventType($302); // Keyboard text editing (composition)
65+
SDL_TEXTINPUT = TSDL_EventType($303); // Keyboard text input
66+
SDL_KEYMAPCHANGED = TSDL_EventType($304); // Keymap changed due to a system event such as an input language or keyboard layout change.
5867

5968
{ Mouse events }
60-
SDL_MOUSEMOTION = $400; // Mouse moved
61-
SDL_MOUSEBUTTONDOWN = $401; // Mouse button pressed
62-
SDL_MOUSEBUTTONUP = $402; // Mouse button released
63-
SDL_MOUSEWHEEL = $403; // Mouse wheel motion
69+
SDL_MOUSEMOTION = TSDL_EventType($400); // Mouse moved
70+
SDL_MOUSEBUTTONDOWN = TSDL_EventType($401); // Mouse button pressed
71+
SDL_MOUSEBUTTONUP = TSDL_EventType($402); // Mouse button released
72+
SDL_MOUSEWHEEL = TSDL_EventType($403); // Mouse wheel motion
6473

6574
{ Joystick events }
66-
SDL_JOYAXISMOTION = $600; // Joystick axis motion
67-
SDL_JOYBALLMOTION = $601; // Joystick trackball motion
68-
SDL_JOYHATMOTION = $602; // Joystick hat position change
69-
SDL_JOYBUTTONDOWN = $603; // Joystick button pressed
70-
SDL_JOYBUTTONUP = $604; // Joystick button released
71-
SDL_JOYDEVICEADDED = $605; // A new joystick has been inserted into the system
72-
SDL_JOYDEVICEREMOVED = $606; // An opened joystick has been removed
75+
SDL_JOYAXISMOTION = TSDL_EventType($600); // Joystick axis motion
76+
SDL_JOYBALLMOTION = TSDL_EventType($601); // Joystick trackball motion
77+
SDL_JOYHATMOTION = TSDL_EventType($602); // Joystick hat position change
78+
SDL_JOYBUTTONDOWN = TSDL_EventType($603); // Joystick button pressed
79+
SDL_JOYBUTTONUP = TSDL_EventType($604); // Joystick button released
80+
SDL_JOYDEVICEADDED = TSDL_EventType($605); // A new joystick has been inserted into the system
81+
SDL_JOYDEVICEREMOVED = TSDL_EventType($606); // An opened joystick has been removed
7382

7483
{ Game controller events }
75-
SDL_CONTROLLERAXISMOTION = $650; // Game controller axis motion
76-
SDL_CONTROLLERBUTTONDOWN = $651; // Game controller button pressed
77-
SDL_CONTROLLERBUTTONUP = $652; // Game controller button released
78-
SDL_CONTROLLERDEVICEADDED = $653; // A new Game controller has been inserted into the system
79-
SDL_CONTROLLERDEVICEREMOVED = $654; // An opened Game controller has been removed
80-
SDL_CONTROLLERDEVICEREMAPPED = $655; // The controller mapping was updated
84+
SDL_CONTROLLERAXISMOTION = TSDL_EventType($650); // Game controller axis motion
85+
SDL_CONTROLLERBUTTONDOWN = TSDL_EventType($651); // Game controller button pressed
86+
SDL_CONTROLLERBUTTONUP = TSDL_EventType($652); // Game controller button released
87+
SDL_CONTROLLERDEVICEADDED = TSDL_EventType($653); // A new Game controller has been inserted into the system
88+
SDL_CONTROLLERDEVICEREMOVED = TSDL_EventType($654); // An opened Game controller has been removed
89+
SDL_CONTROLLERDEVICEREMAPPED = TSDL_EventType($655); // The controller mapping was updated
8190

8291
{ Touch events }
83-
SDL_FINGERDOWN = $700;
84-
SDL_FINGERUP = $701;
85-
SDL_FINGERMOTION = $702;
92+
SDL_FINGERDOWN = TSDL_EventType($700);
93+
SDL_FINGERUP = TSDL_EventType($701);
94+
SDL_FINGERMOTION = TSDL_EventType($702);
8695

8796
{ Gesture events }
88-
SDL_DOLLARGESTURE = $800;
89-
SDL_DOLLARRECORD = $801;
90-
SDL_MULTIGESTURE = $802;
97+
SDL_DOLLARGESTURE = TSDL_EventType($800);
98+
SDL_DOLLARRECORD = TSDL_EventType($801);
99+
SDL_MULTIGESTURE = TSDL_EventType($802);
91100

92101
{ Clipboard events }
93-
SDL_CLIPBOARDUPDATE = $900; // The clipboard changed
102+
SDL_CLIPBOARDUPDATE = TSDL_EventType($900); // The clipboard changed
94103

95104
{ Drag and drop events }
96-
SDL_DROPFILE = $1000; // The system requests a file open
97-
SDL_DROPTEXT = $1001; // text/plain drag-and-drop event
98-
SDL_DROPBEGIN = $1002; // A new set of drops is beginning (NULL filename)
99-
SDL_DROPCOMPLETE = $1003; // Current set of drops is now complete (NULL filename)
105+
SDL_DROPFILE = TSDL_EventType($1000); // The system requests a file open
106+
SDL_DROPTEXT = TSDL_EventType($1001); // text/plain drag-and-drop event
107+
SDL_DROPBEGIN = TSDL_EventType($1002); // A new set of drops is beginning (NULL filename)
108+
SDL_DROPCOMPLETE = TSDL_EventType($1003); // Current set of drops is now complete (NULL filename)
100109

101110
{ Audio hotplug events }
102-
SDL_AUDIODEVICEADDED = $1100; // A new audio device is available
103-
SDL_AUDIODEVICEREMOVED = $1101; // An audio device has been removed.
111+
SDL_AUDIODEVICEADDED = TSDL_EventType($1100); // A new audio device is available
112+
SDL_AUDIODEVICEREMOVED = TSDL_EventType($1101); // An audio device has been removed.
104113

105114
{ Render events }
106-
SDL_RENDER_TARGETS_RESET = $2000; // The render targets have been reset
107-
SDL_RENDER_DEVICE_RESET = $2001; // The device has been reset and all textures need to be recreated
115+
SDL_RENDER_TARGETS_RESET = TSDL_EventType($2000); // The render targets have been reset
116+
SDL_RENDER_DEVICE_RESET = TSDL_EventType($2001); // The device has been reset and all textures need to be recreated
108117

109118
{** Events SDL_USEREVENT through SDL_LASTEVENT are for your use,
110119
* and should be allocated with SDL_RegisterEvents()
111120
*}
112-
SDL_USEREVENT = $8000;
121+
SDL_USEREVENT = TSDL_EventType($8000);
113122

114123
{**
115124
* This last event is only for bounding internal arrays (needed in pascal ??)
116125
*}
117-
SDL_LASTEVENT = $FFFF;
126+
SDL_LASTEVENT = TSDL_EventType($FFFF);
118127

119128
type
120-
121-
TSDL_EventType = Word;
122-
123129
{**
124130
* Fields shared by every event
125131
*}
@@ -561,21 +567,21 @@ type
561567
* This function is thread-safe.
562568
*}
563569

564-
function SDL_PeepEvents(events: PSDL_Event; numevents: SInt32; action: TSDL_EventAction; minType: UInt32; maxType: UInt32): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PeepEvents' {$ENDIF} {$ENDIF};
570+
function SDL_PeepEvents(events: PSDL_Event; numevents: SInt32; action: TSDL_EventAction; minType, maxType: TSDL_EventType): SInt32 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_PeepEvents' {$ENDIF} {$ENDIF};
565571

566572
{**
567573
* Checks to see if certain event types are in the event queue.
568574
*}
569575

570-
function SDL_HasEvent(type_: UInt32): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvent' {$ENDIF} {$ENDIF};
571-
function SDL_HasEvents(minType: UInt32; maxType: UInt32): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvents' {$ENDIF} {$ENDIF};
576+
function SDL_HasEvent(evType: TSDL_EventType): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvent' {$ENDIF} {$ENDIF};
577+
function SDL_HasEvents(minType, maxType: TSDL_EventType): TSDL_Bool cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_HasEvents' {$ENDIF} {$ENDIF};
572578

573579
{**
574580
* This function clears events from the event queue
575581
*}
576582

577-
procedure SDL_FlushEvent(type_: UInt32) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvent' {$ENDIF} {$ENDIF};
578-
procedure SDL_FlushEvents(minType: UInt32; maxType: UInt32) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvents' {$ENDIF} {$ENDIF};
583+
procedure SDL_FlushEvent(evType: TSDL_EventType) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvent' {$ENDIF} {$ENDIF};
584+
procedure SDL_FlushEvents(minType, maxType: TSDL_EventType) cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_FlushEvents' {$ENDIF} {$ENDIF};
579585

580586
{**
581587
* Polls for currently pending events.
@@ -694,9 +700,9 @@ const
694700
* current processing state of the specified event.
695701
*}
696702

697-
function SDL_EventState(type_: UInt32; state: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_EventState' {$ENDIF} {$ENDIF};
703+
function SDL_EventState(evType: TSDL_EventType; state: SInt32): UInt8 cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_EventState' {$ENDIF} {$ENDIF};
698704

699-
function SDL_GetEventState(type_: UInt32): UInt8;
705+
function SDL_GetEventState(evType: TSDL_EventType): UInt8;
700706

701707
{**
702708
* This function allocates a set of user-defined events, and returns

0 commit comments

Comments
 (0)