Fix last commit
[carla.git] / source / tests.old / ctypes-test.py
blobf03676d15280eaeab191ceee903254f79fa0d10c
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
4 from ctypes import *
6 PythonSideFn = CFUNCTYPE(None, c_int)
8 lib = CDLL("./ctypes-test.so", RTLD_LOCAL)
10 lib.set_python_side_fn.argtypes = [PythonSideFn]
11 lib.set_python_side_fn.restype = None
12 lib.call_python_side_fn.argtypes = None
13 lib.call_python_side_fn.restype = None
15 def pyFn(checker):
16 print("Python function called from C code, checker:", checker)
18 _pyFn = PythonSideFn(pyFn)
19 lib.set_python_side_fn(_pyFn)
21 print("Python side ready, calling C function now")
22 lib.call_python_side_fn()