-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use FfiConverter
for metadata generation/storage
#1469
Merged
Merged
Commits on Mar 31, 2023
-
New system for interface metadata
- Added the `uniffi_core::metadata` module, which provides a system for building metadata buffers using const code. - Added the `FfiConverter::TYPE_ID_META` const, which holds metadata to identify the type. - Made the proc-macros generate use the new system to generate metadata consts, then export them using static variables. - Removed the current code to generate/store metadata based on the syn parsing. - Removed the type assertions and the requirement for a `uniffi_types` module. We don't need them now that we`re getting the type ids from the type itself. - Made the `FnMetadata.throws` field a Type rather than a String. - Calculate module paths with the `module_path!()` macro. This means we get accurate module paths without nightly. Changed mod_path to be a String, rather than a Vec since this is what `module_path!()` outputs. - Added code to strip the `r#` part out of raw idents before serializing it into the metadata. - Replaced the `collect_params()` function with the `ScaffoldingBits` struct. There was too much complexity for a single function -- for example unzip() only works with pairs, not 3-tuples. In general, the new metadata system is more reliable doing everything in the proc-macros. Proc-macros can only see the type identifiers, but they don't anything about the underlying type, since users can rename types with type aliases. It's also simpler since you don't have to walk the AST so much. One TODO is getting checksum working again. One limitation of the const code is that we can't use it to generate function identifiers.
Configuration menu - View commit details
-
Copy full SHA for 5367a3d - Browse repository at this point
Copy the full SHA 5367a3dView commit details -
Added return handling to
FfiConverter
Added the `FfiConverter::lower_return` method. This is like `lower()` but specialized for scaffolding returns. This allows us to always use a single function to handle scaffolding calls, rather than `call_with_output` or `call_with_result` depending on if the return type is a `Result<>` or not. Having a single code-path for return handling simplifies the code generation, especially the macros. We no longer need to try to parse `Result<>` type names. This is especially useful for crates that type-alias their `Result<>` types. Updated the async code to work with the new system. Now `RustFuture` only needs 1 generic argument. Updated `object_references.md` and removed example code that's no longer valid. Replaced it with higher-level descriptions of what's going on, hopefully this will stay not get out of date as quickly.
Configuration menu - View commit details
-
Copy full SHA for 8e10392 - Browse repository at this point
Copy the full SHA 8e10392View commit details -
Configuration menu - View commit details
-
Copy full SHA for e1fcb39 - Browse repository at this point
Copy the full SHA e1fcb39View commit details -
Refactoring the rustcall/rustfuture code
Define a lower-level version of `rust_call()` that `uniffi_rustfuture_poll` can use without going through so many hoops.
Configuration menu - View commit details
-
Copy full SHA for 6bd31ad - Browse repository at this point
Copy the full SHA 6bd31adView commit details -
Updated the checksum handling to work with the new proc-macro metadata system. Now that the metadata is calcualted using const functions rather than inside the macro code, we don't have a way to include the checksum in the exported symbol name. Instead, calculate the metadata and store it as its own symbol. Then the bindings code checks the checksums on startup as well as the contract ABI version. One nice aspect of this is that we can output a nicer error message than just "linker error". - Added scripts to test this. - Added flag to allow FFIFunctions to not always have the `&mut RustCallStatus` arg. - Changed the contract version to be a u32 rather than a &str. This simplifies the bindings code. - Added the `uniffi_meta::ffi_names` module. This contains the canonical code to generate ffi symbol names. - Use the module path that we calculate in the proc-macro when generating the metadata rather than calling `module_path!()`. `module_path!()` returns the full module path, but it's more important that our metadata agrees with the module path we used whene generating the scaffolding. - Reworked the `metadata::reader` code - Make `uniffi_meta` depend on `uniffi_core`. I was trying to avoid this, but uniffi_core is where the metadata buffer code lives and I don't want to duplicate it. Maybe we could make this a separate crate, but it doesn't seem worth it yet since `uniffi_core` is fairly small.
Configuration menu - View commit details
-
Copy full SHA for b20b228 - Browse repository at this point
Copy the full SHA b20b228View commit details -
Configuration menu - View commit details
-
Copy full SHA for e8e5ff6 - Browse repository at this point
Copy the full SHA e8e5ff6View commit details
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.