[pypy-svn] r9625 - in pypy: branch/annotation-no-rev-num dist/pypy/objspace
arigo at codespeak.net
arigo at codespeak.net
Fri Mar 4 14:35:19 CET 2005
Author: arigo
Date: Fri Mar 4 14:35:19 2005
New Revision: 9625
Modified:
pypy/branch/annotation-no-rev-num/classdef.py
pypy/dist/pypy/objspace/descroperation.py
Log:
naive support for _mixin_ multiple inheritance
Modified: pypy/branch/annotation-no-rev-num/classdef.py
==============================================================================
--- pypy/branch/annotation-no-rev-num/classdef.py (original)
+++ pypy/branch/annotation-no-rev-num/classdef.py Fri Mar 4 14:35:19 2005
@@ -48,19 +48,28 @@
#self.instantiation_locations = {}
self.cls = cls
self.subdefs = {}
- assert (len(cls.__bases__) <= 1 or
- cls.__bases__[1:] == (object,) # for baseobjspace.Wrappable
- ), "single inheritance only right now: %r" % (cls,)
- if cls.__bases__:
- base = cls.__bases__[0]
- else:
- base = object
+ base = object
+ mixeddict = {}
+ baselist = list(cls.__bases__)
+ baselist.reverse()
+ for b1 in baselist:
+ if b1 is object:
+ continue
+ if getattr(b1, '_mixin_', False):
+ assert b1.__bases__ == () or b1.__bases__ == (object,), (
+ "mixin class %r should have no base" % (b1,))
+ mixeddict.update(b1.__dict__)
+ else:
+ assert base is object, ("multiple inheritance only supported "
+ "with _mixin_: %r" % (cls,))
+ base = b1
+ mixeddict.update(cls.__dict__)
self.basedef = bookkeeper.getclassdef(base)
if self.basedef:
self.basedef.subdefs[cls] = self
# collect the (supposed constant) class attributes
- for name, value in cls.__dict__.items():
+ for name, value in mixeddict.items():
# ignore some special attributes
if name.startswith('_') and not isinstance(value, FunctionType):
continue
Modified: pypy/dist/pypy/objspace/descroperation.py
==============================================================================
--- pypy/dist/pypy/objspace/descroperation.py (original)
+++ pypy/dist/pypy/objspace/descroperation.py Fri Mar 4 14:35:19 2005
@@ -55,6 +55,7 @@
pass # XXX some strange checking maybe
class DescrOperation:
+ _mixin_ = True
def getdict(space, w_obj):
return w_obj.getdict()
More information about the Pypy-commit
mailing list