py-sdl2 / sdl2 / version.py

from ctypes import Structure, POINTER, c_char_p, c_int
from .dll import _bind
from .stdinc import Uint8

__all__ = ["SDL_version", "SDL_MAJOR_VERSION", "SDL_MINOR_VERSION",
           "SDL_PATCHLEVEL", "SDL_VERSION", "SDL_VERSIONNUM",
           "SDL_COMPILEDVERSION", "SDL_VERSION_ATLEAST", "SDL_GetVersion",
           "SDL_GetRevision", "SDL_GetRevisionNumber"
           ]

class SDL_version(Structure):
    _fields_ = [("major", Uint8),
                ("minor", Uint8),
                ("patch", Uint8),
                ]

SDL_MAJOR_VERSION = 2
SDL_MINOR_VERSION = 0
SDL_PATCHLEVEL = 1

def SDL_VERSION(x):
    x.major = SDL_MAJOR_VERSION
    x.minor = SDL_MINOR_VERSION
    x.patch = SDL_PATCHLEVEL

SDL_VERSIONNUM = lambda x, y, z: (x * 1000 + y * 100 + z)
SDL_COMPILEDVERSION = SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
SDL_VERSION_ATLEAST = lambda x, y, z: (SDL_COMPILEDVERSION >= SDL_VERSIONNUM(x, y, z))
SDL_GetVersion = _bind("SDL_GetVersion", [POINTER(SDL_version)])
SDL_GetRevision = _bind("SDL_GetRevision", None, c_char_p)
SDL_GetRevisionNumber = _bind("SDL_GetRevisionNumber", None, c_int)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.