Cython has moved to github.
pyrex
view Tests/Bugs/wyatt/Reference/vector.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 PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name, long size); /*proto*/
43 static PyObject *__Pyx_ImportModule(char *name); /*proto*/
45 static void __Pyx_AddTraceback(char *funcname); /*proto*/
47 /* Declarations from matrix */
49 struct __pyx_obj_6matrix_Matrix {
50 PyObject_HEAD
51 float m[4][4];
52 };
55 static PyTypeObject *__pyx_ptype_6matrix_Matrix = 0;
57 /* Declarations from vector */
59 struct __pyx_obj_6vector_Vector {
60 PyObject_HEAD
61 float x;
62 float y;
63 float z;
64 float w;
65 };
68 static PyTypeObject *__pyx_ptype_6vector_Vector = 0;
71 static __Pyx_StringTabEntry __pyx_string_tab[] = {
72 {0, 0, 0, 0}
73 };
75 /* Implementation of vector */
77 static PyObject *__pyx_tp_new_6vector_Vector(PyTypeObject *t, PyObject *a, PyObject *k) {
78 PyObject *o = (*t->tp_alloc)(t, 0);
79 if (!o) return 0;
80 return o;
81 }
83 static void __pyx_tp_dealloc_6vector_Vector(PyObject *o) {
84 (*o->ob_type->tp_free)(o);
85 }
87 static struct PyMethodDef __pyx_methods_6vector_Vector[] = {
88 {0, 0, 0, 0}
89 };
91 static PyNumberMethods __pyx_tp_as_number_Vector = {
92 0, /*nb_add*/
93 0, /*nb_subtract*/
94 0, /*nb_multiply*/
95 0, /*nb_divide*/
96 0, /*nb_remainder*/
97 0, /*nb_divmod*/
98 0, /*nb_power*/
99 0, /*nb_negative*/
100 0, /*nb_positive*/
101 0, /*nb_absolute*/
102 0, /*nb_nonzero*/
103 0, /*nb_invert*/
104 0, /*nb_lshift*/
105 0, /*nb_rshift*/
106 0, /*nb_and*/
107 0, /*nb_xor*/
108 0, /*nb_or*/
109 0, /*nb_coerce*/
110 0, /*nb_int*/
111 0, /*nb_long*/
112 0, /*nb_float*/
113 0, /*nb_oct*/
114 0, /*nb_hex*/
115 0, /*nb_inplace_add*/
116 0, /*nb_inplace_subtract*/
117 0, /*nb_inplace_multiply*/
118 0, /*nb_inplace_divide*/
119 0, /*nb_inplace_remainder*/
120 0, /*nb_inplace_power*/
121 0, /*nb_inplace_lshift*/
122 0, /*nb_inplace_rshift*/
123 0, /*nb_inplace_and*/
124 0, /*nb_inplace_xor*/
125 0, /*nb_inplace_or*/
126 0, /*nb_floor_divide*/
127 0, /*nb_true_divide*/
128 0, /*nb_inplace_floor_divide*/
129 0, /*nb_inplace_true_divide*/
130 #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX
131 0, /*nb_index*/
132 #endif
133 };
135 static PySequenceMethods __pyx_tp_as_sequence_Vector = {
136 0, /*sq_length*/
137 0, /*sq_concat*/
138 0, /*sq_repeat*/
139 0, /*sq_item*/
140 0, /*sq_slice*/
141 0, /*sq_ass_item*/
142 0, /*sq_ass_slice*/
143 0, /*sq_contains*/
144 0, /*sq_inplace_concat*/
145 0, /*sq_inplace_repeat*/
146 };
148 static PyMappingMethods __pyx_tp_as_mapping_Vector = {
149 0, /*mp_length*/
150 0, /*mp_subscript*/
151 0, /*mp_ass_subscript*/
152 };
154 static PyBufferProcs __pyx_tp_as_buffer_Vector = {
155 0, /*bf_getreadbuffer*/
156 0, /*bf_getwritebuffer*/
157 0, /*bf_getsegcount*/
158 0, /*bf_getcharbuffer*/
159 };
161 PyTypeObject __pyx_type_6vector_Vector = {
162 PyObject_HEAD_INIT(0)
163 0, /*ob_size*/
164 "vector.Vector", /*tp_name*/
165 sizeof(struct __pyx_obj_6vector_Vector), /*tp_basicsize*/
166 0, /*tp_itemsize*/
167 __pyx_tp_dealloc_6vector_Vector, /*tp_dealloc*/
168 0, /*tp_print*/
169 0, /*tp_getattr*/
170 0, /*tp_setattr*/
171 0, /*tp_compare*/
172 0, /*tp_repr*/
173 &__pyx_tp_as_number_Vector, /*tp_as_number*/
174 &__pyx_tp_as_sequence_Vector, /*tp_as_sequence*/
175 &__pyx_tp_as_mapping_Vector, /*tp_as_mapping*/
176 0, /*tp_hash*/
177 0, /*tp_call*/
178 0, /*tp_str*/
179 0, /*tp_getattro*/
180 0, /*tp_setattro*/
181 &__pyx_tp_as_buffer_Vector, /*tp_as_buffer*/
182 Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/
183 0, /*tp_doc*/
184 0, /*tp_traverse*/
185 0, /*tp_clear*/
186 0, /*tp_richcompare*/
187 0, /*tp_weaklistoffset*/
188 0, /*tp_iter*/
189 0, /*tp_iternext*/
190 __pyx_methods_6vector_Vector, /*tp_methods*/
191 0, /*tp_members*/
192 0, /*tp_getset*/
193 0, /*tp_base*/
194 0, /*tp_dict*/
195 0, /*tp_descr_get*/
196 0, /*tp_descr_set*/
197 0, /*tp_dictoffset*/
198 0, /*tp_init*/
199 0, /*tp_alloc*/
200 __pyx_tp_new_6vector_Vector, /*tp_new*/
201 0, /*tp_free*/
202 0, /*tp_is_gc*/
203 0, /*tp_bases*/
204 0, /*tp_mro*/
205 0, /*tp_cache*/
206 0, /*tp_subclasses*/
207 0, /*tp_weaklist*/
208 };
210 static struct PyMethodDef __pyx_methods[] = {
211 {0, 0, 0, 0}
212 };
214 static void __pyx_init_filenames(void); /*proto*/
216 PyMODINIT_FUNC initvector(void); /*proto*/
217 PyMODINIT_FUNC initvector(void) {
218 __pyx_init_filenames();
219 __pyx_m = Py_InitModule4("vector", __pyx_methods, 0, 0, PYTHON_API_VERSION);
220 if (!__pyx_m) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
221 Py_INCREF(__pyx_m);
222 __pyx_b = PyImport_AddModule("__builtin__");
223 if (!__pyx_b) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
224 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
225 if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; goto __pyx_L1;};
226 if (PyType_Ready(&__pyx_type_6vector_Vector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; goto __pyx_L1;}
227 if (PyObject_SetAttrString(__pyx_m, "Vector", (PyObject *)&__pyx_type_6vector_Vector) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 1; goto __pyx_L1;}
228 __pyx_ptype_6vector_Vector = &__pyx_type_6vector_Vector;
229 __pyx_ptype_6matrix_Matrix = __Pyx_ImportType("matrix", "Matrix", sizeof(struct __pyx_obj_6matrix_Matrix)); if (!__pyx_ptype_6matrix_Matrix) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 1; goto __pyx_L1;}
231 /* "/Local/Projects/D/Pyrex/Source/Tests/Bugs/wyatt/vector.pyx":1 */
232 return;
233 __pyx_L1:;
234 __Pyx_AddTraceback("vector");
235 }
237 static char *__pyx_filenames[] = {
238 "vector.pyx",
239 "vector.pxd",
240 "matrix.pxd",
241 };
243 /* Runtime support code */
245 static void __pyx_init_filenames(void) {
246 __pyx_f = __pyx_filenames;
247 }
249 #ifndef __PYX_HAVE_RT_ImportType
250 #define __PYX_HAVE_RT_ImportType
251 static PyTypeObject *__Pyx_ImportType(char *module_name, char *class_name,
252 long size)
253 {
254 PyObject *py_module = 0;
255 PyObject *result = 0;
257 py_module = __Pyx_ImportModule(module_name);
258 if (!py_module)
259 goto bad;
260 result = PyObject_GetAttrString(py_module, class_name);
261 if (!result)
262 goto bad;
263 if (!PyType_Check(result)) {
264 PyErr_Format(PyExc_TypeError,
265 "%s.%s is not a type object",
266 module_name, class_name);
267 goto bad;
268 }
269 if (((PyTypeObject *)result)->tp_basicsize != size) {
270 PyErr_Format(PyExc_ValueError,
271 "%s.%s does not appear to be the correct type object",
272 module_name, class_name);
273 goto bad;
274 }
275 return (PyTypeObject *)result;
276 bad:
277 Py_XDECREF(result);
278 return 0;
279 }
280 #endif
282 #ifndef __PYX_HAVE_RT_ImportModule
283 #define __PYX_HAVE_RT_ImportModule
284 static PyObject *__Pyx_ImportModule(char *name) {
285 PyObject *py_name = 0;
287 py_name = PyString_FromString(name);
288 if (!py_name)
289 goto bad;
290 return PyImport_Import(py_name);
291 bad:
292 Py_XDECREF(py_name);
293 return 0;
294 }
295 #endif
297 #include "compile.h"
298 #include "frameobject.h"
299 #include "traceback.h"
301 static void __Pyx_AddTraceback(char *funcname) {
302 PyObject *py_srcfile = 0;
303 PyObject *py_funcname = 0;
304 PyObject *py_globals = 0;
305 PyObject *empty_tuple = 0;
306 PyObject *empty_string = 0;
307 PyCodeObject *py_code = 0;
308 PyFrameObject *py_frame = 0;
310 py_srcfile = PyString_FromString(__pyx_filename);
311 if (!py_srcfile) goto bad;
312 py_funcname = PyString_FromString(funcname);
313 if (!py_funcname) goto bad;
314 py_globals = PyModule_GetDict(__pyx_m);
315 if (!py_globals) goto bad;
316 empty_tuple = PyTuple_New(0);
317 if (!empty_tuple) goto bad;
318 empty_string = PyString_FromString("");
319 if (!empty_string) goto bad;
320 py_code = PyCode_New(
321 0, /*int argcount,*/
322 0, /*int nlocals,*/
323 0, /*int stacksize,*/
324 0, /*int flags,*/
325 empty_string, /*PyObject *code,*/
326 empty_tuple, /*PyObject *consts,*/
327 empty_tuple, /*PyObject *names,*/
328 empty_tuple, /*PyObject *varnames,*/
329 empty_tuple, /*PyObject *freevars,*/
330 empty_tuple, /*PyObject *cellvars,*/
331 py_srcfile, /*PyObject *filename,*/
332 py_funcname, /*PyObject *name,*/
333 __pyx_lineno, /*int firstlineno,*/
334 empty_string /*PyObject *lnotab*/
335 );
336 if (!py_code) goto bad;
337 py_frame = PyFrame_New(
338 PyThreadState_Get(), /*PyThreadState *tstate,*/
339 py_code, /*PyCodeObject *code,*/
340 py_globals, /*PyObject *globals,*/
341 0 /*PyObject *locals*/
342 );
343 if (!py_frame) goto bad;
344 py_frame->f_lineno = __pyx_lineno;
345 PyTraceBack_Here(py_frame);
346 bad:
347 Py_XDECREF(py_srcfile);
348 Py_XDECREF(py_funcname);
349 Py_XDECREF(empty_tuple);
350 Py_XDECREF(empty_string);
351 Py_XDECREF(py_code);
352 Py_XDECREF(py_frame);
353 }
