10 #if PY_VERSION_HEX >= 0x030C0000
12 PyObject*
result = PyType_FromMetaclass(metaclass, mod, spec, base);
24 PyObject* temp = PyType_FromSpecWithBases(spec, base);
26 PyHeapTypeObject* temp_ht = (PyHeapTypeObject*) temp;
27 PyTypeObject* temp_tp = &temp_ht->ht_type;
29 Py_INCREF(temp_ht->ht_name);
30 Py_INCREF(temp_ht->ht_qualname);
31 Py_INCREF(temp_tp->tp_base);
32 Py_XINCREF(temp_ht->ht_slots);
39 PyHeapTypeObject* ht = (PyHeapTypeObject*)
result;
40 PyTypeObject* tp = &ht->ht_type;
42 memcpy(ht, temp_ht,
sizeof(PyHeapTypeObject));
44 tp->ob_base.ob_base.ob_type = metaclass;
45 tp->ob_base.ob_base.ob_refcnt = 1;
46 tp->ob_base.ob_size = 0;
47 tp->tp_as_async = &ht->as_async;
48 tp->tp_as_number = &ht->as_number;
49 tp->tp_as_sequence = &ht->as_sequence;
50 tp->tp_as_mapping = &ht->as_mapping;
51 tp->tp_as_buffer = &ht->as_buffer;
52 tp->tp_name = strdup(spec->name);
53 tp->tp_flags = spec->flags | Py_TPFLAGS_HEAPTYPE;
55 tp->tp_dict = tp->tp_bases = tp->tp_mro = tp->tp_cache = tp->tp_subclasses = tp->tp_weaklist =
57 ht->ht_cached_keys =
nullptr;
58 tp->tp_version_tag = 0;
66 PyObject* module_name = PyUnicode_FromString(
"hoc");
67 if (PyObject_SetAttrString(
result,
"__module__", module_name) < 0) {
68 Py_DECREF(module_name);
71 Py_DECREF(module_name);