Debian Codegraph @

extra_tests/cffi_tests/embedding/add_recursive.py

raw symbols SCIP
1 # Generated by pypy/tool/import_cffi.py
2 import cffi
3
4 ffi = cffi.FFI()
5
6 ffi.embedding_api("""
7 extern int (*my_callback)(int);
8 int add_rec(int, int);
9 """)
10
11 ffi.embedding_init_code(r"""
12 from _add_recursive_cffi import ffi, lib
13 import sys
14 print("preparing REC")
15 sys.stdout.flush()
16
17 @ffi.def_extern()
18 def add_rec(x, y):
19 print("adding %d and %d" % (x, y))
20 sys.stdout.flush()
21 return x + y
22
23 x = lib.my_callback(400)
24 print('<<< %d >>>' % (x,))
25 """)
26
27 ffi.set_source("_add_recursive_cffi", """
28 /* use CFFI_DLLEXPORT: on windows, it expands to __declspec(dllexport),
29 which is needed to export a variable from a dll */
30 CFFI_DLLEXPORT int (*my_callback)(int);
31 """)
32
33 fn = ffi.compile(verbose=True)
34 print('FILENAME: %s' % (fn,))