Merged release21-maint changes.
[python/dscho.git] / Tools / modulator / Templates / object_tp_as_number
blob2f90edc2f5020d1bf83b815f47f3644e437047c8
2 /* Code to access $name$ objects as numbers */
4 static PyObject *
5 $abbrev$_add(v, w)
6         $abbrev$object *v;
7         $abbrev$object *w;
9         /* XXXX Add them */
12 static PyObject *
13 $abbrev$_sub(v, w)
14         $abbrev$object *v;
15         $abbrev$object *w;
17         /* XXXX Subtract them */
20 static PyObject *
21 $abbrev$_mul(v, w)
22         $abbrev$object *v;
23         $abbrev$object *w;
25         /* XXXX Multiply them */
28 static PyObject *
29 $abbrev$_div(x, y)
30         $abbrev$object *x;
31         $abbrev$object *y;
33         /* XXXX Divide them */
36 static PyObject *
37 $abbrev$_mod(x, y)
38         $abbrev$object *x;
39         $abbrev$object *y;
41         /* XXXX Modulo them */
44 static PyObject *
45 $abbrev$_divmod(x, y)
46         $abbrev$object *x;
47         $abbrev$object *y;
49         /* XXXX Return 2-tuple with div and mod */
52 static PyObject *
53 $abbrev$_pow(v, w, z)
54         $abbrev$object *v;
55         $abbrev$object *w;
56         $abbrev$object *z;
58         /* XXXX */
59 }                               
61 static PyObject *
62 $abbrev$_neg(v)
63         $abbrev$object *v;
65         /* XXXX */
68 static PyObject *
69 $abbrev$_pos(v)
70         $abbrev$object *v;
72         /* XXXX */
75 static PyObject *
76 $abbrev$_abs(v)
77         $abbrev$object *v;
79         /* XXXX */
82 static int
83 $abbrev$_nonzero(v)
84         $abbrev$object *v;
86         /* XXXX Return 1 if non-zero */
89 static PyObject *
90 $abbrev$_invert(v)
91         $abbrev$object *v;
93         /* XXXX */
96 static PyObject *
97 $abbrev$_lshift(v, w)
98         $abbrev$object *v;
99         $abbrev$object *w;
101         /* XXXX */
104 static PyObject *
105 $abbrev$_rshift(v, w)
106         $abbrev$object *v;
107         $abbrev$object *w;
109         /* XXXX */
112 static PyObject *
113 $abbrev$_and(v, w)
114         $abbrev$object *v;
115         $abbrev$object *w;
117         /* XXXX */
120 static PyObject *
121 $abbrev$_xor(v, w)
122         $abbrev$object *v;
123         $abbrev$object *w;
125         /* XXXX */
128 static PyObject *
129 $abbrev$_or(v, w)
130         $abbrev$object *v;
131         $abbrev$object *w;
133         /* XXXX */
136 static int
137 $abbrev$_coerce(pv, pw)
138         PyObject **pv;
139         PyObject **pw;
141         /* XXXX I haven't a clue... */
142         return 1;
145 static PyObject *
146 $abbrev$_int(v)
147         $abbrev$object *v;
149         /* XXXX */
152 static PyObject *
153 $abbrev$_long(v)
154         $abbrev$object *v;
156         /* XXXX */
159 static PyObject *
160 $abbrev$_float(v)
161         $abbrev$object *v;
163         /* XXXX */
166 static PyObject *
167 $abbrev$_oct(v)
168         $abbrev$object *v;
170         /* XXXX Return object as octal stringobject */
173 static PyObject *
174 $abbrev$_hex(v)
175         $abbrev$object *v;
177         /* XXXX Return object as hex stringobject */
180 static PyNumberMethods $abbrev$_as_number = {
181         (binaryfunc)$abbrev$_add,       /*nb_add*/
182         (binaryfunc)$abbrev$_sub,       /*nb_subtract*/
183         (binaryfunc)$abbrev$_mul,       /*nb_multiply*/
184         (binaryfunc)$abbrev$_div,       /*nb_divide*/
185         (binaryfunc)$abbrev$_mod,       /*nb_remainder*/
186         (binaryfunc)$abbrev$_divmod,    /*nb_divmod*/
187         (ternaryfunc)$abbrev$_pow,      /*nb_power*/
188         (unaryfunc)$abbrev$_neg,        /*nb_negative*/
189         (unaryfunc)$abbrev$_pos,        /*nb_positive*/
190         (unaryfunc)$abbrev$_abs,        /*nb_absolute*/
191         (inquiry)$abbrev$_nonzero,      /*nb_nonzero*/
192         (unaryfunc)$abbrev$_invert,     /*nb_invert*/
193         (binaryfunc)$abbrev$_lshift,    /*nb_lshift*/
194         (binaryfunc)$abbrev$_rshift,    /*nb_rshift*/
195         (binaryfunc)$abbrev$_and,       /*nb_and*/
196         (binaryfunc)$abbrev$_xor,       /*nb_xor*/
197         (binaryfunc)$abbrev$_or,        /*nb_or*/
198         (coercion)$abbrev$_coerce,      /*nb_coerce*/
199         (unaryfunc)$abbrev$_int,        /*nb_int*/
200         (unaryfunc)$abbrev$_long,       /*nb_long*/
201         (unaryfunc)$abbrev$_float,      /*nb_float*/
202         (unaryfunc)$abbrev$_oct,        /*nb_oct*/
203         (unaryfunc)$abbrev$_hex,        /*nb_hex*/
206 /* ------------------------------------------------------- */