| 572 | } |
| 573 | #define RATIONAL_BINOP(name) RATIONAL_BINOP_2(name,rational_##name(x,y)) |
| 574 | RATIONAL_BINOP(add) |
| 575 | RATIONAL_BINOP(subtract) |
| 576 | RATIONAL_BINOP(multiply) |
| 577 | RATIONAL_BINOP(divide) |
| 578 | RATIONAL_BINOP(remainder) |
| 579 | RATIONAL_BINOP_2(floor_divide, |
| 580 | make_rational_int(rational_floor(rational_divide(x,y)))) |
| 581 | |
| 582 | #define RATIONAL_UNOP(name,type,exp,convert) \ |
| 583 | static PyObject* \ |
| 584 | pyrational_##name(PyObject* self) { \ |
| 585 | rational x = ((PyRational*)self)->r; \ |
| 586 | type y = exp; \ |
| 587 | if (PyErr_Occurred()) { \ |
| 588 | return 0; \ |
| 589 | } \ |
| 590 | return convert(y); \ |
| 591 | } |
| 592 | RATIONAL_UNOP(negative,rational,rational_negative(x),PyRational_FromRational) |
| 593 | RATIONAL_UNOP(absolute,rational,rational_abs(x),PyRational_FromRational) |
| 594 | RATIONAL_UNOP(int,long,rational_int(x),PyLong_FromLong) |
nothing calls this directly
no test coverage detected