Skip to content

Remove empty record types #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions CHEATSHEET.md
Original file line number Diff line number Diff line change
@@ -116,9 +116,8 @@ type
### Opaque Structs

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

C:

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

Pascal:

Prefered:
```pascal
type
PPSDL_Window = ^PSDL_Window;
PSDL_Window = ^TSDL_Window;
TSDL_Window = type Pointer;
PSDL_Window = type Pointer;
```

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


## Unions

5 changes: 2 additions & 3 deletions units/sdl2_mixer.pas
Original file line number Diff line number Diff line change
@@ -166,8 +166,7 @@ TMix_Chunk = record

{* The internal format for a music chunk interpreted via mikmod *}
PPMix_Music = ^PMix_Music;
PMix_Music = ^TMix_Music;
TMix_Music = record end;
PMix_Music = type Pointer;

{* Open the mixer with a certain audio format *}
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;
{* Find out the music format of a mixer music, or the currently playing
music, if 'music' is NULL.
*}
function Mix_GetMusicType(music: TMix_Music): TMix_MusicType cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetMusicType' {$ENDIF} {$ENDIF};
function Mix_GetMusicType(music: PMix_Music): TMix_MusicType cdecl; external MIX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_MIX_GetMusicType' {$ENDIF} {$ENDIF};

{* Set a function that is called after all mixing is performed.
This can be used to provide real-time visual display of the audio stream
3 changes: 1 addition & 2 deletions units/sdl2_ttf.pas
Original file line number Diff line number Diff line change
@@ -175,8 +175,7 @@ procedure TTF_ByteSwappedUNICODE(swapped: TSDL_bool); cdecl;
{* The internal structure containing font information *}
type
PPTTF_Font = ^PTTF_Font;
PTTF_Font = ^TTTF_Font;
TTTF_Font = record end; //todo?
PTTF_Font = type Pointer;

{*
* Initialize SDL_ttf.
3 changes: 1 addition & 2 deletions units/sdlaudio.inc
Original file line number Diff line number Diff line change
@@ -942,8 +942,7 @@ function SDL_ConvertAudio(cvt: PSDL_AudioCVT): cint; cdecl;
}
{ this is opaque to the outside world. }
type
PSDL_AudioStream = ^TSDL_AudioStream;
TSDL_AudioStream = record end;
PSDL_AudioStream = type Pointer;

{*
* Create a new audio stream.
3 changes: 1 addition & 2 deletions units/sdlgamecontroller.inc
Original file line number Diff line number Diff line change
@@ -15,8 +15,7 @@
{* The gamecontroller structure used to identify an SDL game controller *}
type
PPSDL_GameController = ^PSDL_GameController;
PSDL_GameController = ^TSDL_GameController;
TSDL_GameController = record end;
PSDL_GameController = type Pointer;

PPSDL_GameControllerType = ^PSDL_GameControllerType;
PSDL_GameControllerType = ^TSDL_GameControllerType;
3 changes: 1 addition & 2 deletions units/sdlhaptic.inc
Original file line number Diff line number Diff line change
@@ -93,8 +93,7 @@
*}
type
PPSDL_Haptic = ^PSDL_Haptic;
PSDL_Haptic = ^TSDL_Haptic;
TSDL_Haptic = record end;
PSDL_Haptic = type Pointer;

{**
* Haptic features
3 changes: 1 addition & 2 deletions units/sdlhidapi.inc
Original file line number Diff line number Diff line change
@@ -42,8 +42,7 @@ type
(**
* \brief A handle representing an open HID device.
*)
PSDL_hid_device = ^TSDL_hid_device;
TSDL_hid_device = record end; // opaque struct
PSDL_hid_device = type Pointer;

PSDL_hid_device_info = ^TSDL_hid_device_info;

3 changes: 1 addition & 2 deletions units/sdljoystick.inc
Original file line number Diff line number Diff line change
@@ -30,8 +30,7 @@
type
{* The joystick structure used to identify an SDL joystick *}
PPSDL_Joystick = ^PSDL_Joystick;
PSDL_Joystick = ^TSDL_Joystick;
TSDL_Joystick = record end;
PSDL_Joystick = type Pointer;

{* A structure that encodes the stable unique id for a joystick device *}
PPSDL_JoystickGUID = ^PSDL_JoystickGUID;
8 changes: 2 additions & 6 deletions units/sdlrenderer.inc
Original file line number Diff line number Diff line change
@@ -91,17 +91,13 @@ type
*}

PPSDL_Renderer = ^PSDL_Renderer;
PSDL_Renderer = ^TSDL_Renderer;
TSDL_Renderer = record
end;
PSDL_Renderer = type Pointer;

{**
* An efficient driver-specific representation of pixel data
*}
PPSDL_Texture = ^PSDL_Texture;
PSDL_Texture = ^TSDL_Texture;
TSDL_Texture = record
end;
PSDL_Texture = type Pointer;

{* Function prototypes *}

3 changes: 1 addition & 2 deletions units/sdlsensor.inc
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@
*}
type
PPSDL_Sensor = ^PSDL_Sensor;
PSDL_Sensor = ^TSDL_Sensor;
TSDL_Sensor = record end;
PSDL_Sensor = type Pointer;

