Skip to content

Commit 293e2ba

Browse files
committed
Added SDL_SET_CURRENT_DLL call after imports.
1 parent 7cce516 commit 293e2ba

Some content is hidden

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

43 files changed

+193
-49
lines changed

sdl3/SDL_atomic.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, dll, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
3+
4+
SDL_SET_CURRENT_DLL(SDL_DLL)
25

36
SDL_SpinLock = ctypes.c_int
47

@@ -23,10 +26,10 @@ class LP_SDL_AtomicInt(ctypes._Pointer):
2326
...
2427

2528
def SDL_AtomicIncRef(a: LP_SDL_AtomicInt) -> ctypes.c_int:
26-
return SDL_AtomicAdd(a, 1)
29+
return dll.SDL_AtomicAdd(a, 1)
2730

2831
def SDL_AtomicDecRef(a: LP_SDL_AtomicInt) -> ctypes.c_int:
29-
return SDL_AtomicAdd(a, -1) == 1
32+
return dll.SDL_AtomicAdd(a, -1) == 1
3033

3134
SDL_FUNC("SDL_AtomicCompareAndSwapPointer", ctypes.c_bool, ctypes.POINTER(ctypes.c_void_p), ctypes.c_void_p, ctypes.c_void_p)
3235
SDL_FUNC("SDL_AtomicSetPtr", ctypes.c_void_p, ctypes.POINTER(ctypes.c_void_p), ctypes.c_void_p)

sdl3/SDL_audio.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
23

34
from .SDL_endian import SDL_BYTEORDER, SDL_LIL_ENDIAN
45
from .SDL_properties import SDL_PropertiesID
56
from .SDL_iostream import SDL_IOStream
67

8+
SDL_SET_CURRENT_DLL(SDL_DLL)
9+
710
SDL_AUDIO_MASK_BITSIZE = 0xFF
811
SDL_AUDIO_MASK_FLOAT = 1 << 8
912
SDL_AUDIO_MASK_BIG_ENDIAN = 1 << 12

sdl3/SDL_bits.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
3+
4+
SDL_SET_CURRENT_DLL(SDL_DLL)
25

36
def SDL_HasExactlyOneBitSet32(x: ctypes.c_uint32) -> ctypes.c_bool:
47
if x and not (x & (x - 1)): return ctypes.c_bool(1)

sdl3/SDL_blendmode.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
3+
4+
SDL_SET_CURRENT_DLL(SDL_DLL)
25

36
SDL_BlendMode = ctypes.c_uint32
47

sdl3/SDL_camera.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
23

34
from .SDL_pixels import SDL_PixelFormat, SDL_Colorspace
45
from .SDL_properties import SDL_PropertiesID
56
from .SDL_surface import SDL_Surface
67

8+
SDL_SET_CURRENT_DLL(SDL_DLL)
9+
710
SDL_CameraID = ctypes.c_uint32
811

912
class SDL_Camera(ctypes.Structure):

sdl3/SDL_clipboard.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
3+
4+
SDL_SET_CURRENT_DLL(SDL_DLL)
25

36
SDL_FUNC("SDL_SetClipboardText", ctypes.c_int, ctypes.c_char_p)
47
SDL_FUNC("SDL_GetClipboardText", ctypes.c_char_p)

sdl3/SDL_cpuinfo.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
3+
4+
SDL_SET_CURRENT_DLL(SDL_DLL)
25

36
SDL_CACHELINE_SIZE = 128
47

sdl3/SDL_dialog.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
23

34
from .SDL_video import SDL_Window
45

6+
SDL_SET_CURRENT_DLL(SDL_DLL)
7+
58
class SDL_DialogFileFilter(ctypes.Structure):
69
_fields_ = [
710
("name", ctypes.c_char_p),

sdl3/SDL_endian.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
from .__init__ import sys
1+
from .__init__ import sys, ctypes, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
23

34
import array
45

6+
SDL_SET_CURRENT_DLL(SDL_DLL)
7+
58
SDL_LIL_ENDIAN, SDL_BIG_ENDIAN = 1234, 4321
69
SDL_BYTEORDER = SDL_LIL_ENDIAN \
710
if sys.byteorder == "little" else SDL_BIG_ENDIAN

sdl3/SDL_error.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
from .__init__ import ctypes, SDL_FUNC
1+
from .__init__ import ctypes, dll, \
2+
SDL_FUNC, SDL_SET_CURRENT_DLL, SDL_DLL
3+
4+
SDL_SET_CURRENT_DLL(SDL_DLL)
25

36
SDL_FUNC("SDL_SetError", ctypes.c_int, ctypes.c_char_p)
47
SDL_FUNC("SDL_OutOfMemory", ctypes.c_int)
58
SDL_FUNC("SDL_GetError", ctypes.c_char_p)
69
SDL_FUNC("SDL_ClearError", ctypes.c_int)
710

8-
def SDL_Unsupported() -> int:
9-
return SDL_SetError("That operation is not supported".encode())
11+
def SDL_Unsupported() -> ctypes.c_int:
12+
return dll.SDL_SetError("That operation is not supported".encode())
1013

11-
def SDL_InvalidParamError(param: str) -> int:
12-
return SDL_SetError(f"Parameter '{param}' is invalid".encode())
14+
def SDL_InvalidParamError(param: ctypes.c_char_p) -> ctypes.c_int:
15+
if isinstance(param, bytes): param = param.decode()
16+
return dll.SDL_SetError(f"Parameter '{param}' is invalid".encode())

0 commit comments

Comments
 (0)