Source

pysdl-cffi / sdl / __init__.py

Full commit
from __future__ import (print_function, division, absolute_import)

from ._sdl import *
from .internal import SDLError 

################################################################################

def SDL_Init(*args):
    result = _SDL_Init(*args)
    SDL_ClearError()
    return result

def SDL_GetError():
    return _ffi.string(_SDL_GetError()) 

def SDL_PollEvent():
    event = _ffi.new('SDL_Event *')
    if not _SDL_PollEvent(event):
        return None
    return event

def SDL_GetWindowSize(window):
    w = _ffi.new('int *')
    h = _ffi.new('int *')
    _SDL_GetWindowSize(window, w, h)
    return w[0], h[0]

def SDL_GetMouseState():
    x = _ffi.new('int *')
    y = _ffi.new('int *')
    state = _SDL_GetMouseState(x, y)
    return state, x[0], y[0]

def SDL_GetCurrentDisplayMode(displayIndex):
    mode = _ffi.new('SDL_DisplayMode *')
    result = _SDL_GetCurrentDisplayMode(displayIndex, mode)
    if result == 0:
        return mode

def SDL_GetDisplayMode(displayIndex, modeIndex):
    mode = _ffi.new('SDL_DisplayMode *')
    result = _SDL_GetDisplayMode(displayIndex, modeIndex, mode)
    if result == 0:
        return mode

def SDL_GetDesktopDisplayMode():
    mode = _ffi.new('SDL_DisplayMode *')
    result = _SDL_GetDesktopDisplayMode(displayIndex, mode)
    if result == 0:
        return mode

def SDL_GL_GetAttribute(attr):
    value = _ffi.new('int *')
    _SDL_GL_GetAttribute(attr, value)
    return value[0]

################################################################################

# add wrapped functions
_module_names = set(locals().keys())
def get_mangled_names():
    for name in UNMANGLED_EXPORTS:
        mangled_name = name.lstrip('_')
        if mangled_name in _module_names:
            yield mangled_name
        else:
            yield name 
__all__ = [
    'SDLError',
] + EXPORTS + list(get_mangled_names())
del _module_names