Author: Ronan Lamy <[email protected]>
Branch: rffi-parser-2
Changeset: r89613:d218f1328c08
Date: 2017-01-16 17:28 +0000
http://bitbucket.org/pypy/pypy/changeset/d218f1328c08/

Log:    Use only one cts for all of cpyext

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
@@ -40,7 +40,7 @@
 from rpython.rlib import rawrefcount
 from rpython.rlib import rthread
 from rpython.rlib.debug import fatalerror_notb
-from pypy.module.cpyext.cparser import parse_source
+from pypy.module.cpyext.cparser import CTypeSpace
 
 DEBUG_WRAPPER = True
 
@@ -671,30 +671,30 @@
 build_exported_objects()
 
 object_cdef = (parse_dir / 'cpyext_object.h').read()
-object_h = parse_source(object_cdef,
-    headers=['sys/types.h', 'stdarg.h', 'stdio.h'])
+cts = CTypeSpace(headers=['sys/types.h', 'stdarg.h', 'stdio.h'])
+cts.parse_source(object_cdef)
 
-Py_ssize_t = object_h.gettype('Py_ssize_t')
-Py_ssize_tP = object_h.gettype('Py_ssize_t *')
+Py_ssize_t = cts.gettype('Py_ssize_t')
+Py_ssize_tP = cts.gettype('Py_ssize_t *')
 size_t = rffi.ULONG
 ADDR = lltype.Signed
 
 # Note: as a special case, "PyObject" is the pointer type in RPython,
 # corresponding to "PyObject *" in C.  We do that only for PyObject.
 # For example, "PyTypeObject" is the struct type even in RPython.
-PyTypeObject = object_h.gettype('PyTypeObject')
-PyTypeObjectPtr = object_h.gettype('PyTypeObject *')
-PyObjectStruct = object_h.gettype('PyObject')
-PyObject = object_h.gettype('PyObject *')
+PyTypeObject = cts.gettype('PyTypeObject')
+PyTypeObjectPtr = cts.gettype('PyTypeObject *')
+PyObjectStruct = cts.gettype('PyObject')
+PyObject = cts.gettype('PyObject *')
 PyObjectFields = (("ob_refcnt", lltype.Signed),
                   ("ob_pypy_link", lltype.Signed),
                   ("ob_type", PyTypeObjectPtr))
 PyVarObjectFields = PyObjectFields + (("ob_size", Py_ssize_t), )
-PyVarObjectStruct = object_h.gettype('PyVarObject')
-PyVarObject = object_h.gettype('PyVarObject *')
+PyVarObjectStruct = cts.gettype('PyVarObject')
+PyVarObject = cts.gettype('PyVarObject *')
 
-Py_buffer = object_h.gettype('Py_buffer')
-Py_bufferP = object_h.gettype('Py_buffer *')
+Py_buffer = cts.gettype('Py_buffer')
+Py_bufferP = cts.gettype('Py_buffer *')
 
 
 @specialize.memo()
diff --git a/pypy/module/cpyext/methodobject.py 
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -11,13 +11,13 @@
     CONST_STRING, METH_CLASS, METH_COEXIST, METH_KEYWORDS, METH_NOARGS, METH_O,
     METH_STATIC, METH_VARARGS, PyObject, PyObjectFields, bootstrap_function,
     build_type_checkers, cpython_api, cpython_struct, generic_cpy_call,
-    PyTypeObjectPtr, slot_function, object_h, api_decl)
+    PyTypeObjectPtr, slot_function, cts, api_decl)
 from pypy.module.cpyext.pyobject import (
     Py_DecRef, from_ref, make_ref, as_pyobj, make_typedescr)
 
