Commit eaa464a2 authored by Boxiang Sun's avatar Boxiang Sun Committed by Kirill Smelkov

Add two functions wrappers for PyPy

The change in PyCode_HasFreeVars and PyFrame_SetLineNumber will also
effect Cython under PyPy. So add those two functions for PyPy. But
didn't test those yet.

[ @kirr: we might want to restructure pycapicompat.h in the future to be
  driven by function name as primary key. Not sure for now though - we'll
  see how it goes ]

/reviewed-by @kirr
/reviewed-on !2
parent 9d2c4626
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* https://lab.nexedi.com/nexedi/pycapicompat/raw/master/pycapicompat.h * https://lab.nexedi.com/nexedi/pycapicompat/raw/master/pycapicompat.h
* (or https://lab.nexedi.com/nexedi/pycapicompat.git for Git access) * (or https://lab.nexedi.com/nexedi/pycapicompat.git for Git access)
* *
* Last updated: 2016-06-17 * Last updated: 2016-06-27
*/ */
#include <Python.h> #include <Python.h>
...@@ -69,8 +69,18 @@ PyFrame_SetLineNumber(PyFrameObject *f, int lineno) { ...@@ -69,8 +69,18 @@ PyFrame_SetLineNumber(PyFrameObject *f, int lineno) {
#elif defined(PYPY_VERSION) #elif defined(PYPY_VERSION)
// TODO: PyFrame_SetLineNumber(f, lineno) // PyCode. Check whether there are free variables
// TODO: PyCode_HasFreeVars(co) // TODO: need to check it on PyPy
static inline int PyCode_HasFreeVars(PyCodeObject *co) {
return PyCode_GetNumFree(co) > 0 ? 1 : 0;
}
// PyFrame. Set frame line number
// TODO: need to check it on PyPy
static inline void
PyFrame_SetLineNumber(PyFrameObject *f, int lineno) {
f->f_lineno = lineno;
}
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment