Get the meta class inheritance right.

This commit is contained in:
Jeremy Hylton 2002-07-12 15:42:10 +00:00
parent 58e2ff2e81
commit 98013be797
1 changed files with 6 additions and 5 deletions

View File

@ -4,6 +4,11 @@ from new import function
class EiffelBaseMetaClass(type):
def __new__(meta, name, bases, dict):
meta.convert_methods(dict)
return super(EiffelBaseMetaClass, meta).__new__(meta, name, bases,
dict)
def convert_methods(cls, dict):
"""Replace functions in dict with EiffelMethod wrappers.
@ -30,10 +35,6 @@ class EiffelBaseMetaClass(type):
class EiffelMetaClass1(EiffelBaseMetaClass):
# an implementation of the "eiffel" meta class that uses nested functions
def __new__(meta, name, bases, dict):
meta.convert_methods(dict)
return super(EiffelMetaClass1, meta).__new__(meta, name, bases, dict)
def make_eiffel_method(func, pre, post):
def method(self, *args, **kwargs):
if pre:
@ -80,7 +81,7 @@ class EiffelDescriptor(object):
self._post(inst, x, *args, **kwargs)
return x
class EiffelMetaClass2(EiffelMetaClass1):
class EiffelMetaClass2(EiffelBaseMetaClass):
# an implementation of the "eiffel" meta class that uses descriptors
make_eiffel_method = EiffelDescriptor