Browse Source

py_panda: Add Dtool_GetPyTypeObject macro

This is a cleaner, future-proof way of accessing a Panda type as PyTypeObject pointer
rdb 1 year ago
parent
commit
ca7ba4eab3
1 changed files with 3 additions and 0 deletions
  1. 3 0
      dtool/src/interrogatedb/py_panda.h

+ 3 - 0
dtool/src/interrogatedb/py_panda.h

@@ -161,6 +161,9 @@ static void Dtool_FreeInstance_##CLASS_NAME(PyObject *self) {\
   Py_TYPE(self)->tp_free(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.
 // Use DtoolInstance_Check to check whether a PyObject* is a DtoolInstance.
 #define DtoolInstance_Check(obj) \
 #define DtoolInstance_Check(obj) \
   (Py_TYPE(obj)->tp_basicsize >= (int)sizeof(Dtool_PyInstDef) && \
   (Py_TYPE(obj)->tp_basicsize >= (int)sizeof(Dtool_PyInstDef) && \