SimObject.py (13719:74853963ddcf) | SimObject.py (13764:1647bbdc9444) |
---|---|
1# Copyright (c) 2017-2018 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 868 unchanged lines hidden (view full) --- 877 878def cxxMethod(*args, **kwargs): 879 """Decorator to export C++ functions to Python""" 880 881 def decorate(func): 882 name = func.__name__ 883 override = kwargs.get("override", False) 884 cxx_name = kwargs.get("cxx_name", name) | 1# Copyright (c) 2017-2018 ARM Limited 2# All rights reserved. 3# 4# The license below extends only to copyright in the software and shall 5# not be construed as granting a license to any other intellectual 6# property including but not limited to intellectual property relating 7# to a hardware implementation of the functionality of the software 8# licensed hereunder. You may use the software subject to the license --- 868 unchanged lines hidden (view full) --- 877 878def cxxMethod(*args, **kwargs): 879 """Decorator to export C++ functions to Python""" 880 881 def decorate(func): 882 name = func.__name__ 883 override = kwargs.get("override", False) 884 cxx_name = kwargs.get("cxx_name", name) |
885 return_value_policy = kwargs.get("return_value_policy", None) |
|
885 886 args, varargs, keywords, defaults = inspect.getargspec(func) 887 if varargs or keywords: 888 raise ValueError("Wrapped methods must not contain variable " \ 889 "arguments") 890 891 # Create tuples of (argument, default) 892 if defaults: --- 8 unchanged lines hidden (view full) --- 901 ccobj = self.getCCObject() 902 return getattr(ccobj, name)(*args, **kwargs) 903 904 @wraps(func) 905 def py_call(self, *args, **kwargs): 906 return func(self, *args, **kwargs) 907 908 f = py_call if override else cxx_call | 886 887 args, varargs, keywords, defaults = inspect.getargspec(func) 888 if varargs or keywords: 889 raise ValueError("Wrapped methods must not contain variable " \ 890 "arguments") 891 892 # Create tuples of (argument, default) 893 if defaults: --- 8 unchanged lines hidden (view full) --- 902 ccobj = self.getCCObject() 903 return getattr(ccobj, name)(*args, **kwargs) 904 905 @wraps(func) 906 def py_call(self, *args, **kwargs): 907 return func(self, *args, **kwargs) 908 909 f = py_call if override else cxx_call |
909 f.__pybind = PyBindMethod(name, cxx_name=cxx_name, args=args) | 910 f.__pybind = PyBindMethod(name, cxx_name=cxx_name, args=args, 911 return_value_policy=return_value_policy) |
910 911 return f 912 913 if len(args) == 0: 914 return decorate 915 elif len(args) == 1 and len(kwargs) == 0: 916 return decorate(*args) 917 else: --- 762 unchanged lines hidden --- | 912 913 return f 914 915 if len(args) == 0: 916 return decorate 917 elif len(args) == 1 and len(kwargs) == 0: 918 return decorate(*args) 919 else: --- 762 unchanged lines hidden --- |