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) 20 #ifdef _POSIX_C_SOURCE 21 #undef _POSIX_C_SOURCE 24 #ifdef _FILE_OFFSET_BITS 25 #undef _FILE_OFFSET_BITS 36 #include <sys/types.h> 41 typedef unsigned long UInt_t;
46 #ifdef R__B64 // Note: Long_t and ULong_t are currently not portable types 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 118 void* cobj,
const char* ,
void (*destr)(
void*))
120 return PyCObject_FromVoidPtr(cobj, destr);
122 #define CPyCppyy_PyCapsule_CheckExact PyCObject_Check 125 return (
void*)PyCObject_AsVoidPtr(capsule);
128 #define CPPYY__long__ "__long__" 129 #define CPPYY__idiv__ "__idiv__" 130 #define CPPYY__div__ "__div__" 131 #define CPPYY__next__ "next" 138 #if PY_VERSION_HEX >= 0x03000000 139 #define CPyCppyy_PyText_Check PyUnicode_Check 140 #define CPyCppyy_PyText_CheckExact PyUnicode_CheckExact 141 #define CPyCppyy_PyText_AsString PyUnicode_AsUTF8 142 #define CPyCppyy_PyText_AsStringChecked PyUnicode_AsUTF8 143 #define CPyCppyy_PyText_GetSize PyUnicode_GetSize 144 #define CPyCppyy_PyText_GET_SIZE PyUnicode_GET_SIZE 145 #define CPyCppyy_PyText_FromFormat PyUnicode_FromFormat 146 #define CPyCppyy_PyText_FromString PyUnicode_FromString 147 #define CPyCppyy_PyText_InternFromString PyUnicode_InternFromString 148 #define CPyCppyy_PyText_Append PyUnicode_Append 149 #define CPyCppyy_PyText_AppendAndDel PyUnicode_AppendAndDel 150 #define CPyCppyy_PyText_FromStringAndSize PyUnicode_FromStringAndSize 152 #if PY_VERSION_HEX >= 0x03030000 153 #define _CPyCppyy_PyText_AsStringAndSize PyUnicode_AsUTF8AndSize 155 #define _CPyCppyy_PyText_AsStringAndSize PyUnicode_AsStringAndSize 160 const char* cstr = _CPyCppyy_PyText_AsStringAndSize(pystr, size);
163 PyBytes_AsStringAndSize(pystr, (
char**)&cstr, size);
168 #define CPyCppyy_PyText_Type PyUnicode_Type 170 #define PyIntObject PyLongObject 171 #define PyInt_Check PyLong_Check 172 #define PyInt_AsLong PyLong_AsLong 173 #define PyInt_AS_LONG PyLong_AsLong 174 #define PyInt_AsSsize_t PyLong_AsSsize_t 175 #define PyInt_CheckExact PyLong_CheckExact 176 #define PyInt_FromLong PyLong_FromLong 177 #define PyInt_FromSsize_t PyLong_FromSsize_t 179 #define PyInt_Type PyLong_Type 181 #define CPyCppyy_PyCapsule_New PyCapsule_New 182 #define CPyCppyy_PyCapsule_CheckExact PyCapsule_CheckExact 183 #define CPyCppyy_PyCapsule_GetPointer PyCapsule_GetPointer 185 #define CPPYY__long__ "__int__" 186 #define CPPYY__idiv__ "__itruediv__" 187 #define CPPYY__div__ "__truediv__" 188 #define CPPYY__next__ "__next__" 190 #define Py_TPFLAGS_HAVE_RICHCOMPARE 0 191 #define Py_TPFLAGS_CHECKTYPES 0 193 #define PyClass_Check PyType_Check 195 #define PyBuffer_Type PyMemoryView_Type 198 #if PY_VERSION_HEX >= 0x03020000 199 #define CPyCppyy_PySliceCast PyObject* 200 #define PyUnicode_GetSize PyUnicode_GetLength 202 #define CPyCppyy_PySliceCast PySliceObject* 206 #if PY_VERSION_HEX < 0x02060000 207 #define PyVarObject_HEAD_INIT(type, size) \ 208 PyObject_HEAD_INIT(type) size, 209 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type) 213 #if PY_VERSION_HEX < 0x03020000 216 #if PY_VERSION_HEX < 0x02050000 217 return (
Py_ssize_t)PyUnicode_AsWideChar((PyUnicodeObject*)pyobj, w, (
int)size);
219 return PyUnicode_AsWideChar((PyUnicodeObject*)pyobj, w, size);
223 #define CPyCppyy_PyUnicode_AsWideChar PyUnicode_AsWideChar 227 #if PY_VERSION_HEX < 0x02050000 229 #define PyInt_AsSsize_t PyInt_AsLong 230 #define PyInt_FromSsize_t PyInt_FromLong 231 # define PY_SSIZE_T_FORMAT "%d" 232 # if !defined(PY_SSIZE_T_MIN) 233 # define PY_SSIZE_T_MAX INT_MAX 234 # define PY_SSIZE_T_MIN INT_MIN 236 #define ssizeobjargproc intobjargproc 237 #define lenfunc inquiry 238 #define ssizeargfunc intargfunc 240 #define PyIndex_Check(obj) \ 241 (PyInt_Check(obj) || PyLong_Check(obj)) 249 # if SIZEOF_SIZE_T == SIZEOF_INT 250 # if defined(MAC_OS_X_VERSION_10_4) 251 # define PY_SSIZE_T_FORMAT "%ld" 253 # define PY_SSIZE_T_FORMAT "%d" 255 # elif SIZEOF_SIZE_T == SIZEOF_LONG 256 # define PY_SSIZE_T_FORMAT "%ld" 259 # define PY_SSIZE_T_FORMAT "%zd" 263 #if PY_VERSION_HEX < 0x02020000 264 #define PyBool_FromLong PyInt_FromLong 267 #if PY_VERSION_HEX < 0x03000000 271 #define Py_False ((PyObject*)(void*)&_Py_ZeroStruct) 276 #define Py_True ((PyObject*)(void*)&_Py_TrueStruct) 280 #ifndef Py_RETURN_NONE 281 #define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None 284 #ifndef Py_RETURN_TRUE 285 #define Py_RETURN_TRUE return Py_INCREF(Py_True), Py_True 288 #ifndef Py_RETURN_FALSE 289 #define Py_RETURN_FALSE return Py_INCREF(Py_False), Py_False 298 #endif // !CPYCPPYY_CPYCPPYY_H
static PyObject * CPyCppyy_PyCapsule_New(void *cobj, const char *, void(*destr)(void *))
static const char * CPyCppyy_PyText_AsStringAndSize(PyObject *pystr, Py_ssize_t *size)
Py_ssize_t PyNumber_AsSsize_t(PyObject *obj, PyObject *)
unsigned long long ULong64_t
#define PyBytes_CheckExact
static Py_ssize_t CPyCppyy_PyUnicode_AsWideChar(PyObject *pyobj, wchar_t *w, Py_ssize_t size)
#define CPyCppyy_PyText_GetSize
PyDictEntry *(* dict_lookup_func)(PyDictObject *, PyObject *, long)
static void * CPyCppyy_PyCapsule_GetPointer(PyObject *capsule, const char *)
#define CPyCppyy_PyText_AsStringChecked