source: vendor/python/2.5/Modules/operator.c

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 17.6 KB
RevLine 
[3225]1
2#include "Python.h"
3
4PyDoc_STRVAR(operator_doc,
5"Operator interface.\n\
6\n\
7This module exports a set of functions implemented in C corresponding\n\
8to the intrinsic operators of Python. For example, operator.add(x, y)\n\
9is equivalent to the expression x+y. The function names are those\n\
10used 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; \