1#ifndef CPYCPPYY_CPYCPPYY_H
2#define CPYCPPYY_CPYCPPYY_H
6#pragma warning (disable : 4275)
8#pragma warning (disable : 4251)
10#pragma warning (disable : 4800)
24#ifdef _FILE_OFFSET_BITS
25#undef _FILE_OFFSET_BITS
41typedef unsigned long UInt_t;
68#if PY_VERSION_HEX < 0x03030000
69 typedef PyDictEntry* (*dict_lookup_func)(PyDictObject*,
PyObject*,
long);
71#if PY_VERSION_HEX >= 0x03060000
75 struct PyDictKeyEntry;
77#define PyDictEntry PyDictKeyEntry
82#if PY_VERSION_HEX < 0x03000000
83#define PyBytes_Check PyString_Check
84#define PyBytes_CheckExact PyString_CheckExact
85#define PyBytes_AS_STRING PyString_AS_STRING
86#define PyBytes_AsString PyString_AsString
87#define PyBytes_GET_SIZE PyString_GET_SIZE
88#define PyBytes_Size PyString_Size
89#define PyBytes_FromFormat PyString_FromFormat
90#define PyBytes_FromString PyString_FromString
91#define PyBytes_FromStringAndSize PyString_FromStringAndSize
93#define PyBytes_Type PyString_Type
95#define CPyCppyy_PyText_Check PyString_Check
96#define CPyCppyy_PyText_CheckExact PyString_CheckExact
97#define CPyCppyy_PyText_AsString PyString_AS_STRING
98#define CPyCppyy_PyText_AsStringChecked PyString_AsString
99#define CPyCppyy_PyText_GET_SIZE PyString_GET_SIZE
100#define CPyCppyy_PyText_GetSize PyString_Size
101#define CPyCppyy_PyText_FromFormat PyString_FromFormat
102#define CPyCppyy_PyText_FromString PyString_FromString
103#define CPyCppyy_PyText_InternFromString PyString_InternFromString
104#define CPyCppyy_PyText_Append PyString_Concat
105#define CPyCppyy_PyText_AppendAndDel PyString_ConcatAndDel
106#define CPyCppyy_PyText_FromStringAndSize PyString_FromStringAndSize
115#define CPyCppyy_PyText_Type PyString_Type
117#define CPyCppyy_PyUnicode_GET_SIZE PyUnicode_GET_SIZE
120 void* cobj,
const char* ,
void (*destr)(
void*))
122 return PyCObject_FromVoidPtr(cobj, destr);
124#define CPyCppyy_PyCapsule_CheckExact PyCObject_Check
127 return (
void*)PyCObject_AsVoidPtr(capsule);
130#define CPPYY__long__ "__long__"
131#define CPPYY__idiv__ "__idiv__"
132#define CPPYY__div__ "__div__"
133#define CPPYY__next__ "next"
140#if PY_VERSION_HEX >= 0x03000000
141#define CPyCppyy_PyText_Check PyUnicode_Check
142#define CPyCppyy_PyText_CheckExact PyUnicode_CheckExact
143#define CPyCppyy_PyText_AsString PyUnicode_AsUTF8
144#define CPyCppyy_PyText_AsStringChecked PyUnicode_AsUTF8
145#define CPyCppyy_PyText_GetSize PyUnicode_GetSize
146#if PY_VERSION_HEX < 0x03090000
147#define CPyCppyy_PyText_GET_SIZE PyUnicode_GET_SIZE
148#define CPyCppyy_PyUnicode_GET_SIZE PyUnicode_GET_LENGTH
150#define CPyCppyy_PyText_GET_SIZE PyUnicode_GET_LENGTH
151#define CPyCppyy_PyUnicode_GET_SIZE PyUnicode_GET_LENGTH
153#define CPyCppyy_PyText_FromFormat PyUnicode_FromFormat
154#define CPyCppyy_PyText_FromString PyUnicode_FromString
155#define CPyCppyy_PyText_InternFromString PyUnicode_InternFromString
156#define CPyCppyy_PyText_Append PyUnicode_Append
157#define CPyCppyy_PyText_AppendAndDel PyUnicode_AppendAndDel
158#define CPyCppyy_PyText_FromStringAndSize PyUnicode_FromStringAndSize
160#if PY_VERSION_HEX >= 0x03030000
161#define _CPyCppyy_PyText_AsStringAndSize PyUnicode_AsUTF8AndSize
163#define _CPyCppyy_PyText_AsStringAndSize PyUnicode_AsStringAndSize
168 const char* cstr = _CPyCppyy_PyText_AsStringAndSize(pystr,
size);
171 PyBytes_AsStringAndSize(pystr, (
char**)&cstr,
size);
176#define CPyCppyy_PyText_Type PyUnicode_Type
178#define PyIntObject PyLongObject
179#define PyInt_Check PyLong_Check
180#define PyInt_AsLong PyLong_AsLong
181#define PyInt_AS_LONG PyLong_AsLong
182#define PyInt_AsSsize_t PyLong_AsSsize_t
183#define PyInt_CheckExact PyLong_CheckExact
184#define PyInt_FromLong PyLong_FromLong
185#define PyInt_FromSsize_t PyLong_FromSsize_t
187#define PyInt_Type PyLong_Type
189#define CPyCppyy_PyCapsule_New PyCapsule_New
190#define CPyCppyy_PyCapsule_CheckExact PyCapsule_CheckExact
191#define CPyCppyy_PyCapsule_GetPointer PyCapsule_GetPointer
193#define CPPYY__long__ "__int__"
194#define CPPYY__idiv__ "__itruediv__"
195#define CPPYY__div__ "__truediv__"
196#define CPPYY__next__ "__next__"
198#define Py_TPFLAGS_HAVE_RICHCOMPARE 0
199#define Py_TPFLAGS_CHECKTYPES 0
201#define PyClass_Check PyType_Check
203#define PyBuffer_Type PyMemoryView_Type
206#if PY_VERSION_HEX >= 0x03020000
207#define CPyCppyy_PySliceCast PyObject*
208#define PyUnicode_GetSize PyUnicode_GetLength
210#define CPyCppyy_PySliceCast PySliceObject*
214#if PY_VERSION_HEX < 0x02060000
215#define PyVarObject_HEAD_INIT(type, size) \
216 PyObject_HEAD_INIT(type) size,
217#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
221#if PY_VERSION_HEX < 0x03020000
224#if PY_VERSION_HEX < 0x02050000
225 return (
Py_ssize_t)PyUnicode_AsWideChar((PyUnicodeObject*)pyobj, w, (
int)
size);
227 return PyUnicode_AsWideChar((PyUnicodeObject*)pyobj, w,
size);
231#define CPyCppyy_PyUnicode_AsWideChar PyUnicode_AsWideChar
235#if PY_VERSION_HEX < 0x02050000
237#define PyInt_AsSsize_t PyInt_AsLong
238#define PyInt_FromSsize_t PyInt_FromLong
239# define PY_SSIZE_T_FORMAT "%d"
240# if !defined(PY_SSIZE_T_MIN)
241# define PY_SSIZE_T_MAX INT_MAX
242# define PY_SSIZE_T_MIN INT_MIN
244#define ssizeobjargproc intobjargproc
245#define lenfunc inquiry
246#define ssizeargfunc intargfunc
248#define PyIndex_Check(obj) \
249 (PyInt_Check(obj) || PyLong_Check(obj))
257# if SIZEOF_SIZE_T == SIZEOF_INT
258# if defined(MAC_OS_X_VERSION_10_4)
259# define PY_SSIZE_T_FORMAT "%ld"
261# define PY_SSIZE_T_FORMAT "%d"
263# elif SIZEOF_SIZE_T == SIZEOF_LONG
264# define PY_SSIZE_T_FORMAT "%ld"
267# define PY_SSIZE_T_FORMAT "%zd"
271#if PY_VERSION_HEX < 0x02020000
272#define PyBool_FromLong PyInt_FromLong
275#if PY_VERSION_HEX < 0x03000000
279#define Py_False ((PyObject*)(void*)&_Py_ZeroStruct)
284#define Py_True ((PyObject*)(void*)&_Py_TrueStruct)
288#ifndef Py_RETURN_NONE
289#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
292#ifndef Py_RETURN_TRUE
293#define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True
296#ifndef Py_RETURN_FALSE
297#define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False
301#if PY_VERSION_HEX >= 0x03090000
302#define CPyCppyy_PyCFunction_Call PyObject_Call
304#define CPyCppyy_PyCFunction_Call PyCFunction_Call
308#if PY_VERSION_HEX < 0x030900A4 && !defined(Py_SET_TYPE)
311#define Py_SET_TYPE(ob, type) _Py_SET_TYPE((PyObject*)(ob), type)
static Py_ssize_t CPyCppyy_PyUnicode_AsWideChar(PyObject *pyobj, wchar_t *w, Py_ssize_t size)
PyDictEntry *(* dict_lookup_func)(PyDictObject *, PyObject *, long)
Py_ssize_t PyNumber_AsSsize_t(PyObject *obj, PyObject *)
static void * CPyCppyy_PyCapsule_GetPointer(PyObject *capsule, const char *)
static PyObject * CPyCppyy_PyCapsule_New(void *cobj, const char *, void(*destr)(void *))
#define CPyCppyy_PyText_GetSize
#define PyBytes_CheckExact
static const char * CPyCppyy_PyText_AsStringAndSize(PyObject *pystr, Py_ssize_t *size)
static void _Py_SET_TYPE(PyObject *ob, PyTypeObject *type)
#define CPyCppyy_PyText_AsStringChecked
unsigned long long ULong64_t
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix