File tree 14 files changed +25
-48
lines changed
14 files changed +25
-48
lines changed Original file line number Diff line number Diff line change 116
116
### Opaque Structs
117
117
118
118
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.
122
121
123
122
C:
124
123
@@ -128,21 +127,17 @@ typedef struct SDL_Window SDL_Window;
128
127
129
128
Pascal:
130
129
131
- Prefered:
132
130
``` pascal
133
131
type
134
132
PPSDL_Window = ^PSDL_Window;
135
- PSDL_Window = ^TSDL_Window;
136
- TSDL_Window = type Pointer;
133
+ PSDL_Window = type Pointer;
137
134
```
138
135
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
+
146
141
147
142
## Unions
148
143
Original file line number Diff line number Diff line change @@ -166,8 +166,7 @@ TMix_Chunk = record
166
166
167
167
{ * The internal format for a music chunk interpreted via mikmod *}
168
168
PPMix_Music = ^PMix_Music;
169
- PMix_Music = ^TMix_Music;
170
- TMix_Music = record end ;
169
+ PMix_Music = type Pointer;
171
170
172
171
{ * Open the mixer with a certain audio format *}
173
172
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;
241
240
{ * Find out the music format of a mixer music, or the currently playing
242
241
music, if 'music' is NULL.
243
242
*}
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} ;
245
244
246
245
{ * Set a function that is called after all mixing is performed.
247
246
This can be used to provide real-time visual display of the audio stream
Original file line number Diff line number Diff line change @@ -175,8 +175,7 @@ procedure TTF_ByteSwappedUNICODE(swapped: TSDL_bool); cdecl;
175
175
{ * The internal structure containing font information *}
176
176
type
177
177
PPTTF_Font = ^PTTF_Font;
178
- PTTF_Font = ^TTTF_Font;
179
- TTTF_Font = record end ; // todo?
178
+ PTTF_Font = type Pointer;
180
179
181
180
{ *
182
181
* Initialize SDL_ttf.
Original file line number Diff line number Diff line change @@ -942,8 +942,7 @@ function SDL_ConvertAudio(cvt: PSDL_AudioCVT): cint; cdecl;
942
942
}
943
943
{ this is opaque to the outside world. }
944
944
type
945
- PSDL_AudioStream = ^TSDL_AudioStream;
946
- TSDL_AudioStream = record end ;
945
+ PSDL_AudioStream = type Pointer;
947
946
948
947
{ *
949
948
* Create a new audio stream.
Original file line number Diff line number Diff line change 15
15
{ * The gamecontroller structure used to identify an SDL game controller *}
16
16
type
17
17
PPSDL_GameController = ^PSDL_GameController;
18
- PSDL_GameController = ^TSDL_GameController;
19
- TSDL_GameController = record end ;
18
+ PSDL_GameController = type Pointer;
20
19
21
20
PPSDL_GameControllerType = ^PSDL_GameControllerType;
22
21
PSDL_GameControllerType = ^TSDL_GameControllerType;
Original file line number Diff line number Diff line change 93
93
*}
94
94
type
95
95
PPSDL_Haptic = ^PSDL_Haptic;
96
- PSDL_Haptic = ^TSDL_Haptic;
97
- TSDL_Haptic = record end ;
96
+ PSDL_Haptic = type Pointer;
98
97
99
98
{ **
100
99
* Haptic features
Original file line number Diff line number Diff line change 42
42
(* *
43
43
* \brief A handle representing an open HID device.
44
44
*)
45
- PSDL_hid_device = ^TSDL_hid_device;
46
- TSDL_hid_device = record end ; // opaque struct
45
+ PSDL_hid_device = type Pointer;
47
46
48
47
PSDL_hid_device_info = ^TSDL_hid_device_info;
49
48
Original file line number Diff line number Diff line change 30
30
type
31
31
{ * The joystick structure used to identify an SDL joystick *}
32
32
PPSDL_Joystick = ^PSDL_Joystick;
33
- PSDL_Joystick = ^TSDL_Joystick;
34
- TSDL_Joystick = record end ;
33
+ PSDL_Joystick = type Pointer;
35
34
36
35
{ * A structure that encodes the stable unique id for a joystick device *}
37
36
PPSDL_JoystickGUID = ^PSDL_JoystickGUID;
Original file line number Diff line number Diff line change 91
91
*}
92
92
93
93
PPSDL_Renderer = ^PSDL_Renderer;
94
- PSDL_Renderer = ^TSDL_Renderer;
95
- TSDL_Renderer = record
96
- end ;
94
+ PSDL_Renderer = type Pointer;
97
95
98
96
{ **
99
97
* An efficient driver-specific representation of pixel data
100
98
*}
101
99
PPSDL_Texture = ^PSDL_Texture;
102
- PSDL_Texture = ^TSDL_Texture;
103
- TSDL_Texture = record
104
- end ;
100
+ PSDL_Texture = type Pointer;
105
101
106
102
{ * Function prototypes *}
107
103
Original file line number Diff line number Diff line change 10
10
*}
11
11
type
12
12
PPSDL_Sensor = ^PSDL_Sensor;
13
- PSDL_Sensor = ^TSDL_Sensor;
14
- TSDL_Sensor = record end ;
13
+ PSDL_Sensor = type Pointer;
15
14
16
15
{**
17
16
* This is a unique ID for a sensor for the time it is connected to the system ,
Original file line number Diff line number Diff line change @@ -685,8 +685,7 @@ const
685
685
SDL_ICONV_EINVAL = csize_t(-4 );
686
686
687
687
type
688
- TSDL_iconv = record end ;
689
- PSDL_iconv = ^TSDL_iconv;
688
+ PSDL_iconv = type Pointer;
690
689
691
690
function SDL_iconv_open (Const tocode, fromcode: PAnsiChar): PSDL_iconv; cdecl;
692
691
external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_iconv_open' { $ENDIF} { $ENDIF} ;
Original file line number Diff line number Diff line change 23
23
* which, if not NULL, contains the raw pixel data for the surface.
24
24
*}
25
25
PPSDL_BlitMap = ^PSDL_BlitMap;
26
- PSDL_BlitMap = ^TSDL_BlitMap;
27
- TSDL_BlitMap = record
28
- map: Pointer;
29
- end ;
26
+ PSDL_BlitMap = type Pointer;
30
27
31
28
PPSDL_Surface = ^PSDL_Surface;
32
29
PSDL_Surface = ^TSDL_Surface;
51
48
clip_rect: TSDL_Rect; { **< Read-only *}
52
49
53
50
{ ** info for fast blit mapping to other surfaces *}
54
- map: Pointer ; { **< Private *} // TODO: Check: Why Pointer and not PSDL_BlitMap used here?
51
+ map: PSDL_BlitMap ; { **< Private *}
55
52
56
53
{ ** Reference count -- used when freeing surface *}
57
54
refcount: cint; { **< Read-mostly *}
Original file line number Diff line number Diff line change 8
8
9
9
{ * The SDL thread structure, defined in SDL_thread.c *}
10
10
type
11
- PSDL_Thread = ^TSDL_Thread;
12
- TSDL_Thread = record end ;
11
+ PSDL_Thread = type Pointer;
13
12
14
13
{ * The SDL thread ID *}
15
14
PPSDL_threadID = ^PSDL_threadID;
@@ -340,7 +339,7 @@ procedure SDL_WaitThread(thread: PSDL_Thread; status: pcint); cdecl;
340
339
* \sa SDL_CreateThread
341
340
* \sa SDL_WaitThread
342
341
*}
343
- procedure SDL_DetachThread (thread:TSDL_Thread ); cdecl;
342
+ procedure SDL_DetachThread (thread:PSDL_Thread ); cdecl;
344
343
external SDL_LibName { $IFDEF DELPHI} { $IFDEF MACOS} name ' _SDL_DetachThread' { $ENDIF}{ $ENDIF} ;
345
344
346
345
{ **
Original file line number Diff line number Diff line change 3
3
4
4
type
5
5
PPSDL_Window = ^PSDL_Window;
6
- PSDL_Window = ^TSDL_Window;
7
- TSDL_Window = record end ;
6
+ PSDL_Window = type Pointer;
8
7
9
8
{ **
10
9
* The structure that defines a display mode
You can’t perform that action at this time.
0 commit comments