Cython has moved to github.
pyrex
view Tests/Runnable2/l_capi.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 int __Pyx_ExportFunction(char *n, void *f, char *s); /*proto*/
44 static void __Pyx_AddTraceback(char *funcname); /*proto*/
46 /* Declarations from l_capi */
49 /* Declarations from implementation of l_capi */
51 static float f(float); /*proto*/
56 static __Pyx_StringTabEntry __pyx_string_tab[] = {
57 {0, 0, 0, 0}
58 };
62 /* Implementation of l_capi */
64 static float f(float __pyx_v_x) {
65 float __pyx_r;
66 __pyx_r = ((0.5 * __pyx_v_x) * __pyx_v_x);
67 goto __pyx_L0;
69 __pyx_r = 0;
70 __pyx_L0:;
71 return __pyx_r;
72 }
74 static struct PyMethodDef __pyx_methods[] = {
75 {0, 0, 0, 0}
76 };
78 static void __pyx_init_filenames(void); /*proto*/
80 PyMODINIT_FUNC initl_capi(void); /*proto*/
81 PyMODINIT_FUNC initl_capi(void) {
82 __pyx_init_filenames();
83 __pyx_m = Py_InitModule4("l_capi", __pyx_methods, 0, 0, PYTHON_API_VERSION);
84 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
85 Py_INCREF(__pyx_m);
86 __pyx_b = PyImport_AddModule("__builtin__");
87 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
88 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
89 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
90 if (__Pyx_ExportFunction("f", (void*)f, "float (float)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;}
91 return;
92 __pyx_L1:;
93 __Pyx_AddTraceback("l_capi");
94 }
96 static char *__pyx_filenames[] = {
97 "l_capi.pyx",
98 };
100 /* Runtime support code */
102 static void __pyx_init_filenames(void) {
103 __pyx_f = __pyx_filenames;
104 }
106 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
107 while (t->p) {
108 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
109 if (!*t->p)
110 return -1;
111 if (t->i)
112 PyString_InternInPlace(t->p);
113 ++t;
114 }
115 return 0;
116 }
118 static int __Pyx_ExportFunction(char *n, void *f, char *s) {
119 PyObject *d = 0;
120 PyObject *p = 0;
121 d = PyObject_GetAttrString(__pyx_m, "__pyx_capi__");
122 if (!d) {
123 PyErr_Clear();
124 d = PyDict_New();
125 if (!d)
126 goto bad;
127 Py_INCREF(d);
128 if (PyModule_AddObject(__pyx_m, "__pyx_capi__", d) < 0)
129 goto bad;
130 }
131 p = PyCObject_FromVoidPtrAndDesc(f, s, 0);
132 if (!p)
133 goto bad;
134 if (PyDict_SetItemString(d, n, p) < 0)
135 goto bad;
136 Py_DECREF(d);
137 return 0;
138 bad:
139 Py_XDECREF(p);
140 Py_XDECREF(d);
141 return -1;
142 }
144 #include "compile.h"
145 #include "frameobject.h"
146 #include "traceback.h"
148 static void __Pyx_AddTraceback(char *funcname) {
149 PyObject *py_srcfile = 0;
150 PyObject *py_funcname = 0;
151 PyObject *py_globals = 0;
152 PyObject *empty_tuple = 0;
153 PyObject *empty_string = 0;
154 PyCodeObject *py_code = 0;
155 PyFrameObject *py_frame = 0;
157 py_srcfile = PyString_FromString(__pyx_filename);
158 if (!py_srcfile) goto bad;
159 py_funcname = PyString_FromString(funcname);
160 if (!py_funcname) goto bad;
161 py_globals = PyModule_GetDict(__pyx_m);
162 if (!py_globals) goto bad;
163 empty_tuple = PyTuple_New(0);
164 if (!empty_tuple) goto bad;
165 empty_string = PyString_FromString("");
166 if (!empty_string) goto bad;
167 py_code = PyCode_New(
168 0, /*int argcount,*/
169 0, /*int nlocals,*/
170 0, /*int stacksize,*/
171 0, /*int flags,*/
172 empty_string, /*PyObject *code,*/
173 empty_tuple, /*PyObject *consts,*/
174 empty_tuple, /*PyObject *names,*/
175 empty_tuple, /*PyObject *varnames,*/
176 empty_tuple, /*PyObject *freevars,*/
177 empty_tuple, /*PyObject *cellvars,*/
178 py_srcfile, /*PyObject *filename,*/
179 py_funcname, /*PyObject *name,*/
180 __pyx_lineno, /*int firstlineno,*/
181 empty_string /*PyObject *lnotab*/
182 );
183 if (!py_code) goto bad;
184 py_frame = PyFrame_New(
185 PyThreadState_Get(), /*PyThreadState *tstate,*/
186 py_code, /*PyCodeObject *code,*/
187 py_globals, /*PyObject *globals,*/
188 0 /*PyObject *locals*/
189 );
190 if (!py_frame) goto bad;
191 py_frame->f_lineno = __pyx_lineno;
192 PyTraceBack_Here(py_frame);
193 bad:
194 Py_XDECREF(py_srcfile);
195 Py_XDECREF(py_funcname);
196 Py_XDECREF(empty_tuple);
197 Py_XDECREF(empty_string);
198 Py_XDECREF(py_code);
199 Py_XDECREF(py_frame);
200 }
