Cython has moved to github.

pyrex

view Tests/5/extstarargs.c @ 86:da6e97bb7e6d

Multiple compilation fixed
author Gregory Ewing <greg.ewing@canterbury.ac.nz>
date Sat May 24 15:50:12 2008 +1200 (4 years ago)
parents 12072e0e4fd5
children 94d46b3c5354
line source
1 /* Generated by Pyrex */
3 #define PY_SSIZE_T_CLEAN
4 #include "Python.h"
5 #include "structmember.h"
6 #ifndef PY_LONG_LONG
7 #define PY_LONG_LONG LONG_LONG
8 #endif
9 #if PY_VERSION_HEX < 0x02050000
10 typedef int Py_ssize_t;
11 #define PY_SSIZE_T_MAX INT_MAX
12 #define PY_SSIZE_T_MIN INT_MIN
13 #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
14 #define PyInt_AsSsize_t(o) PyInt_AsLong(o)
15 #endif
16 #ifndef WIN32
17 #ifndef __stdcall
18 #define __stdcall
19 #endif
20 #ifndef __cdecl
21 #define __cdecl
22 #endif
23 #endif
24 #ifdef __cplusplus
25 #define __PYX_EXTERN_C extern "C"
26 #else
27 #define __PYX_EXTERN_C extern
28 #endif
29 #include <math.h>
32 typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
34 static PyObject *__pyx_m;
35 static PyObject *__pyx_b;
36 static int __pyx_lineno;
37 static char *__pyx_filename;
38 static char **__pyx_f;
40 static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/
42 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
44 static void __Pyx_AddTraceback(char *funcname); /*proto*/
46 /* Declarations from extstarargs */
49 /* Declarations from implementation of extstarargs */
51 struct __pyx_obj_11extstarargs_Silly {
52 PyObject_HEAD
53 };
56 static PyTypeObject *__pyx_ptype_11extstarargs_Silly = 0;
61 static __Pyx_StringTabEntry __pyx_string_tab[] = {
62 {0, 0, 0, 0}
63 };
67 /* Implementation of extstarargs */
69 static int __pyx_f_11extstarargs_5Silly___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
70 static int __pyx_f_11extstarargs_5Silly___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
71 PyObject *__pyx_v_a = 0;
72 int __pyx_r;
73 static char *__pyx_argnames[] = {0};
74 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_a, 0, 0) < 0) return -1;
75 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
76 Py_XDECREF(__pyx_args);
77 Py_XDECREF(__pyx_kwds);
78 Py_XDECREF(__pyx_v_a);
79 return -1;
80 }
81 Py_INCREF(__pyx_v_self);
83 __pyx_r = 0;
84 Py_XDECREF(__pyx_v_a);
85 Py_DECREF(__pyx_v_self);
86 Py_XDECREF(__pyx_args);
87 Py_XDECREF(__pyx_kwds);
88 return __pyx_r;
89 }
91 static PyObject *__pyx_f_11extstarargs_5Silly_spam(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
92 static PyObject *__pyx_f_11extstarargs_5Silly_spam(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
93 PyObject *__pyx_v_x = 0;
94 PyObject *__pyx_v_y = 0;
95 PyObject *__pyx_v_z = 0;
96 PyObject *__pyx_r;
97 static char *__pyx_argnames[] = {"x","y","z",0};
98 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
99 Py_INCREF(__pyx_v_self);
100 Py_INCREF(__pyx_v_x);
101 Py_INCREF(__pyx_v_y);
102 Py_INCREF(__pyx_v_z);
104 __pyx_r = Py_None; Py_INCREF(Py_None);
105 Py_DECREF(__pyx_v_self);
106 Py_DECREF(__pyx_v_x);
107 Py_DECREF(__pyx_v_y);
108 Py_DECREF(__pyx_v_z);
109 return __pyx_r;
110 }
112 static PyObject *__pyx_f_11extstarargs_5Silly_grail(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
113 static PyObject *__pyx_f_11extstarargs_5Silly_grail(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
114 PyObject *__pyx_v_x = 0;
115 PyObject *__pyx_v_y = 0;
116 PyObject *__pyx_v_z = 0;
117 PyObject *__pyx_v_a = 0;
118 PyObject *__pyx_r;
119 static char *__pyx_argnames[] = {"x","y","z",0};
120 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, &__pyx_v_a, 0, 0) < 0) return 0;
121 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) {
122 Py_XDECREF(__pyx_args);
123 Py_XDECREF(__pyx_kwds);
124 Py_XDECREF(__pyx_v_a);
125 return 0;
126 }
127 Py_INCREF(__pyx_v_self);
128 Py_INCREF(__pyx_v_x);
129 Py_INCREF(__pyx_v_y);
130 Py_INCREF(__pyx_v_z);
132 __pyx_r = Py_None; Py_INCREF(Py_None);
133 Py_XDECREF(__pyx_v_a);
134 Py_DECREF(__pyx_v_self);
135 Py_DECREF(__pyx_v_x);
136 Py_DECREF(__pyx_v_y);
137 Py_DECREF(__pyx_v_z);
138 Py_XDECREF(__pyx_args);
139 Py_XDECREF(__pyx_kwds);
140 return __pyx_r;
141 }
143 static PyObject *__pyx_f_11extstarargs_5Silly_swallow(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
144 static PyObject *__pyx_f_11extstarargs_5Silly_swallow(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
145 PyObject *__pyx_v_x = 0;
146 PyObject *__pyx_v_y = 0;
147 PyObject *__pyx_v_z = 0;
148 PyObject *__pyx_v_k = 0;
149 PyObject *__pyx_r;
150 static char *__pyx_argnames[] = {"x","y","z",0};
151 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, 0, &__pyx_v_k, 0) < 0) return 0;
152 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) {
153 Py_XDECREF(__pyx_args);
154 Py_XDECREF(__pyx_kwds);
155 Py_XDECREF(__pyx_v_k);
156 return 0;
157 }
158 Py_INCREF(__pyx_v_self);
159 Py_INCREF(__pyx_v_x);
160 Py_INCREF(__pyx_v_y);
161 Py_INCREF(__pyx_v_z);
163 __pyx_r = Py_None; Py_INCREF(Py_None);
164 Py_XDECREF(__pyx_v_k);
165 Py_DECREF(__pyx_v_self);
166 Py_DECREF(__pyx_v_x);
167 Py_DECREF(__pyx_v_y);
168 Py_DECREF(__pyx_v_z);
169 Py_XDECREF(__pyx_args);
170 Py_XDECREF(__pyx_kwds);
171 return __pyx_r;
172 }
174 static PyObject *__pyx_f_11extstarargs_5Silly_creosote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
175 static PyObject *__pyx_f_11extstarargs_5Silly_creosote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
176 PyObject *__pyx_v_x = 0;
177 PyObject *__pyx_v_y = 0;
178 PyObject *__pyx_v_z = 0;
179 PyObject *__pyx_v_a = 0;
180 PyObject *__pyx_v_k = 0;
181 PyObject *__pyx_r;
182 static char *__pyx_argnames[] = {"x","y","z",0};
183 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, &__pyx_v_a, &__pyx_v_k, 0) < 0) return 0;
184 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) {
185 Py_XDECREF(__pyx_args);
186 Py_XDECREF(__pyx_kwds);
187 Py_XDECREF(__pyx_v_a);
188 Py_XDECREF(__pyx_v_k);
189 return 0;
190 }
191 Py_INCREF(__pyx_v_self);
192 Py_INCREF(__pyx_v_x);
193 Py_INCREF(__pyx_v_y);
194 Py_INCREF(__pyx_v_z);
196 __pyx_r = Py_None; Py_INCREF(Py_None);
197 Py_XDECREF(__pyx_v_a);
198 Py_XDECREF(__pyx_v_k);
199 Py_DECREF(__pyx_v_self);
200 Py_DECREF(__pyx_v_x);
201 Py_DECREF(__pyx_v_y);
202 Py_DECREF(__pyx_v_z);
203 Py_XDECREF(__pyx_args);
204 Py_XDECREF(__pyx_kwds);
205 return __pyx_r;
206 }
208 static PyObject *__pyx_tp_new_11extstarargs_Silly(PyTypeObject *t, PyObject *a, PyObject *k) {
209 PyObject *o = (*t->tp_alloc)(t, 0);
210 if (!o) return 0;
211 return o;
212 }
214 static void __pyx_tp_dealloc_11extstarargs_Silly(PyObject *o) {
215 (*o->ob_type->tp_free)(o);
216 }
218 static struct PyMethodDef __pyx_methods_11extstarargs_Silly[] = {
219 {"spam", (PyCFunction)__pyx_f_11extstarargs_5Silly_spam, METH_VARARGS|METH_KEYWORDS, 0},
220 {"grail", (PyCFunction)__pyx_f_11extstarargs_5Silly_grail, METH_VARARGS|METH_KEYWORDS, 0},
221 {"swallow", (PyCFunction)__pyx_f_11extstarargs_5Silly_swallow, METH_VARARGS|METH_KEYWORDS, 0},
222 {"creosote", (PyCFunction)__pyx_f_11extstarargs_5Silly_creosote, METH_VARARGS|METH_KEYWORDS, 0},
223 {0, 0, 0, 0}
224 };
226 static PyNumberMethods __pyx_tp_as_number_Silly = {
227 0, /*nb_add*/
228 0, /*nb_subtract*/
229 0, /*nb_multiply*/
230 0, /*nb_divide*/
231 0, /*nb_remainder*/
232 0, /*nb_divmod*/
233 0, /*nb_power*/
234 0, /*nb_negative*/
235 0, /*nb_positive*/
236 0, /*nb_absolute*/
237 0, /*nb_nonzero*/
238 0, /*nb_invert*/
239 0, /*nb_lshift*/
240 0, /*nb_rshift*/
241 0, /*nb_and*/
242 0, /*nb_xor*/
243 0, /*nb_or*/
244 0, /*nb_coerce*/
245 0, /*nb_int*/
246 0, /*nb_long*/
247 0, /*nb_float*/
248 0, /*nb_oct*/
249 0, /*nb_hex*/
250 0, /*nb_inplace_add*/
251 0, /*nb_inplace_subtract*/
252 0, /*nb_inplace_multiply*/
253 0, /*nb_inplace_divide*/
254 0, /*nb_inplace_remainder*/
255 0, /*nb_inplace_power*/
256 0, /*nb_inplace_lshift*/
257 0, /*nb_inplace_rshift*/
258 0, /*nb_inplace_and*/
259 0, /*nb_inplace_xor*/
260 0, /*nb_inplace_or*/
261 0, /*nb_floor_divide*/
262 0, /*nb_true_divide*/
263 0, /*nb_inplace_floor_divide*/
264 0, /*nb_inplace_true_divide*/
265 #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
266 0, /*nb_index*/
267 #endif
268 };
270 static PySequenceMethods __pyx_tp_as_sequence_Silly = {
271 0, /*sq_length*/
272 0, /*sq_concat*/
273 0, /*sq_repeat*/
274 0, /*sq_item*/
275 0, /*sq_slice*/
276 0, /*sq_ass_item*/
277 0, /*sq_ass_slice*/
278 0, /*sq_contains*/
279 0, /*sq_inplace_concat*/
280 0, /*sq_inplace_repeat*/
281 };
283 static PyMappingMethods __pyx_tp_as_mapping_Silly = {
284 0, /*mp_length*/
285 0, /*mp_subscript*/
286 0, /*mp_ass_subscript*/
287 };
289 static PyBufferProcs __pyx_tp_as_buffer_Silly = {
290 0, /*bf_getreadbuffer*/
291 0, /*bf_getwritebuffer*/
292 0, /*bf_getsegcount*/
293 0, /*bf_getcharbuffer*/
294 };
296 PyTypeObject __pyx_type_11extstarargs_Silly = {
297 PyObject_HEAD_INIT(0)
298 0, /*ob_size*/
299 "extstarargs.Silly", /*tp_name*/
300 sizeof(struct __pyx_obj_11extstarargs_Silly), /*tp_basicsize*/
301 0, /*tp_itemsize*/
302 __pyx_tp_dealloc_11extstarargs_Silly, /*tp_dealloc*/
303 0, /*tp_print*/
304 0, /*tp_getattr*/
305 0, /*tp_setattr*/
306 0, /*tp_compare*/
307 0, /*tp_repr*/
308 &__pyx_tp_as_number_Silly, /*tp_as_number*/
309 &__pyx_tp_as_sequence_Silly, /*tp_as_sequence*/
310 &__pyx_tp_as_mapping_Silly, /*tp_as_mapping*/
311 0, /*tp_hash*/
312 0, /*tp_call*/
313 0, /*tp_str*/
314 0, /*tp_getattro*/
315 0, /*tp_setattro*/
316 &__pyx_tp_as_buffer_Silly, /*tp_as_buffer*/
317 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
318 0, /*tp_doc*/
319 0, /*tp_traverse*/
320 0, /*tp_clear*/
321 0, /*tp_richcompare*/
322 0, /*tp_weaklistoffset*/
323 0, /*tp_iter*/
324 0, /*tp_iternext*/
325 __pyx_methods_11extstarargs_Silly, /*tp_methods*/
326 0, /*tp_members*/
327 0, /*tp_getset*/
328 0, /*tp_base*/
329 0, /*tp_dict*/
330 0, /*tp_descr_get*/
331 0, /*tp_descr_set*/
332 0, /*tp_dictoffset*/
333 __pyx_f_11extstarargs_5Silly___init__, /*tp_init*/
334 0, /*tp_alloc*/
335 __pyx_tp_new_11extstarargs_Silly, /*tp_new*/
336 0, /*tp_free*/
337 0, /*tp_is_gc*/
338 0, /*tp_bases*/
339 0, /*tp_mro*/
340 0, /*tp_cache*/
341 0, /*tp_subclasses*/
342 0, /*tp_weaklist*/
343 };
345 static struct PyMethodDef __pyx_methods[] = {
346 {0, 0, 0, 0}
347 };
349 static void __pyx_init_filenames(void); /*proto*/
351 PyMODINIT_FUNC initextstarargs(void); /*proto*/
352 PyMODINIT_FUNC initextstarargs(void) {
353 __pyx_init_filenames();
354 __pyx_m = Py_InitModule4("extstarargs", __pyx_methods, 0, 0, PYTHON_API_VERSION);
355 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
356 Py_INCREF(__pyx_m);
357 __pyx_b = PyImport_AddModule("__builtin__");
358 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
359 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
360 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
361 if (PyType_Ready(&__pyx_type_11extstarargs_Silly) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
362 if (PyObject_SetAttrString(__pyx_m, "Silly", (PyObject *)&__pyx_type_11extstarargs_Silly) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
363 __pyx_ptype_11extstarargs_Silly = &__pyx_type_11extstarargs_Silly;
365 /* "/Local/Projects/D/Pyrex/Source/Tests/5/extstarargs.pyx":15 */
366 return;
367 __pyx_L1:;
368 __Pyx_AddTraceback("extstarargs");
369 }
371 static char *__pyx_filenames[] = {
372 "extstarargs.pyx",
373 };
375 /* Runtime support code */
377 static void __pyx_init_filenames(void) {
378 __pyx_f = __pyx_filenames;
379 }
381 static int __Pyx_GetStarArgs(
382 PyObject **args,
383 PyObject **kwds,
384 char *kwd_list[],
385 Py_ssize_t nargs,
386 PyObject **args2,
387 PyObject **kwds2,
388 char rqd_kwds[])
389 {
390 PyObject *x = 0, *args1 = 0, *kwds1 = 0;
391 int i;
392 char **p;
394 if (args2)
395 *args2 = 0;
396 if (kwds2)
397 *kwds2 = 0;
399 if (args2) {
400 args1 = PyTuple_GetSlice(*args, 0, nargs);
401 if (!args1)
402 goto bad;
403 *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args));
404 if (!*args2)
405 goto bad;
406 }
407 else if (PyTuple_GET_SIZE(*args) > nargs) {
408 int m = nargs;
409 int n = PyTuple_GET_SIZE(*args);
410 PyErr_Format(PyExc_TypeError,
411 "function takes at most %d positional arguments (%d given)",
412 m, n);
413 goto bad;
414 }
415 else {
416 args1 = *args;
417 Py_INCREF(args1);
418 }
420 if (rqd_kwds && !*kwds)
421 for (i = 0, p = kwd_list; *p; i++, p++)
422 if (rqd_kwds[i])
423 goto missing_kwarg;
425 if (kwds2) {
426 if (*kwds) {
427 kwds1 = PyDict_New();
428 if (!kwds1)
429 goto bad;
430 *kwds2 = PyDict_Copy(*kwds);
431 if (!*kwds2)
432 goto bad;
433 for (i = 0, p = kwd_list; *p; i++, p++) {
434 x = PyDict_GetItemString(*kwds, *p);
435 if (x) {
436 if (PyDict_SetItemString(kwds1, *p, x) < 0)
437 goto bad;
438 if (PyDict_DelItemString(*kwds2, *p) < 0)
439 goto bad;
440 }
441 else if (rqd_kwds && rqd_kwds[i])
442 goto missing_kwarg;
443 }
444 }
445 else {
446 *kwds2 = PyDict_New();
447 if (!*kwds2)
448 goto bad;
449 }
450 }
451 else {
452 kwds1 = *kwds;
453 Py_XINCREF(kwds1);
454 if (rqd_kwds && *kwds)
455 for (i = 0, p = kwd_list; *p; i++, p++)
456 if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p))
457 goto missing_kwarg;
458 }
460 *args = args1;
461 *kwds = kwds1;
462 return 0;
463 missing_kwarg:
464 PyErr_Format(PyExc_TypeError,
465 "required keyword argument '%s' is missing", *p);
466 bad:
467 Py_XDECREF(args1);
468 Py_XDECREF(kwds1);
469 if (args2) {
470 Py_XDECREF(*args2);
471 }
472 if (kwds2) {
473 Py_XDECREF(*kwds2);
474 }
475 return -1;
476 }
478 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
479 while (t->p) {
480 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
481 if (!*t->p)
482 return -1;
483 if (t->i)
484 PyString_InternInPlace(t->p);
485 ++t;
486 }
487 return 0;
488 }
490 #include "compile.h"
491 #include "frameobject.h"
492 #include "traceback.h"
494 static void __Pyx_AddTraceback(char *funcname) {
495 PyObject *py_srcfile = 0;
496 PyObject *py_funcname = 0;
497 PyObject *py_globals = 0;
498 PyObject *empty_tuple = 0;
499 PyObject *empty_string = 0;
500 PyCodeObject *py_code = 0;
501 PyFrameObject *py_frame = 0;
503 py_srcfile = PyString_FromString(__pyx_filename);
504 if (!py_srcfile) goto bad;
505 py_funcname = PyString_FromString(funcname);
506 if (!py_funcname) goto bad;
507 py_globals = PyModule_GetDict(__pyx_m);
508 if (!py_globals) goto bad;
509 empty_tuple = PyTuple_New(0);
510 if (!empty_tuple) goto bad;
511 empty_string = PyString_FromString("");
512 if (!empty_string) goto bad;
513 py_code = PyCode_New(
514 0, /*int argcount,*/
515 0, /*int nlocals,*/
516 0, /*int stacksize,*/
517 0, /*int flags,*/
518 empty_string, /*PyObject *code,*/
519 empty_tuple, /*PyObject *consts,*/
520 empty_tuple, /*PyObject *names,*/
521 empty_tuple, /*PyObject *varnames,*/
522 empty_tuple, /*PyObject *freevars,*/
523 empty_tuple, /*PyObject *cellvars,*/
524 py_srcfile, /*PyObject *filename,*/
525 py_funcname, /*PyObject *name,*/
526 __pyx_lineno, /*int firstlineno,*/
527 empty_string /*PyObject *lnotab*/
528 );
529 if (!py_code) goto bad;
530 py_frame = PyFrame_New(
531 PyThreadState_Get(), /*PyThreadState *tstate,*/
532 py_code, /*PyCodeObject *code,*/
533 py_globals, /*PyObject *globals,*/
534 0 /*PyObject *locals*/
535 );
536 if (!py_frame) goto bad;
537 py_frame->f_lineno = __pyx_lineno;
538 PyTraceBack_Here(py_frame);
539 bad:
540 Py_XDECREF(py_srcfile);
541 Py_XDECREF(py_funcname);
542 Py_XDECREF(empty_tuple);
543 Py_XDECREF(empty_string);
544 Py_XDECREF(py_code);
545 Py_XDECREF(py_frame);
546 }