diff options
Diffstat (limited to 'src/if_python3.c')
-rw-r--r-- | src/if_python3.c | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/src/if_python3.c b/src/if_python3.c index c135e7e..ac817bd 100644 --- a/src/if_python3.c +++ b/src/if_python3.c @@ -219,6 +219,17 @@ static HINSTANCE hinstPy3 = 0; // Instance of python.dll # define PyObject_GetItem py3_PyObject_GetItem # define PyObject_IsTrue py3_PyObject_IsTrue # define PyModule_GetDict py3_PyModule_GetDict +# if defined(USE_LIMITED_API) \ + && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) +# undef Py_INCREF +# if Py_LIMITED_API+0 >= 0x030a00A7 +# define _Py_IncRef py3__Py_IncRef +# define Py_INCREF _Py_IncRef +# else +# define Py_IncRef py3_Py_IncRef +# define Py_INCREF Py_IncRef +# endif +# endif # ifdef USE_LIMITED_API # define Py_CompileString py3_Py_CompileString # define PyEval_EvalCode py3_PyEval_EvalCode @@ -232,7 +243,11 @@ static HINSTANCE hinstPy3 = 0; // Instance of python.dll # define PyObject_HasAttrString py3_PyObject_HasAttrString # define PyObject_SetAttrString py3_PyObject_SetAttrString # define PyObject_CallFunctionObjArgs py3_PyObject_CallFunctionObjArgs -# define _PyObject_CallFunction_SizeT py3__PyObject_CallFunction_SizeT +# if PY_VERSION_HEX >= 0x030d0000 +# define PyObject_CallFunction py3_PyObject_CallFunction +# else +# define _PyObject_CallFunction_SizeT py3__PyObject_CallFunction_SizeT +# endif # define PyObject_Call py3_PyObject_Call # define PyEval_GetLocals py3_PyEval_GetLocals # define PyEval_GetGlobals py3_PyEval_GetGlobals @@ -387,6 +402,15 @@ static void (*py3_Py_Finalize)(void); static void (*py3_PyErr_SetString)(PyObject *, const char *); static void (*py3_PyErr_SetObject)(PyObject *, PyObject *); static int (*py3_PyErr_ExceptionMatches)(PyObject *); +# if defined(USE_LIMITED_API) \ + && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) +# if Py_LIMITED_API+0 >= 0x030a00A7 +# define _Py_IncRef py3__Py_IncRef +static void (*py3__Py_IncRef)(PyObject *); +# else +static void (*py3_Py_IncRef)(PyObject *); +# endif +# endif # ifdef USE_LIMITED_API static PyObject* (*py3_Py_CompileString)(const char *, const char *, int); static PyObject* (*py3_PyEval_EvalCode)(PyObject *co, PyObject *globals, PyObject *locals); @@ -398,7 +422,11 @@ static PyObject* (*py3_PyObject_GetAttrString)(PyObject *, const char *); static int (*py3_PyObject_HasAttrString)(PyObject *, const char *); static int (*py3_PyObject_SetAttrString)(PyObject *, const char *, PyObject *); static PyObject* (*py3_PyObject_CallFunctionObjArgs)(PyObject *, ...); +# if PY_VERSION_HEX >= 0x030d0000 +static PyObject* (*py3_PyObject_CallFunction)(PyObject *, char *, ...); +# else static PyObject* (*py3__PyObject_CallFunction_SizeT)(PyObject *, char *, ...); +# endif static PyObject* (*py3_PyObject_Call)(PyObject *, PyObject *, PyObject *); static PyObject* (*py3_PyEval_GetGlobals)(void); static PyObject* (*py3_PyEval_GetLocals)(void); @@ -590,6 +618,14 @@ static struct {"PyErr_SetString", (PYTHON_PROC*)&py3_PyErr_SetString}, {"PyErr_SetObject", (PYTHON_PROC*)&py3_PyErr_SetObject}, {"PyErr_ExceptionMatches", (PYTHON_PROC*)&py3_PyErr_ExceptionMatches}, +# if defined(USE_LIMITED_API) \ + && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) +# if Py_LIMITED_API+0 >= 0x030a00A7 + {"_Py_IncRef", (PYTHON_PROC*)&py3__Py_IncRef}, +# else + {"Py_IncRef", (PYTHON_PROC*)&py3_Py_IncRef}, +# endif +# endif # ifdef USE_LIMITED_API {"Py_CompileString", (PYTHON_PROC*)&py3_Py_CompileString}, {"PyEval_EvalCode", (PYTHON_PROC*)&PyEval_EvalCode}, @@ -601,7 +637,11 @@ static struct {"PyObject_HasAttrString", (PYTHON_PROC*)&py3_PyObject_HasAttrString}, {"PyObject_SetAttrString", (PYTHON_PROC*)&py3_PyObject_SetAttrString}, {"PyObject_CallFunctionObjArgs", (PYTHON_PROC*)&py3_PyObject_CallFunctionObjArgs}, +# if PY_VERSION_HEX >= 0x030d0000 + {"PyObject_CallFunction", (PYTHON_PROC*)&py3_PyObject_CallFunction}, +# else {"_PyObject_CallFunction_SizeT", (PYTHON_PROC*)&py3__PyObject_CallFunction_SizeT}, +# endif {"PyObject_Call", (PYTHON_PROC*)&py3_PyObject_Call}, {"PyEval_GetGlobals", (PYTHON_PROC*)&py3_PyEval_GetGlobals}, {"PyEval_GetLocals", (PYTHON_PROC*)&py3_PyEval_GetLocals}, @@ -762,6 +802,20 @@ py3__Py_XDECREF(PyObject *op) # define Py_XDECREF(op) py3__Py_XDECREF(_PyObject_CAST(op)) # endif +# if defined(USE_LIMITED_API) \ + && (Py_LIMITED_API+0 >= 0x030c0000 || defined(Py_REF_DEBUG)) + static inline void +py3__Py_XINCREF(PyObject *op) +{ + if (op != NULL) + { + Py_INCREF(op); + } +} +# undef Py_XINCREF +# define Py_XINCREF(op) py3__Py_XINCREF(_PyObject_CAST(op)) +# endif + # if PY_VERSION_HEX >= 0x030900b0 static inline int py3_PyType_HasFeature(PyTypeObject *type, unsigned long feature) @@ -1067,7 +1121,7 @@ static int python_end_called = FALSE; #ifdef USE_LIMITED_API # define DESTRUCTOR_FINISH(self) \ - ((freefunc)PyType_GetSlot(Py_TYPE(self), Py_tp_free))((PyObject*)self) + ((freefunc)PyType_GetSlot(Py_TYPE((PyObject*)self), Py_tp_free))((PyObject*)self) #else # define DESTRUCTOR_FINISH(self) Py_TYPE(self)->tp_free((PyObject*)self) #endif |