Commit cd111013 authored by Kirill Smelkov's avatar Kirill Smelkov

pycapicompat.h: Initial stub - lots of TODO for @Daetalus

parent d48f4c17
========================================================================================================
pycapicompat.h - Extra CAPI functions for compatibility between various C-based Python implementations
========================================================================================================
`pycapicompat.h` is a C-header with additional CAPI functions providing unified
access to C-based functionality between various C-bases Python implementations.
Currently covered are:
- Pyston_
- CPython_
we would also be glad to cover PyPy_ and we will try to do so on a best effort basis.
Patches are, as always, welcome.
.. _Pyston: https://pyston.org/
.. _CPython: https://www.python.org/
.. _PyPy: http://pypy.org/
#ifndef _PYCAPICOMPAT_H_
#define _PYCAPICOMPAT_H_
/* pycapicompat.h - Extra CAPI functions for compatibility between various C-based Python implementations
* This file has been placed into Public Domain.
*
* The recommended way to use pycapicompat.h is to copy it from canonical
* location to your project on as-needed basis and include locally.
*
* The canonical location is:
*
* https://lab.nexedi.com/nexedi/pycapicompat/raw/master/pycapicompat.h
* (or https://lab.nexedi.com/nexedi/pycapicompat.git for Git access)
*
* Last updated: 2016-06-13
*/
#include <Python.h>
#ifdef __cplusplus
extern "C" {
#endif
// TODO(Daetalus)
#if 0
#ifndef IMPLEMENTATION_SUPPORTS_EXTENDED_C_API
#define PyErr_GetExcInfoType() PyThreadState_GET()->exc_type
#endif
#ifdef PYSTON_VERSION
foo = PyErr_GetExcInfoType(); // a new API function
#else
foo = PyThreadState_GET()->exc_type; // direct field access
#endif
#endif
// info about free variables
// TODO(Daetalus) verify and fill more
#ifdef CPYTHON_VERSION
// TODO(Daetalus) see how Cython does this check
#elif defined(PYSTON_VERSION)
void PyCode_HasFreeVars(BoxedCode* code) {
return code->source->getScopeInfo()->takesClosure();
}
#else
# error TODO pypy:PyCode_HasFreeVars not implemented for your python version
#endif
// TODO(Daetalus) add more stuff.
#ifdef __cplusplus
}
#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