Cython has moved to github.
pyrex
view Tests/3/raise.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 void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
42 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
44 static void __Pyx_AddTraceback(char *funcname); /*proto*/
46 /* Declarations from raise */
49 /* Declarations from implementation of raise */
52 static char __pyx_k1[] = "spam";
54 static PyObject *__pyx_n_spam;
57 static __Pyx_StringTabEntry __pyx_string_tab[] = {
58 {&__pyx_n_spam, 1, __pyx_k1, sizeof(__pyx_k1)},
59 {0, 0, 0, 0}
60 };
64 /* Implementation of raise */
66 static PyObject *__pyx_f_5raise_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
67 static PyObject *__pyx_f_5raise_f(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
68 PyObject *__pyx_v_a = 0;
69 PyObject *__pyx_v_b = 0;
70 PyObject *__pyx_v_c = 0;
71 PyObject *__pyx_r;
72 PyObject *__pyx_1 = 0;
73 PyObject *__pyx_2 = 0;
74 static char *__pyx_argnames[] = {"a","b","c",0};
75 if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOO", __pyx_argnames, &__pyx_v_a, &__pyx_v_b, &__pyx_v_c)) return 0;
76 Py_INCREF(__pyx_v_a);
77 Py_INCREF(__pyx_v_b);
78 Py_INCREF(__pyx_v_c);
80 /* "/Local/Projects/D/Pyrex/Source/Tests/3/raise.pyx":3 */
81 __Pyx_Raise(__pyx_v_a, 0, 0);
82 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3; goto __pyx_L1;}
84 /* "/Local/Projects/D/Pyrex/Source/Tests/3/raise.pyx":4 */
85 __Pyx_Raise(__pyx_n_spam, 0, 0);
86 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; goto __pyx_L1;}
88 /* "/Local/Projects/D/Pyrex/Source/Tests/3/raise.pyx":5 */
89 __Pyx_Raise(__pyx_v_a, __pyx_v_b, 0);
90 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 5; goto __pyx_L1;}
92 /* "/Local/Projects/D/Pyrex/Source/Tests/3/raise.pyx":6 */
93 __pyx_1 = PyInt_FromLong(42); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
94 __Pyx_Raise(__pyx_n_spam, __pyx_1, 0);
95 Py_DECREF(__pyx_1); __pyx_1 = 0;
96 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; goto __pyx_L1;}
98 /* "/Local/Projects/D/Pyrex/Source/Tests/3/raise.pyx":7 */
99 __Pyx_Raise(__pyx_v_a, __pyx_v_b, __pyx_v_c);
100 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 7; goto __pyx_L1;}
102 /* "/Local/Projects/D/Pyrex/Source/Tests/3/raise.pyx":8 */
103 __pyx_1 = PyInt_FromLong(42); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
104 __pyx_2 = PyObject_CallObject(__pyx_v_c, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
105 __Pyx_Raise(__pyx_n_spam, __pyx_1, __pyx_2);
106 Py_DECREF(__pyx_1); __pyx_1 = 0;
107 Py_DECREF(__pyx_2); __pyx_2 = 0;
108 {__pyx_filename = __pyx_f[0]; __pyx_lineno = 8; goto __pyx_L1;}
110 __pyx_r = Py_None; Py_INCREF(Py_None);
111 goto __pyx_L0;
112 __pyx_L1:;
113 Py_XDECREF(__pyx_1);
114 Py_XDECREF(__pyx_2);
115 __Pyx_AddTraceback("raise.f");
116 __pyx_r = 0;
117 __pyx_L0:;
118 Py_DECREF(__pyx_v_a);
119 Py_DECREF(__pyx_v_b);
120 Py_DECREF(__pyx_v_c);
121 return __pyx_r;
122 }
124 static struct PyMethodDef __pyx_methods[] = {
125 {"f", (PyCFunction)__pyx_f_5raise_f, METH_VARARGS|METH_KEYWORDS, 0},
126 {0, 0, 0, 0}
127 };
129 static void __pyx_init_filenames(void); /*proto*/
131 PyMODINIT_FUNC initraise(void); /*proto*/
132 PyMODINIT_FUNC initraise(void) {
133 __pyx_init_filenames();
134 __pyx_m = Py_InitModule4("raise", __pyx_methods, 0, 0, PYTHON_API_VERSION);
135 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
136 Py_INCREF(__pyx_m);
137 __pyx_b = PyImport_AddModule("__builtin__");
138 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
139 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
140 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
141 return;
142 __pyx_L1:;
143 __Pyx_AddTraceback("raise");
144 }
146 static char *__pyx_filenames[] = {
147 "raise.pyx",
148 };
150 /* Runtime support code */
152 static void __pyx_init_filenames(void) {
153 __pyx_f = __pyx_filenames;
154 }
156 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) {
157 Py_XINCREF(type);
158 Py_XINCREF(value);
159 Py_XINCREF(tb);
160 /* First, check the traceback argument, replacing None with NULL. */
161 if (tb == Py_None) {
162 Py_DECREF(tb);
163 tb = 0;
164 }
165 else if (tb != NULL && !PyTraceBack_Check(tb)) {
166 PyErr_SetString(PyExc_TypeError,
167 "raise: arg 3 must be a traceback or None");
168 goto raise_error;
169 }
170 /* Next, replace a missing value with None */
171 if (value == NULL) {
172 value = Py_None;
173 Py_INCREF(value);
174 }
175 #if PY_VERSION_HEX < 0x02050000
176 if (!PyClass_Check(type))
177 #else
178 if (!PyType_Check(type))
179 #endif
180 {
181 /* Raising an instance. The value should be a dummy. */
182 if (value != Py_None) {
183 PyErr_SetString(PyExc_TypeError,
184 "instance exception may not have a separate value");
185 goto raise_error;
186 }
187 /* Normalize to raise <class>, <instance> */
188 Py_DECREF(value);
189 value = type;
190 #if PY_VERSION_HEX < 0x02050000
191 if (PyInstance_Check(type)) {
192 type = (PyObject*) ((PyInstanceObject*)type)->in_class;
193 Py_INCREF(type);
194 }
195 else {
196 PyErr_SetString(PyExc_TypeError,
197 "raise: exception must be an old-style class or instance");
198 goto raise_error;
199 }
200 #else
201 type = (PyObject*) type->ob_type;
202 Py_INCREF(type);
203 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
204 PyErr_SetString(PyExc_TypeError,
205 "raise: exception class must be a subclass of BaseException");
206 goto raise_error;
207 }
208 #endif
209 }
210 PyErr_Restore(type, value, tb);
211 return;
212 raise_error:
213 Py_XDECREF(value);
214 Py_XDECREF(type);
215 Py_XDECREF(tb);
216 return;
217 }
219 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
220 while (t->p) {
221 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
222 if (!*t->p)
223 return -1;
224 if (t->i)
225 PyString_InternInPlace(t->p);
226 ++t;
227 }
228 return 0;
229 }
231 #include "compile.h"
232 #include "frameobject.h"
233 #include "traceback.h"
235 static void __Pyx_AddTraceback(char *funcname) {
236 PyObject *py_srcfile = 0;
237 PyObject *py_funcname = 0;
238 PyObject *py_globals = 0;
239 PyObject *empty_tuple = 0;
240 PyObject *empty_string = 0;
241 PyCodeObject *py_code = 0;
242 PyFrameObject *py_frame = 0;
244 py_srcfile = PyString_FromString(__pyx_filename);
245 if (!py_srcfile) goto bad;
246 py_funcname = PyString_FromString(funcname);
247 if (!py_funcname) goto bad;
248 py_globals = PyModule_GetDict(__pyx_m);
249 if (!py_globals) goto bad;
250 empty_tuple = PyTuple_New(0);
251 if (!empty_tuple) goto bad;
252 empty_string = PyString_FromString("");
253 if (!empty_string) goto bad;
254 py_code = PyCode_New(
255 0, /*int argcount,*/
256 0, /*int nlocals,*/
257 0, /*int stacksize,*/
258 0, /*int flags,*/
259 empty_string, /*PyObject *code,*/
260 empty_tuple, /*PyObject *consts,*/
261 empty_tuple, /*PyObject *names,*/
262 empty_tuple, /*PyObject *varnames,*/
263 empty_tuple, /*PyObject *freevars,*/
264 empty_tuple, /*PyObject *cellvars,*/
265 py_srcfile, /*PyObject *filename,*/
266 py_funcname, /*PyObject *name,*/
267 __pyx_lineno, /*int firstlineno,*/
268 empty_string /*PyObject *lnotab*/
269 );
270 if (!py_code) goto bad;
271 py_frame = PyFrame_New(
272 PyThreadState_Get(), /*PyThreadState *tstate,*/
273 py_code, /*PyCodeObject *code,*/
274 py_globals, /*PyObject *globals,*/
275 0 /*PyObject *locals*/
276 );
277 if (!py_frame) goto bad;
278 py_frame->f_lineno = __pyx_lineno;
279 PyTraceBack_Here(py_frame);
280 bad:
281 Py_XDECREF(py_srcfile);
282 Py_XDECREF(py_funcname);
283 Py_XDECREF(empty_tuple);
284 Py_XDECREF(empty_string);
285 Py_XDECREF(py_code);
286 Py_XDECREF(py_frame);
287 }
