From ca7ba4eab321fe84e4cdcb2dbee6197358818a57 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Aug 2024 15:53:27 +0200 Subject: [PATCH] py_panda: Add Dtool_GetPyTypeObject macro This is a cleaner, future-proof way of accessing a Panda type as PyTypeObject pointer --- dtool/src/interrogatedb/py_panda.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dtool/src/interrogatedb/py_panda.h b/dtool/src/interrogatedb/py_panda.h index 026d1c6858..23a38c4f7f 100644 --- a/dtool/src/interrogatedb/py_panda.h +++ b/dtool/src/interrogatedb/py_panda.h @@ -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) && \