Commits

Marcus von Appen committed 7b5b3e0

- synchronized the dll loader codebase with python-utils

Comments (0)

Files changed (5)

 from ctypes import CDLL
 from ctypes.util import find_library
 
-__all__ = ["get_dll_file"]
+__all__ = ["DLL", "nullfunc"]
 
 
 def _findlib(libnames, path=None):
     return results
 
 
-class _DLL(object):
+class DLL(object):
     """Function wrapper around the different DLL functions. Do not use or
     instantiate this one directly from your user code.
     """
         """Gets the filename of the loaded library."""
         return self._libfile
 
+
 def _nonexistent(funcname, func):
     """A simple wrapper to mark functions and methods as nonexistent."""
     def wrapper(*fargs, **kw):
     return wrapper
 
 
-try:
-    dll = _DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
-except RuntimeError as exc:
-    raise ImportError(exc)
-
 def nullfunc(*args):
     """A simple no-op function to be used as dll replacement."""
     return
 
+try:
+    dll = DLL("SDL2", ["SDL2", "SDL2-2.0"], os.getenv("PYSDL2_DLL_PATH"))
+except RuntimeError as exc:
+    raise ImportError(exc)
+
 def get_dll_file():
     """Gets the file name of the loaded SDL2 library."""
     return dll.libfile
 import os
 from ctypes import Structure, POINTER, c_int, c_float, c_void_p, c_char, \
     c_char_p, c_double
-from .dll import _DLL
+from .dll import DLL
 from .stdinc import Uint8, Uint32, Sint16
 from .render import SDL_Renderer
 from .surface import SDL_Surface
            ]
 
 try:
-    dll = _DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"],
-               os.getenv("PYSDL2_DLL_PATH"))
+    dll = DLL("SDL2_gfx", ["SDL2_gfx", "SDL2_gfx-1.0"],
+              os.getenv("PYSDL2_DLL_PATH"))
 except RuntimeError as exc:
     raise ImportError(exc)
 
 import os
 from ctypes import POINTER, c_int, c_char_p
-from .dll import _DLL
+from .dll import DLL
 from .version import SDL_version
 from .surface import SDL_Surface
 from .rwops import SDL_RWops
            ]
 
 try:
-    dll = _DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"],
-               os.getenv("PYSDL2_DLL_PATH"))
+    dll = DLL("SDL2_image", ["SDL2_image", "SDL2_image-2.0"],
+              os.getenv("PYSDL2_DLL_PATH"))
 except RuntimeError as exc:
     raise ImportError(exc)
 
 import os
 from ctypes import Structure, POINTER, CFUNCTYPE, c_int, c_char_p, c_void_p, \
     c_double
-from .dll import _DLL
+from .dll import DLL
 from .version import SDL_version
 from .audio import AUDIO_S16LSB, AUDIO_S16MSB
 from .stdinc import Uint8, Uint16, Uint32, Sint16
           ]
 
 try:
-    dll = _DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"],
-               os.getenv("PYSDL2_DLL_PATH"))
+    dll = DLL("SDL2_mixer", ["SDL2_mixer", "SDL2_mixer-2.0"],
+              os.getenv("PYSDL2_DLL_PATH"))
 except RuntimeError as exc:
     raise ImportError(exc)
 
 import os
 from ctypes import Structure, POINTER, c_int, c_long, c_char_p
-from .dll import _DLL
+from .dll import DLL
 from .version import SDL_version
 from .rwops import SDL_RWops
 from .stdinc import Uint16, Uint32
           ]
 
 try:
-    dll = _DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
-               os.getenv("PYSDL2_DLL_PATH"))
+    dll = DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
+              os.getenv("PYSDL2_DLL_PATH"))
 except RuntimeError as exc:
     raise ImportError(exc)