-PyMethodDef = object_h.gettype('PyMethodDef')
-PyCFunction = object_h.gettype('PyCFunction')
-PyCFunctionKwArgs = object_h.gettype('PyCFunctionWithKeywords')
+PyMethodDef = cts.gettype('PyMethodDef')
+PyCFunction = cts.gettype('PyCFunction')
+PyCFunctionKwArgs = cts.gettype('PyCFunctionWithKeywords')
 PyCFunctionObjectStruct = cpython_struct(
     'PyCFunctionObject',
     PyObjectFields + (
@@ -282,7 +282,7 @@
 def PyCFunction_NewEx(space, ml, w_self, w_name):
     return space.wrap(W_PyCFunctionObject(space, ml, w_self, w_name))
 
-@api_decl("PyCFunction PyCFunction_GetFunction(PyObject *)", object_h)
+@api_decl("PyCFunction PyCFunction_GetFunction(PyObject *)", cts)
 def PyCFunction_GetFunction(space, w_obj):
     try:
         cfunction = space.interp_w(W_PyCFunctionObject, w_obj)
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,7 @@
     Py_TPFLAGS_HAVE_GETCHARBUFFER, build_type_checkers,
     PyObjectFields, PyTypeObject, PyTypeObjectPtr,
     Py_TPFLAGS_HAVE_NEWBUFFER, Py_TPFLAGS_CHECKTYPES,
-    Py_TPFLAGS_HAVE_INPLACEOPS, object_h, parse_dir)
+    Py_TPFLAGS_HAVE_INPLACEOPS, cts, parse_dir)
 from pypy.module.cpyext.cparser import parse_source
 from pypy.module.cpyext.methodobject import (W_PyCClassMethodObject,
     W_PyCWrapperObject, PyCFunction_NewEx, PyCFunction, PyMethodDef,
@@ -42,9 +42,9 @@
 PyType_Check, PyType_CheckExact = build_type_checkers("Type", "w_type")
 
 cdef = (parse_dir / 'cpyext_typeobject.h').read()
-typeobject_h = parse_source(cdef, includes=[object_h])
-PyHeapTypeObjectStruct = typeobject_h.gettype('PyHeapTypeObject')
-PyHeapTypeObject = typeobject_h.gettype('PyHeapTypeObject *')
+cts.parse_source(cdef)
+PyHeapTypeObjectStruct = cts.gettype('PyHeapTypeObject')
+PyHeapTypeObject = cts.gettype('PyHeapTypeObject *')
 
 
 class W_GetSetPropertyEx(GetSetProperty):
diff --git a/pypy/module/cpyext/typeobjectdefs.py 
b/pypy/module/cpyext/typeobjectdefs.py
--- a/pypy/module/cpyext/typeobjectdefs.py
+++ b/pypy/module/cpyext/typeobjectdefs.py
@@ -1,59 +1,59 @@
-from pypy.module.cpyext.api import object_h
+from pypy.module.cpyext.api import cts
 
 
-freefunc = object_h.definitions['freefunc']
-destructor = object_h.definitions['destructor']
-printfunc = object_h.definitions['printfunc']
-getattrfunc = object_h.definitions['getattrfunc']
-getattrofunc = object_h.definitions['getattrofunc']
-setattrfunc = object_h.definitions['setattrfunc']
-setattrofunc = object_h.definitions['setattrofunc']
-cmpfunc = object_h.definitions['cmpfunc']
-reprfunc = object_h.definitions['reprfunc']
-hashfunc = object_h.definitions['hashfunc']
-richcmpfunc = object_h.definitions['richcmpfunc']
-getiterfunc = object_h.definitions['getiterfunc']
-iternextfunc = object_h.definitions['iternextfunc']
-descrgetfunc = object_h.definitions['descrgetfunc']
-descrsetfunc = object_h.definitions['descrsetfunc']
-initproc = object_h.definitions['initproc']
-newfunc = object_h.definitions['newfunc']
-allocfunc = object_h.definitions['allocfunc']
+freefunc = cts.definitions['freefunc']
+destructor = cts.definitions['destructor']
+printfunc = cts.definitions['printfunc']
+getattrfunc = cts.definitions['getattrfunc']
+getattrofunc = cts.definitions['getattrofunc']
+setattrfunc = cts.definitions['setattrfunc']
+setattrofunc = cts.definitions['setattrofunc']
+cmpfunc = cts.definitions['cmpfunc']
+reprfunc = cts.definitions['reprfunc']
+hashfunc = cts.definitions['hashfunc']
+richcmpfunc = cts.definitions['richcmpfunc']
+getiterfunc = cts.definitions['getiterfunc']
+iternextfunc = cts.definitions['iternextfunc']
+descrgetfunc = cts.definitions['descrgetfunc']
+descrsetfunc = cts.definitions['descrsetfunc']
+initproc = cts.definitions['initproc']
+newfunc = cts.definitions['newfunc']
+allocfunc = cts.definitions['allocfunc']
 
-unaryfunc = object_h.definitions['unaryfunc']
-binaryfunc = object_h.definitions['binaryfunc']
-ternaryfunc = object_h.definitions['ternaryfunc']
-inquiry = object_h.definitions['inquiry']
-lenfunc = object_h.definitions['lenfunc']
-coercion = object_h.definitions['coercion']
-intargfunc = object_h.definitions['intargfunc']
-intintargfunc = object_h.definitions['intintargfunc']
-ssizeargfunc = object_h.definitions['ssizeargfunc']
-ssizessizeargfunc = object_h.definitions['ssizessizeargfunc']
-intobjargproc = object_h.definitions['intobjargproc']
-intintobjargproc = object_h.definitions['intintobjargproc']
-ssizeobjargproc = object_h.definitions['ssizeobjargproc']
-ssizessizeobjargproc = object_h.definitions['ssizessizeobjargproc']
-objobjargproc = object_h.definitions['objobjargproc']
+unaryfunc = cts.definitions['unaryfunc']
+binaryfunc = cts.definitions['binaryfunc']
+ternaryfunc = cts.definitions['ternaryfunc']
+inquiry = cts.definitions['inquiry']
+lenfunc = cts.definitions['lenfunc']
+coercion = cts.definitions['coercion']
+intargfunc = cts.definitions['intargfunc']
+intintargfunc = cts.definitions['intintargfunc']
+ssizeargfunc = cts.definitions['ssizeargfunc']
+ssizessizeargfunc = cts.definitions['ssizessizeargfunc']
+intobjargproc = cts.definitions['intobjargproc']
+intintobjargproc = cts.definitions['intintobjargproc']
+ssizeobjargproc = cts.definitions['ssizeobjargproc']
+ssizessizeobjargproc = cts.definitions['ssizessizeobjargproc']
+objobjargproc = cts.definitions['objobjargproc']
 
-objobjproc = object_h.definitions['objobjproc']
-visitproc = object_h.definitions['visitproc']
-traverseproc = object_h.definitions['traverseproc']
+objobjproc = cts.definitions['objobjproc']
+visitproc = cts.definitions['visitproc']
+traverseproc = cts.definitions['traverseproc']
 
-getter = object_h.definitions['getter']
-setter = object_h.definitions['setter']
+getter = cts.definitions['getter']
+setter = cts.definitions['setter']
 
-readbufferproc = object_h.definitions['readbufferproc']
-writebufferproc = object_h.definitions['writebufferproc']
-segcountproc = object_h.definitions['segcountproc']
-charbufferproc = object_h.definitions['charbufferproc']
-getbufferproc = object_h.definitions['getbufferproc']
-releasebufferproc = object_h.definitions['releasebufferproc']
+readbufferproc = cts.definitions['readbufferproc']
+writebufferproc = cts.definitions['writebufferproc']
+segcountproc = cts.definitions['segcountproc']
+charbufferproc = cts.definitions['charbufferproc']
+getbufferproc = cts.definitions['getbufferproc']
+releasebufferproc = cts.definitions['releasebufferproc']
 
 
-PyGetSetDef = object_h.definitions['PyGetSetDef']
-PyNumberMethods = object_h.definitions['PyNumberMethods']
-PySequenceMethods = object_h.definitions['PySequenceMethods']
-PyMappingMethods = object_h.definitions['PyMappingMethods']
-PyBufferProcs = object_h.definitions['PyBufferProcs']
-PyMemberDef = object_h.definitions['PyMemberDef']
+PyGetSetDef = cts.definitions['PyGetSetDef']
+PyNumberMethods = cts.definitions['PyNumberMethods']
+PySequenceMethods = cts.definitions['PySequenceMethods']
+PyMappingMethods = cts.definitions['PyMappingMethods']
+PyBufferProcs = cts.definitions['PyBufferProcs']
+PyMemberDef = cts.definitions['PyMemberDef']
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to