Debian Codegraph @

tests/run/extern_impl_excvalue.srctree

raw
1 PYTHON setup.py build_ext --inplace
2 PYTHON -c "import foo"
3 PYTHON -c "import a"
4 PYTHON -c "import b"
5
6 ######## setup.py ########
7
8 from Cython.Build import cythonize
9 from distutils.core import setup
10
11 setup(
12 ext_modules = cythonize("*.pyx"),
13 )
14
15 ######## foo.pxd ########
16
17 cdef int bar() except *
18
19 cdef extern from "bar_impl.c":
20 struct mystruct:
21 int (*func_ptr)(int param) nogil
22
23 ######## foo.pyx ########
24
25 cdef extern from "bar_impl.c":
26 int bar() except *
27
28 ######## bar_impl.c ########
29
30 static int bar() { return -1; }
31
32 typedef struct mystruct {
33 int (*func_ptr)(int param);
34 } mystruct_t;
35
36 ######## a.pyx ########
37
38 cimport cython
39 from foo cimport bar
40
41 assert bar() == -1
42
43
44 ######## b.pyx ########
45
46 from foo cimport mystruct
47
48 cdef int cb(int param) noexcept nogil:
49 return param
50
51 cdef mystruct ms = mystruct(&cb)
52 assert ms.func_ptr(5) == 5