Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0fcaf6a

Browse files
Merge pull request #135 from suve/remove-empty-record-types
Remove empty record types
2 parents ce2065a + 89ac010 commit 0fcaf6a

14 files changed

+25
-48
lines changed

‎CHEATSHEET.md

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,8 @@ type
116116
### Opaque Structs
117117

118118
If you have something like ```typedef struct name name```. the concrete
119-
structure is opaque. See issue
120-
[#63](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/63))
121-
for details.
119+
structure is opaque, and the programmer is expected to only ever
120+
interact with pointers to the struct.
122121

123122
C:
124123

@@ -128,21 +127,17 @@ typedef struct SDL_Window SDL_Window;
128127

129128
Pascal:
130129

131-
Prefered:
132130
```pascal
133131
type
134132
PPSDL_Window = ^PSDL_Window;
135-
PSDL_Window = ^TSDL_Window;
136-
TSDL_Window = type Pointer;
133+
PSDL_Window = type Pointer;
137134
```
138135

139-
Alternativly:
140-
```pascal
141-
type
142-
PPSDL_Window = ^PSDL_Window;
143-
PSDL_Window = ^TSDL_Window;
144-
TSDL_Window = record end;
145-
```
136+
As shown above, for opaque structs, we avoid defining the base `TType`
137+
and define only the pointer `PType`.
138+
For the rationale behind this decision, read the discussion in
139+
[issue #63](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/63).
140+
146141

147142
## Unions
148143

‎units/sdl2_mixer.pas

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ TMix_Chunk = record
166166

167167
{* The internal format for a music chunk interpreted via mikmod *}
168168
PPMix_Music = ^PMix_Music;
169-
PMix_Music = ^TMix_Music;
170-
TMix_Music = record end;
169+
PMix_Music = type Pointer;
171170

172171
{* Open the mixer with a certain audio format *}
173172
function Mix_OpenAudio(frequency: cint; format: cuint16; channels: cint; chunksize: cint): cint cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_OpenAudio' {$ENDIF} {$ENDIF};
@@ -241,7 +240,7 @@ function Mix_HasMusicDecoder(const name: PAnsiChar): TSDL_Bool cdecl;
241240
{* Find out the music format of a mixer music, or the currently playing
242241
music, if 'music' is NULL.
243242
*}
244-
function Mix_GetMusicType(music: TMix_Music): TMix_MusicType cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetMusicType' {$ENDIF} {$ENDIF};
243+
function Mix_GetMusicType(music: PMix_Music): TMix_MusicType cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetMusicType' {$ENDIF} {$ENDIF};
245244

246245
{* Set a function that is called after all mixing is performed.
247246
This can be used to provide real-time visual display of the audio stream

‎units/sdl2_ttf.pas

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,7 @@ procedure TTF_ByteSwappedUNICODE(swapped: TSDL_bool); cdecl;
175175
{* The internal structure containing font information *}
176176
type
177177
PPTTF_Font = ^PTTF_Font;
178-
PTTF_Font = ^TTTF_Font;
179-
TTTF_Font = record end; //todo?
178+
PTTF_Font = type Pointer;
180179

181180
{*
182181
* Initialize SDL_ttf.

‎units/sdlaudio.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,8 +942,7 @@ function SDL_ConvertAudio(cvt: PSDL_AudioCVT): cint; cdecl;
942942
}
943943
{ this is opaque to the outside world. }
944944
type
945-
PSDL_AudioStream = ^TSDL_AudioStream;
946-
TSDL_AudioStream = record end;
945+
PSDL_AudioStream = type Pointer;
947946

948947
{*
949948
* Create a new audio stream.

‎units/sdlgamecontroller.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
{* The gamecontroller structure used to identify an SDL game controller *}
1616
type
1717
PPSDL_GameController = ^PSDL_GameController;
18-
PSDL_GameController = ^TSDL_GameController;
19-
TSDL_GameController = record end;
18+
PSDL_GameController = type Pointer;
2019

2120
PPSDL_GameControllerType = ^PSDL_GameControllerType;
2221
PSDL_GameControllerType = ^TSDL_GameControllerType;

‎units/sdlhaptic.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@
9393
*}
9494
type
9595
PPSDL_Haptic = ^PSDL_Haptic;
96-
PSDL_Haptic = ^TSDL_Haptic;
97-
TSDL_Haptic = record end;
96+
PSDL_Haptic = type Pointer;
9897

9998
{**
10099
* Haptic features

‎units/sdlhidapi.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ type
4242
(**
4343
* \brief A handle representing an open HID device.
4444
*)
45-
PSDL_hid_device = ^TSDL_hid_device;
46-
TSDL_hid_device = record end; // opaque struct
45+
PSDL_hid_device = type Pointer;
4746

4847
PSDL_hid_device_info = ^TSDL_hid_device_info;
4948

‎units/sdljoystick.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
type
3131
{* The joystick structure used to identify an SDL joystick *}
3232
PPSDL_Joystick = ^PSDL_Joystick;
33-
PSDL_Joystick = ^TSDL_Joystick;
34-
TSDL_Joystick = record end;
33+
PSDL_Joystick = type Pointer;
3534

3635
{* A structure that encodes the stable unique id for a joystick device *}
3736
PPSDL_JoystickGUID = ^PSDL_JoystickGUID;

‎units/sdlrenderer.inc

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,13 @@ type
9191
*}
9292

9393
PPSDL_Renderer = ^PSDL_Renderer;
94-
PSDL_Renderer = ^TSDL_Renderer;
95-
TSDL_Renderer = record
96-
end;
94+
PSDL_Renderer = type Pointer;
9795

9896
{**
9997
* An efficient driver-specific representation of pixel data
10098
*}
10199
PPSDL_Texture = ^PSDL_Texture;
102-
PSDL_Texture = ^TSDL_Texture;
103-
TSDL_Texture = record
104-
end;
100+
PSDL_Texture = type Pointer;
105101

106102
{* Function prototypes *}
107103

‎units/sdlsensor.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
*}
1111
type
1212
PPSDL_Sensor = ^PSDL_Sensor;
13-
PSDL_Sensor = ^TSDL_Sensor;
14-
TSDL_Sensor = record end;
13+
PSDL_Sensor = type Pointer;
1514

1615
{**
1716
* This is a unique ID for a sensor for the time it is connected to the system,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /