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