Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 1 | typedef struct _typeobject { |
| 2 | PyObject_VAR_HEAD |
Martin Panter | 78d5033 | 2015-08-25 05:06:39 +0000 | [diff] [blame] | 3 | const char *tp_name; /* For printing, in format "<module>.<name>" */ |
| 4 | Py_ssize_t tp_basicsize, tp_itemsize; /* For allocation */ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 5 | |
| 6 | /* Methods to implement standard operations */ |
| 7 | |
| 8 | destructor tp_dealloc; |
| 9 | printfunc tp_print; |
| 10 | getattrfunc tp_getattr; |
| 11 | setattrfunc tp_setattr; |
Yury Selivanov | beaa509 | 2015-08-26 13:03:57 -0400 | [diff] [blame] | 12 | PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2) |
| 13 | or tp_reserved (Python 3) */ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 14 | reprfunc tp_repr; |
| 15 | |
| 16 | /* Method suites for standard classes */ |
| 17 | |
| 18 | PyNumberMethods *tp_as_number; |
| 19 | PySequenceMethods *tp_as_sequence; |
| 20 | PyMappingMethods *tp_as_mapping; |
| 21 | |
| 22 | /* More standard operations (here for binary compatibility) */ |
| 23 | |
| 24 | hashfunc tp_hash; |
| 25 | ternaryfunc tp_call; |
| 26 | reprfunc tp_str; |
| 27 | getattrofunc tp_getattro; |
| 28 | setattrofunc tp_setattro; |
| 29 | |
| 30 | /* Functions to access object as input/output buffer */ |
| 31 | PyBufferProcs *tp_as_buffer; |
| 32 | |
| 33 | /* Flags to define presence of optional/expanded features */ |
Martin Panter | 78d5033 | 2015-08-25 05:06:39 +0000 | [diff] [blame] | 34 | unsigned long tp_flags; |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 35 | |
Martin Panter | 78d5033 | 2015-08-25 05:06:39 +0000 | [diff] [blame] | 36 | const char *tp_doc; /* Documentation string */ |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 37 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 38 | /* call function for all accessible objects */ |
| 39 | traverseproc tp_traverse; |
| 40 | |
| 41 | /* delete references to contained objects */ |
| 42 | inquiry tp_clear; |
| 43 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 44 | /* rich comparisons */ |
| 45 | richcmpfunc tp_richcompare; |
| 46 | |
| 47 | /* weak reference enabler */ |
Martin Panter | 78d5033 | 2015-08-25 05:06:39 +0000 | [diff] [blame] | 48 | Py_ssize_t tp_weaklistoffset; |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 49 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 50 | /* Iterators */ |
| 51 | getiterfunc tp_iter; |
| 52 | iternextfunc tp_iternext; |
| 53 | |
| 54 | /* Attribute descriptor and subclassing stuff */ |
| 55 | struct PyMethodDef *tp_methods; |
| 56 | struct PyMemberDef *tp_members; |
| 57 | struct PyGetSetDef *tp_getset; |
| 58 | struct _typeobject *tp_base; |
| 59 | PyObject *tp_dict; |
| 60 | descrgetfunc tp_descr_get; |
| 61 | descrsetfunc tp_descr_set; |
Martin Panter | 78d5033 | 2015-08-25 05:06:39 +0000 | [diff] [blame] | 62 | Py_ssize_t tp_dictoffset; |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 63 | initproc tp_init; |
| 64 | allocfunc tp_alloc; |
| 65 | newfunc tp_new; |
| 66 | freefunc tp_free; /* Low-level free-memory routine */ |
| 67 | inquiry tp_is_gc; /* For PyObject_IS_GC */ |
| 68 | PyObject *tp_bases; |
| 69 | PyObject *tp_mro; /* method resolution order */ |
| 70 | PyObject *tp_cache; |
| 71 | PyObject *tp_subclasses; |
| 72 | PyObject *tp_weaklist; |
Antoine Pitrou | 796564c | 2013-07-30 19:59:21 +0200 | [diff] [blame] | 73 | destructor tp_del; |
| 74 | |
| 75 | /* Type attribute cache version tag. Added in version 2.6 */ |
| 76 | unsigned int tp_version_tag; |
| 77 | |
| 78 | destructor tp_finalize; |
| 79 | |
Georg Brandl | 116aa62 | 2007-08-15 14:28:22 +0000 | [diff] [blame] | 80 | } PyTypeObject; |