[pypy-commit] pypy api_func-refactor: Replace body of @cpython_api with a _create_api_func() function

rlamy pypy.commits at gmail.com
Fri Jan 6 09:22:58 EST 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: api_func-refactor
Changeset: r89397:de8be6201edb
Date: 2017-01-06 14:15 +0000
http://bitbucket.org/pypy/pypy/changeset/de8be6201edb/

Log:	Replace body of @cpython_api with a _create_api_func() function

diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -344,6 +344,14 @@
     - set `gil` to "acquire", "release" or "around" to acquire the GIL,
       release the GIL, or both
     """
+    def decorate(func):
+        return _create_api_func(func, argtypes, restype, error, header, gil,
+            result_borrowed, result_is_ll)
+    return decorate
+
+def _create_api_func(
+        func, argtypes, restype, error=_NOT_SPECIFIED, header=DEFAULT_HEADER,
+        gil=None, result_borrowed=False, result_is_ll=False):
     if isinstance(restype, lltype.Typedef):
         real_restype = restype.OF
     else:
@@ -359,7 +367,7 @@
     expect_integer = (isinstance(real_restype, lltype.Primitive) and
                       rffi.cast(restype, 0) == 0)
 
-    def decorate(func):
+    if True:  # preserve indentation
         func._always_inline_ = 'try'
         func_name = func.func_name
         if header is not None:
@@ -466,7 +474,7 @@
             FUNCTIONS_BY_HEADER[header][func_name] = api_function
         INTERPLEVEL_API[func_name] = unwrapper_catch  # used in tests
         return unwrapper  # used in 'normal' RPython code.
-    return decorate
+
 
 def cpython_struct(name, fields, forward=None, level=1):
     configname = name.replace(' ', '__')


More information about the pypy-commit mailing list