You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: STYLESHEET.md
+7-46Lines changed: 7 additions & 46 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,13 +21,15 @@ data types. For Delphi we have a temporary solution provided.
21
21
22
22
**Example:** Use `cuint32` (if `Uint32` is used in
23
23
the original code) instead of `UInt32`, `Cardinal`, `LongWord` or `DWord`.
24
-
Exception: Replace `*char` by `PAnsiChar`.
24
+
Exception 1: Replace `*char` by `PAnsiChar`.
25
25
26
-
**Hint:** Use `TSDL_Bool` to translate `SDL_bool`. For macro functions use `Boolean`.
26
+
4. In SDL3 the type `SDL_Bool` has been replaced by plain `bool`. C's bool is usually 1 byte in size
27
+
and therefore fully memory comaptible with Free Pascal's and Delphi's Boolean.
28
+
Hence we translate `bool` by `Boolean`.
27
29
28
-
4. If an identifier or a function declaration is gone, mark them as `deprecated`.
30
+
5. If an identifier or a function declaration is gone, mark it as `deprecated`.
29
31
30
-
5. For convenience we encourage to add single and double pointers for any SDL type.
32
+
6. For convenience we encourage to add single and double pointers for any SDL type.
31
33
32
34
## Defines
33
35
@@ -319,45 +321,4 @@ return values depend on the context in which this macro is used. Here from the
319
321
context is known that X, Y and Z stand for the major version, minor version and
320
322
the patch level which are declared to be 8 bit unsigned integers. From the
321
323
context it is also clear, that the macro returns true or false, hence the
322
-
function should return a Boolean value. The context does not suggest to use,
323
-
e. g., TSDL_Bool here, although in a different context this could be the better
324
-
translation.
325
-
326
-
## When to use TSDL_Bool?
327
-
328
-
TSDL_Bool is memory compatible with C's bool (integer size, e. g. 2 or 4 bytes).
329
-
Pascal's Boolean is different and typically 1 byte in size. ([FPC Ref.](https://www.freepascal.org/docs-html/current/ref/refsu4.html#x26-270003.1.1))
330
-
331
-
* return values and paramters of original SDL functions which are of SDL_Bool type, should be translated with TSDL_Bool
332
-
* DO NOT use TSDL_Bool for macro functions which evaluate to a boolean value, use Pascal's Boolean instead (exception: the value is an argument for a SDL_Bool parameter)
333
-
334
-
_Example code_
335
-
```pascal
336
-
program SDLBoolTest;
337
-
338
-
uses SDL2, ctypes, SysUtils;
339
-
340
-
var
341
-
a, b: Integer;
342
-
343
-
function BoolTest(a, b: Integer): TSDL_Bool;
344
-
begin
345
-
// works
346
-
//Result := TSDL_Bool(a > b);
347
-
348
-
// works, too
349
-
Result := (a > b);
350
-
end;
351
-
352
-
begin
353
-
writeln('Bool Test a > b');
354
-
for a:= 0 to 3 do
355
-
for b := 0 to 3 do
356
-
begin
357
-
write('a = ' + IntToStr(a) + '; b = ' + IntToStr(b) +'; Result = ');
0 commit comments