Author: Ronan Lamy <ronan.l...@gmail.com> Branch: py3.5 Changeset: r89839:f5231270d7c6 Date: 2017-01-30 16:13 +0000 http://bitbucket.org/pypy/pypy/changeset/f5231270d7c6/
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 @@ -486,19 +486,23 @@ return unwrapper return decorate +def api_func_from_cdef(func, cdef, cts, + error=_NOT_SPECIFIED, header=DEFAULT_HEADER): + 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) + FUNCTIONS_BY_HEADER[header][cdecl.name] = api_function + unwrapper = api_function.get_unwrapper() + unwrapper.func = func + unwrapper.api_func = api_function + return unwrapper + def api_decl(cdef, cts, error=_NOT_SPECIFIED, header=DEFAULT_HEADER): def decorate(func): - 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) - FUNCTIONS_BY_HEADER[header][cdecl.name] = api_function - unwrapper = api_function.get_unwrapper() - unwrapper.func = func - unwrapper.api_func = api_function - return unwrapper + return api_func_from_cdef(func, cdef, cts, error=error, header=header) return decorate def slot_function(argtypes, restype, error=_NOT_SPECIFIED): @@ -681,7 +685,17 @@ % (cpyname, )) build_exported_objects() -cts = CTypeSpace(headers=['sys/types.h', 'stdarg.h', 'stdio.h', 'stddef.h']) + +class CpyextTypeSpace(CTypeSpace): + def decl(self, cdef, error=_NOT_SPECIFIED, header=DEFAULT_HEADER): + def decorate(func): + return api_func_from_cdef( + func, cdef, self, error=error, header=header) + return decorate + + +CPYEXT_BASE_HEADERS = ['sys/types.h', 'stdarg.h', 'stdio.h', 'stddef.h'] +cts = CpyextTypeSpace(headers=CPYEXT_BASE_HEADERS) cts.parse_header(parse_dir / 'cpyext_object.h') Py_ssize_t = cts.gettype('Py_ssize_t') 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,7 +11,7 @@ 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, cts, api_decl) + PyTypeObjectPtr, slot_function, cts) from pypy.module.cpyext.pyobject import ( Py_DecRef, from_ref, make_ref, as_pyobj, make_typedescr) @@ -272,7 +272,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 *)", cts) +@cts.decl("PyCFunction PyCFunction_GetFunction(PyObject *)") def PyCFunction_GetFunction(space, w_obj): try: cfunction = space.interp_w(W_PyCFunctionObject, w_obj) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit