forked from M-Labs/artiq
1
0
Fork 0

language/core: pass docstrings through kernel decorator

This commit is contained in:
Sebastien Bourdeauducq 2014-09-30 16:43:00 +08:00
parent 5099643f84
commit 05d8dde412
1 changed files with 3 additions and 0 deletions

View File

@ -2,6 +2,7 @@
from collections import namedtuple as _namedtuple from collections import namedtuple as _namedtuple
from copy import copy as _copy from copy import copy as _copy
from functools import wraps as _wraps
class int64(int): class int64(int):
@ -204,6 +205,7 @@ def kernel(arg):
""" """
if isinstance(arg, str): if isinstance(arg, str):
def real_decorator(k_function): def real_decorator(k_function):
@_wraps(k_function)
def run_on_core(exp, *k_args, **k_kwargs): def run_on_core(exp, *k_args, **k_kwargs):
getattr(exp, arg).run(k_function, ((exp,) + k_args), k_kwargs) getattr(exp, arg).run(k_function, ((exp,) + k_args), k_kwargs)
run_on_core.k_function_info = _KernelFunctionInfo( run_on_core.k_function_info = _KernelFunctionInfo(
@ -211,6 +213,7 @@ def kernel(arg):
return run_on_core return run_on_core
return real_decorator return real_decorator
else: else:
@_wraps(arg)
def run_on_core(exp, *k_args, **k_kwargs): def run_on_core(exp, *k_args, **k_kwargs):
exp.core.run(arg, ((exp,) + k_args), k_kwargs) exp.core.run(arg, ((exp,) + k_args), k_kwargs)
run_on_core.k_function_info = _KernelFunctionInfo( run_on_core.k_function_info = _KernelFunctionInfo(