Python: Fix importing .gb or .gba before .core

This commit is contained in:
Vicki Pfau 2017-07-16 23:22:43 -07:00
parent f4c4be7b12
commit 69c068c551
2 changed files with 12 additions and 9 deletions

View File

@ -1,3 +1,7 @@
0.6.1: (Future)
Bugfixes:
- Python: Fix importing .gb or .gba before .core
0.6.0: (2017-07-16)
Features:
- Library view

View File

@ -39,6 +39,12 @@ def needsReset(f):
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 @@ class Core(object):
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 @@ class Core(object):
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