Compare commits
3 Commits
804dbfc992
...
cc5dec9122
Author | SHA1 | Date | |
---|---|---|---|
cc5dec9122 | |||
05ac9871da | |||
dd5dca1099 |
@ -148,11 +148,8 @@ class InterfacePtrMeta(type(ctypes.POINTER(COMInterface))):
|
|||||||
return super(InterfacePtrMeta, cls).__new__(cls, name, bases, dct)
|
return super(InterfacePtrMeta, cls).__new__(cls, name, bases, dct)
|
||||||
|
|
||||||
|
|
||||||
# pyglet.util.with_metaclass does not work here, as the base class is from _ctypes.lib
|
class pInterface(ctypes.POINTER(COMInterface), metaclass=InterfacePtrMeta):
|
||||||
# See https://wiki.python.org/moin/PortingToPy3k/BilingualQuickRef
|
"""Base COM interface pointer."""
|
||||||
pInterface = InterfacePtrMeta(str('Interface'),
|
|
||||||
(ctypes.POINTER(COMInterface),),
|
|
||||||
{'__doc__': 'Base COM interface pointer.'})
|
|
||||||
|
|
||||||
|
|
||||||
class COMInterfaceMeta(type):
|
class COMInterfaceMeta(type):
|
||||||
|
@ -3,7 +3,6 @@ from enum import Enum, auto
|
|||||||
from typing import Dict, Optional
|
from typing import Dict, Optional
|
||||||
|
|
||||||
from pyglet import event
|
from pyglet import event
|
||||||
from pyglet.util import with_metaclass
|
|
||||||
|
|
||||||
|
|
||||||
class DeviceState(Enum):
|
class DeviceState(Enum):
|
||||||
@ -37,7 +36,7 @@ class AudioDevice:
|
|||||||
self.__class__.__name__, self.name, self.platform_state[self.state].name, self.platform_flow[self.flow].name)
|
self.__class__.__name__, self.name, self.platform_state[self.state].name, self.platform_flow[self.flow].name)
|
||||||
|
|
||||||
|
|
||||||
class AbstractAudioDeviceManager(with_metaclass(ABCMeta, event.EventDispatcher, object)):
|
class AbstractAudioDeviceManager(event.EventDispatcher, metaclass=ABCMeta):
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
"""Required to remove handlers before exit, as it can cause problems with the event system's weakrefs."""
|
"""Required to remove handlers before exit, as it can cause problems with the event system's weakrefs."""
|
||||||
|
@ -4,10 +4,9 @@ import weakref
|
|||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
import pyglet
|
import pyglet
|
||||||
from pyglet.util import with_metaclass
|
|
||||||
|
|
||||||
|
|
||||||
class AbstractAudioPlayer(with_metaclass(ABCMeta)):
|
class AbstractAudioPlayer(metaclass=ABCMeta):
|
||||||
"""Base class for driver audio players.
|
"""Base class for driver audio players.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
@ -176,7 +175,7 @@ class AbstractAudioPlayer(with_metaclass(ABCMeta)):
|
|||||||
self._source = weakref.proxy(value)
|
self._source = weakref.proxy(value)
|
||||||
|
|
||||||
|
|
||||||
class AbstractAudioDriver(with_metaclass(ABCMeta)):
|
class AbstractAudioDriver(metaclass=ABCMeta):
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def create_audio_player(self, source, player):
|
def create_audio_player(self, source, player):
|
||||||
pass
|
pass
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
from pyglet.util import with_metaclass
|
|
||||||
|
|
||||||
|
class AbstractListener(metaclass=ABCMeta):
|
||||||
class AbstractListener(with_metaclass(ABCMeta, object)):
|
|
||||||
"""The listener properties for positional audio.
|
"""The listener properties for positional audio.
|
||||||
|
|
||||||
You can obtain the singleton instance of this class by calling
|
You can obtain the singleton instance of this class by calling
|
||||||
|
@ -31,37 +31,6 @@ def asstr(s):
|
|||||||
return s.decode("utf-8")
|
return s.decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
def with_metaclass(meta, *bases):
|
|
||||||
"""
|
|
||||||
Function from jinja2/_compat.py. License: BSD.
|
|
||||||
Use it like this::
|
|
||||||
class BaseForm:
|
|
||||||
pass
|
|
||||||
class FormType(type):
|
|
||||||
pass
|
|
||||||
class Form(with_metaclass(FormType, BaseForm)):
|
|
||||||
pass
|
|
||||||
This requires a bit of explanation: the basic idea is to make a
|
|
||||||
dummy metaclass for one level of class instantiation that replaces
|
|
||||||
itself with the actual metaclass. Because of internal type checks
|
|
||||||
we also need to make sure that we downgrade the custom metaclass
|
|
||||||
for one level to something closer to type (that's why __call__ and
|
|
||||||
__init__ comes back from type etc.).
|
|
||||||
This has the advantage over six.with_metaclass of not introducing
|
|
||||||
dummy classes into the final MRO.
|
|
||||||
"""
|
|
||||||
class MetaClass(meta):
|
|
||||||
__call__ = type.__call__
|
|
||||||
__init__ = type.__init__
|
|
||||||
|
|
||||||
def __new__(cls, name, this_bases, d):
|
|
||||||
if this_bases is None:
|
|
||||||
return type.__new__(cls, name, (), d)
|
|
||||||
return meta(name, bases, d)
|
|
||||||
|
|
||||||
return MetaClass('temporary_class', None, {})
|
|
||||||
|
|
||||||
|
|
||||||
def debug_print(enabled_or_option='debug'):
|
def debug_print(enabled_or_option='debug'):
|
||||||
"""Get a debug printer that is enabled based on a boolean input or a pyglet option.
|
"""Get a debug printer that is enabled based on a boolean input or a pyglet option.
|
||||||
The debug print function returned should be used in an assert. This way it can be
|
The debug print function returned should be used in an assert. This way it can be
|
||||||
|
@ -99,7 +99,6 @@ from pyglet import gl
|
|||||||
from pyglet.math import Mat4
|
from pyglet.math import Mat4
|
||||||
from pyglet.event import EventDispatcher
|
from pyglet.event import EventDispatcher
|
||||||
from pyglet.window import key, event
|
from pyglet.window import key, event
|
||||||
from pyglet.util import with_metaclass
|
|
||||||
from pyglet.graphics import shader
|
from pyglet.graphics import shader
|
||||||
|
|
||||||
|
|
||||||
@ -256,7 +255,7 @@ class _WindowMetaclass(type):
|
|||||||
super(_WindowMetaclass, cls).__init__(name, bases, dict)
|
super(_WindowMetaclass, cls).__init__(name, bases, dict)
|
||||||
|
|
||||||
|
|
||||||
class BaseWindow(with_metaclass(_WindowMetaclass, EventDispatcher)):
|
class BaseWindow(EventDispatcher, metaclass=_WindowMetaclass):
|
||||||
"""Platform-independent application window.
|
"""Platform-independent application window.
|
||||||
|
|
||||||
A window is a "heavyweight" object occupying operating system resources.
|
A window is a "heavyweight" object occupying operating system resources.
|
||||||
|
@ -45,6 +45,7 @@ class CompilerHelper(Options):
|
|||||||
|
|
||||||
show_progress: bool = True # --show-progress
|
show_progress: bool = True # --show-progress
|
||||||
show_memory: bool = False # --show-memory
|
show_memory: bool = False # --show-memory
|
||||||
|
remove_output: bool = True # --remove-output
|
||||||
save_xml: bool = False # --xml
|
save_xml: bool = False # --xml
|
||||||
xml_path: Path = Path('build/compile_data.xml')
|
xml_path: Path = Path('build/compile_data.xml')
|
||||||
|
|
||||||
@ -147,6 +148,7 @@ class CompilerHelper(Options):
|
|||||||
_add_cmd(cmd_list, '--disable-ccache' if not self.use_ccache else None)
|
_add_cmd(cmd_list, '--disable-ccache' if not self.use_ccache else None)
|
||||||
_add_cmd(cmd_list, '--show-progress' if self.show_progress else None)
|
_add_cmd(cmd_list, '--show-progress' if self.show_progress else None)
|
||||||
_add_cmd(cmd_list, '--show-memory' if self.show_memory else None)
|
_add_cmd(cmd_list, '--show-memory' if self.show_memory else None)
|
||||||
|
_add_cmd(cmd_list, '--remove-output' if self.remove_output else None)
|
||||||
_add_cmd(cmd_list, '--assume-yes-for-download' if self.download_confirm else None)
|
_add_cmd(cmd_list, '--assume-yes-for-download' if self.download_confirm else None)
|
||||||
_add_cmd(cmd_list, '--run' if self.run_after_build else None)
|
_add_cmd(cmd_list, '--run' if self.run_after_build else None)
|
||||||
_add_cmd(cmd_list, '--enable-console' if self.enable_console else '--disable-console')
|
_add_cmd(cmd_list, '--enable-console' if self.enable_console else '--disable-console')
|
||||||
|
@ -37,7 +37,6 @@ if __name__ == '__main__':
|
|||||||
compiler.output_path = Path('./build/github')
|
compiler.output_path = Path('./build/github')
|
||||||
compiler.python_cmd = 'python'
|
compiler.python_cmd = 'python'
|
||||||
compiler.save_xml = False
|
compiler.save_xml = False
|
||||||
compiler.use_lto = True
|
|
||||||
|
|
||||||
# 检测 --xml 参数
|
# 检测 --xml 参数
|
||||||
if '--xml' in sys.argv:
|
if '--xml' in sys.argv:
|
||||||
@ -47,9 +46,10 @@ if __name__ == '__main__':
|
|||||||
# 检测 --output xx 参数
|
# 检测 --output xx 参数
|
||||||
if '--output' in sys.argv:
|
if '--output' in sys.argv:
|
||||||
# 输入的是输出目录
|
# 输入的是输出目录
|
||||||
compiler.output_path = sys.argv[sys.argv.index('--output') + 1]
|
out_path = sys.argv[sys.argv.index('--output') + 1]
|
||||||
|
compiler.output_path = Path(out_path)
|
||||||
sys.argv.remove('--output')
|
sys.argv.remove('--output')
|
||||||
sys.argv.remove(compiler.output_path)
|
sys.argv.remove(out_path)
|
||||||
|
|
||||||
# 检测 --no-pyglet-opt 参数
|
# 检测 --no-pyglet-opt 参数
|
||||||
pyglet_optimizations = True
|
pyglet_optimizations = True
|
||||||
|
Loading…
Reference in New Issue
Block a user