Python: Fix importing .gb or .gba before .core
Vicki Pfau vi@endrift.com
Sun, 16 Jul 2017 23:22:43 -0700
2 files changed,
12 insertions(+),
9 deletions(-)
M
src/platform/python/mgba/core.py
→
src/platform/python/mgba/core.py
@@ -39,6 +39,12 @@ return f(self, *args, **kwargs)
return wrapper class Core(object): + if hasattr(lib, 'PLATFORM_GBA'): + PLATFORM_GBA = lib.PLATFORM_GBA + + if hasattr(lib, 'PLATFORM_GB'): + PLATFORM_GB = lib.PLATFORM_GB + def __init__(self, native): self._core = native self._wasReset = False@@ -54,8 +60,10 @@ success = bool(core.init(core))
if not success: raise RuntimeError("Failed to initialize core") if hasattr(cls, 'PLATFORM_GBA') and core.platform(core) == cls.PLATFORM_GBA: + from .gba import GBA return GBA(core) if hasattr(cls, 'PLATFORM_GB') and core.platform(core) == cls.PLATFORM_GB: + from .gb import GB return GB(core) return Core(core)@@ -151,12 +159,3 @@ def getGameCode(self):
code = ffi.new("char[12]") self._core.getGameCode(self._core, code) return ffi.string(code, 12).decode("ascii") - -if hasattr(lib, 'PLATFORM_GBA'): - from .gba import GBA - Core.PLATFORM_GBA = lib.PLATFORM_GBA - -if hasattr(lib, 'PLATFORM_GB'): - from .gb import GB - from .lr35902 import LR35902Core - Core.PLATFORM_GB = lib.PLATFORM_GB