[ffi] `NativeFinalizer` should have a getter for the finalizer function
#63.811 aberto em 13 de jul. de 2026
Métricas do repositório
- Stars
- (11.144 stars)
- Métricas de merge de PR
- (Nenhuma PRs mesclada em 30d)
Description
In FFIgen's C++ prototype we have native wrapper objects that use NativeFinalizers. Since C++ has many ways of allocating and destroying objects, we need to support custom finalizers. The wrapper object has a dispose method which needs to invoke the finalizer function, and detach the wrapper object from the NativeFinalizer.
Currently the wrapper object needs to hold a reference to both the NativeFinalizer, and the underlying finalizer function. During construction the user either needs to provide both, or neither. And we would like to assert that the finalizer function is the same one held by the NativeFinalizer, but that's not possible.
It would make more sense for the NativeFinalizer to have a getter that returns the finalizer function. Then the wrapper object could just hold a reference to the NativeFinalizer.