File: error.py

package info (click to toggle)
pysdl2 0.9.9%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,276 kB
  • sloc: python: 18,592; makefile: 148; sh: 40
file content (37 lines) | stat: -rw-r--r-- 1,011 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
from ctypes import POINTER, c_char_p, c_int, c_char
from .dll import _bind

__all__ = [
    # Enums
    "SDL_errorcode",
    "SDL_ENOMEM", "SDL_EFREAD", "SDL_EFWRITE", "SDL_EFSEEK",
    "SDL_UNSUPPORTED", "SDL_LASTERROR",

    # Macro Functions
    "SDL_OutOfMemory", "SDL_Unsupported", "SDL_InvalidParamError", "SDL_Error",

    # Functions
    "SDL_SetError", "SDL_GetError", "SDL_GetErrorMsg", "SDL_ClearError"
]


SDL_SetError = _bind("SDL_SetError", [c_char_p], c_int)
SDL_GetError = _bind("SDL_GetError", None, c_char_p)
SDL_GetErrorMsg = _bind("SDL_GetErrorMsg", [POINTER(c_char), c_int], c_char_p, added='2.0.14')
SDL_ClearError = _bind("SDL_ClearError")


SDL_errorcode = c_int

SDL_ENOMEM = 0
SDL_EFREAD = 1
SDL_EFWRITE = 2
SDL_EFSEEK = 3
SDL_UNSUPPORTED = 4
SDL_LASTERROR = 5


SDL_Error = _bind("SDL_Error", [SDL_errorcode], c_int)
SDL_OutOfMemory = SDL_Error(SDL_ENOMEM)
SDL_Unsupported = SDL_Error(SDL_UNSUPPORTED)
SDL_InvalidParamError = lambda x: SDL_SetError("Parameter '%s' is invalid" % (x))