[pypy-commit] pypy rffi-parser: Use object_h definitions in methodobject.py
rlamy
pypy.commits at gmail.com
Sun Dec 18 12:18:43 EST 2016
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: rffi-parser
Changeset: r89153:e7350a8db95b
Date: 2016-12-18 17:17 +0000
http://bitbucket.org/pypy/pypy/changeset/e7350a8db95b/
Log: Use object_h definitions in methodobject.py
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
@@ -293,7 +293,11 @@
argtypesw = zip(self.argtypes,
[_name.startswith("w_") for _name in self.argnames])
error_value = getattr(self, "error_value", CANNOT_FAIL)
- if (isinstance(self.restype, lltype.Ptr)
+ if isinstance(self.restype, lltype.Typedef):
+ real_restype = self.restype.OF
+ else:
+ real_restype = self.restype
+ if (isinstance(real_restype, lltype.Ptr)
and error_value is not CANNOT_FAIL):
assert lltype.typeOf(error_value) == self.restype
assert not error_value # only support error=NULL
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,22 +11,14 @@
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)
+ PyTypeObjectPtr, object_h)
from pypy.module.cpyext.pyobject import (
Py_DecRef, from_ref, make_ref, as_pyobj, make_typedescr)
PyCFunction_typedef = rffi.COpaquePtr(typedef='PyCFunction')
-PyCFunction = lltype.Ptr(lltype.FuncType([PyObject, PyObject], PyObject))
-PyCFunctionKwArgs = lltype.Ptr(lltype.FuncType([PyObject, PyObject, PyObject],
- PyObject))
-
-PyMethodDef = cpython_struct(
- 'PyMethodDef',
- [('ml_name', rffi.CONST_CCHARP),
- ('ml_meth', PyCFunction_typedef),
- ('ml_flags', rffi.INT_real),
- ('ml_doc', rffi.CONST_CCHARP),
- ])
+PyCFunction = object_h.definitions['PyCFunction']
+PyCFunctionKwArgs = object_h.definitions['PyCFunctionWithKeywords']
+PyMethodDef = object_h.definitions['PyMethodDef']
PyCFunctionObjectStruct = cpython_struct(
'PyCFunctionObject',
More information about the pypy-commit
mailing list