[Python-checkins] python/dist/src/Objects abstract.c,2.108,2.109
nascheme@users.sourceforge.net
nascheme@users.sourceforge.net
Sat, 23 Nov 2002 17:34:51 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv2511/Objects
Modified Files:
abstract.c
Log Message:
Simplify use of NB_BINOP and NB_TERNOP by making them do the pointer
dereference rather than the caller.
Index: abstract.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
retrieving revision 2.108
retrieving revision 2.109
diff -C2 -d -r2.108 -r2.109
*** abstract.c 24 Nov 2002 01:07:42 -0000 2.108
--- abstract.c 24 Nov 2002 01:34:49 -0000 2.109
***************
*** 319,325 ****
#define NB_SLOT(x) offsetof(PyNumberMethods, x)
#define NB_BINOP(nb_methods, slot) \
! ((binaryfunc*)(& ((char*)nb_methods)[slot] ))
#define NB_TERNOP(nb_methods, slot) \
! ((ternaryfunc*)(& ((char*)nb_methods)[slot] ))
/*
--- 319,325 ----
#define NB_SLOT(x) offsetof(PyNumberMethods, x)
#define NB_BINOP(nb_methods, slot) \
! (*(binaryfunc*)(& ((char*)nb_methods)[slot]))
#define NB_TERNOP(nb_methods, slot) \
! (*(ternaryfunc*)(& ((char*)nb_methods)[slot]))
/*
***************
*** 353,360 ****
if (v->ob_type->tp_as_number != NULL && NEW_STYLE_NUMBER(v))
! slotv = *NB_BINOP(v->ob_type->tp_as_number, op_slot);
if (w->ob_type != v->ob_type &&
w->ob_type->tp_as_number != NULL && NEW_STYLE_NUMBER(w)) {
! slotw = *NB_BINOP(w->ob_type->tp_as_number, op_slot);
if (slotw == slotv)
slotw = NULL;
--- 353,360 ----
if (v->ob_type->tp_as_number != NULL && NEW_STYLE_NUMBER(v))
! slotv = NB_BINOP(v->ob_type->tp_as_number, op_slot);
if (w->ob_type != v->ob_type &&
w->ob_type->tp_as_number != NULL && NEW_STYLE_NUMBER(w)) {
! slotw = NB_BINOP(w->ob_type->tp_as_number, op_slot);
if (slotw == slotv)
slotw = NULL;
***************
*** 388,392 ****
if (mv) {
binaryfunc slot;
! slot = *NB_BINOP(mv, op_slot);
if (slot) {
PyObject *x = slot(v, w);
--- 388,392 ----
if (mv) {
binaryfunc slot;
! slot = NB_BINOP(mv, op_slot);
if (slot) {
PyObject *x = slot(v, w);
***************
*** 467,474 ****
mw = w->ob_type->tp_as_number;
if (mv != NULL && NEW_STYLE_NUMBER(v))
! slotv = *NB_TERNOP(mv, op_slot);
if (w->ob_type != v->ob_type &&
mv != NULL && NEW_STYLE_NUMBER(w)) {
! slotw = *NB_TERNOP(mw, op_slot);
if (slotw == slotv)
slotw = NULL;
--- 467,474 ----
mw = w->ob_type->tp_as_number;
if (mv != NULL && NEW_STYLE_NUMBER(v))
! slotv = NB_TERNOP(mv, op_slot);
if (w->ob_type != v->ob_type &&
mv != NULL && NEW_STYLE_NUMBER(w)) {
! slotw = NB_TERNOP(mw, op_slot);
if (slotw == slotv)
slotw = NULL;
***************
*** 495,499 ****
mz = z->ob_type->tp_as_number;
if (mz != NULL && NEW_STYLE_NUMBER(z)) {
! slotz = *NB_TERNOP(mz, op_slot);
if (slotz == slotv || slotz == slotw)
slotz = NULL;
--- 495,499 ----
mz = z->ob_type->tp_as_number;
if (mz != NULL && NEW_STYLE_NUMBER(z)) {
! slotz = NB_TERNOP(mz, op_slot);
if (slotz == slotv || slotz == slotw)
slotz = NULL;
***************
*** 520,525 ****
if (z == Py_None) {
if (v->ob_type->tp_as_number) {
! slotz = *NB_TERNOP(v->ob_type->tp_as_number,
! op_slot);
if (slotz)
x = slotz(v, w, z);
--- 520,525 ----
if (z == Py_None) {
if (v->ob_type->tp_as_number) {
! slotz = NB_TERNOP(v->ob_type->tp_as_number,
! op_slot);
if (slotz)
x = slotz(v, w, z);
***************
*** 543,548 ****
if (v1->ob_type->tp_as_number != NULL) {
! slotv = *NB_TERNOP(v1->ob_type->tp_as_number,
! op_slot);
if (slotv)
x = slotv(v1, w2, z2);
--- 543,548 ----
if (v1->ob_type->tp_as_number != NULL) {
! slotv = NB_TERNOP(v1->ob_type->tp_as_number,
! op_slot);
if (slotv)
x = slotv(v1, w2, z2);
***************
*** 674,680 ****
PyNumberMethods *mv = v->ob_type->tp_as_number;
if (mv != NULL && HASINPLACE(v)) {
! binaryfunc *slot = NB_BINOP(mv, iop_slot);
! if (*slot) {
! PyObject *x = (*slot)(v, w);
if (x != Py_NotImplemented) {
return x;
--- 674,680 ----
PyNumberMethods *mv = v->ob_type->tp_as_number;
if (mv != NULL && HASINPLACE(v)) {
! binaryfunc slot = NB_BINOP(mv, iop_slot);
! if (slot) {
! PyObject *x = (slot)(v, w);
if (x != Py_NotImplemented) {
return x;