cpython/Modules/_testcapi/heaptype.c

#include "parts.h"
#include <stddef.h>               // offsetof()


static struct PyModuleDef *_testcapimodule =;  // set at initialization

/* Tests for heap types (PyType_From*) */

static PyObject *pytype_fromspec_meta(PyObject* self, PyObject *meta)
{}


static PyType_Slot empty_type_slots[] =;

static PyType_Spec MinimalMetaclass_spec =;

static PyType_Spec MinimalType_spec =;


static PyObject *
test_from_spec_metatype_inheritance(PyObject *self, PyObject *Py_UNUSED(ignored))
{}


static PyObject *
test_from_spec_invalid_metatype_inheritance(PyObject *self, PyObject *Py_UNUSED(ignored))
{}


static PyObject *
simple_str(PyObject *self) {}


static PyObject *
test_type_from_ephemeral_spec(PyObject *self, PyObject *Py_UNUSED(ignored))
{}

PyType_Slot repeated_doc_slots[] =;

PyType_Spec repeated_doc_slots_spec =;

HeapCTypeWithDataObject;


static struct PyMemberDef members_to_repeat[] =;

PyType_Slot repeated_members_slots[] =;

PyType_Spec repeated_members_slots_spec =;

static PyObject *
create_type_from_repeated_slots(PyObject *self, PyObject *variant_obj)
{}


static PyObject *
make_immutable_type_with_base(PyObject *self, PyObject *base)
{}

static PyObject *
make_type_with_base(PyObject *self, PyObject *base)
{}


static PyObject *
pyobject_getitemdata(PyObject *self, PyObject *o)
{}


static PyObject *
create_type_with_token(PyObject *module, PyObject *args)
{}

static PyObject *
get_tp_token(PyObject *self, PyObject *type)
{}

static PyObject *
pytype_getbasebytoken(PyObject *self, PyObject *args)
{}


static PyMethodDef TestMethods[] =;


PyDoc_STRVAR(heapdocctype__doc__,
"HeapDocCType(arg1, arg2)\n"
"--\n"
"\n"
"somedoc");

HeapDocCTypeObject;

static PyType_Slot HeapDocCType_slots[] =;

static PyType_Spec HeapDocCType_spec =;

NullTpDocTypeObject;

static PyType_Slot NullTpDocType_slots[] =;

static PyType_Spec NullTpDocType_spec =;


PyDoc_STRVAR(heapgctype__doc__,
"A heap type with GC, and with overridden dealloc.\n\n"
"The 'value' attribute is set to 10 in __init__.");

HeapCTypeObject;

static struct PyMemberDef heapctype_members[] =;

static int
heapctype_init(PyObject *self, PyObject *args, PyObject *kwargs)
{}

static int
heapgcctype_traverse(HeapCTypeObject *self, visitproc visit, void *arg)
{}

static void
heapgcctype_dealloc(HeapCTypeObject *self)
{}

static PyType_Slot HeapGcCType_slots[] =;

static PyType_Spec HeapGcCType_spec =;

PyDoc_STRVAR(heapctype__doc__,
"A heap type without GC, but with overridden dealloc.\n\n"
"The 'value' attribute is set to 10 in __init__.");

static void
heapctype_dealloc(HeapCTypeObject *self)
{}

static PyType_Slot HeapCType_slots[] =;

static PyType_Spec HeapCType_spec =;

PyDoc_STRVAR(heapctypesubclass__doc__,
"Subclass of HeapCType, without GC.\n\n"
"__init__ sets the 'value' attribute to 10 and 'value2' to 20.");

HeapCTypeSubclassObject;

static int
heapctypesubclass_init(PyObject *self, PyObject *args, PyObject *kwargs)
{}

static struct PyMemberDef heapctypesubclass_members[] =;

static PyType_Slot HeapCTypeSubclass_slots[] =;

static PyType_Spec HeapCTypeSubclass_spec =;

PyDoc_STRVAR(heapctypewithbuffer__doc__,
"Heap type with buffer support.\n\n"
"The buffer is set to [b'1', b'2', b'3', b'4']");

HeapCTypeWithBufferObject;

static int
heapctypewithbuffer_getbuffer(HeapCTypeWithBufferObject *self, Py_buffer *view, int flags)
{}

static void
heapctypewithbuffer_releasebuffer(HeapCTypeWithBufferObject *self, Py_buffer *view)
{}

static PyType_Slot HeapCTypeWithBuffer_slots[] =;

static PyType_Spec HeapCTypeWithBuffer_spec =;

PyDoc_STRVAR(heapctypesubclasswithfinalizer__doc__,
"Subclass of HeapCType with a finalizer that reassigns __class__.\n\n"
"__class__ is set to plain HeapCTypeSubclass during finalization.\n"
"__init__ sets the 'value' attribute to 10 and 'value2' to 20.");

static int
heapctypesubclasswithfinalizer_init(PyObject *self, PyObject *args, PyObject *kwargs)
{}

static void
heapctypesubclasswithfinalizer_finalize(PyObject *self)
{}

static PyType_Slot HeapCTypeSubclassWithFinalizer_slots[] =;

