uniffi-rs icon indicating copy to clipboard operation
uniffi-rs copied to clipboard

[Propsal] Updating FFI naming and checksums

Open bendk opened this issue 3 years ago • 0 comments

This PR represents a proposal for changing how scaffolding functions are named. I believe it represents the consensus from the planning meeting and also will work with the new proc-macro code being developed. Please tell me if I'm wrong on either of those parts.

The main point of the PR is just to start a discussion and hopefully get agreement on the general plan. The motivation for this all is that I want to get the initial proc-macro PR that @jplatte put up merged. I think the FFI naming change is the most controversial part of it and if we can agree that this is the direction we want to go, then that PR can be merged (we can discuss more in that PR of course).


Updated how we calculate FFI names and especially how we calculate the checksum part for functions. Now the checksum is only derived from the function definition, not the entire component interface. This is needed so the proc-macros can generate the checksums. The new system should still prevent the possibility of the bindings using one function definition when the scaffolding was build using a different one.

Added the concept of a uniffi scaffolding contract. We can bump that whenever we make changes to how scaffolding calls work. The FFI names depend on this value rather than the UniFFI version, which should prevent linker errors when uniffi and uniffi-bindgen don't have the exact same version.

Consolidated the code into one module. I think it's easier to understand what's going on if you can see it in one place.

Removed some unneeded Result<> returns.

bendk avatar Jun 10 '22 13:06 bendk