Skip to content

Commit d423b12

Browse files
Merge branch 'master' into update-sdlthread
2 parents 2cba02c + 40389bb commit d423b12

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+3910
-1499
lines changed

Diff for: CHEATSHEET.md

+29-5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Pascal:
5656

5757
```pascal
5858
type
59+
PPSDL_JoystickPowerLevel = ^PSDL_JoystickPowerLevel;
60+
PSDL_JoystickPowerLevel = ^TSDL_JoystickPowerLevel;
5961
TSDL_JoystickPowerLevel = type Integer;
6062
6163
const
@@ -70,15 +72,23 @@ const
7072

7173
Hint 1: C enums start at 0 if no explicit value is set.
7274

73-
Hint 2: The type should be Word if only unsigned values are possible. Otherwise
74-
it should be Integer.
75+
Hint 2: The type should always be cint. Most C compilers have the enum elements
76+
> In C, each enumeration constant has type int and each enumeration type
77+
> is compatible with some integer type. (The integer types include all three
78+
> character types–plain, signed, and unsigned.) The choice of compatible
79+
> type is implementation-defined. The C standard grants the freedom to
80+
> use different integer types to represent different enumeration types,
81+
> but most compilers just use int to represent all enumeration types.
82+
Ref.: [https://www.embedded.com/enumerations-are-integers-except-when-theyre-not/](https://www.embedded.com/enumerations-are-integers-except-when-theyre-not/)
7583

7684
Hint 3: Do not translate C enums to Pascal enums. C enums are handled like plain
7785
integers which will make bitwise operations (e. g. in macros) possible
7886
without typecasting.
7987

8088
## Structs
8189

90+
### Defined Structs
91+
8292
C:
8393

8494
```c
@@ -94,6 +104,7 @@ Pascal:
94104

95105
```pascal
96106
type
107+
PPSDL_Version = ^PSDL_Version;
97108
PSDL_Version = ^TSDL_Version;
98109
TSDL_Version = record
99110
major: cuint8 { major version }
@@ -102,10 +113,12 @@ type
102113
end;
103114
```
104115