static PyType_Spec HeapCTypeSubclassWithFinalizer_spec =;

static PyType_Slot HeapCTypeMetaclass_slots[] =;

static PyType_Spec HeapCTypeMetaclass_spec =;

static PyObject *
heap_ctype_metaclass_custom_tp_new(PyTypeObject *tp, PyObject *args, PyObject *kwargs)
{}

static PyType_Slot HeapCTypeMetaclassCustomNew_slots[] =;

static PyType_Spec HeapCTypeMetaclassCustomNew_spec =;

static PyType_Spec HeapCTypeMetaclassNullNew_spec =;


HeapCTypeWithDictObject;

static void
heapctypewithdict_dealloc(HeapCTypeWithDictObject* self)
{}

static PyGetSetDef heapctypewithdict_getsetlist[] =;

static struct PyMemberDef heapctypewithdict_members[] =;

static PyType_Slot HeapCTypeWithDict_slots[] =;

static PyType_Spec HeapCTypeWithDict_spec =;

static PyType_Spec HeapCTypeWithDict2_spec =;

static int
heapmanaged_traverse(HeapCTypeObject *self, visitproc visit, void *arg)
{}

static int
heapmanaged_clear(HeapCTypeObject *self)
{}

static void
heapmanaged_dealloc(HeapCTypeObject *self)
{}

static PyType_Slot HeapCTypeWithManagedDict_slots[] =;

static PyType_Spec  HeapCTypeWithManagedDict_spec =;

static void
heapctypewithmanagedweakref_dealloc(PyObject* self)
{}

static PyType_Slot HeapCTypeWithManagedWeakref_slots[] =;

static PyType_Spec  HeapCTypeWithManagedWeakref_spec =;

static struct PyMemberDef heapctypewithnegativedict_members[] =;

static PyType_Slot HeapCTypeWithNegativeDict_slots[] =;

static PyType_Spec HeapCTypeWithNegativeDict_spec =;

HeapCTypeWithWeakrefObject;

static struct PyMemberDef heapctypewithweakref_members[] =;

static void
heapctypewithweakref_dealloc(HeapCTypeWithWeakrefObject* self)
{}

static PyType_Slot HeapCTypeWithWeakref_slots[] =;

static PyType_Spec HeapCTypeWithWeakref_spec =;

static PyType_Spec HeapCTypeWithWeakref2_spec =;

PyDoc_STRVAR(heapctypesetattr__doc__,
"A heap type without GC, but with overridden __setattr__.\n\n"
"The 'value' attribute is set to 10 in __init__ and updated via attribute setting.");

HeapCTypeSetattrObject;

static struct PyMemberDef heapctypesetattr_members[] =;

static int
heapctypesetattr_init(PyObject *self, PyObject *args, PyObject *kwargs)
{}

static void
heapctypesetattr_dealloc(HeapCTypeSetattrObject *self)
{}

static int
heapctypesetattr_setattro(HeapCTypeSetattrObject *self, PyObject *attr, PyObject *value)
{}

static PyType_Slot HeapCTypeSetattr_slots[] =;

static PyType_Spec HeapCTypeSetattr_spec =;

/*
 * The code below is for a test that uses PyType_FromSpec API to create a heap
 * type that simultaneously exposes
 *
 * - A regular __new__ / __init__ constructor pair
 * - A vector call handler in the type object
 *
 * A general requirement of vector call implementations is that they should
 * behave identically (except being potentially faster). The example below
 * deviates from this rule by initializing the instance with a different value.
 * This is only done here only so that we can see which path was taken and is
 * strongly discouraged in other cases.
 */

HeapCTypeVectorcallObject;

static PyObject *heapctype_vectorcall_vectorcall(PyObject *self,
                                                 PyObject *const *args_in,
                                                 size_t nargsf,
                                                 PyObject *kwargs_in)
{}

static PyObject *
heapctype_vectorcall_new(PyTypeObject* type, PyObject* args, PyObject *kwargs)
{}

static int
heapctype_vectorcall_init(PyObject *self, PyObject *args, PyObject *kwargs) {}

static struct PyMemberDef heapctype_vectorcall_members[] =;

static PyType_Slot HeapCTypeVectorcall_slots[] =;

static PyType_Spec HeapCTypeVectorcall_spec =;

PyDoc_STRVAR(HeapCCollection_doc,
"Tuple-like heap type that uses PyObject_GetItemData for items.");

static PyObject*
HeapCCollection_new(PyTypeObject *subtype, PyObject *args, PyObject *kwds)
{}

static Py_ssize_t
HeapCCollection_length(PyVarObject *self)
{}

static PyObject*
HeapCCollection_item(PyObject *self, Py_ssize_t i)
{}

static int
HeapCCollection_traverse(PyObject *self, visitproc visit, void *arg)
{}

static int
HeapCCollection_clear(PyObject *self)
{}

static void
HeapCCollection_dealloc(PyObject *self)
{}

static PyType_Slot HeapCCollection_slots[] =;

static PyType_Spec HeapCCollection_spec =;

int
_PyTestCapi_Init_Heaptype(PyObject *m) {}