Skip to content

Commit f9e3ca8

Browse files
author
Matteo Fusi
committed
FFI: remove legacy callback
1 parent 32539dd commit f9e3ca8

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/buildFFI.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def make_ffi(name, headers, libraries, includes=[], extra_header=""):
2525
# Define C declarations
2626
ffi.cdef(header_content)
2727

28+
ffi.cdef("""
29+
extern "Python" void iter_callback(void*, char*, char*);
30+
""")
31+
2832
# Set the C source file
2933
ffi.set_source(name, '''
3034
#include "nix_api_util.h"

src/nix/store.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ def build(self, path: StorePath | str) -> dict[str, str]:
8080
path = self._ensure_store_path(path)
8181
res = {}
8282

83-
# todo extern "Python"
84-
@ffi.callback("void(void*, char*, char*)")
83+
@ffi.def_extern()
8584
def iter_callback(userdata: CData, key: CData, path: CData) -> None:
8685
res[ffi.string(key).decode()] = ffi.string(path).decode()
8786

88-
lib.nix_store_build(self._store, path._path, ffi.NULL, iter_callback)
87+
lib.nix_store_build(self._store, path._path, ffi.NULL, lib_unwrapped.iter_callback)
8988
return res

0 commit comments

Comments
 (0)