18 static PyMemberDef standard_type_members[] = {
19 {(
char *)
"this", (
sizeof(
void*) ==
sizeof(int)) ? T_UINT : T_ULONGLONG, offsetof(Dtool_PyInstDef, _ptr_to_object), READONLY, (
char *)
"C++ 'this' pointer, if any"},
20 {(
char *)
"this_ownership", T_BOOL, offsetof(Dtool_PyInstDef, _memory_rules), READONLY, (
char *)
"C++ 'this' ownership rules"},
21 {(
char *)
"this_const", T_BOOL, offsetof(Dtool_PyInstDef, _is_const), READONLY, (
char *)
"C++ 'this' const flag"},
24 {(
char *)
"this_metatype", T_OBJECT, offsetof(Dtool_PyInstDef, _My_Type), READONLY, (
char *)
"The dtool meta object"},
28 static PyObject *GetSuperBase(PyObject *
self) {
29 Dtool_PyTypedObject *super_base = Dtool_GetSuperBase();
30 Py_XINCREF((PyTypeObject *)super_base);
31 return (PyObject *)super_base;
34 static void Dtool_PyModuleClassInit_DTOOL_SUPER_BASE(PyObject *module) {
35 if (module !=
nullptr) {
36 Dtool_PyTypedObject *super_base = Dtool_GetSuperBase();
37 Py_INCREF((PyTypeObject *)&super_base);
38 PyModule_AddObject(module,
"DTOOL_SUPER_BASE", (PyObject *)&super_base);
42 static void *Dtool_DowncastInterface_DTOOL_SUPER_BASE(
void *from_this, Dtool_PyTypedObject *from_type) {
46 static void *Dtool_UpcastInterface_DTOOL_SUPER_BASE(PyObject *
self, Dtool_PyTypedObject *requested_type) {
50 static int Dtool_Init_DTOOL_SUPER_BASE(PyObject *
self, PyObject *args, PyObject *kwds) {
51 assert(
self !=
nullptr);
52 PyErr_Format(PyExc_TypeError,
"cannot init constant class %s", Py_TYPE(
self)->tp_name);
56 static void Dtool_FreeInstance_DTOOL_SUPER_BASE(PyObject *
self) {
57 Py_TYPE(
self)->tp_free(
self);
64 Dtool_PyTypedObject *Dtool_GetSuperBase() {
65 Dtool_TypeMap *type_map = Dtool_GetGlobalTypeMap();
66 auto it = type_map->find(
"DTOOL_SUPER_BASE");
67 if (it != type_map->end()) {
71 static PyMethodDef methods[] = {
72 {
"DtoolGetSuperBase", (PyCFunction)&GetSuperBase, METH_NOARGS,
"Will Return SUPERbase Class"},
73 {
nullptr,
nullptr, 0,
nullptr }
76 static Dtool_PyTypedObject super_base_type = {
78 PyVarObject_HEAD_INIT(
nullptr, 0)
79 "dtoolconfig.DTOOL_SUPER_BASE",
80 sizeof(Dtool_PyInstDef),
82 &Dtool_FreeInstance_DTOOL_SUPER_BASE,
86 #
if PY_MAJOR_VERSION >= 3
98 PyObject_GenericGetAttr,
99 PyObject_GenericSetAttr,
101 (Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_CHECKTYPES),
105 #if PY_MAJOR_VERSION >= 3 114 standard_type_members,
121 Dtool_Init_DTOOL_SUPER_BASE,
134 Dtool_PyModuleClassInit_DTOOL_SUPER_BASE,
135 Dtool_UpcastInterface_DTOOL_SUPER_BASE,
136 Dtool_DowncastInterface_DTOOL_SUPER_BASE,
141 super_base_type._PyType.tp_dict = PyDict_New();
142 PyDict_SetItemString(super_base_type._PyType.tp_dict,
"DtoolClassDict", super_base_type._PyType.tp_dict);
144 if (PyType_Ready((PyTypeObject *)&super_base_type) < 0) {
145 PyErr_SetString(PyExc_TypeError,
"PyType_Ready(Dtool_DTOOL_SUPER_BASE)");
148 Py_INCREF((PyTypeObject *)&super_base_type);
150 PyDict_SetItemString(super_base_type._PyType.tp_dict,
"DtoolGetSuperBase", PyCFunction_New(&methods[0], (PyObject *)&super_base_type));
152 (*type_map)[
"DTOOL_SUPER_BASE"] = &super_base_type;
153 return &super_base_type;
156 #endif // HAVE_PYTHON Py_hash_t DtoolInstance_HashPointer(PyObject *self)
Function to create a hash from a wrapped Python object.
PyObject * DtoolInstance_RichComparePointers(PyObject *v1, PyObject *v2, int op)
Rich comparison function that compares objects by pointer.
int DtoolInstance_ComparePointers(PyObject *v1, PyObject *v2)
Python 2-style comparison function that compares objects by pointer.