diff --git a/src/buildFFI.py b/src/buildFFI.py index 32bf4e1..1e4af13 100644 --- a/src/buildFFI.py +++ b/src/buildFFI.py @@ -25,6 +25,10 @@ def make_ffi(name, headers, libraries, includes=[], extra_header=""): # Define C declarations ffi.cdef(header_content) + ffi.cdef(""" + extern "Python" void iter_callback(void*, char*, char*); + """) + # Set the C source file ffi.set_source(name, ''' #include "nix_api_util.h" diff --git a/src/nix/store.py b/src/nix/store.py index c512678..ceec56d 100644 --- a/src/nix/store.py +++ b/src/nix/store.py @@ -80,10 +80,9 @@ def build(self, path: StorePath | str) -> dict[str, str]: path = self._ensure_store_path(path) res = {} - # todo extern "Python" - @ffi.callback("void(void*, char*, char*)") + @ffi.def_extern() def iter_callback(userdata: CData, key: CData, path: CData) -> None: res[ffi.string(key).decode()] = ffi.string(path).decode() - lib.nix_store_build(self._store, path._path, ffi.NULL, iter_callback) + lib.nix_store_build(self._store, path._path, ffi.NULL, lib_unwrapped.iter_callback) return res