00001
00002
00003
00004 #ifndef PYROOT_PYROOT_H
00005 #define PYROOT_PYROOT_H
00006
00007 #ifdef _WIN32
00008
00009 #pragma warning ( disable : 4275 )
00010
00011 #pragma warning ( disable : 4251 )
00012
00013 #pragma warning ( disable : 4800 )
00014
00015
00016 #endif
00017
00018
00019 #if defined(linux)
00020
00021 #include <stdio.h>
00022
00023 #ifdef _POSIX_C_SOURCE
00024 #undef _POSIX_C_SOURCE
00025 #endif
00026
00027 #ifdef _FILE_OFFSET_BITS
00028 #undef _FILE_OFFSET_BITS
00029 #endif
00030
00031 #ifdef _XOPEN_SOURCE
00032 #undef _XOPEN_SOURCE
00033 #endif
00034
00035 #endif
00036
00037 #include "Python.h"
00038 #include "Rtypes.h"
00039
00040
00041 #if PY_VERSION_HEX < 0x03000000
00042 #define PyBytes_Check PyString_Check
00043 #define PyBytes_CheckExact PyString_CheckExact
00044 #define PyBytes_AS_STRING PyString_AS_STRING
00045 #define PyBytes_AsString PyString_AsString
00046 #define PyBytes_GET_SIZE PyString_GET_SIZE
00047 #define PyBytes_Size PyString_Size
00048 #define PyBytes_FromFormat PyString_FromFormat
00049 #define PyBytes_FromString PyString_FromString
00050 #define PyBytes_FromStringAndSize PyString_FromStringAndSize
00051
00052 #define PyBytes_Type PyString_Type
00053
00054 #define PyROOT_PyUnicode_Check PyString_Check
00055 #define PyROOT_PyUnicode_CheckExact PyString_CheckExact
00056 #define PyROOT_PyUnicode_AsString PyString_AS_STRING
00057 #define PyROOT_PyUnicode_AsStringChecked PyString_AsString
00058 #define PyROOT_PyUnicode_GET_SIZE PyString_GET_SIZE
00059 #define PyROOT_PyUnicode_GetSize PyString_Size
00060 #define PyROOT_PyUnicode_FromFormat PyString_FromFormat
00061 #define PyROOT_PyUnicode_FromString PyString_FromString
00062 #define PyROOT_PyUnicode_InternFromString PyString_InternFromString
00063 #define PyROOT_PyUnicode_Append PyString_Concat
00064 #define PyROOT_PyUnicode_AppendAndDel PyString_ConcatAndDel
00065 #define PyROOT_PyUnicode_FromStringAndSize PyString_FromStringAndSize
00066
00067 #define PyROOT_PyUnicode_Type PyString_Type
00068
00069 #define PYROOT__long__ "__long__"
00070 #define PYROOT__idiv__ "__idiv__"
00071 #define PYROOT__div__ "__div__"
00072
00073 #endif // ! 3.0
00074
00075
00076 #if PY_VERSION_HEX >= 0x03000000
00077 #define PyROOT_PyUnicode_Check PyUnicode_Check
00078 #define PyROOT_PyUnicode_CheckExact PyUnicode_CheckExact
00079 #define PyROOT_PyUnicode_AsString _PyUnicode_AsString
00080 #define PyROOT_PyUnicode_AsStringChecked _PyUnicode_AsString
00081 #define PyROOT_PyUnicode_GetSize PyUnicode_GetSize
00082 #define PyROOT_PyUnicode_GET_SIZE PyUnicode_GET_SIZE
00083 #define PyROOT_PyUnicode_FromFormat PyUnicode_FromFormat
00084 #define PyROOT_PyUnicode_FromString PyUnicode_FromString
00085 #define PyROOT_PyUnicode_InternFromString PyUnicode_InternFromString
00086 #define PyROOT_PyUnicode_Append PyUnicode_Append
00087 #define PyROOT_PyUnicode_AppendAndDel PyUnicode_AppendAndDel
00088 #define PyROOT_PyUnicode_FromStringAndSize PyUnicode_FromStringAndSize
00089
00090 #define PyROOT_PyUnicode_Type PyUnicode_Type
00091
00092 #define PyIntObject PyLongObject
00093 #define PyInt_Check PyLong_Check
00094 #define PyInt_AsLong PyLong_AsLong
00095 #define PyInt_AS_LONG PyLong_AsLong
00096 #define PyInt_AsSsize_t PyLong_AsSsize_t
00097 #define PyInt_CheckExact PyLong_CheckExact
00098 #define PyInt_FromLong PyLong_FromLong
00099 #define PyInt_FromSsize_t PyLong_FromSsize_t
00100
00101 #define PyInt_Type PyLong_Type
00102
00103 #define PYROOT__long__ "__int__"
00104 #define PYROOT__idiv__ "__itruediv__"
00105 #define PYROOT__div__ "__truediv__"
00106
00107 #define Py_TPFLAGS_HAVE_RICHCOMPARE 0
00108 #define Py_TPFLAGS_CHECKTYPES 0
00109
00110 #define PyClass_Check PyType_Check
00111
00112 #define PyBuffer_Type PyMemoryView_Type
00113 #endif // ! 3.0
00114
00115
00116 #if PY_VERSION_HEX < 0x02060000
00117 #define PyVarObject_HEAD_INIT(type, size) \
00118 PyObject_HEAD_INIT(type) size,
00119 #define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
00120 #endif
00121
00122
00123 #if PY_VERSION_HEX < 0x02050000
00124 typedef int Py_ssize_t;
00125 #define PyInt_AsSsize_t PyInt_AsLong
00126 #define PyInt_FromSsize_t PyInt_FromLong
00127 # define PY_SSIZE_T_FORMAT "%d"
00128 # if !defined(PY_SSIZE_T_MIN)
00129 # define PY_SSIZE_T_MAX INT_MAX
00130 # define PY_SSIZE_T_MIN INT_MIN
00131 # endif
00132 #define ssizeobjargproc intobjargproc
00133 #define lenfunc inquiry
00134 #define ssizeargfunc intargfunc
00135
00136 #define PyIndex_Check(obj) \
00137 (PyInt_Check(obj) || PyLong_Check(obj))
00138
00139 inline Py_ssize_t PyNumber_AsSsize_t( PyObject* obj, PyObject* ) {
00140 return (Py_ssize_t)PyLong_AsLong( obj );
00141 }
00142
00143 #else
00144 # ifdef R__MACOSX
00145 # if SIZEOF_SIZE_T == SIZEOF_INT
00146 # if defined(MAC_OS_X_VERSION_10_4)
00147 # define PY_SSIZE_T_FORMAT "%ld"
00148 # else
00149 # define PY_SSIZE_T_FORMAT "%d"
00150 # endif
00151 # elif SIZEOF_SIZE_T == SIZEOF_LONG
00152 # define PY_SSIZE_T_FORMAT "%ld"
00153 # endif
00154 # else
00155 # define PY_SSIZE_T_FORMAT "%zd"
00156 # endif
00157 #endif
00158
00159 #if PY_VERSION_HEX < 0x03000000
00160
00161 #ifdef Py_False
00162 #undef Py_False
00163 #define Py_False ( (PyObject*)(void*)&_Py_ZeroStruct )
00164 #endif
00165
00166 #ifdef Py_True
00167 #undef Py_True
00168 #define Py_True ( (PyObject*)(void*)&_Py_TrueStruct )
00169 #endif
00170 #endif
00171
00172 #endif // !PYROOT_PYROOT_H