Commit 1328b52c authored by Thomas Heller's avatar Thomas Heller

Two new public API functions, Py_IncRef and Py_DecRef. Useful for

dynamic embedders of Python.
parent 1a9d32b8
...@@ -42,6 +42,11 @@ of Python objects. ...@@ -42,6 +42,11 @@ of Python objects.
applies. applies.
\end{cfuncdesc} \end{cfuncdesc}
The following functions are for runtime dynamic embedding of Python:
\cfunction{Py_IncRef(PyObject *o)}, \cfunction{Py_DecRef(PyObject *o)}.
They are simply exported function versions of \cfunction{Py_XINCREF()} and
\cfunction{Py_XDECREF()}, respectively.
The following functions or macros are only for use within the The following functions or macros are only for use within the
interpreter core: \cfunction{_Py_Dealloc()}, interpreter core: \cfunction{_Py_Dealloc()},
\cfunction{_Py_ForgetReference()}, \cfunction{_Py_NewReference()}, as \cfunction{_Py_ForgetReference()}, \cfunction{_Py_NewReference()}, as
......
...@@ -624,6 +624,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force); ...@@ -624,6 +624,13 @@ PyAPI_FUNC(void) _Py_AddToAllObjects(PyObject *, int force);
#define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op) #define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op)
#define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op) #define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
/*
These are provided as conveniences to Python runtime embedders, so that
they can have object code that is not dependent on Python compilation flags.
*/
PyAPI_FUNC(void) Py_IncRef(PyObject *);
PyAPI_FUNC(void) Py_DecRef(PyObject *);
/* /*
_Py_NoneStruct is an object of undefined type which can be used in contexts _Py_NoneStruct is an object of undefined type which can be used in contexts
where NULL (nil) is not suitable (since NULL often means 'error'). where NULL (nil) is not suitable (since NULL often means 'error').
......
...@@ -471,6 +471,10 @@ Build ...@@ -471,6 +471,10 @@ Build
C API C API
----- -----
- New public functions Py_IncRef() and Py_DecRef(), exposing the
functionality of the Py_XINCREF() and Py_XDECREF macros. Useful for
runtime dynamic embedding of Python.
- Added a new macro, PySequence_Fast_ITEMS, which retrieves a fast sequence's - Added a new macro, PySequence_Fast_ITEMS, which retrieves a fast sequence's
underlying array of PyObject pointers. Useful for high speed looping. underlying array of PyObject pointers. Useful for high speed looping.
......
...@@ -146,6 +146,18 @@ _Py_NegativeRefcount(const char *fname, int lineno, PyObject *op) ...@@ -146,6 +146,18 @@ _Py_NegativeRefcount(const char *fname, int lineno, PyObject *op)
#endif /* Py_REF_DEBUG */ #endif /* Py_REF_DEBUG */
void
Py_IncRef(PyObject *o)
{
Py_XINCREF(o);
}
void
Py_DecRef(PyObject *o)
{
Py_XDECREF(o);
}
PyObject * PyObject *
PyObject_Init(PyObject *op, PyTypeObject *tp) PyObject_Init(PyObject *op, PyTypeObject *tp)
{ {
......
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