Skip to content

Commit d7cbc26

Browse files
committed
Improve typing.
Also reorder some imports and variables.
1 parent 0702400 commit d7cbc26

File tree

13 files changed

+39
-41
lines changed

13 files changed

+39
-41
lines changed

sdl3/SDL_audio.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from .__init__ import ctypes, typing, abc, SDL_FUNC_TYPE, \
22
SDL_POINTER, SDL_FUNC, SDL_TYPE, SDL_BINARY, SDL_ENUM
33

4-
from .SDL_endian import SDL_BYTEORDER, SDL_LIL_ENDIAN
54
from .SDL_properties import SDL_PropertiesID
5+
from .SDL_endian import SDL_BYTEORDER, SDL_LIL_ENDIAN
66
from .SDL_iostream import SDL_IOStream
77

88
SDL_AUDIO_MASK_BITSIZE: int = 0xFF

sdl3/SDL_haptic.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SDL_Haptic(ctypes.c_void_p):
3535
class SDL_HapticDirection(ctypes.Structure):
3636
_fields_ = [
3737
("type", ctypes.c_uint8),
38-
("dir", ctypes.c_int32* 3)
38+
("dir", ctypes.c_int32 * 3)
3939
]
4040

4141
class SDL_HapticConstant(ctypes.Structure):
@@ -79,12 +79,12 @@ class SDL_HapticCondition(ctypes.Structure):
7979
("delay", ctypes.c_uint16),
8080
("button", ctypes.c_uint16),
8181
("interval", ctypes.c_uint16),
82-
("right_sat", ctypes.c_uint16* 3),
83-
("left_sat", ctypes.c_uint16* 3),
84-
("right_coeff", ctypes.c_int16* 3),
85-
("left_coeff", ctypes.c_int16* 3),
86-
("deadband", ctypes.c_uint16* 3),
87-
("center", ctypes.c_int16* 3)
82+
("right_sat", ctypes.c_uint16 * 3),
83+
("left_sat", ctypes.c_uint16 * 3),
84+
("right_coeff", ctypes.c_int16 * 3),
85+
("left_coeff", ctypes.c_int16 * 3),
86+
("deadband", ctypes.c_uint16 * 3),
87+
("center", ctypes.c_int16 * 3)
8888
]
8989

9090
class SDL_HapticRamp(ctypes.Structure):

sdl3/SDL_joystick.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,14 +124,10 @@ class SDL_VirtualJoystickDesc(ctypes.Structure):
124124
SDL_GetJoystickBall: abc.Callable[..., typing.Any] = SDL_FUNC["SDL_GetJoystickBall", ctypes.c_bool, [SDL_POINTER[SDL_Joystick], ctypes.c_int, SDL_POINTER[ctypes.c_int], SDL_POINTER[ctypes.c_int]], SDL_BINARY]
125125
SDL_GetJoystickHat: abc.Callable[..., typing.Any] = SDL_FUNC["SDL_GetJoystickHat", ctypes.c_uint8, [SDL_POINTER[SDL_Joystick], ctypes.c_int], SDL_BINARY]
126126

127-
SDL_HAT_CENTERED, SDL_HAT_UP, SDL_HAT_RIGHT, \
128-
SDL_HAT_DOWN, SDL_HAT_LEFT = 0x00, 0x01, 0x02, 0x04, 0x08
127+
SDL_HAT_CENTERED, SDL_HAT_UP, SDL_HAT_RIGHT, SDL_HAT_DOWN, SDL_HAT_LEFT = 0x00, 0x01, 0x02, 0x04, 0x08
129128

130-
SDL_HAT_RIGHTUP, SDL_HAT_RIGHTDOWN = \
131-
SDL_HAT_RIGHT | SDL_HAT_UP, SDL_HAT_RIGHT | SDL_HAT_DOWN
132-
133-
SDL_HAT_LEFTUP, SDL_HAT_LEFTDOWN = \
134-
SDL_HAT_LEFT | SDL_HAT_UP, SDL_HAT_LEFT | SDL_HAT_DOWN
129+
SDL_HAT_RIGHTUP, SDL_HAT_RIGHTDOWN, SDL_HAT_LEFTUP, SDL_HAT_LEFTDOWN = \
130+
SDL_HAT_RIGHT | SDL_HAT_UP, SDL_HAT_RIGHT | SDL_HAT_DOWN, SDL_HAT_LEFT | SDL_HAT_UP, SDL_HAT_LEFT | SDL_HAT_DOWN
135131

136132
SDL_GetJoystickButton: abc.Callable[..., typing.Any] = SDL_FUNC["SDL_GetJoystickButton", ctypes.c_bool, [SDL_POINTER[SDL_Joystick], ctypes.c_int], SDL_BINARY]
137133
SDL_RumbleJoystick: abc.Callable[..., typing.Any] = SDL_FUNC["SDL_RumbleJoystick", ctypes.c_bool, [SDL_POINTER[SDL_Joystick], ctypes.c_uint16, ctypes.c_uint16, ctypes.c_uint32], SDL_BINARY]

sdl3/SDL_mouse.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ class SDL_Cursor(ctypes.c_void_p):
2828

2929
SDL_BUTTON_MASK: abc.Callable[..., int] = lambda x: 1 << (x - 1)
3030

31-
SDL_BUTTON_LMASK, SDL_BUTTON_MMASK, SDL_BUTTON_RMASK, SDL_BUTTON_X1MASK, SDL_BUTTON_X2MASK = \
32-
[SDL_BUTTON_MASK(x) for x in range(1, 6)]
31+
SDL_BUTTON_LMASK, SDL_BUTTON_MMASK, SDL_BUTTON_RMASK, \
32+
SDL_BUTTON_X1MASK, SDL_BUTTON_X2MASK = [SDL_BUTTON_MASK(x) for x in range(1, 6)]
3333

