py_panda: Add Dtool_GetPyTypeObject macro

This is a cleaner, future-proof way of accessing a Panda type as PyTypeObject pointer
This commit is contained in:
rdb 2024-08-07 15:53:27 +02:00
parent b8d6c7a2ef
commit ca7ba4eab3
1 changed files with 3 additions and 0 deletions

View File

@ -161,6 +161,9 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\
Py_TYPE(self)->tp_free(self);\
}
// Extract the PyTypeObject pointer corresponding to a Dtool_PyTypedObject.
#define Dtool_GetPyTypeObject(type) (&(type)->_PyType)
// Use DtoolInstance_Check to check whether a PyObject* is a DtoolInstance.
#define DtoolInstance_Check(obj) \
(Py_TYPE(obj)->tp_basicsize >= (int)sizeof(Dtool_PyInstDef) && \