sync pyglet
This commit is contained in:
parent
dd5dca1099
commit
05ac9871da
@ -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.
|
||||||
|
Loading…
Reference in New Issue
Block a user