Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ctypes-test.py 542B

12345678910111213141516171819202122
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. from ctypes import *
  4. PythonSideFn = CFUNCTYPE(None, c_int)
  5. lib = CDLL("./ctypes-test.so", RTLD_LOCAL)
  6. lib.set_python_side_fn.argtypes = [PythonSideFn]
  7. lib.set_python_side_fn.restype = None
  8. lib.call_python_side_fn.argtypes = None
  9. lib.call_python_side_fn.restype = None
  10. def pyFn(checker):
  11. print("Python function called from C code, checker:", checker)
  12. _pyFn = PythonSideFn(pyFn)
  13. lib.set_python_side_fn(_pyFn)
  14. print("Python side ready, calling C function now")
  15. lib.call_python_side_fn()