Cython has moved to github.
pyrex
view Tests/2/dict.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_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
42 static void __Pyx_AddTraceback(char *funcname); /*proto*/
44 /* Declarations from dict */
47 /* Declarations from implementation of dict */
50 static char __pyx_k1[] = "parrot";
51 static char __pyx_k2[] = "resting";
52 static char __pyx_k3[] = "answer";
54 static PyObject *__pyx_n_answer;
55 static PyObject *__pyx_n_parrot;
56 static PyObject *__pyx_n_resting;
59 static __Pyx_StringTabEntry __pyx_string_tab[] = {
60 {&__pyx_n_answer, 1, __pyx_k3, sizeof(__pyx_k3)},
61 {&__pyx_n_parrot, 1, __pyx_k1, sizeof(__pyx_k1)},
62 {&__pyx_n_resting, 1, __pyx_k2, sizeof(__pyx_k2)},
63 {0, 0, 0, 0}
64 };
68 /* Implementation of dict */
70 static PyObject *__pyx_f_4dict_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
71 static PyObject *__pyx_f_4dict_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
72 PyObject *__pyx_v_adict = 0;
73 PyObject *__pyx_v_key1 = 0;
74 PyObject *__pyx_v_value1 = 0;
75 PyObject *__pyx_v_key2 = 0;
76 PyObject *__pyx_v_value2 = 0;
77 PyObject *__pyx_r;
78 PyObject *__pyx_1 = 0;
79 PyObject *__pyx_2 = 0;
80 static char *__pyx_argnames[] = {"adict","key1","value1","key2","value2",0};
81 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOO", __pyx_argnames, &__pyx_v_adict, &__pyx_v_key1, &__pyx_v_value1, &__pyx_v_key2, &__pyx_v_value2)) return 0;
82 Py_INCREF(__pyx_v_adict);
83 Py_INCREF(__pyx_v_key1);
84 Py_INCREF(__pyx_v_value1);
85 Py_INCREF(__pyx_v_key2);
86 Py_INCREF(__pyx_v_value2);
88 /* "/Local/Projects/D/Pyrex/Source/Tests/2/dict.pyx":2 */
89 __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2; goto __pyx_L1;}
90 Py_DECREF(__pyx_v_adict);
91 __pyx_v_adict = __pyx_1;
92 __pyx_1 = 0;
94 /* "/Local/Projects/D/Pyrex/Source/Tests/2/dict.pyx":3 */
95 __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
96 if (PyDict_SetItem(__pyx_1, __pyx_v_key1, __pyx_v_value1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
97 Py_DECREF(__pyx_v_adict);
98 __pyx_v_adict = __pyx_1;
99 __pyx_1 = 0;
101 /* "/Local/Projects/D/Pyrex/Source/Tests/2/dict.pyx":4 */
102 __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
103 if (PyDict_SetItem(__pyx_1, __pyx_v_key1, __pyx_v_value1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
104 if (PyDict_SetItem(__pyx_1, __pyx_v_key2, __pyx_v_value2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
105 Py_DECREF(__pyx_v_adict);
106 __pyx_v_adict = __pyx_1;
107 __pyx_1 = 0;
109 /* "/Local/Projects/D/Pyrex/Source/Tests/2/dict.pyx":5 */
110 __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
111 if (PyDict_SetItem(__pyx_1, __pyx_v_key1, __pyx_v_value1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
112 if (PyDict_SetItem(__pyx_1, __pyx_v_key2, __pyx_v_value2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
113 Py_DECREF(__pyx_v_adict);
114 __pyx_v_adict = __pyx_1;
115 __pyx_1 = 0;
117 /* "/Local/Projects/D/Pyrex/Source/Tests/2/dict.pyx":6 */
118 __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
119 if (PyDict_SetItem(__pyx_1, __pyx_n_parrot, __pyx_n_resting) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
120 __pyx_2 = PyInt_FromLong(42); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
121 if (PyDict_SetItem(__pyx_1, __pyx_n_answer, __pyx_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
122 Py_DECREF(__pyx_2); __pyx_2 = 0;
123 Py_DECREF(__pyx_v_adict);
124 __pyx_v_adict = __pyx_1;
125 __pyx_1 = 0;
127 __pyx_r = Py_None; Py_INCREF(Py_None);
128 goto __pyx_L0;
129 __pyx_L1:;
130 Py_XDECREF(__pyx_1);
131 Py_XDECREF(__pyx_2);
132 __Pyx_AddTraceback("dict.f");
133 __pyx_r = 0;
134 __pyx_L0:;
135 Py_DECREF(__pyx_v_adict);
136 Py_DECREF(__pyx_v_key1);
137 Py_DECREF(__pyx_v_value1);
138 Py_DECREF(__pyx_v_key2);
139 Py_DECREF(__pyx_v_value2);
140 return __pyx_r;
141 }
143 static struct PyMethodDef __pyx_methods[] = {
144 {"f", (PyCFunction)__pyx_f_4dict_f, METH_VARARGS|METH_KEYWORDS, 0},
145 {0, 0, 0, 0}
146 };
148 static void __pyx_init_filenames(void); /*proto*/
150 PyMODINIT_FUNC initdict(void); /*proto*/
151 PyMODINIT_FUNC initdict(void) {
152 __pyx_init_filenames();
153 __pyx_m = Py_InitModule4("dict", __pyx_methods, 0, 0, PYTHON_API_VERSION);
154 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
155 Py_INCREF(__pyx_m);
156 __pyx_b = PyImport_AddModule("__builtin__");
157 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
158 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
159 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
160 return;
161 __pyx_L1:;
162 __Pyx_AddTraceback("dict");
163 }
165 static char *__pyx_filenames[] = {
166 "dict.pyx",
167 };
169 /* Runtime support code */
171 static void __pyx_init_filenames(void) {
172 __pyx_f = __pyx_filenames;
173 }
175 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
176 while (t->p) {
177 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
178 if (!*t->p)
179 return -1;
180 if (t->i)
181 PyString_InternInPlace(t->p);
182 ++t;
183 }
184 return 0;
185 }
187 #include "compile.h"
188 #include "frameobject.h"
189 #include "traceback.h"
191 static void __Pyx_AddTraceback(char *funcname) {
192 PyObject *py_srcfile = 0;
193 PyObject *py_funcname = 0;
194 PyObject *py_globals = 0;
195 PyObject *empty_tuple = 0;
196 PyObject *empty_string = 0;
197 PyCodeObject *py_code = 0;
198 PyFrameObject *py_frame = 0;
200 py_srcfile = PyString_FromString(__pyx_filename);
201 if (!py_srcfile) goto bad;
202 py_funcname = PyString_FromString(funcname);
203 if (!py_funcname) goto bad;
204 py_globals = PyModule_GetDict(__pyx_m);
205 if (!py_globals) goto bad;
206 empty_tuple = PyTuple_New(0);
207 if (!empty_tuple) goto bad;
208 empty_string = PyString_FromString("");
209 if (!empty_string) goto bad;
210 py_code = PyCode_New(
211 0, /*int argcount,*/
212 0, /*int nlocals,*/
213 0, /*int stacksize,*/
214 0, /*int flags,*/
215 empty_string, /*PyObject *code,*/
216 empty_tuple, /*PyObject *consts,*/
217 empty_tuple, /*PyObject *names,*/
218 empty_tuple, /*PyObject *varnames,*/
219 empty_tuple, /*PyObject *freevars,*/
220 empty_tuple, /*PyObject *cellvars,*/
221 py_srcfile, /*PyObject *filename,*/
222 py_funcname, /*PyObject *name,*/
223 __pyx_lineno, /*int firstlineno,*/
224 empty_string /*PyObject *lnotab*/
225 );
226 if (!py_code) goto bad;
227 py_frame = PyFrame_New(
228 PyThreadState_Get(), /*PyThreadState *tstate,*/
229 py_code, /*PyCodeObject *code,*/
230 py_globals, /*PyObject *globals,*/
231 0 /*PyObject *locals*/
232 );
233 if (!py_frame) goto bad;
234 py_frame->f_lineno = __pyx_lineno;
235 PyTraceBack_Here(py_frame);
236 bad:
237 Py_XDECREF(py_srcfile);
238 Py_XDECREF(py_funcname);
239 Py_XDECREF(empty_tuple);
240 Py_XDECREF(empty_string);
241 Py_XDECREF(py_code);
242 Py_XDECREF(py_frame);
243 }
