Cython has moved to github.

cython-devel

view tests/run/cstruct.pyx @ 1622:4f0327bdebc9

test for temp allocation bug in call
author Robert Bradshaw <robertwb@math.washington.edu>
date Sat Jan 17 01:25:34 2009 -0800 (3 years ago)
parents 585d725fe537
children 82d312a9f1fc
line source
1 __doc__ = u"""
2 >>> test_i()
3 >>> test_c()
4 >>> test_p()
5 >>> test_g()
6 """
8 cdef struct Grail
10 cdef struct Spam:
11 int i
12 char c
13 float *p[42]
14 Grail *g
16 cdef struct Grail:
17 Spam *s
19 cdef Spam spam, ham
21 cdef void eggs_i(Spam s):
22 cdef int j
23 j = s.i
24 s.i = j
26 cdef void eggs_c(Spam s):
27 cdef char c
28 c = s.c
29 s.c = c
31 cdef void eggs_p(Spam s):
32 cdef float *p
33 p = s.p[0]
34 s.p[0] = p
36 cdef void eggs_g(Spam s):
37 cdef float *p
38 p = s.p[0]
39 s.p[0] = p
41 spam = ham
43 def test_i():
44 spam.i = 1
45 eggs_i(spam)
47 def test_c():
48 spam.c = c'a'
49 eggs_c(spam)
51 def test_p():
52 cdef float f
53 spam.p[0] = &f
54 eggs_p(spam)
56 def test_g():
57 cdef Grail l
58 spam.g = &l
59 eggs_g(spam)