diff --git a/src/SDL/__init__.py b/src/m64py/SDL/__init__.py similarity index 80% rename from src/SDL/__init__.py rename to src/m64py/SDL/__init__.py index 53f1359..cb0d9e5 100644 --- a/src/SDL/__init__.py +++ b/src/m64py/SDL/__init__.py @@ -27,26 +27,26 @@ __version__ = '$Id: $' import ctypes import sys -import SDL.dll -from SDL.active import * -from SDL.audio import * -from SDL.cdrom import * -from SDL.constants import * -from SDL.endian import * -from SDL.error import * -from SDL.events import * -from SDL.joystick import * -from SDL.keyboard import * -from SDL.mouse import * -from SDL.quit import * -from SDL.rwops import * -from SDL.timer import * -from SDL.version import * -from SDL.video import * +from .dll import private_function, function +from .active import * +from .audio import * +from .cdrom import * +from .constants import * +from .endian import * +from .error import * +from .events import * +from .joystick import * +from .keyboard import * +from .mouse import * +from .quit import * +from .rwops import * +from .timer import * +from .version import * +from .video import * # SDL.h -_SDL_Init = SDL.dll.private_function('SDL_Init', +_SDL_Init = private_function('SDL_Init', arg_types=[ctypes.c_uint], return_type=ctypes.c_int) @@ -81,7 +81,7 @@ def SDL_Init(flags): SDL.darwin.init() return _SDL_Init(flags) -_SDL_InitSubSystem = SDL.dll.private_function('SDL_InitSubSystem', +_SDL_InitSubSystem = private_function('SDL_InitSubSystem', arg_types=[ctypes.c_uint], return_type=ctypes.c_int) @@ -100,7 +100,7 @@ def SDL_InitSubSystem(flags): SDL.darwin.init() return _SDL_InitSubSystem(flags) -SDL_QuitSubSystem = SDL.dll.function('SDL_QuitSubSystem', +SDL_QuitSubSystem = function('SDL_QuitSubSystem', '''Clean up specific SDL subsystems. :Parameters: @@ -112,7 +112,7 @@ SDL_QuitSubSystem = SDL.dll.function('SDL_QuitSubSystem', arg_types=[ctypes.c_uint], return_type=None) -SDL_WasInit = SDL.dll.function('SDL_WasInit', +SDL_WasInit = function('SDL_WasInit', '''Return a mask of the specified subsystems which have been initialized. @@ -129,7 +129,7 @@ SDL_WasInit = SDL.dll.function('SDL_WasInit', arg_types=[ctypes.c_uint], return_type=ctypes.c_int) -SDL_Quit = SDL.dll.function('SDL_Quit', +SDL_Quit = function('SDL_Quit', '''Clean up all initialized subsystems. You should call this function upon all exit conditions. diff --git a/src/m64py/SDL/__init__.pyc b/src/m64py/SDL/__init__.pyc new file mode 100644 index 0000000..5673f1e Binary files /dev/null and b/src/m64py/SDL/__init__.pyc differ diff --git a/src/SDL/active.py b/src/m64py/SDL/active.py similarity index 90% rename from src/SDL/active.py rename to src/m64py/SDL/active.py index 513fcdc..1820b10 100644 --- a/src/SDL/active.py +++ b/src/m64py/SDL/active.py @@ -8,9 +8,9 @@ __version__ = '$Id: $' from ctypes import * -import SDL.dll +from .dll import function -SDL_GetAppState = SDL.dll.function('SDL_GetAppState', +SDL_GetAppState = function('SDL_GetAppState', '''Return the current state of the application. The return value is a bitwise combination of `SDL_APPMOUSEFOCUS`, diff --git a/src/m64py/SDL/active.pyc b/src/m64py/SDL/active.pyc new file mode 100644 index 0000000..82aeafe Binary files /dev/null and b/src/m64py/SDL/active.pyc differ diff --git a/src/SDL/array.py b/src/m64py/SDL/array.py similarity index 100% rename from src/SDL/array.py rename to src/m64py/SDL/array.py diff --git a/src/m64py/SDL/array.pyc b/src/m64py/SDL/array.pyc new file mode 100644 index 0000000..4e7667c Binary files /dev/null and b/src/m64py/SDL/array.pyc differ diff --git a/src/SDL/audio.py b/src/m64py/SDL/audio.py similarity index 90% rename from src/SDL/audio.py rename to src/m64py/SDL/audio.py index 2ea7153..63703f3 100644 --- a/src/SDL/audio.py +++ b/src/m64py/SDL/audio.py @@ -7,12 +7,11 @@ __docformat__ = 'restructuredtext' __version__ = '$Id: $' from ctypes import * -import sys -import SDL.array -import SDL.constants -import SDL.dll -import SDL.rwops +from .array import SDL_array, to_ctypes +from .constants import AUDIO_U8, AUDIO_S8, AUDIO_U16LSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_S16MSB +from .dll import function, private_function +from .rwops import SDL_RWops, SDL_RWFromFile _SDL_AudioSpec_fn = \ CFUNCTYPE(POINTER(c_ubyte), POINTER(c_ubyte), POINTER(c_ubyte), c_int) @@ -93,7 +92,7 @@ SetPointerType(_SDL_AudioCVT_p, SDL_AudioCVT) # SDL_AudioInit and SDL_AudioQuit marked private -_SDL_AudioDriverName = SDL.dll.private_function('SDL_AudioDriverName', +_SDL_AudioDriverName = private_function('SDL_AudioDriverName', arg_types=[c_char_p, c_int], return_type=c_char_p) @@ -114,18 +113,18 @@ def SDL_AudioDriverName(maxlen=1024): return None def _ctype_audio_format(fmt): - if fmt == SDL.constants.AUDIO_U8: + if fmt == AUDIO_U8: return c_ubyte - elif fmt == SDL.constants.AUDIO_S8: + elif fmt == AUDIO_S8: return c_char - elif fmt in (SDL.constants.AUDIO_U16LSB, SDL.constants.AUDIO_U16MSB): + elif fmt in (AUDIO_U16LSB, AUDIO_U16MSB): return c_ushort - elif fmt in (SDL.constants.AUDIO_S16LSB, SDL.constants.AUDIO_S16MSB): + elif fmt in (AUDIO_S16LSB, AUDIO_S16MSB): return c_short else: raise TypeError, 'Unsupported format %r' % fmt -_SDL_OpenAudio = SDL.dll.private_function('SDL_OpenAudio', +_SDL_OpenAudio = private_function('SDL_OpenAudio', arg_types=[POINTER(SDL_AudioSpec), POINTER(SDL_AudioSpec)], return_type=c_int, error_return=-1) @@ -202,7 +201,7 @@ def SDL_OpenAudio(desired, obtained): ctype = [_ctype_audio_format(desired.format)] # List, so mutable def cb(data, stream, len): - ar = SDL.array.SDL_array(stream, len/sizeof(ctype[0]), ctype[0]) + ar = SDL_array(stream, len/sizeof(ctype[0]), ctype[0]) callback(userdata, ar) desired._callback = _SDL_AudioSpec_fn(cb) @@ -212,7 +211,7 @@ def SDL_OpenAudio(desired, obtained): obtained.callback = desired.callback ctype[0] = _ctype_audio_format(obtained.format) -SDL_GetAudioStatus = SDL.dll.function('SDL_GetAudioStatus', +SDL_GetAudioStatus = function('SDL_GetAudioStatus', '''Get the current audio state. :rtype: int @@ -222,7 +221,7 @@ SDL_GetAudioStatus = SDL.dll.function('SDL_GetAudioStatus', arg_types=[], return_type=c_int) -SDL_PauseAudio = SDL.dll.function('SDL_PauseAudio', +SDL_PauseAudio = function('SDL_PauseAudio', '''Pause and unpause the audio callback processing. It should be called with a parameter of 0 after opening the audio @@ -238,8 +237,8 @@ SDL_PauseAudio = SDL.dll.function('SDL_PauseAudio', arg_types=[c_int], return_type=None) -_SDL_LoadWAV_RW = SDL.dll.private_function('SDL_LoadWAV_RW', - arg_types=[POINTER(SDL.rwops.SDL_RWops), +_SDL_LoadWAV_RW = private_function('SDL_LoadWAV_RW', + arg_types=[POINTER(SDL_RWops), c_int, POINTER(SDL_AudioSpec), POINTER(POINTER(c_ubyte)), @@ -272,7 +271,7 @@ def SDL_LoadWAV_RW(src, freesrc): _SDL_LoadWAV_RW(src, freesrc, spec, byref(audio_buf), byref(audio_len)) ctype = _ctype_audio_format(spec.format) return (spec, - SDL.array.SDL_array(audio_buf, audio_len.value/sizeof(ctype), ctype)) + SDL_array(audio_buf, audio_len.value/sizeof(ctype), ctype)) def SDL_LoadWAV(file): '''Load a WAVE from a file. @@ -283,9 +282,9 @@ def SDL_LoadWAV(file): :rtype: (`SDL_AudioSpec`, `SDL_array`) :see: `SDL_LoadWAV_RW` ''' - return SDL_LoadWAV_RW(SDL.rwops.SDL_RWFromFile(file, 'rb'), 1) + return SDL_LoadWAV_RW(SDL_RWFromFile(file, 'rb'), 1) -_SDL_FreeWAV = SDL.dll.private_function('SDL_FreeWAV', +_SDL_FreeWAV = private_function('SDL_FreeWAV', arg_types=[POINTER(c_ubyte)], return_type=None) @@ -299,7 +298,7 @@ def SDL_FreeWAV(audio_buf): ''' _SDL_FreeWAV(audio_buf.as_bytes().as_ctypes()) -_SDL_BuildAudioCVT = SDL.dll.private_function('SDL_BuildAudioCVT', +_SDL_BuildAudioCVT = private_function('SDL_BuildAudioCVT', arg_types=[POINTER(SDL_AudioCVT), c_ushort, c_ubyte, c_uint, c_ushort, c_ubyte, c_uint], return_type=c_int, @@ -328,7 +327,7 @@ def SDL_BuildAudioCVT(src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate) return cvt -SDL_ConvertAudio = SDL.dll.function('SDL_ConvertAudio', +SDL_ConvertAudio = function('SDL_ConvertAudio', '''Convert audio data in-place. Once you have initialized the 'cvt' structure using @@ -354,7 +353,7 @@ SDL_ConvertAudio = SDL.dll.function('SDL_ConvertAudio', arg_types=[POINTER(SDL_AudioCVT)], return_type=c_int) -_SDL_MixAudio = SDL.dll.private_function('SDL_MixAudio', +_SDL_MixAudio = private_function('SDL_MixAudio', arg_types=[POINTER(c_ubyte), POINTER(c_ubyte), c_uint, c_int], return_type=None) @@ -378,15 +377,15 @@ def SDL_MixAudio(dst, src, length, volume): - `volume`: int ''' - dstref, dst = SDL.array.to_ctypes(dst, len(dst), c_ubyte) - srcref, src = SDL.array.to_ctypes(src, len(src), c_ubyte) + dstref, dst = to_ctypes(dst, len(dst), c_ubyte) + srcref, src = to_ctypes(src, len(src), c_ubyte) if len(dst) < length: raise TypeError, 'Destination buffer too small' elif len(src) < length: raise TypeError, 'Source buffer too small' _SDL_MixAudio(dst, src, length, volume) -SDL_LockAudio = SDL.dll.function('SDL_LockAudio', +SDL_LockAudio = function('SDL_LockAudio', '''Guarantee the callback function is not running. The lock manipulated by these functions protects the callback function. @@ -398,7 +397,7 @@ SDL_LockAudio = SDL.dll.function('SDL_LockAudio', arg_types=[], return_type=None) -SDL_UnlockAudio = SDL.dll.function('SDL_UnlockAudio', +SDL_UnlockAudio = function('SDL_UnlockAudio', '''Release the audio callback lock. :see: `SDL_LockAudio` @@ -407,7 +406,7 @@ SDL_UnlockAudio = SDL.dll.function('SDL_UnlockAudio', arg_types=[], return_type=None) -SDL_CloseAudio = SDL.dll.function('SDL_CloseAudio', +SDL_CloseAudio = function('SDL_CloseAudio', '''Shut down audio processing and close the audio device. ''', args=[], diff --git a/src/m64py/SDL/audio.pyc b/src/m64py/SDL/audio.pyc new file mode 100644 index 0000000..14a4ccd Binary files /dev/null and b/src/m64py/SDL/audio.pyc differ diff --git a/src/SDL/cdrom.py b/src/m64py/SDL/cdrom.py similarity index 89% rename from src/SDL/cdrom.py rename to src/m64py/SDL/cdrom.py index 95b4d2d..1934d43 100644 --- a/src/SDL/cdrom.py +++ b/src/m64py/SDL/cdrom.py @@ -12,8 +12,8 @@ __version__ = '$Id: $' from ctypes import * -import SDL.constants -import SDL.dll +from .constants import SDL_MAX_TRACKS, CD_FPS +from .dll import function class SDL_CDtrack(Structure): '''Structure describing a single CD track. @@ -61,7 +61,7 @@ class SDL_CD(Structure): ('numtracks', c_int), ('cur_track', c_int), ('cur_frame', c_int), - ('track', SDL_CDtrack * (SDL.constants.SDL_MAX_TRACKS + 1))] + ('track', SDL_CDtrack * (SDL_MAX_TRACKS + 1))] def CD_INDRIVE(status): '''Given a status, returns True if there's a disk in the drive. @@ -82,8 +82,8 @@ def FRAMES_TO_MSF(frames): :rtype: (int, int, int) :return: tuple of (minutes, seconds, frames) ''' - F = frames % SDL.constants.CD_FPS - frames /= SDL.constants.CD_FPS + F = frames % CD_FPS + frames /= CD_FPS S = frames % 60 frames /= 60 M = frames @@ -99,9 +99,9 @@ def MSF_TO_FRAMES(minutes, seconds, frames): :rtype: int ''' - return SDL.constants.CD_FPS(minutes * 60 + seconds) + frames + return CD_FPS(minutes * 60 + seconds) + frames -SDL_CDNumDrives = SDL.dll.function('SDL_CDNumDrives', +SDL_CDNumDrives = function('SDL_CDNumDrives', '''Return the number of CD-ROM drives on the system. :rtype: int @@ -111,7 +111,7 @@ SDL_CDNumDrives = SDL.dll.function('SDL_CDNumDrives', return_type=c_int, error_return=-1) -SDL_CDName = SDL.dll.function('SDL_CDName', +SDL_CDName = function('SDL_CDName', '''Return a human-readable, system-dependent identifier for the CD-ROM. @@ -133,7 +133,7 @@ SDL_CDName = SDL.dll.function('SDL_CDName', return_type=c_char_p, require_return=True) -SDL_CDOpen = SDL.dll.function('SDL_CDOpen', +SDL_CDOpen = function('SDL_CDOpen', '''Open a CD-ROM drive for access. It returns a drive handle on success, or raises an exception if the @@ -155,7 +155,7 @@ SDL_CDOpen = SDL.dll.function('SDL_CDOpen', dereference_return=True, require_return=True) -SDL_CDStatus = SDL.dll.function('SDL_CDStatus', +SDL_CDStatus = function('SDL_CDStatus', '''Return the current status of the given drive. If the drive has a CD in it, the table of contents of the CD and @@ -178,7 +178,7 @@ SDL_CDStatus = SDL.dll.function('SDL_CDStatus', return_type=int, error_return=-1) -SDL_CDPlayTracks = SDL.dll.function('SDL_CDPlayTracks', +SDL_CDPlayTracks = function('SDL_CDPlayTracks', '''Play the given CD. Plays the given CD starting at `start_track` and `start_frame` for @@ -214,7 +214,7 @@ SDL_CDPlayTracks = SDL.dll.function('SDL_CDPlayTracks', return_type=c_int, error_return=-1) -SDL_CDPlay = SDL.dll.function('SDL_CDPlay', +SDL_CDPlay = function('SDL_CDPlay', '''Play the given CD. Plays the given CD starting at `start` frame for `length` frames. @@ -230,7 +230,7 @@ SDL_CDPlay = SDL.dll.function('SDL_CDPlay', return_type=c_int, error_return=-1) -SDL_CDPause = SDL.dll.function('SDL_CDPause', +SDL_CDPause = function('SDL_CDPause', '''Pause play. :Parameters: @@ -242,7 +242,7 @@ SDL_CDPause = SDL.dll.function('SDL_CDPause', return_type=c_int, error_return=-1) -SDL_CDResume = SDL.dll.function('SDL_CDResume', +SDL_CDResume = function('SDL_CDResume', '''Resume play. :Parameters: @@ -254,7 +254,7 @@ SDL_CDResume = SDL.dll.function('SDL_CDResume', return_type=c_int, error_return=-1) -SDL_CDStop = SDL.dll.function('SDL_CDStop', +SDL_CDStop = function('SDL_CDStop', '''Stop play. :Parameters: @@ -266,7 +266,7 @@ SDL_CDStop = SDL.dll.function('SDL_CDStop', return_type=c_int, error_return=-1) -SDL_CDEject = SDL.dll.function('SDL_CDEject', +SDL_CDEject = function('SDL_CDEject', '''Eject CD-ROM. :Parameters: @@ -278,7 +278,7 @@ SDL_CDEject = SDL.dll.function('SDL_CDEject', return_type=c_int, error_return=-1) -SDL_CDClose = SDL.dll.function('SDL_CDClose', +SDL_CDClose = function('SDL_CDClose', '''Close the handle for the CD-ROM drive. :Parameters: diff --git a/src/m64py/SDL/cdrom.pyc b/src/m64py/SDL/cdrom.pyc new file mode 100644 index 0000000..caab60d Binary files /dev/null and b/src/m64py/SDL/cdrom.pyc differ diff --git a/src/SDL/constants.py b/src/m64py/SDL/constants.py similarity index 100% rename from src/SDL/constants.py rename to src/m64py/SDL/constants.py diff --git a/src/m64py/SDL/constants.pyc b/src/m64py/SDL/constants.pyc new file mode 100644 index 0000000..446af72 Binary files /dev/null and b/src/m64py/SDL/constants.pyc differ diff --git a/src/SDL/darwin.py b/src/m64py/SDL/darwin.py similarity index 95% rename from src/SDL/darwin.py rename to src/m64py/SDL/darwin.py index 334ed90..79a9fb2 100644 --- a/src/SDL/darwin.py +++ b/src/m64py/SDL/darwin.py @@ -17,8 +17,8 @@ from AppKit import * import objc import MacOS -import SDL.dll -import SDL.events +from .dll import version_compatible +from .events import SDL_Event, SDL_PushEvent __all__ = ['init'] @@ -47,14 +47,14 @@ def setupWindowMenu(app): # Used to cleanly terminate class SDLAppDelegate(NSObject): def applicationShouldTerminate_(self, app): - event = SDL.events.SDL_Event() + event = SDL_Event() event.type = SDL_QUIT - SDL.events.SDL_PushEvent(event) + SDL_PushEvent(event) return NSTerminateLater def windowUpdateNotification_(self, notification): win = notification.object() - if not SDL.dll.version_compatible((1, 2, 8)) and isinstance(win, objc.lookUpClass('SDL_QuartzWindow')): + if not version_compatible((1, 2, 8)) and isinstance(win, objc.lookUpClass('SDL_QuartzWindow')): # Seems to be a retain count bug in SDL.. workaround! win.retain() NSNotificationCenter.defaultCenter().removeObserver_name_object_( diff --git a/src/SDL/dll.py b/src/m64py/SDL/dll.py similarity index 92% rename from src/SDL/dll.py rename to src/m64py/SDL/dll.py index 0ac3bd7..0f65127 100644 --- a/src/SDL/dll.py +++ b/src/m64py/SDL/dll.py @@ -82,8 +82,8 @@ class SDL_DLL: def assert_version_compatible(self, name, since): '''Raises an exception if `since` is later than the loaded library.''' if not version_compatible(since): - import SDL.error - raise SDL.error.SDL_NotImplementedError, \ + from .error import SDL_NotImplementedError + raise SDL_NotImplementedError, \ '%s requires SDL version %s; currently using version %s' % \ (name, _version_string(since), _version_string(self._version)) @@ -145,8 +145,8 @@ class SDL_DLL: # Check for version compatibility first if since and not self.version_compatible(since): def _f(*args, **kwargs): - import SDL.error - raise SDL.error.SDL_NotImplementedError, \ + from .error import SDL_NotImplementedError + raise SDL_NotImplementedError, \ '%s requires %s %s; currently using version %s' % \ (name, self.library_name, _version_string(since), _version_string(self._version)) @@ -171,8 +171,8 @@ class SDL_DLL: result = func(*args, **kwargs) if result: return result.contents - import SDL.error - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + from .error import SDL_Exception, SDL_GetError + raise SDL_Exception, SDL_GetError() else: # Construct a function which dereferences the pointer result, # or returns None if NULL is returned. @@ -187,8 +187,8 @@ class SDL_DLL: def _f(*args, **kwargs): result = func(*args, **kwargs) if result != success_return: - import SDL.error - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + from .error import SDL_Exception, SDL_GetError + raise SDL_Exception, SDL_GetError() return result elif error_return is not None: # Construct a function which returns None, but raises an exception @@ -196,8 +196,8 @@ class SDL_DLL: def _f(*args, **kwargs): result = func(*args, **kwargs) if result == error_return: - import SDL.error - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + from .error import SDL_Exception, SDL_GetError + raise SDL_Exception, SDL_GetError() return result elif require_return: # Construct a function which returns the usual result, or returns @@ -205,8 +205,8 @@ class SDL_DLL: def _f(*args, **kwargs): result = func(*args, **kwargs) if not result: - import SDL.error - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + from .error import SDL_Exception, SDL_GetError + raise SDL_Exception, SDL_GetError() return result else: # Construct a function which returns the C function's return diff --git a/src/m64py/SDL/dll.pyc b/src/m64py/SDL/dll.pyc new file mode 100644 index 0000000..04f84a9 Binary files /dev/null and b/src/m64py/SDL/dll.pyc differ diff --git a/src/SDL/endian.py b/src/m64py/SDL/endian.py similarity index 87% rename from src/SDL/endian.py rename to src/m64py/SDL/endian.py index 567f792..0428099 100644 --- a/src/SDL/endian.py +++ b/src/m64py/SDL/endian.py @@ -8,7 +8,7 @@ __version__ = '$Id: $' import sys -import SDL.constants +from .constants import SDL_BIG_ENDIAN, SDL_LIL_ENDIAN def SDL_Swap16(x): return (x << 8 & 0xff00) | \ @@ -28,7 +28,7 @@ def _noop(x): return x if sys.byteorder == 'big': - SDL_BYTEORDER = SDL.constants.SDL_BIG_ENDIAN + SDL_BYTEORDER = SDL_BIG_ENDIAN SDL_SwapLE16 = SDL_Swap16 SDL_SwapLE32 = SDL_Swap32 SDL_SwapLE64 = SDL_Swap64 @@ -36,7 +36,7 @@ if sys.byteorder == 'big': SDL_SwapBE32 = _noop SDL_SwapBE64 = _noop else: - SDL_BYTEORDER = SDL.constants.SDL_LIL_ENDIAN + SDL_BYTEORDER = SDL_LIL_ENDIAN SDL_SwapLE16 = _noop SDL_SwapLE32 = _noop SDL_SwapLE64 = _noop diff --git a/src/m64py/SDL/endian.pyc b/src/m64py/SDL/endian.pyc new file mode 100644 index 0000000..494dc47 Binary files /dev/null and b/src/m64py/SDL/endian.pyc differ diff --git a/src/SDL/error.py b/src/m64py/SDL/error.py similarity index 87% rename from src/SDL/error.py rename to src/m64py/SDL/error.py index 8fba72f..972ec20 100644 --- a/src/SDL/error.py +++ b/src/m64py/SDL/error.py @@ -8,7 +8,7 @@ __version__ = '$Id: $' from ctypes import * -import SDL.dll +from .dll import function class SDL_Exception(Exception): '''Exception raised for all SDL errors. @@ -26,7 +26,7 @@ class SDL_NotImplementedError(NotImplementedError): requested function.''' pass -SDL_SetError = SDL.dll.function('SDL_SetError', +SDL_SetError = function('SDL_SetError', '''Set the static error string. :Parameters: @@ -38,7 +38,7 @@ SDL_SetError = SDL.dll.function('SDL_SetError', arg_types=[c_char_p], return_type=None) -SDL_GetError = SDL.dll.function('SDL_GetError', +SDL_GetError = function('SDL_GetError', '''Return the last error string set. :rtype: string @@ -47,7 +47,7 @@ SDL_GetError = SDL.dll.function('SDL_GetError', arg_types=[], return_type=c_char_p) -SDL_ClearError = SDL.dll.function('SDL_ClearError', +SDL_ClearError = function('SDL_ClearError', '''Clear any error string set. ''', args=[], diff --git a/src/m64py/SDL/error.pyc b/src/m64py/SDL/error.pyc new file mode 100644 index 0000000..b5f0624 Binary files /dev/null and b/src/m64py/SDL/error.pyc differ diff --git a/src/SDL/events.py b/src/m64py/SDL/events.py similarity index 87% rename from src/SDL/events.py rename to src/m64py/SDL/events.py index 4d34fef..e388d9c 100644 --- a/src/SDL/events.py +++ b/src/m64py/SDL/events.py @@ -8,9 +8,10 @@ __version__ = '$Id: $' from ctypes import * -import SDL.constants -import SDL.dll -import SDL.keyboard +from .constants import * +from .dll import function, private_function +from .keyboard import SDL_keysym +from .error import SDL_Exception, SDL_GetError class SDL_ActiveEvent(Structure): '''Application visibility event structure. @@ -48,7 +49,7 @@ class SDL_KeyboardEvent(Structure): _fields_ = [('type', c_ubyte), ('which', c_ubyte), ('state', c_ubyte), - ('keysym', SDL.keyboard.SDL_keysym)] + ('keysym', SDL_keysym)] class SDL_MouseMotionEvent(Structure): '''Mouse motion event structure. @@ -279,21 +280,21 @@ class SDL_Event(Union): ('syswm', SDL_SysWMEvent)] types = { - SDL.constants.SDL_ACTIVEEVENT: (SDL_ActiveEvent, 'active'), - SDL.constants.SDL_KEYDOWN: (SDL_KeyboardEvent, 'key'), - SDL.constants.SDL_KEYUP: (SDL_KeyboardEvent, 'key'), - SDL.constants.SDL_MOUSEMOTION: (SDL_MouseMotionEvent, 'motion'), - SDL.constants.SDL_MOUSEBUTTONDOWN: (SDL_MouseButtonEvent, 'button'), - SDL.constants.SDL_MOUSEBUTTONUP: (SDL_MouseButtonEvent, 'button'), - SDL.constants.SDL_JOYAXISMOTION: (SDL_JoyAxisEvent, 'jaxis'), - SDL.constants.SDL_JOYBALLMOTION: (SDL_JoyBallEvent, 'jball'), - SDL.constants.SDL_JOYHATMOTION: (SDL_JoyHatEvent, 'jhat'), - SDL.constants.SDL_JOYBUTTONDOWN: (SDL_JoyButtonEvent, 'jbutton'), - SDL.constants.SDL_JOYBUTTONUP: (SDL_JoyButtonEvent, 'jbutton'), - SDL.constants.SDL_VIDEORESIZE: (SDL_ResizeEvent, 'resize'), - SDL.constants.SDL_VIDEOEXPOSE: (SDL_ExposeEvent, 'expose'), - SDL.constants.SDL_QUIT: (SDL_QuitEvent, 'quit'), - SDL.constants.SDL_SYSWMEVENT: (SDL_SysWMEvent, 'syswm') + SDL_ACTIVEEVENT: (SDL_ActiveEvent, 'active'), + SDL_KEYDOWN: (SDL_KeyboardEvent, 'key'), + SDL_KEYUP: (SDL_KeyboardEvent, 'key'), + SDL_MOUSEMOTION: (SDL_MouseMotionEvent, 'motion'), + SDL_MOUSEBUTTONDOWN: (SDL_MouseButtonEvent, 'button'), + SDL_MOUSEBUTTONUP: (SDL_MouseButtonEvent, 'button'), + SDL_JOYAXISMOTION: (SDL_JoyAxisEvent, 'jaxis'), + SDL_JOYBALLMOTION: (SDL_JoyBallEvent, 'jball'), + SDL_JOYHATMOTION: (SDL_JoyHatEvent, 'jhat'), + SDL_JOYBUTTONDOWN: (SDL_JoyButtonEvent, 'jbutton'), + SDL_JOYBUTTONUP: (SDL_JoyButtonEvent, 'jbutton'), + SDL_VIDEORESIZE: (SDL_ResizeEvent, 'resize'), + SDL_VIDEOEXPOSE: (SDL_ExposeEvent, 'expose'), + SDL_QUIT: (SDL_QuitEvent, 'quit'), + SDL_SYSWMEVENT: (SDL_SysWMEvent, 'syswm') } def __init__(self, typecode=0): @@ -302,7 +303,7 @@ class SDL_Event(Union): def __repr__(self): if self.type in self.types: return self.types[self.type][0].__repr__(self) - elif self.type >= SDL.constants.SDL_USEREVENT: + elif self.type >= SDL_USEREVENT: # SDL_MAXEVENTS not defined return SDL_UserEvent.__repr__(self) return 'SDLEvent(type=%d)' % self.type @@ -315,12 +316,12 @@ class SDL_Event(Union): ''' if self.type in self.types: return getattr(self, self.types[self.type][1]) - elif self.type >= SDL.constants.SDL_USEREVENT: + elif self.type >= SDL_USEREVENT: # SDL_MAXEVENTS not defined return self.user return self -SDL_PumpEvents = SDL.dll.function('SDL_PumpEvents', +SDL_PumpEvents = function('SDL_PumpEvents', '''Pumps the event loop, gathering events from the input devices. This function updates the event queue and internal input device state. @@ -330,7 +331,7 @@ SDL_PumpEvents = SDL.dll.function('SDL_PumpEvents', arg_types=[], return_type=None) -_SDL_PeepEvents = SDL.dll.private_function('SDL_PeepEvents', +_SDL_PeepEvents = private_function('SDL_PeepEvents', arg_types=[POINTER(SDL_Event), c_int, c_int, c_uint], return_type=c_int) @@ -362,12 +363,12 @@ def SDL_PeepEvents(numevents, action, mask): :return: list of SDL_Event (or subclass) :see: `SDL_PushEvent`, `SDL_HaveEvents` ''' - if action == SDL.constants.SDL_ADDEVENT: + if action == SDL_ADDEVENT: raise NotImplementedError, 'Use SDL_PushEvent to add events' ar = (SDL_Event * numevents)() num = _SDL_PeepEvents(ar, numevents, action, mask) if num == -1: - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + raise SDL_Exception, SDL_GetError() return list([e.specialize() for e in ar[:num]]) def SDL_HaveEvents(mask): @@ -384,10 +385,10 @@ def SDL_HaveEvents(mask): :return: True if at least one event matches the mask in the event queue. ''' - num = _SDL_PeepEvents(None, 1, SDL.constants.SDL_PEEKEVENT, mask) + num = _SDL_PeepEvents(None, 1, SDL_PEEKEVENT, mask) return num > 0 -_SDL_PollEvent = SDL.dll.private_function('SDL_PollEvent', +_SDL_PollEvent = private_function('SDL_PollEvent', arg_types=[POINTER(SDL_Event)], return_type=c_int) @@ -415,7 +416,7 @@ def SDL_PollEventAndReturn(): return e.specialize() return None -_SDL_WaitEvent = SDL.dll.private_function('SDL_WaitEvent', +_SDL_WaitEvent = private_function('SDL_WaitEvent', arg_types=[POINTER(SDL_Event)], return_type=c_int) @@ -428,7 +429,7 @@ def SDL_WaitEvent(): :see: `SDL_WaitEventAndReturn` ''' if _SDL_WaitEvent(None) == 0: - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + raise SDL_Exception, SDL_GetError() def SDL_WaitEventAndReturn(): '''Wait indefinitely for the next event and return it. @@ -441,9 +442,9 @@ def SDL_WaitEventAndReturn(): if result == 1: return ev.specialize() else: - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + raise SDL_Exception, SDL_GetError() -SDL_PushEvent = SDL.dll.function('SDL_PushEvent', +SDL_PushEvent = function('SDL_PushEvent', '''Add an event to the event queue. :Parameters: @@ -457,7 +458,7 @@ SDL_PushEvent = SDL.dll.function('SDL_PushEvent', _SDL_EventFilter = CFUNCTYPE(c_int, POINTER(SDL_Event)) -_SDL_SetEventFilter = SDL.dll.private_function('SDL_SetEventFilter', +_SDL_SetEventFilter = private_function('SDL_SetEventFilter', arg_types=[_SDL_EventFilter], return_type=None) @@ -496,7 +497,7 @@ def SDL_SetEventFilter(filter): _eventfilter_ref = _SDL_EventFilter() _SDL_SetEventFilter(_eventfilter_ref) -SDL_GetEventFilter = SDL.dll.function('SDL_GetEventFilter', +SDL_GetEventFilter = function('SDL_GetEventFilter', '''Return the current event filter. This can be used to "chain" filters. If there is no event filter set, @@ -508,7 +509,7 @@ SDL_GetEventFilter = SDL.dll.function('SDL_GetEventFilter', arg_types=[], return_type=_SDL_EventFilter) -SDL_EventState = SDL.dll.function('SDL_EventState', +SDL_EventState = function('SDL_EventState', '''Ignore or enable the processing of certain events. The behaviour of this function depends on `state` diff --git a/src/m64py/SDL/events.pyc b/src/m64py/SDL/events.pyc new file mode 100644 index 0000000..1f5c7c2 Binary files /dev/null and b/src/m64py/SDL/events.pyc differ diff --git a/src/SDL/image.py b/src/m64py/SDL/image.py similarity index 80% rename from src/SDL/image.py rename to src/m64py/SDL/image.py index 6f5f960..4a82579 100644 --- a/src/SDL/image.py +++ b/src/m64py/SDL/image.py @@ -19,13 +19,13 @@ __version__ = '$Id: $' from ctypes import * -import SDL.dll -import SDL.error -import SDL.rwops -import SDL.version -import SDL.video +from .dll import SDL_DLL +from .error import SDL_NotImplementedError +from .rwops import SDL_RWops +from .version import SDL_version +from .video import SDL_Surface -_dll = SDL.dll.SDL_DLL('SDL_image', 'IMG_Linked_Version') +_dll = SDL_DLL('SDL_image', 'IMG_Linked_Version') IMG_Linked_Version = _dll.function('IMG_Linked_Version', '''Get the version of the dynamically linked SDL_image library. @@ -34,7 +34,7 @@ IMG_Linked_Version = _dll.function('IMG_Linked_Version', ''', args=[], arg_types=[], - return_type=POINTER(SDL.version.SDL_version), + return_type=POINTER(SDL_version), dereference_return=True, require_return=True, since=(1,2,5)) @@ -59,8 +59,8 @@ IMG_LoadTyped_RW = _dll.function('IMG_LoadTyped_RW', :rtype: `SDL_Surface` ''', args=['src', 'freesrc', 'type'], - arg_types=[POINTER(SDL.rwops.SDL_RWops), c_int, c_char_p], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops), c_int, c_char_p], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -81,7 +81,7 @@ IMG_Load = _dll.function('IMG_Load', ''', args=['file'], arg_types=[c_char_p], - return_type=POINTER(SDL.video.SDL_Surface), + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -103,8 +103,8 @@ IMG_Load_RW = _dll.function('IMG_Load_RW', :rtype: `SDL_Surface` ''', args=['src', 'freesrc'], - arg_types=[POINTER(SDL.rwops.SDL_RWops), c_int], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops), c_int], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -120,7 +120,7 @@ IMG_isBMP = _dll.function('IMG_isBMP', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) IMG_isGIF = _dll.function('IMG_isGIF', @@ -133,7 +133,7 @@ IMG_isGIF = _dll.function('IMG_isGIF', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -147,7 +147,7 @@ IMG_isJPG = _dll.function('IMG_isJPG', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -161,7 +161,7 @@ IMG_isLBM = _dll.function('IMG_isLBM', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -175,7 +175,7 @@ IMG_isPCX = _dll.function('IMG_isPCX', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -189,7 +189,7 @@ IMG_isPNG = _dll.function('IMG_isPNG', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -203,7 +203,7 @@ IMG_isPNM = _dll.function('IMG_isPNM', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -217,7 +217,7 @@ IMG_isTIF = _dll.function('IMG_isTIF', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -231,7 +231,7 @@ IMG_isXCF = _dll.function('IMG_isXCF', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -245,7 +245,7 @@ IMG_isXPM = _dll.function('IMG_isXPM', :rtype: int ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int) @@ -261,13 +261,13 @@ if hasattr(_dll._dll, 'IMG_isXV'): :since: SDL_image 1.2.5 ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], + arg_types=[POINTER(SDL_RWops)], return_type=c_int, since=(1,2,5)) else: # Broken build of SDL_image 1.2.5 on OS X does define xv.c symbols def IMG_isXV(src): - raise SDL.error.SDL_NotImplementedError, 'Linked version of ' + \ + raise SDL_NotImplementedError, 'Linked version of ' + \ 'SDL_image does not define IMG_isXV' IMG_LoadBMP_RW = _dll.function('IMG_LoadBMP_RW', @@ -280,8 +280,8 @@ IMG_LoadBMP_RW = _dll.function('IMG_LoadBMP_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -295,8 +295,8 @@ IMG_LoadGIF_RW = _dll.function('IMG_LoadGIF_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -310,8 +310,8 @@ IMG_LoadJPG_RW = _dll.function('IMG_LoadJPG_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -325,8 +325,8 @@ IMG_LoadLBM_RW = _dll.function('IMG_LoadLBM_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -340,8 +340,8 @@ IMG_LoadPCX_RW = _dll.function('IMG_LoadPCX_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -355,8 +355,8 @@ IMG_LoadPNG_RW = _dll.function('IMG_LoadPNG_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -370,8 +370,8 @@ IMG_LoadPNM_RW = _dll.function('IMG_LoadPNM_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -385,8 +385,8 @@ IMG_LoadTGA_RW = _dll.function('IMG_LoadTGA_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -400,8 +400,8 @@ IMG_LoadTIF_RW = _dll.function('IMG_LoadTIF_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -415,8 +415,8 @@ IMG_LoadXCF_RW = _dll.function('IMG_LoadXCF_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -430,8 +430,8 @@ IMG_LoadXPM_RW = _dll.function('IMG_LoadXPM_RW', :rtype: `SDL_Surface` ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -447,15 +447,15 @@ if hasattr(_dll._dll, 'IMG_LoadXV_RW'): :since: SDL_image 1.2.5 ''', args=['src'], - arg_types=[POINTER(SDL.rwops.SDL_RWops)], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[POINTER(SDL_RWops)], + return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True, since=(1,2,5)) else: # Broken build of SDL_image 1.2.5 on OS X does define xv.c symbols def IMG_LoadXV_RW(src): - raise SDL.error.SDL_NotImplementedError, 'Linked version of ' + \ + raise SDL_NotImplementedError, 'Linked version of ' + \ 'SDL_image does not define IMG_LoadXV_RW' # IMG_ReadXPMFromArray cannot be implemented. diff --git a/src/SDL/joystick.py b/src/m64py/SDL/joystick.py similarity index 83% rename from src/SDL/joystick.py rename to src/m64py/SDL/joystick.py index 0b9ac57..3b70b99 100644 --- a/src/SDL/joystick.py +++ b/src/m64py/SDL/joystick.py @@ -10,15 +10,14 @@ __version__ = '$Id: $' from ctypes import * -import SDL.constants -import SDL.dll +from .dll import function, private_function class _SDL_Joystick(Structure): _fields_ = [('_dummy', c_void_p)] SDL_Joystick_p = POINTER(_SDL_Joystick) -SDL_NumJoysticks = SDL.dll.function('SDL_NumJoysticks', +SDL_NumJoysticks = function('SDL_NumJoysticks', '''Count the number of joysticks attached to the system. :rtype: int @@ -27,7 +26,7 @@ SDL_NumJoysticks = SDL.dll.function('SDL_NumJoysticks', arg_types=[], return_type=c_int) -SDL_JoystickName = SDL.dll.function('SDL_JoystickName', +SDL_JoystickName = function('SDL_JoystickName', '''Get the implementation dependent name of a joystick. This can be called before any joysticks are opened. If no name can be @@ -42,7 +41,7 @@ SDL_JoystickName = SDL.dll.function('SDL_JoystickName', arg_types=[c_int], return_type=c_char_p) -SDL_JoystickOpen = SDL.dll.function('SDL_JoystickOpen', +SDL_JoystickOpen = function('SDL_JoystickOpen', '''Open a joystick for use. The index passed as an argument refers to the N'th joystick on the @@ -61,7 +60,7 @@ SDL_JoystickOpen = SDL.dll.function('SDL_JoystickOpen', return_type=SDL_Joystick_p, require_return=True) -SDL_JoystickOpened = SDL.dll.function('SDL_JoystickOpened', +SDL_JoystickOpened = function('SDL_JoystickOpened', '''Determine if a joystick has been opened. :Parameters: @@ -74,7 +73,7 @@ SDL_JoystickOpened = SDL.dll.function('SDL_JoystickOpened', arg_types=[c_int], return_type=c_int) -SDL_JoystickIndex = SDL.dll.function('SDL_JoystickIndex', +SDL_JoystickIndex = function('SDL_JoystickIndex', '''Get the device index of an opened joystick. :Parameters: @@ -86,7 +85,7 @@ SDL_JoystickIndex = SDL.dll.function('SDL_JoystickIndex', arg_types=[SDL_Joystick_p], return_type=c_int) -SDL_JoystickNumAxes = SDL.dll.function('SDL_JoystickNumAxes', +SDL_JoystickNumAxes = function('SDL_JoystickNumAxes', '''Get the number of general axis controls on a joystick. :Parameters: @@ -98,7 +97,7 @@ SDL_JoystickNumAxes = SDL.dll.function('SDL_JoystickNumAxes', arg_types=[SDL_Joystick_p], return_type=c_int) -SDL_JoystickNumBalls = SDL.dll.function('SDL_JoystickNumBalls', +SDL_JoystickNumBalls = function('SDL_JoystickNumBalls', '''Get the number of trackballs on a joystick. Joystick trackballs have only relative motion events associated with @@ -113,7 +112,7 @@ SDL_JoystickNumBalls = SDL.dll.function('SDL_JoystickNumBalls', arg_types=[SDL_Joystick_p], return_type=c_int) -SDL_JoystickNumHats = SDL.dll.function('SDL_JoystickNumHats', +SDL_JoystickNumHats = function('SDL_JoystickNumHats', '''Get the number of POV hats on a joystick. :Parameters: @@ -125,7 +124,7 @@ SDL_JoystickNumHats = SDL.dll.function('SDL_JoystickNumHats', arg_types=[SDL_Joystick_p], return_type=c_int) -SDL_JoystickNumButtons = SDL.dll.function('SDL_JoystickNumButtons', +SDL_JoystickNumButtons = function('SDL_JoystickNumButtons', '''Get the number of buttons on a joystick. :Parameters: @@ -137,7 +136,7 @@ SDL_JoystickNumButtons = SDL.dll.function('SDL_JoystickNumButtons', arg_types=[SDL_Joystick_p], return_type=c_int) -SDL_JoystickUpdate = SDL.dll.function('SDL_JoystickUpdate', +SDL_JoystickUpdate = function('SDL_JoystickUpdate', '''Update the current state of the open joysticks. This is called automatically by the event loop if any joystick events @@ -147,7 +146,7 @@ SDL_JoystickUpdate = SDL.dll.function('SDL_JoystickUpdate', arg_types=[], return_type=None) -SDL_JoystickEventState = SDL.dll.function('SDL_JoystickEventState', +SDL_JoystickEventState = function('SDL_JoystickEventState', '''Enable/disable joystick event polling. If joystick events are disabled, you must call `SDL_JoystickUpdate` @@ -166,7 +165,7 @@ SDL_JoystickEventState = SDL.dll.function('SDL_JoystickEventState', return_type=c_int) -SDL_JoystickGetAxis = SDL.dll.function('SDL_JoystickGetAxis', +SDL_JoystickGetAxis = function('SDL_JoystickGetAxis', '''Get the current state of an axis control on a joystick. The axis indices start at index 0. @@ -182,7 +181,7 @@ SDL_JoystickGetAxis = SDL.dll.function('SDL_JoystickGetAxis', arg_types=[SDL_Joystick_p, c_int], return_type=c_short) -SDL_JoystickGetHat = SDL.dll.function('SDL_JoystickGetHat', +SDL_JoystickGetHat = function('SDL_JoystickGetHat', '''Get the current state of POV hat on a joystick. The hat indices start at index 0. @@ -201,7 +200,7 @@ SDL_JoystickGetHat = SDL.dll.function('SDL_JoystickGetHat', arg_types=[SDL_Joystick_p, c_int], return_type=c_ubyte) -_SDL_JoystickGetBall = SDL.dll.private_function('SDL_JoystickGetBall', +_SDL_JoystickGetBall = private_function('SDL_JoystickGetBall', arg_types=[SDL_Joystick_p, c_int, POINTER(c_int), POINTER(c_int)], return_type=c_int, error_return=-1) @@ -222,7 +221,7 @@ def SDL_JoystickGetBall(joystick, ball): _SDL_JoystickGetBall(joystick, ball, byref(x), byref(y)) return dx.value, dy.value -SDL_JoystickGetButton = SDL.dll.function('SDL_JoystickGetButton', +SDL_JoystickGetButton = function('SDL_JoystickGetButton', '''Get the current state of a button on a joystick. The button indices start at index 0. @@ -238,7 +237,7 @@ SDL_JoystickGetButton = SDL.dll.function('SDL_JoystickGetButton', arg_types=[SDL_Joystick_p, c_int], return_type=c_ubyte) -SDL_JoystickClose = SDL.dll.function('SDL_JoystickClose', +SDL_JoystickClose = function('SDL_JoystickClose', '''Close a joystick previously opened with `SDL_JoystickOpen`. :Parameters: diff --git a/src/m64py/SDL/joystick.pyc b/src/m64py/SDL/joystick.pyc new file mode 100644 index 0000000..b53bf74 Binary files /dev/null and b/src/m64py/SDL/joystick.pyc differ diff --git a/src/SDL/keyboard.py b/src/m64py/SDL/keyboard.py similarity index 89% rename from src/SDL/keyboard.py rename to src/m64py/SDL/keyboard.py index 2236ca8..a2a8914 100644 --- a/src/SDL/keyboard.py +++ b/src/m64py/SDL/keyboard.py @@ -10,7 +10,7 @@ __version__ = '$Id: $' from ctypes import * -import SDL.dll +from .dll import function, private_function class SDL_keysym(Structure): '''Keysym structure @@ -44,7 +44,7 @@ class SDL_keysym(Structure): return unichr(self._unicode) raise AttributeError -SDL_EnableUNICODE = SDL.dll.function('SDL_EnableUNICODE', +SDL_EnableUNICODE = function('SDL_EnableUNICODE', '''Enable or disable Unicode translation of keyboard input. This translation has some overhead, so translation defaults off. @@ -62,7 +62,7 @@ SDL_EnableUNICODE = SDL.dll.function('SDL_EnableUNICODE', arg_types=[c_int], return_type=c_int) -SDL_EnableKeyRepeat = SDL.dll.function('SDL_EnableKeyRepeat', +SDL_EnableKeyRepeat = function('SDL_EnableKeyRepeat', '''Enable keyboard repeat. Keyboard repeat defaults to off. @@ -82,7 +82,7 @@ SDL_EnableKeyRepeat = SDL.dll.function('SDL_EnableKeyRepeat', arg_types=[c_int, c_int], return_type=c_int) -_SDL_GetKeyRepeat = SDL.dll.private_function('SDL_GetKeyRepeat', +_SDL_GetKeyRepeat = private_function('SDL_GetKeyRepeat', arg_types=[POINTER(c_int), POINTER(c_int)], return_type=None, since=(1,2,10)) @@ -99,7 +99,7 @@ def SDL_GetKeyRepeat(): _SDL_GetKeyRepeat(byref(delay), byref(interval)) return delay.value, interval.value -_SDL_GetKeyState = SDL.dll.private_function('SDL_GetKeyState', +_SDL_GetKeyState = private_function('SDL_GetKeyState', arg_types=[POINTER(c_int)], return_type=POINTER(c_ubyte)) @@ -120,7 +120,7 @@ def SDL_GetKeyState(): keystate_ar = cast(keystate, POINTER(c_ubyte * numkeys.value)).contents return list(keystate_ar) -SDL_GetModState = SDL.dll.function('SDL_GetModState', +SDL_GetModState = function('SDL_GetModState', '''Get the current key modifier state. :rtype: int @@ -129,7 +129,7 @@ SDL_GetModState = SDL.dll.function('SDL_GetModState', arg_types=[], return_type=c_int) -SDL_SetModState = SDL.dll.function('SDL_SetModState', +SDL_SetModState = function('SDL_SetModState', '''Set the current key modifier state. This does not change the keyboard state, only the key modifier flags. @@ -142,7 +142,7 @@ SDL_SetModState = SDL.dll.function('SDL_SetModState', arg_types=[c_int], return_type=None) -_SDL_GetKeyName = SDL.dll.private_function('SDL_GetKeyName', +_SDL_GetKeyName = private_function('SDL_GetKeyName', arg_types=[c_int], return_type=c_char_p) diff --git a/src/m64py/SDL/keyboard.pyc b/src/m64py/SDL/keyboard.pyc new file mode 100644 index 0000000..22bb784 Binary files /dev/null and b/src/m64py/SDL/keyboard.pyc differ diff --git a/src/SDL/mixer.py b/src/m64py/SDL/mixer.py similarity index 98% rename from src/SDL/mixer.py rename to src/m64py/SDL/mixer.py index 275b6dd..5030f60 100644 --- a/src/SDL/mixer.py +++ b/src/m64py/SDL/mixer.py @@ -24,19 +24,19 @@ __version__ = '$Id: $' from ctypes import * -import SDL.array -import SDL.dll -import SDL.rwops -import SDL.version +from .array import SDL_array, to_ctypes +from .dll import SDL_DLL +from .rwops import SDL_RWops, SDL_RWFromFile +from .version import SDL_version -_dll = SDL.dll.SDL_DLL('SDL_mixer', 'Mix_Linked_Version') +_dll = SDL_DLL('SDL_mixer', 'Mix_Linked_Version') Mix_Linked_Version = _dll.function('Mix_Linked_Version', '''Get the version of the dynamically linked SDL_mixer library. ''', args=[], arg_types=[], - return_type=POINTER(SDL.version.SDL_version), + return_type=POINTER(SDL_version), dereference_return=True, require_return=True) @@ -61,7 +61,7 @@ class Mix_Chunk(Structure): def __getattr__(self, attr): if attr == 'abuf': - return SDL.array.SDL_array(self._abuf, self.alen, c_ubyte) + return SDL_array(self._abuf, self.alen, c_ubyte) raise AttributeException, attr # opaque type @@ -128,7 +128,7 @@ Mix_LoadWAV_RW = _dll.function('Mix_LoadWAV_RW', :rtype: `Mix_Chunk` ''', args=['src', 'freesrc'], - arg_types=[POINTER(SDL.rwops.SDL_RWops), c_int], + arg_types=[POINTER(SDL_RWops), c_int], return_type=POINTER(Mix_Chunk), dereference_return=True, require_return=True) @@ -142,7 +142,7 @@ def Mix_LoadWAV(file): :rtype: `Mix_Chunk` ''' - return Mix_LoadWAV_RW(SDL.rwops.SDL_RWFromFile(file, 'rb'), 1) + return Mix_LoadWAV_RW(SDL_RWFromFile(file, 'rb'), 1) Mix_LoadMUS = _dll.function('Mix_LoadMUS', '''Load a WAV, MID, OGG, MP3 or MOD file. @@ -188,7 +188,7 @@ def Mix_QuickLoad_WAV(mem): :rtype: `Mix_Chunk` ''' - ref, mem = SDL.array.to_ctypes(mem, len(mem), c_ubyte) + ref, mem = to_ctypes(mem, len(mem), c_ubyte) return _Mix_QuickLoad_WAV(mem) _Mix_QuickLoad_RAW = _dll.private_function('Mix_QuickLoad_RAW', @@ -206,7 +206,7 @@ def Mix_QuickLoad_RAW(mem): :rtype: `Mix_Chunk` ''' l = len(mem) - ref, mem = SDL.array.to_ctypes(mem, len(mem), c_ubyte) + ref, mem = to_ctypes(mem, len(mem), c_ubyte) return _Mix_QuickLoad_RAW(mem, l) Mix_FreeChunk = _dll.function('Mix_FreeChunk', @@ -251,7 +251,7 @@ _Mix_FilterFunc = CFUNCTYPE(None, c_void_p, POINTER(c_ubyte), c_int) def _make_filter(func, udata): if func: def f(ignored, stream, len): - stream = SDL.array.SDL_array(stream, len, c_ubyte) + stream = SDL_array(stream, len, c_ubyte) func(udata, stream) return _Mix_FilterFunc(f) else: @@ -369,7 +369,7 @@ _Mix_EffectFunc = CFUNCTYPE(None, c_int, POINTER(c_ubyte), c_int, c_void_p) def _make_Mix_EffectFunc(func, udata): if func: def f(chan, stream, len, ignored): - stream = SDL.array.SDL_array(stream, len, c_ubyte) + stream = SDL_array(stream, len, c_ubyte) func(chan, stream, udata) return _Mix_EffectFunc(f) else: diff --git a/src/SDL/mouse.py b/src/m64py/SDL/mouse.py similarity index 82% rename from src/SDL/mouse.py rename to src/m64py/SDL/mouse.py index 47d8fb0..b95d191 100644 --- a/src/SDL/mouse.py +++ b/src/m64py/SDL/mouse.py @@ -8,9 +8,10 @@ __version__ = '$Id: $' from ctypes import * -import SDL.array -import SDL.dll -import SDL.video +from .array import SDL_array, to_ctypes +from .dll import function, private_function +from .video import SDL_Rect +from .constants import SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT class SDL_Cursor(Structure): '''Cursor structure. @@ -24,7 +25,7 @@ class SDL_Cursor(Structure): Y coordinate of the tip of the cursor ''' - _fields_ = [('area', SDL.video.SDL_Rect), + _fields_ = [('area', SDL_Rect), ('hot_x', c_short), ('hot_y', c_short), ('_data', POINTER(c_ubyte)), @@ -35,12 +36,12 @@ class SDL_Cursor(Structure): def __getattr__(self, name): w, h = self.area.w, self.area.h if name == 'data': - return SDL.array.SDL_array(self._data, w * h / 8, c_ubyte) + return SDL_array(self._data, w * h / 8, c_ubyte) elif name == 'mask': - return SDL.array.SDL_array(self._mask, w * h / 8, c_ubyte) + return SDL_array(self._mask, w * h / 8, c_ubyte) raise AttributeError, name -_SDL_GetMouseState = SDL.dll.private_function('SDL_GetMouseState', +_SDL_GetMouseState = private_function('SDL_GetMouseState', arg_types=[POINTER(c_int), POINTER(c_int)], return_type=c_ubyte) @@ -64,7 +65,7 @@ def SDL_GetMouseState(): return state, x.value, y.value _SDL_GetRelativeMouseState = \ - SDL.dll.private_function('SDL_GetRelativeMouseState', + private_function('SDL_GetRelativeMouseState', arg_types=[POINTER(c_int), POINTER(c_int)], return_type=c_ubyte) @@ -82,7 +83,7 @@ def SDL_GetRelativeMouseState(): state = _SDL_GetRelativeMouseState(byref(dx), byref(dy)) return state, dx.value, dy.value -SDL_WarpMouse = SDL.dll.function('SDL_WarpMouse', +SDL_WarpMouse = function('SDL_WarpMouse', '''Set the position of the mouse cursor. Generates a mouse motion event. @@ -96,7 +97,7 @@ SDL_WarpMouse = SDL.dll.function('SDL_WarpMouse', arg_types=[c_ushort, c_ushort], return_type=None) -_SDL_CreateCursor = SDL.dll.private_function('SDL_CreateCursor', +_SDL_CreateCursor = private_function('SDL_CreateCursor', arg_types=[POINTER(c_ubyte), POINTER(c_ubyte), c_int, c_int, c_int, c_int], return_type=POINTER(SDL_Cursor), dereference_return=True, @@ -132,11 +133,11 @@ def SDL_CreateCursor(data, mask, w, h, hot_x, hot_y): :rtype: `SDL_Cursor` ''' - dataref, data = SDL.array.to_ctypes(data, len(data), c_ubyte) - maskref, mask = SDL.array.to_ctypes(mask, len(mask), c_ubyte) + dataref, data = to_ctypes(data, len(data), c_ubyte) + maskref, mask = to_ctypes(mask, len(mask), c_ubyte) return _SDL_CreateCursor(data, mask, w, h, hot_x, hot_y) -SDL_SetCursor = SDL.dll.function('SDL_SetCursor', +SDL_SetCursor = function('SDL_SetCursor', '''Set the currently active cursor to the specified one. If the cursor is currently visible, the change will be immediately @@ -150,7 +151,7 @@ SDL_SetCursor = SDL.dll.function('SDL_SetCursor', arg_types=[POINTER(SDL_Cursor)], return_type=None) -SDL_GetCursor = SDL.dll.function('SDL_GetCursor', +SDL_GetCursor = function('SDL_GetCursor', '''Return the currently active cursor. :rtype: `SDL_Cursor` @@ -160,7 +161,7 @@ SDL_GetCursor = SDL.dll.function('SDL_GetCursor', return_type=POINTER(SDL_Cursor), dereference_return=True) -SDL_FreeCursor = SDL.dll.function('SDL_FreeCursor', +SDL_FreeCursor = function('SDL_FreeCursor', '''Deallocate a cursor created with `SDL_CreateCursor` :Parameters: @@ -170,7 +171,7 @@ SDL_FreeCursor = SDL.dll.function('SDL_FreeCursor', arg_types=[POINTER(SDL_Cursor)], return_type=None) -SDL_ShowCursor = SDL.dll.function('SDL_ShowCursor', +SDL_ShowCursor = function('SDL_ShowCursor', '''Toggle whether or not the curosr is shown on the screen. The cursor starts off displayed, but can be turned off. @@ -193,6 +194,6 @@ def SDL_BUTTON(X): ''' return 1 << (X-1) -SDL_BUTTON_LMASK = SDL_BUTTON(SDL.constants.SDL_BUTTON_LEFT) -SDL_BUTTON_MMASK = SDL_BUTTON(SDL.constants.SDL_BUTTON_MIDDLE) -SDL_BUTTON_RMASK = SDL_BUTTON(SDL.constants.SDL_BUTTON_RIGHT) +SDL_BUTTON_LMASK = SDL_BUTTON(SDL_BUTTON_LEFT) +SDL_BUTTON_MMASK = SDL_BUTTON(SDL_BUTTON_MIDDLE) +SDL_BUTTON_RMASK = SDL_BUTTON(SDL_BUTTON_RIGHT) diff --git a/src/m64py/SDL/mouse.pyc b/src/m64py/SDL/mouse.pyc new file mode 100644 index 0000000..08bef00 Binary files /dev/null and b/src/m64py/SDL/mouse.pyc differ diff --git a/src/SDL/quit.py b/src/m64py/SDL/quit.py similarity index 87% rename from src/SDL/quit.py rename to src/m64py/SDL/quit.py index 4fe9d0c..f250f71 100644 --- a/src/SDL/quit.py +++ b/src/m64py/SDL/quit.py @@ -19,12 +19,12 @@ quit events for that signal. __docformat__ = 'restructuredtext' __version__ = '$Id: $' -import SDL.events +from .events import SDL_PumpEvents, SDL_HaveEvents, SDL_QUITMASK def SDL_QuitRequested(): '''Return True if there is a quit event in the event queue. :rtype: bool ''' - SDL.events.SDL_PumpEvents() - return SDL.events.SDL_HaveEvents(SDL.events.SDL_QUITMASK) + SDL_PumpEvents() + return SDL_HaveEvents(SDL_QUITMASK) diff --git a/src/m64py/SDL/quit.pyc b/src/m64py/SDL/quit.pyc new file mode 100644 index 0000000..f8a4470 Binary files /dev/null and b/src/m64py/SDL/quit.pyc differ diff --git a/src/SDL/rwops.py b/src/m64py/SDL/rwops.py similarity index 93% rename from src/SDL/rwops.py rename to src/m64py/SDL/rwops.py index 547e9ef..ce4a263 100644 --- a/src/SDL/rwops.py +++ b/src/m64py/SDL/rwops.py @@ -13,8 +13,8 @@ __version__ = '$Id: $' from ctypes import * -import SDL.dll -import SDL.constants +from .dll import function +from .constants import RW_SEEK_CUR _rwops_p = POINTER('SDL_RWops') _seek_fn = CFUNCTYPE(c_int, _rwops_p, c_int, c_int) @@ -53,7 +53,7 @@ class SDL_RWops(Structure): ('_hidden_mem', _hidden_mem_t)] SetPointerType(_rwops_p, SDL_RWops) -SDL_RWFromFile = SDL.dll.function('SDL_RWFromFile', +SDL_RWFromFile = function('SDL_RWFromFile', '''Create an SDL_RWops structure from a file on disk. :Parameters: @@ -70,7 +70,7 @@ SDL_RWFromFile = SDL.dll.function('SDL_RWFromFile', dereference_return=True, require_return=True) -SDL_RWFromMem = SDL.dll.function('SDL_RWFromMem', +SDL_RWFromMem = function('SDL_RWFromMem', '''Create an SDL_RWops structure from a contiguous region of memory. :Parameters: @@ -85,7 +85,7 @@ SDL_RWFromMem = SDL.dll.function('SDL_RWFromMem', dereference_return=True, require_return=True) -SDL_RWFromConstMem = SDL.dll.function('SDL_RWFromConstMem', +SDL_RWFromConstMem = function('SDL_RWFromConstMem', '''Create an SDL_RWops structure from a contiguous region of memory. :Parameters: @@ -103,7 +103,7 @@ SDL_RWFromConstMem = SDL.dll.function('SDL_RWFromConstMem', since=(1,2,7)) """ These functions shouldn't be useful to Pythoners. -SDL_AllocRW = SDL.dll.function('SDL_AllocRW', +SDL_AllocRW = function('SDL_AllocRW', '''Allocate a blank SDL_Rwops structure. :rtype: `SDL_RWops` @@ -114,7 +114,7 @@ SDL_AllocRW = SDL.dll.function('SDL_AllocRW', dereference_return=True, require_return=True) -SDL_FreeRW = SDL.dll.function('SDL_FreeRW', +SDL_FreeRW = function('SDL_FreeRW', '''Free a SDL_RWops structure. :param area: `SDL_RWops` @@ -178,7 +178,7 @@ def SDL_RWseek(ctx, offset, whence): return ctx.seek(ctx, offset, whence) def SDL_RWtell(ctx): - return ctx.seek(ctx, 0, SDL.constants.RW_SEEK_CUR) + return ctx.seek(ctx, 0, RW_SEEK_CUR) def SDL_RWread(ctx, ptr, size, n): return ctx.read(ctx, ptr, size, n) diff --git a/src/m64py/SDL/rwops.pyc b/src/m64py/SDL/rwops.pyc new file mode 100644 index 0000000..a8a6596 Binary files /dev/null and b/src/m64py/SDL/rwops.pyc differ diff --git a/src/SDL/sound.py b/src/m64py/SDL/sound.py similarity index 98% rename from src/SDL/sound.py rename to src/m64py/SDL/sound.py index 90acafe..df66358 100644 --- a/src/SDL/sound.py +++ b/src/m64py/SDL/sound.py @@ -38,12 +38,11 @@ __version__ = '$Id: $' from ctypes import * -import SDL.array -import SDL.dll -import SDL.rwops -import SDL.version +from .array import SDL_array, to_ctypes +from .dll import SDL_DLL, _version_parts +from .rwops import SDL_RWops -_dll = SDL.dll.SDL_DLL('SDL_sound', None) +_dll = SDL_DLL('SDL_sound', None) class Sound_Version(Structure): '''Version structure. @@ -78,7 +77,7 @@ def Sound_GetLinkedVersion(): return version # Fill in non-standard linked version now, so "since" declarations can work -_dll._version = SDL.dll._version_parts(Sound_GetLinkedVersion()) +_dll._version = _version_parts(Sound_GetLinkedVersion()) class Sound_AudioInfo(Structure): '''Information about an existing sample's format. @@ -167,7 +166,7 @@ class Sound_Sample(Structure): if name == 'decoder': return self._decoder.contents elif name == 'buffer': - return SDL.array.SDL_array(self._buffer, self.buffer_size, c_ubyte) + return SDL_array(self._buffer, self.buffer_size, c_ubyte) raise AttributeError, name Sound_Init = _dll.function('Sound_Init', @@ -319,7 +318,7 @@ Sound_NewSample = _dll.function('Sound_NewSample', :rtype: `Sound_Sample` ''', args=['rw', 'ext', 'desired', 'bufferSize'], - arg_types=[POINTER(SDL.rwops.SDL_RWops), c_char_p, + arg_types=[POINTER(SDL_RWops), c_char_p, POINTER(Sound_AudioInfo), c_uint], return_type=POINTER(Sound_Sample), dereference_return=True, @@ -355,7 +354,7 @@ def Sound_NewSampleFromMem(data, ext, desired, bufferSize): :since: Not yet released in SDL_sound ''' - ref, data = SDL.array.to_ctypes(data, len(data), c_ubyte) + ref, data = to_ctypes(data, len(data), c_ubyte) return _Sound_NewSampleFromMem(data, len(data), ext, desired, bufferSize) Sound_NewSampleFromFile = _dll.function('Sound_NewSampleFromFile', diff --git a/src/SDL/timer.py b/src/m64py/SDL/timer.py similarity index 92% rename from src/SDL/timer.py rename to src/m64py/SDL/timer.py index c897e8b..a850042 100644 --- a/src/SDL/timer.py +++ b/src/m64py/SDL/timer.py @@ -8,9 +8,10 @@ __version__ = '$Id: $' from ctypes import * -import SDL.dll +from .dll import function, private_function +from .error import SDL_Exception, SDL_GetError -SDL_GetTicks = SDL.dll.function('SDL_GetTicks', +SDL_GetTicks = function('SDL_GetTicks', '''Get the number of milliseconds since the SDL library initialization. Note that this value wraps if the program runs for more than ~49 days. @@ -21,7 +22,7 @@ SDL_GetTicks = SDL.dll.function('SDL_GetTicks', arg_types=[], return_type=c_uint) -SDL_Delay = SDL.dll.function('SDL_Delay', +SDL_Delay = function('SDL_Delay', '''Wait a specified number of milliseconds before returning. :Parameters: @@ -34,7 +35,7 @@ SDL_Delay = SDL.dll.function('SDL_Delay', return_type=None) _SDL_TimerCallback = CFUNCTYPE(c_int, c_uint) -_SDL_SetTimer = SDL.dll.private_function('SDL_SetTimer', +_SDL_SetTimer = private_function('SDL_SetTimer', arg_types=[c_uint, _SDL_TimerCallback], return_type=c_int) @@ -92,7 +93,7 @@ def SDL_SetTimer(interval, callback): # XXX if this fails the global ref is incorrect and old one will # possibly be collected early. if _SDL_SetTimer(interval, _timercallback_ref) == -1: - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + raise SDL_Exception, SDL_GetError() # For the new timer functions, the void *param passed to the callback @@ -100,7 +101,7 @@ def SDL_SetTimer(interval, callback): # is not defined, we use c_void_p instead. _SDL_NewTimerCallback = CFUNCTYPE(c_uint, c_int, c_void_p) -_SDL_AddTimer = SDL.dll.private_function('SDL_AddTimer', +_SDL_AddTimer = private_function('SDL_AddTimer', arg_types=[c_uint, _SDL_NewTimerCallback, c_void_p], return_type=c_void_p) @@ -136,11 +137,11 @@ def SDL_AddTimer(interval, callback, param): func = _SDL_NewTimerCallback(_callback) result = _SDL_AddTimer(interval, func, None) if not result: - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + raise SDL_Exception, SDL_GetError() _timer_refs[result] = func return result -_SDL_RemoveTimer = SDL.dll.private_function('SDL_RemoveTimer', +_SDL_RemoveTimer = private_function('SDL_RemoveTimer', args=['t'], arg_types=[c_void_p], return_type=c_int, diff --git a/src/m64py/SDL/timer.pyc b/src/m64py/SDL/timer.pyc new file mode 100644 index 0000000..6299552 Binary files /dev/null and b/src/m64py/SDL/timer.pyc differ diff --git a/src/SDL/ttf.py b/src/m64py/SDL/ttf.py similarity index 92% rename from src/SDL/ttf.py rename to src/m64py/SDL/ttf.py index 94f63cf..dc21147 100644 --- a/src/SDL/ttf.py +++ b/src/m64py/SDL/ttf.py @@ -12,12 +12,12 @@ __version__ = '$Id: $' from ctypes import * -import SDL.dll -import SDL.rwops -import SDL.version -import SDL.video +from .dll import SDL_DLL +from .rwops import SDL_RWops +from .version import SDL_version +from .video import SDL_Color, SDL_Surface -_dll = SDL.dll.SDL_DLL('SDL_ttf', 'TTF_Linked_Version') +_dll = SDL_DLL('SDL_ttf', 'TTF_Linked_Version') TTF_Linked_Version = _dll.function('TTF_Linked_Version', '''Get the version of the dynamically linked SDL_ttf library. @@ -26,7 +26,7 @@ TTF_Linked_Version = _dll.function('TTF_Linked_Version', ''', args=[], arg_types=[], - return_type=POINTER(SDL.version.SDL_version), + return_type=POINTER(SDL_version), dereference_return=True, require_return=True) @@ -93,7 +93,7 @@ TTF_OpenFontRW = _dll.function('TTF_OpenFontRW', :rtype: ``TTF_Font`` ''', args=['src', 'freesrc', 'ptsize'], - arg_types=[POINTER(SDL.rwops.SDL_RWops), c_int, c_int], + arg_types=[POINTER(SDL_RWops), c_int, c_int], return_type=_TTF_Font, require_return=True) @@ -113,7 +113,7 @@ TTF_OpenFontIndexRW = _dll.function('TTF_OpenFontIndexRW', :rtype: ``TTF_Font`` ''', args=['src', 'freesrc', 'ptsize', 'index'], - arg_types=[POINTER(SDL.rwops.SDL_RWops), c_int, c_int, c_int], + arg_types=[POINTER(SDL_RWops), c_int, c_int, c_int], return_type=_TTF_Font, require_return=True) @@ -314,8 +314,8 @@ def TTF_SizeText(font, text): return w.value, h.value _TTF_RenderUTF8_Solid = _dll.private_function('TTF_RenderUTF8_Solid', - arg_types=[_TTF_Font, c_char_p, SDL.video.SDL_Color], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[_TTF_Font, c_char_p, SDL_Color], + return_type=POINTER(SDL_Surface), require_return=True, dereference_return=True) @@ -336,8 +336,8 @@ def TTF_RenderText_Solid(font, text, fg): return _TTF_RenderUTF8_Solid(font, text.encode('utf8'), fg) _TTF_RenderGlyph_Solid = _dll.private_function('TTF_RenderGlyph_Solid', - arg_types=[_TTF_Font, c_ushort, SDL.video.SDL_Color], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[_TTF_Font, c_ushort, SDL_Color], + return_type=POINTER(SDL_Surface), require_return=True, dereference_return=True) @@ -361,8 +361,8 @@ def TTF_RenderGlyph_Solid(font, ch, fg): return _TTF_RenderGlyph_Solid(font, ord(text), fg) _TTF_RenderUTF8_Shaded = _dll.private_function('TTF_RenderUTF8_Shaded', - arg_types=[_TTF_Font, c_char_p, SDL.video.SDL_Color, SDL.video.SDL_Color], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[_TTF_Font, c_char_p, SDL_Color, SDL_Color], + return_type=POINTER(SDL_Surface), require_return=True, dereference_return=True) @@ -384,8 +384,8 @@ def TTF_RenderText_Shaded(font, text, fg, bg): return _TTF_RenderUTF8_Shaded(font, text.encode('utf8'), fg, bg) _TTF_RenderGlyph_Shaded = _dll.private_function('TTF_RenderGlyph_Shaded', - arg_types=[_TTF_Font, c_ushort, SDL.video.SDL_Color, SDL.video.SDL_Color], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[_TTF_Font, c_ushort, SDL_Color, SDL_Color], + return_type=POINTER(SDL_Surface), require_return=True, dereference_return=True) @@ -410,8 +410,8 @@ def TTF_RenderGlyph_Shaded(font, ch, fg, bg): return _TTF_RenderGlyph_Shaded(font, ord(ch), fg, bg) _TTF_RenderUTF8_Blended = _dll.private_function('TTF_RenderUTF8_Blended', - arg_types=[_TTF_Font, c_char_p, SDL.video.SDL_Color], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[_TTF_Font, c_char_p, SDL_Color], + return_type=POINTER(SDL_Surface), require_return=True, dereference_return=True) @@ -430,8 +430,8 @@ def TTF_RenderText_Blended(font, text, fg): return _TTF_RenderUTF8_Blended(font, text.encode('utf8'), fg) _TTF_RenderGlyph_Blended = _dll.private_function('TTF_RenderGlyph_Blended', - arg_types=[_TTF_Font, c_ushort, SDL.video.SDL_Color], - return_type=POINTER(SDL.video.SDL_Surface), + arg_types=[_TTF_Font, c_ushort, SDL_Color], + return_type=POINTER(SDL_Surface), require_return=True, dereference_return=True) diff --git a/src/SDL/version.py b/src/m64py/SDL/version.py similarity index 96% rename from src/SDL/version.py rename to src/m64py/SDL/version.py index 267e31d..16ca301 100644 --- a/src/SDL/version.py +++ b/src/m64py/SDL/version.py @@ -8,7 +8,7 @@ __version__ = '$Id: $' from ctypes import * -import SDL.dll +from .dll import function class SDL_version(Structure): '''Version structure. @@ -57,7 +57,7 @@ def SDL_VERSIONNUM(major, minor, patch): ''' return x * 1000 + y * 100 + z -SDL_Linked_Version = SDL.dll.function('SDL_Linked_Version', +SDL_Linked_Version = function('SDL_Linked_Version', '''Get the version of the dynamically linked SDL library. :rtype: `SDL_version` diff --git a/src/m64py/SDL/version.pyc b/src/m64py/SDL/version.pyc new file mode 100644 index 0000000..0706078 Binary files /dev/null and b/src/m64py/SDL/version.pyc differ diff --git a/src/SDL/video.py b/src/m64py/SDL/video.py similarity index 91% rename from src/SDL/video.py rename to src/m64py/SDL/video.py index 8f82d46..cb41492 100644 --- a/src/SDL/video.py +++ b/src/m64py/SDL/video.py @@ -18,11 +18,11 @@ __version__ = '$Id: $' from ctypes import * -import SDL.array -import SDL.dll -import SDL.error -import SDL.constants -import SDL.rwops +from .array import SDL_array, to_ctypes +from .dll import function, private_function, assert_version_compatible +from .error import SDL_Exception, SDL_GetError +from .constants import SDL_HWSURFACE, SDL_ASYNCBLIT, SDL_RLEACCEL +from .rwops import SDL_RWops, SDL_RWFromFile class SDL_Rect(Structure): '''Rectangle structure. @@ -114,7 +114,7 @@ class SDL_Palette(Structure): def __getattr__(self, name): if name == 'colors': - return SDL.array.SDL_array(self._colors, self.ncolors, SDL_Color) + return SDL_array(self._colors, self.ncolors, SDL_Color) raise AttributeError, name @@ -247,7 +247,7 @@ class SDL_Surface(Structure): elif name == 'pixels': # Return SDL_array type for pixels if not self._pixels: - raise SDL.error.SDL_Exception, 'Surface needs locking' + raise SDL_Exception, 'Surface needs locking' bpp = self.format.BitsPerPixel count = self.pitch / self.format.BytesPerPixel * self.h if bpp == 1: @@ -265,8 +265,8 @@ class SDL_Surface(Structure): elif bpp == 32: sz = c_uint else: - raise SDL.error.SDL_Exception, 'Unsupported bytes-per-pixel' - return SDL.array.SDL_array(self._pixels, count, sz) + raise SDL_Exception, 'Unsupported bytes-per-pixel' + return SDL_array(self._pixels, count, sz) raise AttributeError, name def SDL_MUSTLOCK(surface): @@ -280,9 +280,9 @@ def SDL_MUSTLOCK(surface): ''' return surface._offset or \ ((surface.flags & \ - (SDL.constants.SDL_HWSURFACE | \ - SDL.constants.SDL_ASYNCBLIT | \ - SDL.constants.SDL_RLEACCEL)) != 0) + (SDL_HWSURFACE | \ + SDL_ASYNCBLIT | \ + SDL_RLEACCEL)) != 0) SDL_blit = CFUNCTYPE(c_int, POINTER(SDL_Surface), POINTER(SDL_Rect), POINTER(SDL_Surface), POINTER(SDL_Rect)) @@ -354,7 +354,7 @@ class SDL_VideoInfo(Structure): # current_w and current_h added in SDL 1.2.10 if name in ('current_w', 'current_h'): - SDL.dll.assert_version_compatible(name, (1,2,10)) + assert_version_compatible(name, (1,2,10)) return getattr(self, '_%s' % name) raise AttributeError, name @@ -398,18 +398,18 @@ class SDL_Overlay(Structure): elif name == 'pixels': if not self._pixels: - raise SDL.error.SDL_Exception, 'Overlay needs locking' + raise SDL_Exception, 'Overlay needs locking' p = [] for i in range(self.planes): sz = self.pitches[i] * self.h - p.append(SDL.array.SDL_array(self._pixels[i], sz, c_byte)) + p.append(SDL_array(self._pixels[i], sz, c_byte)) return p # SDL_VideoInit and SDL_VideoQuit not implemented (internal only, according # to SDL_video.h). -_SDL_VideoDriverName = SDL.dll.private_function('SDL_VideoDriverName', +_SDL_VideoDriverName = private_function('SDL_VideoDriverName', arg_types=[c_char_p, c_int], return_type=c_int) @@ -428,7 +428,7 @@ def SDL_VideoDriverName(maxlen=1024): return buf.value return None -SDL_GetVideoSurface = SDL.dll.function('SDL_GetVideoSurface', +SDL_GetVideoSurface = function('SDL_GetVideoSurface', '''Return the current display surface. If SDL is doing format conversion on the display surface, this @@ -440,7 +440,7 @@ SDL_GetVideoSurface = SDL.dll.function('SDL_GetVideoSurface', return_type=POINTER(SDL_Surface), dereference_return=True) -SDL_GetVideoInfo = SDL.dll.function('SDL_GetVideoInfo', +SDL_GetVideoInfo = function('SDL_GetVideoInfo', '''Return information about the video hardware. If this is called before `SDL_SetVideoMode`, the ``vfmt`` member @@ -452,7 +452,7 @@ SDL_GetVideoInfo = SDL.dll.function('SDL_GetVideoInfo', return_type=POINTER(SDL_VideoInfo), dereference_return=True) -SDL_VideoModeOK = SDL.dll.function('SDL_VideoModeOK', +SDL_VideoModeOK = function('SDL_VideoModeOK', '''Check to see if a particular video mode is supported. Returns 0 if the requested mode is not supported under any bit @@ -480,7 +480,7 @@ SDL_VideoModeOK = SDL.dll.function('SDL_VideoModeOK', arg_types=[c_int, c_int, c_int, c_uint], return_type=c_int) -_SDL_ListModes = SDL.dll.private_function('SDL_ListModes', +_SDL_ListModes = private_function('SDL_ListModes', arg_types=[POINTER(SDL_PixelFormat), c_uint], return_type=POINTER(POINTER(SDL_Rect))) @@ -513,7 +513,7 @@ def SDL_ListModes(format, flags): i += 1 return lst -SDL_SetVideoMode = SDL.dll.function('SDL_SetVideoMode', +SDL_SetVideoMode = function('SDL_SetVideoMode', '''Set up a video mode with the specified width, height and bits-per-pixel. @@ -593,7 +593,7 @@ SDL_SetVideoMode = SDL.dll.function('SDL_SetVideoMode', dereference_return=True, require_return=True) -_SDL_UpdateRects = SDL.dll.private_function('SDL_UpdateRects', +_SDL_UpdateRects = private_function('SDL_UpdateRects', arg_types=[POINTER(SDL_Surface), c_int, POINTER(SDL_Rect)], return_type=None) @@ -607,10 +607,10 @@ def SDL_UpdateRects(screen, rects): - `screen`: `SDL_Surface` - `rects`: list of `SDL_Rect` ''' - ref, ar = SDL.array.to_ctypes(rects, len(rects), SDL_Rect) + ref, ar = to_ctypes(rects, len(rects), SDL_Rect) _SDL_UpdateRects(screen, len(rects), ar) -SDL_UpdateRect = SDL.dll.function('SDL_UpdateRect', +SDL_UpdateRect = function('SDL_UpdateRect', '''Make sure that the given rectangle is updated on the given screen. @@ -630,7 +630,7 @@ SDL_UpdateRect = SDL.dll.function('SDL_UpdateRect', arg_types=[POINTER(SDL_Surface), c_int, c_int, c_uint, c_uint], return_type=None) -SDL_Flip = SDL.dll.function('SDL_Flip', +SDL_Flip = function('SDL_Flip', '''Flip the front and back buffers. On hardware that supports double-buffering, this function sets up a @@ -652,7 +652,7 @@ SDL_Flip = SDL.dll.function('SDL_Flip', return_type=c_int, success_return=0) -SDL_SetGamma = SDL.dll.function('SDL_SetGamma', +SDL_SetGamma = function('SDL_SetGamma', '''Set the gamma correction for each of the color channels. The gamma values range (approximately) between 0.1 and 10.0 @@ -671,7 +671,7 @@ SDL_SetGamma = SDL.dll.function('SDL_SetGamma', return_type=c_int, success_return=0) -_SDL_SetGammaRamp = SDL.dll.private_function('SDL_SetGammaRamp', +_SDL_SetGammaRamp = private_function('SDL_SetGammaRamp', arg_types=[POINTER(c_ushort), POINTER(c_ushort), POINTER(c_ushort)], return_type=c_int) @@ -700,16 +700,16 @@ def SDL_SetGammaRamp(red, green, blue): ''' rar = gar = bar = None if red: - rref, rar = SDL.array.to_ctypes(red, 256, c_ushort) + rref, rar = to_ctypes(red, 256, c_ushort) if green: - gref, gar = SDL.array.to_ctypes(green, 256, c_ushort) + gref, gar = to_ctypes(green, 256, c_ushort) if blue: - bref, bar = SDL.array.to_ctypes(blue, 256, c_ushort) + bref, bar = to_ctypes(blue, 256, c_ushort) result = _SDL_SetGammaRamp(rar, gar, bar) if result != 0: - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + raise SDL_Exception, SDL_GetError() -_SDL_GetGammaRamp = SDL.dll.private_function('SDL_GetGammaRamp', +_SDL_GetGammaRamp = private_function('SDL_GetGammaRamp', arg_types=[POINTER(c_ushort), POINTER(c_ushort), POINTER(c_ushort)], return_type=c_int) @@ -721,14 +721,14 @@ def SDL_GetGammaRamp(): is either None (if the display driver doesn't support gamma translation) or an SDL_array of 256 ints in the range [0, 2**16). ''' - rar = SDL.array.SDL_array(None, 256, c_ushort) - gar = SDL.array.SDL_array(None, 256, c_ushort) - bar = SDL.array.SDL_array(None, 256, c_ushort) + rar = SDL_array(None, 256, c_ushort) + gar = SDL_array(None, 256, c_ushort) + bar = SDL_array(None, 256, c_ushort) if _SDL_GetGammaRamp(rar.as_ctypes(), gar.as_ctypes(), bar.as_ctypes()) == 0: return rar, gar, bar return None, None, None -_SDL_SetColors = SDL.dll.private_function('SDL_SetColors', +_SDL_SetColors = private_function('SDL_SetColors', arg_types=[POINTER(SDL_Surface), POINTER(SDL_Color), c_int, c_int], return_type=c_int) @@ -756,10 +756,10 @@ def SDL_SetColors(surface, colors, firstcolor): :rtype: int :return: 1 if all colors were set as passed, otherwise 0. ''' - ref, ar = SDL.array.to_ctypes(colors, len(colors), SDL_Color) + ref, ar = to_ctypes(colors, len(colors), SDL_Color) return _SDL_SetColors(surface, ar, firstcolor, len(colors)) -_SDL_SetPalette = SDL.dll.private_function('SDL_SetPalette', +_SDL_SetPalette = private_function('SDL_SetPalette', arg_types=[POINTER(SDL_Surface), c_int, POINTER(SDL_Color), c_int, c_int], return_type=c_int) @@ -787,12 +787,12 @@ def SDL_SetPalette(surface, flags, colors, firstcolor): - `colors`: sequence or SDL_array of `SDL_Color` - `firstcolor`: int; the first color index to set. ''' - ref, ar = SDL.array.to_ctypes(colors, len(colors), SDL_Color) + ref, ar = to_ctypes(colors, len(colors), SDL_Color) result = _SDL_SetPalette(surface, flags, ar, firstcolor, len(colors)) if result != 1: - raise SDL.error.SDL_Exception, SDL.error.SDL_GetError() + raise SDL_Exception, SDL_GetError() -SDL_MapRGB = SDL.dll.function('SDL_MapRGB', +SDL_MapRGB = function('SDL_MapRGB', '''Map an RGB triple to an opaque pixel value for a given pixel format. @@ -809,7 +809,7 @@ SDL_MapRGB = SDL.dll.function('SDL_MapRGB', arg_types=[POINTER(SDL_PixelFormat), c_ubyte, c_ubyte, c_ubyte], return_type=c_uint) -SDL_MapRGBA = SDL.dll.function('SDL_MapRGBA', +SDL_MapRGBA = function('SDL_MapRGBA', '''Map an RGBA quadruple to an opaque pixel value for a given pixel format. @@ -827,7 +827,7 @@ SDL_MapRGBA = SDL.dll.function('SDL_MapRGBA', arg_types=[POINTER(SDL_PixelFormat), c_ubyte, c_ubyte, c_ubyte, c_ubyte], return_type=c_uint) -_SDL_GetRGB = SDL.dll.private_function('SDL_GetRGB', +_SDL_GetRGB = private_function('SDL_GetRGB', arg_types=[c_uint, POINTER(SDL_PixelFormat), POINTER(c_ubyte), POINTER(c_ubyte), POINTER(c_ubyte)], return_type=None) @@ -848,7 +848,7 @@ def SDL_GetRGB(pixel, fmt): _SDL_GetRGB(pixel, fmt, byref(r), byref(g), byref(b)) return r.value, g.value, b.value -_SDL_GetRGBA = SDL.dll.private_function('SDL_GetRGBA', +_SDL_GetRGBA = private_function('SDL_GetRGBA', arg_types=[c_uint, POINTER(SDL_PixelFormat), POINTER(c_ubyte), POINTER(c_ubyte), POINTER(c_ubyte), POINTER(c_ubyte)], @@ -870,7 +870,7 @@ def SDL_GetRGBA(pixel, fmt): _SDL_GetRGBA(pixel, fmt, byref(r), byref(g), byref(b), byref(a)) return r.value, g.value, b.value, a.value -SDL_CreateRGBSurface = SDL.dll.function('SDL_CreateRGBSurface', +SDL_CreateRGBSurface = function('SDL_CreateRGBSurface', '''Allocate an RGB surface. Must be called after `SDL_SetVideoMode`. If the depth is 4 or 8 @@ -938,7 +938,7 @@ SDL_CreateRGBSurface = SDL.dll.function('SDL_CreateRGBSurface', require_return=True) _SDL_CreateRGBSurfaceFrom = \ - SDL.dll.private_function('SDL_CreateRGBSurfaceFrom', + private_function('SDL_CreateRGBSurfaceFrom', arg_types=[POINTER(c_ubyte), c_int, c_int, c_int, c_uint, c_uint, c_uint, c_uint], return_type=POINTER(SDL_Surface), @@ -981,14 +981,14 @@ def SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, if len(pixels) == pitch * 8 / depth * height: # pixel array? if depth == 8: - ref, ar = SDL.array.to_ctypes(pixels, len(pixels), c_ubyte) + ref, ar = to_ctypes(pixels, len(pixels), c_ubyte) elif depth == 16: - ref, ar = SDL.array.to_ctypes(pixels, len(pixels), c_ushort) + ref, ar = to_ctypes(pixels, len(pixels), c_ushort) elif depth == 32: - ref, ar = SDL.array.to_ctypes(pixels, len(pixels), c_uint) + ref, ar = to_ctypes(pixels, len(pixels), c_uint) elif len(pixels) == pitch * height: # byte array - ref, ar = SDL.array.to_ctypes(pixels, len(pixels), c_ubyte) + ref, ar = to_ctypes(pixels, len(pixels), c_ubyte) else: raise TypeError, 'Length of pixels does not match given dimensions.' @@ -997,7 +997,7 @@ def SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, surface._buffer_ref = ref return surface -SDL_FreeSurface = SDL.dll.function('SDL_FreeSurface', +SDL_FreeSurface = function('SDL_FreeSurface', '''Free an RGB Surface. :Parameters: @@ -1007,7 +1007,7 @@ SDL_FreeSurface = SDL.dll.function('SDL_FreeSurface', arg_types=[POINTER(SDL_Surface)], return_type=None) -SDL_LockSurface = SDL.dll.function('SDL_LockSurface', +SDL_LockSurface = function('SDL_LockSurface', '''Set up a surface for directly accessing the pixels. Between calls to `SDL_LockSurface`/`SDL_UnlockSurface`, you can write @@ -1032,7 +1032,7 @@ SDL_LockSurface = SDL.dll.function('SDL_LockSurface', return_type=c_int, success_return=0) -SDL_UnlockSurface = SDL.dll.function('SDL_UnlockSurface', +SDL_UnlockSurface = function('SDL_UnlockSurface', '''Unlock a surface locked with `SDL_LockSurface`. :Parameters: @@ -1042,7 +1042,7 @@ SDL_UnlockSurface = SDL.dll.function('SDL_UnlockSurface', arg_types=[POINTER(SDL_Surface)], return_type=None) -SDL_LoadBMP_RW = SDL.dll.function('SDL_LoadBMP_RW', +SDL_LoadBMP_RW = function('SDL_LoadBMP_RW', '''Load a surface from a seekable SDL data source (memory or file). If `freesrc` is non-zero, the source will be closed after being read. @@ -1056,7 +1056,7 @@ SDL_LoadBMP_RW = SDL.dll.function('SDL_LoadBMP_RW', :rtype: `SDL_Surface` ''', args=['src', 'freesrc'], - arg_types=[POINTER(SDL.rwops.SDL_RWops), c_int], + arg_types=[POINTER(SDL_RWops), c_int], return_type=POINTER(SDL_Surface), dereference_return=True, require_return=True) @@ -1072,9 +1072,9 @@ def SDL_LoadBMP(file): :rtype: `SDL_Surface` ''' - return SDL_LoadBMP_RW(SDL.rwops.SDL_RWFromFile(file, 'rb'), 1) + return SDL_LoadBMP_RW(SDL_RWFromFile(file, 'rb'), 1) -SDL_SaveBMP_RW = SDL.dll.function('SDL_SaveBMP_RW', +SDL_SaveBMP_RW = function('SDL_SaveBMP_RW', '''Save a surface to a seekable SDL data source (memory or file). If `freedst` is non-zero, the destination will be closed after being @@ -1086,7 +1086,7 @@ SDL_SaveBMP_RW = SDL.dll.function('SDL_SaveBMP_RW', - `freesrc`: int ''', args=['surface', 'dst', 'freedst'], - arg_types=[POINTER(SDL_Surface), POINTER(SDL.rwops.SDL_RWops), c_int], + arg_types=[POINTER(SDL_Surface), POINTER(SDL_RWops), c_int], return_type=c_int, success_return=0) @@ -1100,9 +1100,9 @@ def SDL_SaveBMP(surface, file): - `surface`: `SDL_Surface` - `dst`: `SDL_RWops` ''' - return SDL_SaveBMP_RW(surface, SDL.rwops.SDL_RWFromFile(file, 'wb'), 1) + return SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, 'wb'), 1) -SDL_SetColorKey = SDL.dll.function('SDL_SetColorKey', +SDL_SetColorKey = function('SDL_SetColorKey', '''Set the color key (transparent pixel) in a blittable surface. If `flag` is `SDL_SRCCOLORKEY` (optionally OR'd with `SDL_RLEACCEL`), @@ -1121,7 +1121,7 @@ SDL_SetColorKey = SDL.dll.function('SDL_SetColorKey', return_type=c_int, success_return=0) -SDL_SetAlpha = SDL.dll.function('SDL_SetAlpha', +SDL_SetAlpha = function('SDL_SetAlpha', '''Set the alpha value for the entire surface, as opposed to using the alpha component of each pixel. @@ -1151,7 +1151,7 @@ SDL_SetAlpha = SDL.dll.function('SDL_SetAlpha', arg_types=[POINTER(SDL_Surface), c_uint, c_uint], return_type=c_int) -SDL_SetClipRect = SDL.dll.function('SDL_SetClipRect', +SDL_SetClipRect = function('SDL_SetClipRect', '''Set the clipping rectangle for the destination surface in a blit. If the clip rectangle is None, clipping will be disabled. @@ -1175,7 +1175,7 @@ SDL_SetClipRect = SDL.dll.function('SDL_SetClipRect', arg_types=[POINTER(SDL_Surface), POINTER(SDL_Rect)], return_type=c_int) -_SDL_GetClipRect = SDL.dll.private_function('SDL_GetClipRect', +_SDL_GetClipRect = private_function('SDL_GetClipRect', arg_types=[POINTER(SDL_Surface), POINTER(SDL_Rect)], return_type=None) @@ -1193,7 +1193,7 @@ def SDL_GetClipRect(surface): _SDL_GetClipRect(surface, byref(rect)) return rect -SDL_ConvertSurface = SDL.dll.function('SDL_ConvertSurface', +SDL_ConvertSurface = function('SDL_ConvertSurface', '''Create a new surface of the specified format, then copy and map the given surface to it so the blit of the converted surface will be as fast as possible. @@ -1218,7 +1218,7 @@ SDL_ConvertSurface = SDL.dll.function('SDL_ConvertSurface', dereference_return=True, require_return=True) -SDL_UpperBlit = SDL.dll.function('SDL_UpperBlit', +SDL_UpperBlit = function('SDL_UpperBlit', '''Perform a fast blit from the source surface to the destination surface. @@ -1300,7 +1300,7 @@ SDL_UpperBlit = SDL.dll.function('SDL_UpperBlit', return_type=c_int, error_return=-1) -SDL_BlitSurface = SDL.dll.function('SDL_UpperBlit', +SDL_BlitSurface = function('SDL_UpperBlit', '''Perform a fast blit from the source surface to the destination surface. @@ -1314,7 +1314,7 @@ SDL_BlitSurface = SDL.dll.function('SDL_UpperBlit', return_type=c_int, error_return=-1) -SDL_LowerBlit = SDL.dll.function('SDL_LowerBlit', +SDL_LowerBlit = function('SDL_LowerBlit', '''Low-level fast blit. This is a semi-private blit function that does not perform @@ -1329,7 +1329,7 @@ SDL_LowerBlit = SDL.dll.function('SDL_LowerBlit', return_type=c_int, error_return=-1) -SDL_FillRect = SDL.dll.function('SDL_FillRect', +SDL_FillRect = function('SDL_FillRect', '''Perform a fast fill of the given rectangle with `color`. The given rectangle is clipped to the destination surface clip area @@ -1348,7 +1348,7 @@ SDL_FillRect = SDL.dll.function('SDL_FillRect', return_type=c_int, success_return=0) -SDL_DisplayFormat = SDL.dll.function('SDL_DisplayFormat', +SDL_DisplayFormat = function('SDL_DisplayFormat', '''Copy a surface to the pixel format and colors of the display buffer. @@ -1370,7 +1370,7 @@ SDL_DisplayFormat = SDL.dll.function('SDL_DisplayFormat', dereference_return=True, require_return=True) -SDL_DisplayFormatAlpha = SDL.dll.function('SDL_DisplayFormatAlpha', +SDL_DisplayFormatAlpha = function('SDL_DisplayFormatAlpha', '''Copy a surface to the pixel format and colors of the display buffer. @@ -1393,7 +1393,7 @@ SDL_DisplayFormatAlpha = SDL.dll.function('SDL_DisplayFormatAlpha', dereference_return=True, require_return=True) -SDL_CreateYUVOverlay = SDL.dll.function('SDL_CreateYUVOverlay', +SDL_CreateYUVOverlay = function('SDL_CreateYUVOverlay', '''Create a video output overlay. Calling the returned surface an overlay is something of a misnomer @@ -1434,7 +1434,7 @@ SDL_CreateYUVOverlay = SDL.dll.function('SDL_CreateYUVOverlay', dereference_return=True, require_return=True) -SDL_LockYUVOverlay = SDL.dll.function('SDL_LockYUVOverlay', +SDL_LockYUVOverlay = function('SDL_LockYUVOverlay', '''Lock an overlay for direct access. Unlock the overlay when done with `SDL_UnlockYUVOverlay`. @@ -1449,7 +1449,7 @@ SDL_LockYUVOverlay = SDL.dll.function('SDL_LockYUVOverlay', arg_types=[POINTER(SDL_Overlay)], return_type=c_int) -SDL_UnlockYUVOverlay = SDL.dll.function('SDL_UnlockYUVOverlay', +SDL_UnlockYUVOverlay = function('SDL_UnlockYUVOverlay', '''Unlock an overlay after locking it with `SDL_LockYUVOverlay`. :Parameters: @@ -1459,7 +1459,7 @@ SDL_UnlockYUVOverlay = SDL.dll.function('SDL_UnlockYUVOverlay', arg_types=[POINTER(SDL_Overlay)], return_type=None) -SDL_DisplayYUVOverlay = SDL.dll.function('SDL_DisplayYUVOverlay', +SDL_DisplayYUVOverlay = function('SDL_DisplayYUVOverlay', '''Blit a video overlay to the display surface. The contents of the video surface underneath the blit destination @@ -1478,7 +1478,7 @@ SDL_DisplayYUVOverlay = SDL.dll.function('SDL_DisplayYUVOverlay', arg_types=[POINTER(SDL_Overlay), POINTER(SDL_Rect)], return_type=c_int) -SDL_FreeYUVOverlay = SDL.dll.function('SDL_FreeYUVOverlay', +SDL_FreeYUVOverlay = function('SDL_FreeYUVOverlay', '''Free a video overlay. :Parameters: @@ -1491,7 +1491,7 @@ SDL_FreeYUVOverlay = SDL.dll.function('SDL_FreeYUVOverlay', # SDL_GL_LoadLibrary, SDL_GL_GetProcAddress not implemented. -SDL_GL_SetAttribute = SDL.dll.function('SDL_GL_SetAttribute', +SDL_GL_SetAttribute = function('SDL_GL_SetAttribute', '''Set an attribute of the OpenGL subsystem before initialization. :Parameters: @@ -1505,7 +1505,7 @@ SDL_GL_SetAttribute = SDL.dll.function('SDL_GL_SetAttribute', arg_types=[c_uint, c_int], return_type=c_int) -_SDL_GL_GetAttribute = SDL.dll.private_function('SDL_GL_GetAttribute', +_SDL_GL_GetAttribute = private_function('SDL_GL_GetAttribute', arg_types=[c_int, POINTER(c_int)], return_type=c_int) @@ -1517,7 +1517,7 @@ def SDL_GL_GetAttribute(attr): _SDL_GL_GetAttribute(attr, byref(val)) return val.value -SDL_GL_SwapBuffers = SDL.dll.function('SDL_GL_SwapBuffers', +SDL_GL_SwapBuffers = function('SDL_GL_SwapBuffers', '''Swap the OpenGL buffers, if double-buffering is supported. ''', args=[], @@ -1527,7 +1527,7 @@ SDL_GL_SwapBuffers = SDL.dll.function('SDL_GL_SwapBuffers', # SDL_GL_UpdateRects, SDL_GL_Lock and SDL_GL_Unlock not implemented (marked # private in SDL_video.h) -_SDL_WM_SetCaption = SDL.dll.private_function('SDL_WM_SetCaption', +_SDL_WM_SetCaption = private_function('SDL_WM_SetCaption', arg_types=[c_char_p, c_char_p], return_type=None) @@ -1543,7 +1543,7 @@ def SDL_WM_SetCaption(title, icon): _SDL_WM_SetCaption(title.encode('utf-8'), icon.encode('utf-8')) -_SDL_WM_GetCaption = SDL.dll.private_function('SDL_WM_GetCaption', +_SDL_WM_GetCaption = private_function('SDL_WM_GetCaption', arg_types=[POINTER(c_char_p), POINTER(c_char_p)], return_type=None) @@ -1567,7 +1567,7 @@ def SDL_WM_GetCaption(): icon = None return title, icon -_SDL_WM_SetIcon = SDL.dll.private_function('SDL_WM_SetIcon', +_SDL_WM_SetIcon = private_function('SDL_WM_SetIcon', arg_types=[POINTER(SDL_Surface), POINTER(c_ubyte)], return_type=None) @@ -1585,10 +1585,10 @@ def SDL_WM_SetIcon(icon, mask): ''' if mask: ref, mask = \ - SDL.array.to_ctypes(mask, (icon.w * icon.h + 7) / 8, c_ubyte) + to_ctypes(mask, (icon.w * icon.h + 7) / 8, c_ubyte) _SDL_WM_SetIcon(icon, mask) -SDL_WM_IconifyWindow = SDL.dll.function('SDL_WM_IconifyWindow', +SDL_WM_IconifyWindow = function('SDL_WM_IconifyWindow', '''Iconify the window. If the function succeeds, it generates an `SDL_APPACTIVATE` loss @@ -1599,7 +1599,7 @@ SDL_WM_IconifyWindow = SDL.dll.function('SDL_WM_IconifyWindow', return_type=c_int, error_return=0) -SDL_WM_ToggleFullScreen = SDL.dll.function('SDL_WM_ToggleFullScreen', +SDL_WM_ToggleFullScreen = function('SDL_WM_ToggleFullScreen', '''Toggle fullscreen mode without changing the contents of the screen. @@ -1620,7 +1620,7 @@ SDL_WM_ToggleFullScreen = SDL.dll.function('SDL_WM_ToggleFullScreen', return_type=c_int, error_return=0) -SDL_WM_GrabInput = SDL.dll.function('SDL_WM_GrabInput', +SDL_WM_GrabInput = function('SDL_WM_GrabInput', '''Set the grab mode for the mouse and keyboard. Grabbing means that the mouse is confined to the application window, diff --git a/src/m64py/SDL/video.pyc b/src/m64py/SDL/video.pyc new file mode 100644 index 0000000..47d54cb Binary files /dev/null and b/src/m64py/SDL/video.pyc differ