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