| [3225] | 1 |
|
|---|
| 2 | #include "Python.h"
|
|---|
| 3 |
|
|---|
| 4 | PyDoc_STRVAR(operator_doc,
|
|---|
| 5 | "Operator interface.\n\
|
|---|
| 6 | \n\
|
|---|
| 7 | This module exports a set of functions implemented in C corresponding\n\
|
|---|
| 8 | to the intrinsic operators of Python. For example, operator.add(x, y)\n\
|
|---|
| 9 | is equivalent to the expression x+y. The function names are those\n\
|
|---|
| 10 | used for special class methods; variants without leading and trailing\n\
|
|---|
| 11 | '__' are also provided for convenience.");
|
|---|
| 12 |
|
|---|
| 13 | #define spam1(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a1) { \
|
|---|
| 14 | return AOP(a1); }
|
|---|
| 15 |
|
|---|
| 16 | #define spam2(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
|
|---|
| 17 | PyObject *a1, *a2; \
|
|---|
| 18 | if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \
|
|---|
| 19 | return AOP(a1,a2); }
|
|---|
| 20 |
|
|---|
| 21 | #define spamoi(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
|
|---|
| 22 | PyObject *a1; int a2; \
|
|---|
| 23 | if(! PyArg_ParseTuple(a,"Oi:" #OP,&a1,&a2)) return NULL; \
|
|---|
| 24 | return AOP(a1,a2); }
|
|---|
| 25 |
|
|---|
| 26 | #define spam2n(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \
|
|---|
| 27 | PyObject *a1, *a2; \
|
|---|
| |
|---|