adding some decorator stuff
This commit is contained in:
parent
6c8e2dfbb8
commit
9f4c4dcf7f
23
metacall.py
Normal file → Executable file
23
metacall.py
Normal file → Executable file
@ -156,3 +156,26 @@ class Token:
|
||||
hash = (hash << 5) + hash + ord(c)
|
||||
|
||||
return hash
|
||||
|
||||
|
||||
#
|
||||
# Descriptor
|
||||
#
|
||||
|
||||
class Descriptor:
|
||||
def __init__(self, name, *types):
|
||||
self.name = name
|
||||
self.types = types
|
||||
|
||||
|
||||
#
|
||||
# callable
|
||||
#
|
||||
|
||||
def callable(*types):
|
||||
def wrapper(func):
|
||||
assert func.func_code.co_argcount == len(types)
|
||||
func.descriptor = Descriptor(func.func_code.co_name, types)
|
||||
return func
|
||||
|
||||
return wrapper
|
||||
|
12
testing.py
Executable file
12
testing.py
Executable file
@ -0,0 +1,12 @@
|
||||
#!/usr/bin/env python2
|
||||
|
||||
import metacall
|
||||
|
||||
@metacall.callable(int, int, int)
|
||||
def test(a, b, c):
|
||||
print 'Hello world'
|
||||
|
||||
|
||||
|
||||
test(1,2,3)
|
||||
test(1,2,3)
|
Loading…
Reference in New Issue
Block a user