forked from syndicate-lang/preserves
@extend decorator
This commit is contained in:
parent
e45ff6b020
commit
59bcced776
|
@ -360,6 +360,10 @@ class Compiler:
|
|||
c._set_schema(self.root, module_path, n, d, None, None)
|
||||
ns[n] = c
|
||||
|
||||
# a decorator
|
||||
def extend(cls):
|
||||
return lambda f: setattr(cls, f.__name__, f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
c = Compiler()
|
||||
schema_bin_filename = pathlib.Path(__file__).parent / '../../../schema/schema.bin'
|
||||
|
@ -368,10 +372,11 @@ if __name__ == '__main__':
|
|||
x = Decoder(f.read()).next()
|
||||
print(c.root.schema.Schema.decode(x))
|
||||
|
||||
def m(self, x):
|
||||
@extend(c.root.schema.Schema)
|
||||
def f(self, x):
|
||||
return ['yay', self.embeddedType, x]
|
||||
c.root.schema.Schema.f = m
|
||||
print(c.root.schema.Schema.decode(x).f(123))
|
||||
print(f)
|
||||
|
||||
print()
|
||||
|
||||
|
|
Loading…
Reference in New Issue