1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| [typeobject.c] typedef struct wrapperbase slotdef;
[descrobject.h] struct wrapperbase{ char* name; int offset; void* function; wrapperfunc wrapper; char* doc; int flags; PyObject* name_strobj; };
[typeobject.c] #define TPSLOT(NAME,SLOT,FUNCTION,WRAPPER,DOC) {NAME,offsetof(PyTypeObject,SLOT),(void *)(FUNCTION),WRAPPER,PyDoc_STR(DOC)}
#define ETSLOT(NAME,SLOT,FUNCTION,WRAPPER,DOC) {NAME,offsetof(PyHeapTypeObject,SLOT),(void *)(FUNCTION),WRAPPER,PyDoc_STR(DOC)}
[structmember.h] #define offsetof(type,member) ((int)&((type*)0)->member)
[object.h] typedef struct _heaptypeobject { PyTypeObject ht_type; PyNumberMethods as_number; PyMappingMethods as_mapping; PySequenceMethods as_sequence; PyBufferProcs as_buffer; PyObject* ht_name,*ht_slots; } PyHeapTypeObject;
[typeobject.c] .... #define SQSLOT(NAME,SLOT,FUNCTION,WRAPPER,DOC) ETSLOT(NAME,as_sequence.SLOT,FUNCTION,WRAPPER,DOC) ....
static slotdef slotdefs[] = { ... BINSLOT("__add__",nb_add,slot_nb_add,"+"), RBINSLOT("__radd__",nb_add,slot_nb_add,"+"), SQSLOT("__getitem__",sq_item,slot_sq_item,wrap_sq_item,"x.__getitem__(y)<==>x[y]"), MPSLOT("__getitem__",mp_subscript,slot_mp_subscript,wrap_binaryfunc,"x.___getitem__(y)<==>x[y]"), ... }
|