python: Teach cxxMethod how to set return_value_policy.
authorGabe Black <gabeblack@google.com>
Thu, 7 Mar 2019 08:28:50 +0000 (00:28 -0800)
committerGabe Black <gabeblack@google.com>
Thu, 14 Mar 2019 21:04:29 +0000 (21:04 +0000)
This is passed through to the underlying call to PyBindMethod.

Change-Id: Ib46c55664ba0707464bb84e137a0fad817aea1bb
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17034
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>

src/python/m5/SimObject.py

index 7f19c0776465a424163b3cb430dd2cb43587be31..97f6847396a7d1ed7d3472e390594c8226abe712 100644 (file)
@@ -882,6 +882,7 @@ def cxxMethod(*args, **kwargs):
         name = func.__name__
         override = kwargs.get("override", False)
         cxx_name = kwargs.get("cxx_name", name)
+        return_value_policy = kwargs.get("return_value_policy", None)
 
         args, varargs, keywords, defaults = inspect.getargspec(func)
         if varargs or keywords:
@@ -906,7 +907,8 @@ def cxxMethod(*args, **kwargs):
             return func(self, *args, **kwargs)
 
         f = py_call if override else cxx_call
-        f.__pybind = PyBindMethod(name, cxx_name=cxx_name, args=args)
+        f.__pybind = PyBindMethod(name, cxx_name=cxx_name, args=args,
+                                  return_value_policy=return_value_policy)
 
         return f