{**
* This is a unique ID for a sensor for the time it is connected to the system,
3 changes: 1 addition & 2 deletions units/sdlstdinc.inc
Original file line number Diff line number Diff line change
@@ -685,8 +685,7 @@ const
SDL_ICONV_EINVAL = csize_t(-4);

type
TSDL_iconv = record end;
PSDL_iconv = ^TSDL_iconv;
PSDL_iconv = type Pointer;

function SDL_iconv_open(Const tocode, fromcode: PAnsiChar): PSDL_iconv; cdecl;
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_iconv_open' {$ENDIF} {$ENDIF};
7 changes: 2 additions & 5 deletions units/sdlsurface.inc
Original file line number Diff line number Diff line change
@@ -23,10 +23,7 @@ type
* which, if not NULL, contains the raw pixel data for the surface.
*}
PPSDL_BlitMap = ^PSDL_BlitMap;
PSDL_BlitMap = ^TSDL_BlitMap;
TSDL_BlitMap = record
map: Pointer;
end;
PSDL_BlitMap = type Pointer;

PPSDL_Surface = ^PSDL_Surface;
PSDL_Surface = ^TSDL_Surface;
@@ -51,7 +48,7 @@ type
clip_rect: TSDL_Rect; {**< Read-only *}

{** info for fast blit mapping to other surfaces *}
map: Pointer; {**< Private *} // TODO: Check: Why Pointer and not PSDL_BlitMap used here?
map: PSDL_BlitMap; {**< Private *}

{** Reference count -- used when freeing surface *}
refcount: cint; {**< Read-mostly *}
5 changes: 2 additions & 3 deletions units/sdlthread.inc
Original file line number Diff line number Diff line change
@@ -8,8 +8,7 @@

{* The SDL thread structure, defined in SDL_thread.c *}
type
PSDL_Thread = ^TSDL_Thread;
TSDL_Thread = record end;
PSDL_Thread = type Pointer;

{* The SDL thread ID *}
PPSDL_threadID = ^PSDL_threadID;
@@ -340,7 +339,7 @@ procedure SDL_WaitThread(thread: PSDL_Thread; status: pcint); cdecl;
* \sa SDL_CreateThread
* \sa SDL_WaitThread
*}
procedure SDL_DetachThread(thread:TSDL_Thread); cdecl;
procedure SDL_DetachThread(thread:PSDL_Thread); cdecl;
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_DetachThread' {$ENDIF}{$ENDIF};

{**
3 changes: 1 addition & 2 deletions units/sdlvideo.inc
Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@

type
PPSDL_Window = ^PSDL_Window;
PSDL_Window = ^TSDL_Window;
TSDL_Window = record end;
PSDL_Window = type Pointer;

{**
* The structure that defines a display mode
Loading