[pypy-commit] pypy py3.5: hg merge default

rlamy pypy.commits at gmail.com
Mon Jul 3 13:50:32 EDT 2017


Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: py3.5
Changeset: r91671:d5cde34e0278
Date: 2017-07-03 18:49 +0100
http://bitbucket.org/pypy/pypy/changeset/d5cde34e0278/

Log:	hg merge default

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
@@ -459,13 +459,15 @@
     return decorate
 
 def api_func_from_cdef(func, cdef, cts,
-        error=_NOT_SPECIFIED, header=DEFAULT_HEADER):
+        error=_NOT_SPECIFIED, header=DEFAULT_HEADER,
+        result_is_ll=False):
     func._always_inline_ = 'try'
     cdecl = cts.parse_func(cdef)
     RESULT = cdecl.get_llresult(cts)
     api_function = ApiFunction(
         cdecl.get_llargs(cts), RESULT, func,
-        error=_compute_error(error, RESULT), cdecl=cdecl)
+        error=_compute_error(error, RESULT), cdecl=cdecl,
+        result_is_ll=result_is_ll)
     FUNCTIONS_BY_HEADER[header][cdecl.name] = api_function
     unwrapper = api_function.get_unwrapper()
     unwrapper.func = func
@@ -670,10 +672,12 @@
 
 
 class CpyextTypeSpace(CTypeSpace):
-    def decl(self, cdef, error=_NOT_SPECIFIED, header=DEFAULT_HEADER):
+    def decl(self, cdef, error=_NOT_SPECIFIED, header=DEFAULT_HEADER,
+            result_is_ll=False):
         def decorate(func):
             return api_func_from_cdef(
-                    func, cdef, self, error=error, header=header)
+                func, cdef, self, error=error, header=header,
+                result_is_ll=result_is_ll)
         return decorate
 
 
diff --git a/pypy/module/cpyext/include/memoryobject.h b/pypy/module/cpyext/include/memoryobject.h
--- a/pypy/module/cpyext/include/memoryobject.h
+++ b/pypy/module/cpyext/include/memoryobject.h
@@ -5,14 +5,7 @@
 extern "C" {
 #endif
 
-/* The struct is declared here but it shouldn't
-   be considered public. Don't access those fields directly,
-   use the functions instead! */
-typedef struct {
-    PyObject_HEAD
-    Py_buffer view;
-} PyMemoryViewObject;
-
+#include "cpyext_memoryobject.h"
 
 /* Get a pointer to the memoryview's private copy of the exporter's buffer. */
 #define PyMemoryView_GET_BUFFER(op) (&((PyMemoryViewObject *)(op))->view)
diff --git a/pypy/module/cpyext/memoryobject.py b/pypy/module/cpyext/memoryobject.py
--- a/pypy/module/cpyext/memoryobject.py
+++ b/pypy/module/cpyext/memoryobject.py
@@ -1,11 +1,8 @@
-from rpython.rlib.objectmodel import keepalive_until_here
-from pypy.interpreter.error import oefmt
 from pypy.module.cpyext.api import (
-    cpython_api, Py_buffer, CANNOT_FAIL, Py_MAX_FMT, Py_MAX_NDIMS,
-    build_type_checkers, Py_ssize_tP, PyObjectFields, cpython_struct,
-    bootstrap_function, Py_bufferP, slot_function, generic_cpy_call)
+    cpython_api, CANNOT_FAIL, Py_MAX_FMT, Py_MAX_NDIMS, build_type_checkers,
+    Py_ssize_tP, cts, parse_dir, bootstrap_function, Py_bufferP, slot_function)
 from pypy.module.cpyext.pyobject import (
-    PyObject, make_ref, as_pyobj, decref, from_ref, make_typedescr,
+    PyObject, make_ref, decref, from_ref, make_typedescr,
     get_typedescr, track_reference)
 from rpython.rtyper.lltypesystem import lltype, rffi
 from rpython.rlib.rarithmetic import widen
@@ -14,17 +11,12 @@
 from pypy.module.cpyext.object import _dealloc
 from pypy.module.cpyext.import_ import PyImport_Import
 
+cts.parse_header(parse_dir / 'cpyext_memoryobject.h')
+PyMemoryViewObject = cts.gettype('PyMemoryViewObject*')
+
 PyMemoryView_Check, PyMemoryView_CheckExact = build_type_checkers("MemoryView")
 
 
-PyMemoryViewObjectStruct = lltype.ForwardReference()
-PyMemoryViewObject = lltype.Ptr(PyMemoryViewObjectStruct)
-PyMemoryViewObjectFields = PyObjectFields + \
-    (("view", Py_buffer),)
-cpython_struct(
-    "PyMemoryViewObject", PyMemoryViewObjectFields, PyMemoryViewObjectStruct,
-    level=2)
-
 @bootstrap_function
 def init_memoryobject(space):
     "Type description of PyDictObject"
@@ -33,7 +25,7 @@
                    attach=memory_attach,
                    dealloc=memory_dealloc,
                    realize=memory_realize,
-                  )
+                   )
 
 def memory_attach(space, py_obj, w_obj, w_userdata=None):
     """


More information about the pypy-commit mailing list