Cython has moved to github.

pyrex

view Tests/5/Reference/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 6c5f5271ebab
children 3b20cb4923eb
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; char *s;} __Pyx_InternTabEntry; /*proto*/
33 typedef struct {PyObject **p; char *s; long n;} __Pyx_StringTabEntry; /*proto*/
35 static PyObject *__pyx_m;
36 static PyObject *__pyx_b;
37 static int __pyx_lineno;
38 static char *__pyx_filename;
39 static char **__pyx_f;
41 static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/
43 static void __Pyx_AddTraceback(char *funcname); /*proto*/
45 /* Declarations from extstarargs */
47 struct __pyx_obj_11extstarargs_Silly {
48 PyObject_HEAD
49 };
52 static PyTypeObject *__pyx_ptype_11extstarargs_Silly = 0;
55 static __Pyx_StringTabEntry __pyx_string_tab[] = {
56 {0, 0, 0, 0}
57 };
59 /* Implementation of extstarargs */
61 static int __pyx_f_11extstarargs_5Silly___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
62 static int __pyx_f_11extstarargs_5Silly___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
63 PyObject *__pyx_v_a = 0;
64 int __pyx_r;
65 static char *__pyx_argnames[] = {0};
66 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_a, 0, 0) < 0) return -1;
67 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) {
68 Py_XDECREF(__pyx_args);
69 Py_XDECREF(__pyx_kwds);
70 Py_XDECREF(__pyx_v_a);
71 return -1;
72 }
73 Py_INCREF(__pyx_v_self);
75 __pyx_r = 0;
76 Py_XDECREF(__pyx_v_a);
77 Py_DECREF(__pyx_v_self);
78 Py_XDECREF(__pyx_args);
79 Py_XDECREF(__pyx_kwds);
80 return __pyx_r;
81 }
83 static PyObject *__pyx_f_11extstarargs_5Silly_spam(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
84 static PyObject *__pyx_f_11extstarargs_5Silly_spam(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
85 PyObject *__pyx_v_x = 0;
86 PyObject *__pyx_v_y = 0;
87 PyObject *__pyx_v_z = 0;
88 PyObject *__pyx_r;
89 static char *__pyx_argnames[] = {"x","y","z",0};
90 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) return 0;
91 Py_INCREF(__pyx_v_self);
92 Py_INCREF(__pyx_v_x);
93 Py_INCREF(__pyx_v_y);
94 Py_INCREF(__pyx_v_z);
96 __pyx_r = Py_None; Py_INCREF(Py_None);
97 Py_DECREF(__pyx_v_self);
98 Py_DECREF(__pyx_v_x);
99 Py_DECREF(__pyx_v_y);
100 Py_DECREF(__pyx_v_z);
101 return __pyx_r;
102 }
104 static PyObject *__pyx_f_11extstarargs_5Silly_grail(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
105 static PyObject *__pyx_f_11extstarargs_5Silly_grail(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
106 PyObject *__pyx_v_x = 0;
107 PyObject *__pyx_v_y = 0;
108 PyObject *__pyx_v_z = 0;
109 PyObject *__pyx_v_a = 0;
110 PyObject *__pyx_r;
111 static char *__pyx_argnames[] = {"x","y","z",0};
112 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, &__pyx_v_a, 0, 0) < 0) return 0;
113 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) {
114 Py_XDECREF(__pyx_args);
115 Py_XDECREF(__pyx_kwds);
116 Py_XDECREF(__pyx_v_a);
117 return 0;
118 }
119 Py_INCREF(__pyx_v_self);
120 Py_INCREF(__pyx_v_x);
121 Py_INCREF(__pyx_v_y);
122 Py_INCREF(__pyx_v_z);
124 __pyx_r = Py_None; Py_INCREF(Py_None);
125 Py_XDECREF(__pyx_v_a);
126 Py_DECREF(__pyx_v_self);
127 Py_DECREF(__pyx_v_x);
128 Py_DECREF(__pyx_v_y);
129 Py_DECREF(__pyx_v_z);
130 Py_XDECREF(__pyx_args);
131 Py_XDECREF(__pyx_kwds);
132 return __pyx_r;
133 }
135 static PyObject *__pyx_f_11extstarargs_5Silly_swallow(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
136 static PyObject *__pyx_f_11extstarargs_5Silly_swallow(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
137 PyObject *__pyx_v_x = 0;
138 PyObject *__pyx_v_y = 0;
139 PyObject *__pyx_v_z = 0;
140 PyObject *__pyx_v_k = 0;
141 PyObject *__pyx_r;
142 static char *__pyx_argnames[] = {"x","y","z",0};
143 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, 0, &__pyx_v_k, 0) < 0) return 0;
144 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) {
145 Py_XDECREF(__pyx_args);
146 Py_XDECREF(__pyx_kwds);
147 Py_XDECREF(__pyx_v_k);
148 return 0;
149 }
150 Py_INCREF(__pyx_v_self);
151 Py_INCREF(__pyx_v_x);
152 Py_INCREF(__pyx_v_y);
153 Py_INCREF(__pyx_v_z);
155 __pyx_r = Py_None; Py_INCREF(Py_None);
156 Py_XDECREF(__pyx_v_k);
157 Py_DECREF(__pyx_v_self);
158 Py_DECREF(__pyx_v_x);
159 Py_DECREF(__pyx_v_y);
160 Py_DECREF(__pyx_v_z);
161 Py_XDECREF(__pyx_args);
162 Py_XDECREF(__pyx_kwds);
163 return __pyx_r;
164 }
166 static PyObject *__pyx_f_11extstarargs_5Silly_creosote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
167 static PyObject *__pyx_f_11extstarargs_5Silly_creosote(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
168 PyObject *__pyx_v_x = 0;
169 PyObject *__pyx_v_y = 0;
170 PyObject *__pyx_v_z = 0;
171 PyObject *__pyx_v_a = 0;
172 PyObject *__pyx_v_k = 0;
173 PyObject *__pyx_r;
174 static char *__pyx_argnames[] = {"x","y","z",0};
175 if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 3, &__pyx_v_a, &__pyx_v_k, 0) < 0) return 0;
176 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_x, &__pyx_v_y, &__pyx_v_z)) {
177 Py_XDECREF(__pyx_args);
178 Py_XDECREF(__pyx_kwds);
179 Py_XDECREF(__pyx_v_a);
180 Py_XDECREF(__pyx_v_k);
181 return 0;
182 }
183 Py_INCREF(__pyx_v_self);
184 Py_INCREF(__pyx_v_x);
185 Py_INCREF(__pyx_v_y);
186 Py_INCREF(__pyx_v_z);
188 __pyx_r = Py_None; Py_INCREF(Py_None);
189 Py_XDECREF(__pyx_v_a);
190 Py_XDECREF(__pyx_v_k);
191 Py_DECREF(__pyx_v_self);
192 Py_DECREF(__pyx_v_x);
193 Py_DECREF(__pyx_v_y);
194 Py_DECREF(__pyx_v_z);
195 Py_XDECREF(__pyx_args);
196 Py_XDECREF(__pyx_kwds);
197 return __pyx_r;
198 }
200 static PyObject *__pyx_tp_new_11extstarargs_Silly(PyTypeObject *t, PyObject *a, PyObject *k) {
201 PyObject *o = (*t->tp_alloc)(t, 0);
202 if (!o) return 0;
203 return o;
204 }
206 static void __pyx_tp_dealloc_11extstarargs_Silly(PyObject *o) {
207 (*o->ob_type->tp_free)(o);
208 }
210 static struct PyMethodDef __pyx_methods_11extstarargs_Silly[] = {
211 {"spam", (PyCFunction)__pyx_f_11extstarargs_5Silly_spam, METH_VARARGS|METH_KEYWORDS, 0},
212 {"grail", (PyCFunction)__pyx_f_11extstarargs_5Silly_grail, METH_VARARGS|METH_KEYWORDS, 0},
213 {"swallow", (PyCFunction)__pyx_f_11extstarargs_5Silly_swallow, METH_VARARGS|METH_KEYWORDS, 0},
214 {"creosote", (PyCFunction)__pyx_f_11extstarargs_5Silly_creosote, METH_VARARGS|METH_KEYWORDS, 0},
215 {0, 0, 0, 0}
216 };
218 static PyNumberMethods __pyx_tp_as_number_Silly = {
219 0, /*nb_add*/
220 0, /*nb_subtract*/
221 0, /*nb_multiply*/
222 0, /*nb_divide*/
223 0, /*nb_remainder*/
224 0, /*nb_divmod*/
225 0, /*nb_power*/
226 0, /*nb_negative*/
227 0, /*nb_positive*/
228 0, /*nb_absolute*/
229 0, /*nb_nonzero*/
230 0, /*nb_invert*/
231 0, /*nb_lshift*/
232 0, /*nb_rshift*/
233 0, /*nb_and*/
234 0, /*nb_xor*/
235 0, /*nb_or*/
236 0, /*nb_coerce*/
237 0, /*nb_int*/
238 0, /*nb_long*/
239 0, /*nb_float*/
240 0, /*nb_oct*/
241 0, /*nb_hex*/
242 0, /*nb_inplace_add*/
243 0, /*nb_inplace_subtract*/
244 0, /*nb_inplace_multiply*/
245 0, /*nb_inplace_divide*/
246 0, /*nb_inplace_remainder*/
247 0, /*nb_inplace_power*/
248 0, /*nb_inplace_lshift*/
249 0, /*nb_inplace_rshift*/
250 0, /*nb_inplace_and*/
251 0, /*nb_inplace_xor*/
252 0, /*nb_inplace_or*/
253 0, /*nb_floor_divide*/
254 0, /*nb_true_divide*/
255 0, /*nb_inplace_floor_divide*/
256 0, /*nb_inplace_true_divide*/
257 #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
258 0, /*nb_index*/
259 #endif
260 };
262 static PySequenceMethods __pyx_tp_as_sequence_Silly = {
263 0, /*sq_length*/
264 0, /*sq_concat*/
265 0, /*sq_repeat*/
266 0, /*sq_item*/
267 0, /*sq_slice*/
268 0, /*sq_ass_item*/
269 0, /*sq_ass_slice*/
270 0, /*sq_contains*/
271 0, /*sq_inplace_concat*/
272 0, /*sq_inplace_repeat*/
273 };
275 static PyMappingMethods __pyx_tp_as_mapping_Silly = {
276 0, /*mp_length*/
277 0, /*mp_subscript*/
278 0, /*mp_ass_subscript*/
279 };
281 static PyBufferProcs __pyx_tp_as_buffer_Silly = {
282 0, /*bf_getreadbuffer*/
283 0, /*bf_getwritebuffer*/
284 0, /*bf_getsegcount*/
285 0, /*bf_getcharbuffer*/
286 };
288 PyTypeObject __pyx_type_11extstarargs_Silly = {
289 PyObject_HEAD_INIT(0)
290 0, /*ob_size*/
291 "extstarargs.Silly", /*tp_name*/
292 sizeof(struct __pyx_obj_11extstarargs_Silly), /*tp_basicsize*/
293 0, /*tp_itemsize*/
294 __pyx_tp_dealloc_11extstarargs_Silly, /*tp_dealloc*/
295 0, /*tp_print*/
296 0, /*tp_getattr*/
297 0, /*tp_setattr*/
298 0, /*tp_compare*/
299 0, /*tp_repr*/
300 &__pyx_tp_as_number_Silly, /*tp_as_number*/
301 &__pyx_tp_as_sequence_Silly, /*tp_as_sequence*/
302 &__pyx_tp_as_mapping_Silly, /*tp_as_mapping*/
303 0, /*tp_hash*/
304 0, /*tp_call*/
305 0, /*tp_str*/
306 0, /*tp_getattro*/
307 0, /*tp_setattro*/
308 &__pyx_tp_as_buffer_Silly, /*tp_as_buffer*/
309 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
310 0, /*tp_doc*/
311 0, /*tp_traverse*/
312 0, /*tp_clear*/
313 0, /*tp_richcompare*/
314 0, /*tp_weaklistoffset*/
315 0, /*tp_iter*/
316 0, /*tp_iternext*/
317 __pyx_methods_11extstarargs_Silly, /*tp_methods*/
318 0, /*tp_members*/
319 0, /*tp_getset*/
320 0, /*tp_base*/
321 0, /*tp_dict*/
322 0, /*tp_descr_get*/
323 0, /*tp_descr_set*/
324 0, /*tp_dictoffset*/
325 __pyx_f_11extstarargs_5Silly___init__, /*tp_init*/
326 0, /*tp_alloc*/
327 __pyx_tp_new_11extstarargs_Silly, /*tp_new*/
328 0, /*tp_free*/
329 0, /*tp_is_gc*/
330 0, /*tp_bases*/
331 0, /*tp_mro*/
332 0, /*tp_cache*/
333 0, /*tp_subclasses*/
334 0, /*tp_weaklist*/
335 };
337 static struct PyMethodDef __pyx_methods[] = {
338 {0, 0, 0, 0}
339 };
341 static void __pyx_init_filenames(void); /*proto*/
343 PyMODINIT_FUNC initextstarargs(void); /*proto*/
344 PyMODINIT_FUNC initextstarargs(void) {
345 __pyx_init_filenames();
346 __pyx_m = Py_InitModule4("extstarargs", __pyx_methods, 0, 0, PYTHON_API_VERSION);
347 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
348 Py_INCREF(__pyx_m);
349 __pyx_b = PyImport_AddModule("__builtin__");
350 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
351 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
352 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
353 if (PyType_Ready(&__pyx_type_11extstarargs_Silly) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
354 if (PyObject_SetAttrString(__pyx_m, "Silly", (PyObject *)&__pyx_type_11extstarargs_Silly) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
355 __pyx_ptype_11extstarargs_Silly = &__pyx_type_11extstarargs_Silly;
357 /* "/Local/Projects/D/Pyrex/Source/Tests/5/extstarargs.pyx":15 */
358 return;
359 __pyx_L1:;
360 __Pyx_AddTraceback("extstarargs");
361 }
363 static char *__pyx_filenames[] = {
364 "extstarargs.pyx",
365 };
367 /* Runtime support code */
369 static void __pyx_init_filenames(void) {
370 __pyx_f = __pyx_filenames;
371 }
373 static int __Pyx_GetStarArgs(
374 PyObject **args,
375 PyObject **kwds,
376 char *kwd_list[],
377 Py_ssize_t nargs,
378 PyObject **args2,
379 PyObject **kwds2,
380 char rqd_kwds[])
381 {
382 PyObject *x = 0, *args1 = 0, *kwds1 = 0;
383 int i;
384 char **p;
386 if (args2)
387 *args2 = 0;
388 if (kwds2)
389 *kwds2 = 0;
391 if (args2) {
392 args1 = PyTuple_GetSlice(*args, 0, nargs);
393 if (!args1)
394 goto bad;
395 *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args));
396 if (!*args2)
397 goto bad;
398 }
399 else if (PyTuple_GET_SIZE(*args) > nargs) {
400 int m = nargs;
401 int n = PyTuple_GET_SIZE(*args);
402 PyErr_Format(PyExc_TypeError,
403 "function takes at most %d positional arguments (%d given)",
404 m, n);
405 goto bad;
406 }
407 else {
408 args1 = *args;
409 Py_INCREF(args1);
410 }
412 if (rqd_kwds && !*kwds)
413 for (i = 0, p = kwd_list; *p; i++, p++)
414 if (rqd_kwds[i])
415 goto missing_kwarg;
417 if (kwds2) {
418 if (*kwds) {
419 kwds1 = PyDict_New();
420 if (!kwds1)
421 goto bad;
422 *kwds2 = PyDict_Copy(*kwds);
423 if (!*kwds2)
424 goto bad;
425 for (i = 0, p = kwd_list; *p; i++, p++) {
426 x = PyDict_GetItemString(*kwds, *p);
427 if (x) {
428 if (PyDict_SetItemString(kwds1, *p, x) < 0)
429 goto bad;
430 if (PyDict_DelItemString(*kwds2, *p) < 0)
431 goto bad;
432 }
433 else if (rqd_kwds && rqd_kwds[i])
434 goto missing_kwarg;
435 }
436 }
437 else {
438 *kwds2 = PyDict_New();
439 if (!*kwds2)
440 goto bad;
441 }
442 }
443 else {
444 kwds1 = *kwds;
445 Py_XINCREF(kwds1);
446 if (rqd_kwds && *kwds)
447 for (i = 0, p = kwd_list; *p; i++, p++)
448 if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p))
449 goto missing_kwarg;
450 }
452 *args = args1;
453 *kwds = kwds1;
454 return 0;
455 missing_kwarg:
456 PyErr_Format(PyExc_TypeError,
457 "required keyword argument '%s' is missing", *p);
458 bad:
459 Py_XDECREF(args1);
460 Py_XDECREF(kwds1);
461 if (args2) {
462 Py_XDECREF(*args2);
463 }
464 if (kwds2) {
465 Py_XDECREF(*kwds2);
466 }
467 return -1;
468 }
470 #include "compile.h"
471 #include "frameobject.h"
472 #include "traceback.h"
474 static void __Pyx_AddTraceback(char *funcname) {
475 PyObject *py_srcfile = 0;
476 PyObject *py_funcname = 0;
477 PyObject *py_globals = 0;
478 PyObject *empty_tuple = 0;
479 PyObject *empty_string = 0;
480 PyCodeObject *py_code = 0;
481 PyFrameObject *py_frame = 0;
483 py_srcfile = PyString_FromString(__pyx_filename);
484 if (!py_srcfile) goto bad;
485 py_funcname = PyString_FromString(funcname);
486 if (!py_funcname) goto bad;
487 py_globals = PyModule_GetDict(__pyx_m);
488 if (!py_globals) goto bad;
489 empty_tuple = PyTuple_New(0);
490 if (!empty_tuple) goto bad;
491 empty_string = PyString_FromString("");
492 if (!empty_string) goto bad;
493 py_code = PyCode_New(
494 0, /*int argcount,*/
495 0, /*int nlocals,*/
496 0, /*int stacksize,*/
497 0, /*int flags,*/
498 empty_string, /*PyObject *code,*/
499 empty_tuple, /*PyObject *consts,*/
500 empty_tuple, /*PyObject *names,*/
501 empty_tuple, /*PyObject *varnames,*/
502 empty_tuple, /*PyObject *freevars,*/
503 empty_tuple, /*PyObject *cellvars,*/
504 py_srcfile, /*PyObject *filename,*/
505 py_funcname, /*PyObject *name,*/
506 __pyx_lineno, /*int firstlineno,*/
507 empty_string /*PyObject *lnotab*/
508 );
509 if (!py_code) goto bad;
510 py_frame = PyFrame_New(
511 PyThreadState_Get(), /*PyThreadState *tstate,*/
512 py_code, /*PyCodeObject *code,*/
513 py_globals, /*PyObject *globals,*/
514 0 /*PyObject *locals*/
515 );
516 if (!py_frame) goto bad;
517 py_frame->f_lineno = __pyx_lineno;
518 PyTraceBack_Here(py_frame);
519 bad:
520 Py_XDECREF(py_srcfile);
521 Py_XDECREF(py_funcname);
522 Py_XDECREF(empty_tuple);
523 Py_XDECREF(empty_string);
524 Py_XDECREF(py_code);
525 Py_XDECREF(py_frame);
526 }