Anonymous avatar Anonymous committed e8d567d

Workaround broken SDL_image framework on OS X

Comments (0)

Files changed (1)

 from ctypes import *
 
 import SDL.dll
+import SDL.error
 import SDL.rwops
 import SDL.version
 import SDL.video
     return_type=c_int)
 
 
-IMG_isXV = _dll.function('IMG_isXV',
-    '''Detect if a seekable source is a XV image.
+if hasattr(_dll._dll, 'IMG_isXV'):
+    IMG_isXV = _dll.function('IMG_isXV',
+        '''Detect if a seekable source is a XV image.
 
-    :Parameters:
-        `src` : `SDL_RWops`
-            Source RWops to inspect.
-    
-    :rtype: int
-    :since: SDL_image 1.2.5
-    ''',
-    args=['src'],
-    arg_types=[POINTER(SDL.rwops.SDL_RWops)],
-    return_type=c_int,
-    since=(1,2,5))
+        :Parameters:
+            `src` : `SDL_RWops`
+                Source RWops to inspect.
+        
+        :rtype: int
+        :since: SDL_image 1.2.5
+        ''',
+        args=['src'],
+        arg_types=[POINTER(SDL.rwops.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 ' + \
+            'SDL_image does not define IMG_isXV'
 
 IMG_LoadBMP_RW = _dll.function('IMG_LoadBMP_RW',
     '''Load a BMP image from an SDL data source.
     dereference_return=True,
     require_return=True)
 
-IMG_LoadXV_RW = _dll.function('IMG_LoadXV_RW',
-    '''Load a XV image from an SDL data source.
+if hasattr(_dll._dll, 'IMG_LoadXV_RW'):
+    IMG_LoadXV_RW = _dll.function('IMG_LoadXV_RW',
+        '''Load a XV image from an SDL data source.
 
-    :Parameters:
-        `src` : `SDL_RWops`
-            Source RWops to load from.
+        :Parameters:
+            `src` : `SDL_RWops`
+                Source RWops to load from.
 
-    :rtype: `SDL_Surface`
-    :since: SDL_image 1.2.5
-    ''',
-    args=['src'],
-    arg_types=[POINTER(SDL.rwops.SDL_RWops)],
-    return_type=POINTER(SDL.video.SDL_Surface),
-    dereference_return=True,
-    require_return=True,
-    since=(1,2,5))
+        :rtype: `SDL_Surface`
+        :since: SDL_image 1.2.5
+        ''',
+        args=['src'],
+        arg_types=[POINTER(SDL.rwops.SDL_RWops)],
+        return_type=POINTER(SDL.video.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 ' + \
+            'SDL_image does not define IMG_LoadXV_RW'
 
 # IMG_ReadXPMFromArray cannot be implemented.
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.