105-
Hint 1: If you have something like ```typedef struct name name```. the concrete
106-
structure is probably opaque. You should translate it as follows, although
107-
the best way to handle this is still not finally decided on. (see issue
116+
### Opaque Structs
117+
118+
If you have something like ```typedef struct name name```. the concrete
119+
structure is opaque. See issue
108120
[#63](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/63))
121+
for details.
109122

110123
C:
111124

@@ -115,8 +128,18 @@ typedef struct SDL_Window SDL_Window;
115128

116129
Pascal:
117130

131+
Prefered:
132+
```pascal
133+
type
134+
PPSDL_Window = ^PSDL_Window;
135+
PSDL_Window = ^TSDL_Window;
136+
TSDL_Window = type Pointer;
137+
```
138+
139+
Alternativly:
118140
```pascal
119141
type
142+
PPSDL_Window = ^PSDL_Window;
120143
PSDL_Window = ^TSDL_Window;
121144
TSDL_Window = record end;
122145
```
@@ -137,6 +160,7 @@ Pascal:
137160

138161
```pascal
139162
type
163+
PPSDL_WindowShapeParams = ^PSDL_WindowShapeParams;
140164
PSDL_WindowShapeParams = ^TSDL_WindowShapeParams;
141165
TSDL_WindowShapeParams = record
142166
case cint of

Diff for: LEGACYCHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,11 @@ v.1.70-stable; 16.09.2013: Initial Commit
8383
v.1.72-stable; 29.09.2013: fixed bug with procedures without parameters (they must have brackets)
8484

8585
v.1.70-stable; 11.09.2013: Initial Commit
86+
87+
## Extracted from jedi.inc
88+
89+
v. 1.63-stable; 16.09.13: since GPC isn't supported anymore, i've deleted it from here, too.
90+
91+
v. 1.22-alpha; 24.07.13: fixed some bugs. special thanks to kotai from pascalgamedevelopment.com
92+
93+
v. 1.00-alpha; 05.07.13: Initial Alpha-Release

Diff for: README.md

+33-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Unit files for building
44
[Free Pascal](https://freepascal.org/) / [Delphi](https://www.embarcadero.com/products/delphi) applications
55
using the [SDL2 library](https://libsdl.org).
66

7-
This repository is a community-maintained fork of the [Pascal-SDL-2-Headers](https://github.com/ev1313/Pascal-SDL-2-Headers) repo.
7+
The [SDL2-for-Pascal](https://github.com/PascalGameDevelopment/SDL2-for-Pascal) repository is a community-maintained fork of the [Pascal-SDL-2-Headers](https://github.com/ev1313/Pascal-SDL-2-Headers) repository.
88

99
## Installation
1010

@@ -15,16 +15,26 @@ Simply add the units to your include path. You can achieve this by:
1515

1616
Use the `sdl2` unit for the main SDL2 library (should be always needed). Units for the other SDL2 libraries are also provided:
1717
- [`sdl2_gfx`](https://www.ferzkopp.net/wordpress/2016/01/02/sdl_gfx-sdl2_gfx/)
18-
- [`sdl2_image`](https://www.libsdl.org/projects/SDL_image/)
19-
- [`sdl2_mixer`](https://www.libsdl.org/projects/SDL_mixer/)
20-
- [`sdl2_net`](https://www.libsdl.org/projects/SDL_net/)
21-
- [`sdl2_ttf`](https://www.libsdl.org/projects/SDL_ttf/)
18+
- [`sdl2_image`](https://github.com/libsdl-org/SDL_image)
19+
- [`sdl2_mixer`](https://github.com/libsdl-org/SDL_mixer)
20+
- [`sdl2_net`](https://github.com/libsdl-org/SDL_net)
21+
- [`sdl2_ttf`](https://github.com/libsdl-org/SDL_ttf)
22+
23+
## Documentation
24+
25+
[Official SDL2-for-Pascal Documentation](https://pascalgamedevelopment.github.io/SDL2-for-Pascal)
26+
27+
### Further Resources
28+
29+
[Free Pascal meets SDL](https://www.freepascal-meets-sdl.net)
30+
31+
[PGD SDL2 Forum](https://www.pascalgamedevelopment.com/forumdisplay.php?26-SDL-SDL-2)
2232

2333
## Bugs / Contributions / ToDos
2434

2535
If you have any contributions or bugfixes, feel free to drop a pull request or send in a patch.
36+
Please use the GitHub [issue tracker](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues).
2637

27-
Please use the GitHub issue tracker for bug reports.
2838

2939
### ToDos
3040

@@ -34,7 +44,7 @@ See part Enums on the [Cheat sheet](CHEATSHEET.md) for reference.
3444
- (Continously) improve Delphi-compatibility (and even more important, DO NOT break it)
3545
- (Continously) Adapt comments to [PasDoc format](https://pasdoc.github.io). (See issue [#22](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/22))
3646

37-
## Code style guidelines
47+
### Code style guidelines
3848

3949
The main principle is to stay as tight as possible at the names in the C headers.
4050
These guidelines aim to have better consistency in this community project and make
@@ -61,22 +71,30 @@ Exception: Replace `*char` by `PAnsiChar`! (see issue [#26](https://github.com/P
6171

6272
4. If an identifier or a function declaration is gone, mark them as `deprecated`. (see issue [#34](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/34))
6373

64-
5. Have a look at our [Translation Cheat Sheet](CHEATSHEET.md) for reference.
74+
5. For convenience we encourage to add single and double pointers for any SDL type. (see issue [#105](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/issues/105))
75+
76+
6. Have a look at our [Translation Cheat Sheet](CHEATSHEET.md) for reference.
6577

6678
## Versions
6779

6880
The version tag (see [tags](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/tags)) refers to the version of this translation package [SDL2 for Pascal](https://github.com/PascalGameDevelopment/SDL2-for-Pascal), not the `SDL2 library`.
6981

7082
### v2.x (work in progress)
7183

72-
- be up-to-date with _at least_ version 2.0.14 of the `SDL2 library`
73-
- replaced all aliases by typed enums
74-
- (done) update SDL_ttf.pas to latest version 2.21.0
75-
- (done) replace data types by c data types (see PR [#29](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/pull/29))
76-
- (done) add folders to project
77-
- (done) shift all units into unit folder (see PR [#27](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/pull/27))
84+
- update sdlthreads.inc
85+
- add testing framework ([fptest](https://github.com/graemeg/fptest))
86+
87+
### v2.2 Stable (02/01/2024)
88+
89+
- SDL2 unit is up-to-date with _at least_ version 2.0.14 of the `SDL2 library`
90+
- many aliases got replaced by typed enums
91+
- add single and double pointers for all types (thanks furious-programming)
92+
- update SDL_ttf.pas to latest version 2.21.0
93+
- replace data types by c data types (see PR [#29](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/pull/29))
94+
- add folder structure (see PR [#27](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/pull/27))
95+
- many bugfixes
7896

79-
### v2.1 (Compatibility Release)
97+
### v2.1 Compatibility Release (25/09/2021)
8098

8199
- This release has all commits until the change of the project folder structure (see PR [#27](https://github.com/PascalGameDevelopment/SDL2-for-Pascal/pull/27)). Compare the disucssion in issue #22.
82100
- Moving the units to a new location may (1) raise difficulties in committing new changes if the branch was started before and (2) make updates of project research pathes necessary.

Diff for: units/ctypes.inc

+26
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@
2424
type
2525
DWord = LongWord;
2626

27+
ppcbool = ^pcbool;
2728
pcbool = ^cbool;
2829
cbool = LongBool;
2930
{$EXTERNALSYM cbool}
3031

32+
ppcint8 = ^pcint8;
3133
pcint8 = ^cint8;
3234
cint8 = ShortInt;
3335
{$EXTERNALSYM cint8}
@@ -36,50 +38,60 @@ type
3638
cuint8 = Byte;
3739
{$EXTERNALSYM cuint8}
3840

41+
ppcint16 = ^pcint16;
3942
pcint16 = ^cint16;
4043
cint16 = SmallInt;
4144
{$EXTERNALSYM cint16}
4245

46+
ppcuint16 = ^pcuint16;
4347
pcuint16 = ^cuint16;
4448
cuint16 = Word;
4549
{$EXTERNALSYM cuint16}
4650

51+
ppcushort = ^pcushort;
4752
pcushort = ^cushort;
4853
cushort = Word;
4954
{$EXTERNALSYM cushort}
5055

56+
ppcint32 = ^pcint32;
5157
pcint32 = ^cint32;
5258
cint32 = LongInt;
5359
{$EXTERNALSYM cint32}
5460

61+
ppcuint32 = ^pcuint32;
5562
pcuint32 = ^cuint32;
5663
cuint32 = LongWord;
5764
{$EXTERNALSYM cuint32}
5865

5966
{$IFNDEF Has_Int64}
67+
ppcint64 = ^pcint64;
6068
pcint64 = ^cint64;
6169
cint64 = record
6270
hi: cuint32;
6371
lo: cuint32;
6472
end;
6573
{$EXTERNALSYM cint64}
6674

75+
ppcuint64 = ^pcuint64;
6776
pcuint64 = ^cuint64;
6877
cuint64 = record
6978
hi: cuint32;
7079
lo: cuint32;
7180
end;
7281
{$EXTERNALSYM cuint64}
7382
{$ELSE}
83+
ppcint64 = ^pcint64;
7484
pcint64 = ^cint64;
7585
cint64 = Int64;
7686
{$EXTERNALSYM cint64}
7787

88+
ppcuint64 = ^pcuint64;
7889
pcuint64 = ^cuint64;
7990
cuint64 = UInt64;
8091
{$EXTERNALSYM cuint64}
8192
{$ENDIF}
8293

94+
ppcsize_t = ^pcsize_t;
8395
pcsize_t = ^csize_t;
8496
{$IFNDEF WIN64}
8597
csize_t = cuint32;
@@ -88,13 +100,26 @@ type
88100
{$ENDIF}
89101
{$EXTERNALSYM csize_t}
90102

103+
ppcfloat = ^pcfloat;
91104
pcfloat = ^cfloat;
92105
cfloat = Single;
93106
{$EXTERNALSYM cfloat}
94107

108+
ppcdouble = ^pcdouble;
109+
pcdouble = ^cdouble;
110+
cdouble = Double;
111+
{$EXTERNALSYM cfloat}
112+
113+
ppcint = ^pcint;
95114
pcint = ^cint;
115+
116+
ppcuint = ^pcuint;
96117
pcuint = ^cuint;
118+
119+
ppclong = ^pclong;
97120
pclong = ^clong;
121+
122+
ppculong = ^pculong;
98123
pculong = ^culong;
99124
{
100125
Integer type sizes based on:
@@ -123,6 +148,7 @@ type
123148

124149
{ Data types for all compilers }
125150
type
151+
PPUInt8Array = ^PUInt8Array;
126152
PUInt8Array = ^TUInt8Array;
127153
TUInt8Array = array [0..MAXINT shr 1] of cuint8;
128154

Diff for: units/jedi.inc

+8-23
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
11
{
2-
Simple DirectMedia Layer
3-
Copyright (C) 1997-2013 Sam Lantinga <[email protected]>
2+
This file (jedi.inc) is part of SDL2-for-Pascal.
3+
It defines some variables for several Pascal-Compilers and OS-versions.
44
5-
Pascal-Header-Conversion
6-
Copyright (c) 2012/13 Tim Blume aka End
5+
It is based upon:
76
8-
sdl.inc is based on the files:
9-
"begin_code.h",
10-
"close_code.h",
11-
"sdl_config.h",
12-
"sdl_config_windows.h",
13-
...
14-
it defines some variables for several Pascal-Compilers and OS-versions.
7+
Pascal-Header-Conversion
8+
Copyright (c) 2012/13 Tim Blume aka End
159
16-
It is based on mine updated version of jedi-sdl.inc from the SDL 1.2 Headers,
17-
they can be found at delphigl.com or on my github-repository:
18-
19-
https://github.com/ev1313/
10+
jedi-sdl.inc: Global Conditional Definitions for JEDI-SDL cross-compilation
11+
Copyright (C) 2000 - 2013 Prof. Abimbola Olowofoyeku and Tim Blume
12+
See: https://github.com/ev1313/
2013
2114
This software is provided 'as-is', without any express or implied
2215
warranty. In no event will the authors be held liable for any damages
@@ -35,14 +28,6 @@
3528
3. This notice may not be removed or altered from any source distribution.
3629
}
3730

38-
{
39-
Changelog:
40-
----------
41-
v. 1.63-stable; 16.09.13: since GPC isn't supported anymore, i've deleted it from here, too.
42-
v. 1.22-alpha; 24.07.13: fixed some bugs. special thanks to kotai from pascalgamedevelopment.com
43-
v. 1.00-alpha; 05.07.13: Initial Alpha-Release
44-
}
45-
4631
{.$define Debug} { uncomment for debugging }
4732

4833
{$IFNDEF FPC}

Diff for: units/sdl.inc

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// based on "sdl.h"
22

33
type
4+
PPSDL_Init = ^PSDL_Init;
5+
PSDL_Init = ^TSDL_Init;
46
TSDL_Init = type cuint32;
57

68
const

0 commit comments

Comments
 (0)