3434
SDL_HasMouse: abc.Callable[..., typing.Any] = SDL_FUNC["SDL_HasMouse", ctypes.c_bool, [], SDL_BINARY]
3535
SDL_GetMice: abc.Callable[..., typing.Any] = SDL_FUNC["SDL_GetMice", SDL_POINTER[SDL_MouseID], [SDL_POINTER[ctypes.c_int]], SDL_BINARY]

sdl3/SDL_pixels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from .__init__ import ctypes, typing, abc, \
22
SDL_POINTER, SDL_ENUM, SDL_FUNC, SDL_TYPE, SDL_BINARY
33

4-
from .SDL_endian import SDL_BYTEORDER, SDL_BIG_ENDIAN
54
from .SDL_stdinc import SDL_FOURCC
5+
from .SDL_endian import SDL_BYTEORDER, SDL_BIG_ENDIAN
66

77
SDL_ALPHA_OPAQUE, SDL_ALPHA_TRANSPARENT_FLOAT = 255, 1.0
88
SDL_ALPHA_TRANSPARENT, SDL_ALPHA_OPAQUE_FLOAT = 0, 0.0
@@ -34,7 +34,7 @@
3434
def SDL_DEFINE_PIXELFORMAT(ptype: int, order: int, layout: int, bits: int, pbytes: int) -> int:
3535
return (1 << 28) | (ptype << 24) | (order << 20) | (layout << 16) | (bits << 8) | (pbytes << 0)
3636

37-
SDL_DEFINE_PIXELFOURCC = SDL_FOURCC
37+
SDL_DEFINE_PIXELFOURCC: abc.Callable[[int, int, int, int], int] = SDL_FOURCC
3838
SDL_ISPIXELFORMAT_FOURCC: abc.Callable[..., bool] = lambda format: format and SDL_PIXELFLAG(format) != 1
3939

4040
SDL_PIXELFLAG: abc.Callable[..., int] = lambda x: (x >> 28) & 0x0F

sdl3/SDL_render.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
SDL_POINTER, SDL_ENUM, SDL_FUNC, SDL_TYPE, SDL_BINARY
33

44
from .SDL_events import SDL_Event
5+
from .SDL_video import SDL_Window, SDL_WindowFlags
56
from .SDL_rect import SDL_FPoint, SDL_Rect, SDL_FRect
6-
from .SDL_pixels import SDL_Color, SDL_FColor, SDL_PixelFormat
77
from .SDL_surface import SDL_Surface, SDL_ScaleMode, SDL_FlipMode
8-
from .SDL_video import SDL_Window, SDL_WindowFlags
8+
from .SDL_pixels import SDL_FColor, SDL_PixelFormat
99
from .SDL_properties import SDL_PropertiesID
1010
from .SDL_blendmode import SDL_BlendMode
1111

sdl3/SDL_rtf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
SDL_FUNC_TYPE, SDL_FUNC, SDL_TYPE, SDL_RTF_BINARY, SDL_ENUM
33

44
from .SDL_pixels import SDL_Color
5+
from .SDL_iostream import SDL_IOStream
56
from .SDL_error import SDL_SetError, SDL_GetError
67
from .SDL_render import SDL_Renderer, SDL_Texture
78
from .SDL_version import SDL_VERSIONNUM
8-
from .SDL_iostream import SDL_IOStream
99
from .SDL_rect import SDL_Rect
1010

1111
SDL_RTF_MAJOR_VERSION, SDL_RTF_MINOR_VERSION, SDL_RTF_MICRO_VERSION = 3, 0, 0

sdl3/SDL_stdinc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from .__init__ import ctypes, typing, abc, SDL_VA_LIST, \
22
SDL_POINTER, SDL_FUNC_TYPE, SDL_FUNC, SDL_TYPE, SDL_BINARY
33

4-
SDL_arraysize: abc.Callable[[typing.Any], int] = lambda array: ctypes.sizeof(array) // ctypes.sizeof(array[0])
4+
SDL_arraysize: abc.Callable[[typing.Any], int] = lambda array: \
5+
ctypes.sizeof(array) // ctypes.sizeof(array[0])
56

67
def SDL_FOURCC(a: int, b: int, c: int, d: int) -> int:
78
return (ord(a) << 0) | (ord(b) << 8) | (ord(c) << 16) | (ord(d) << 24)

sdl3/SDL_storage.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from .__init__ import ctypes, typing, abc, \
22
SDL_POINTER, SDL_FUNC_TYPE, SDL_FUNC, SDL_BINARY
33

4-
from .SDL_filesystem import SDL_EnumerateDirectoryCallback, SDL_PathInfo, SDL_GlobFlags
54
from .SDL_properties import SDL_PropertiesID
5+
from .SDL_filesystem import SDL_GlobFlags, \
6+
SDL_EnumerateDirectoryCallback, SDL_PathInfo
67

78
class SDL_StorageInterface(ctypes.Structure):
89
_fields_ = [

sdl3/SDL_surface.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from .__init__ import ctypes, typing, abc, \
22
SDL_POINTER, SDL_ENUM, SDL_FUNC, SDL_TYPE, SDL_BINARY
33

4-
from .SDL_pixels import SDL_PixelFormat, SDL_Colorspace, SDL_Palette
5-
from .SDL_properties import SDL_PropertiesID
64
from .SDL_blendmode import SDL_BlendMode
5+
from .SDL_properties import SDL_PropertiesID
6+
from .SDL_pixels import SDL_PixelFormat, SDL_Colorspace, SDL_Palette
77
from .SDL_iostream import SDL_IOStream
88
from .SDL_rect import SDL_Rect
99

0 commit comments

Comments
 (0)