[pypy-commit] pypy rffi-parser-2: Move PyHeapTypeObject definition to C
rlamy
pypy.commits at gmail.com
Sun Jan 15 21:25:45 EST 2017
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: rffi-parser-2
Changeset: r89599:85a419c311cb
Date: 2017-01-16 02:24 +0000
http://bitbucket.org/pypy/pypy/changeset/85a419c311cb/
Log: Move PyHeapTypeObject definition to C
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
@@ -149,6 +149,7 @@
for name in ["pypy_macros.h"] + FUNCTIONS_BY_HEADER.keys():
headers.append(udir.join(name))
headers.append(parse_dir / 'cpyext_object.h')
+ headers.append(parse_dir / 'cpyext_typeobject.h')
_copy_header_files(headers, dstdir)
if copy_numpy_headers:
diff --git a/pypy/module/cpyext/include/object.h b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -112,14 +112,7 @@
#define PyBUF_SHADOW 0x400
/* end Py3k buffer interface */
-typedef struct {
- PyTypeObject ht_type;
- PyNumberMethods as_number;
- PyMappingMethods as_mapping;
- PySequenceMethods as_sequence;
- PyBufferProcs as_buffer;
- PyObject *ht_name, *ht_slots;
-} PyHeapTypeObject;
+#include <cpyext_typeobject.h>
#define PyObject_Bytes PyObject_Str
diff --git a/pypy/module/cpyext/parse/cpyext_typeobject.h b/pypy/module/cpyext/parse/cpyext_typeobject.h
new file mode 100644
--- /dev/null
+++ b/pypy/module/cpyext/parse/cpyext_typeobject.h
@@ -0,0 +1,8 @@
+typedef struct {
+ PyTypeObject ht_type;
+ PyNumberMethods as_number;
+ PyMappingMethods as_mapping;
+ PySequenceMethods as_sequence;
+ PyBufferProcs as_buffer;
+ PyObject *ht_name, *ht_slots;
+} PyHeapTypeObject;
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -17,7 +17,8 @@
Py_TPFLAGS_HAVE_GETCHARBUFFER, build_type_checkers,
PyObjectFields, PyTypeObject, PyTypeObjectPtr,
Py_TPFLAGS_HAVE_NEWBUFFER, Py_TPFLAGS_CHECKTYPES,
- Py_TPFLAGS_HAVE_INPLACEOPS)
+ Py_TPFLAGS_HAVE_INPLACEOPS, object_h, parse_dir)
+from pypy.module.cpyext.cparser import parse_source
from pypy.module.cpyext.methodobject import (W_PyCClassMethodObject,
W_PyCWrapperObject, PyCFunction_NewEx, PyCFunction, PyMethodDef,
W_PyCMethodObject, W_PyCFunctionObject)
@@ -32,7 +33,7 @@
from pypy.module.cpyext.structmember import PyMember_GetOne, PyMember_SetOne
from pypy.module.cpyext.typeobjectdefs import (
PyGetSetDef, PyMemberDef, newfunc, getter, setter,
- PyNumberMethods, PyMappingMethods, PySequenceMethods, PyBufferProcs)
+ PyNumberMethods, PySequenceMethods, PyBufferProcs)
from pypy.objspace.std.typeobject import W_TypeObject, find_best_base
@@ -40,18 +41,11 @@
PyType_Check, PyType_CheckExact = build_type_checkers("Type", "w_type")
-PyHeapTypeObjectStruct = lltype.ForwardReference()
-PyHeapTypeObject = lltype.Ptr(PyHeapTypeObjectStruct)
-PyHeapTypeObjectFields = (
- ("ht_type", PyTypeObject),
- ("ht_name", PyObject),
- ("as_number", PyNumberMethods),
- ("as_mapping", PyMappingMethods),
- ("as_sequence", PySequenceMethods),
- ("as_buffer", PyBufferProcs),
- )
-cpython_struct("PyHeapTypeObject", PyHeapTypeObjectFields, PyHeapTypeObjectStruct,
- level=2)
+cdef = (parse_dir / 'cpyext_typeobject.h').read()
+typeobject_h = parse_source(cdef, includes=[object_h], configure_now=True)
+PyHeapTypeObjectStruct = typeobject_h.gettype('PyHeapTypeObject')
+PyHeapTypeObject = typeobject_h.gettype('PyHeapTypeObject *')
+
class W_GetSetPropertyEx(GetSetProperty):
def __init__(self, getset, w_type):
More information about the pypy-commit
mailing list