uniffi-rs/Cargo.toml

65 строки
1.7 KiB
TOML
Исходник Обычный вид История

[workspace]
members = [
2020-08-05 21:26:16 +03:00
"uniffi_bindgen",
"uniffi_build",
"uniffi_core",
"uniffi_macros",
"uniffi_meta",
"uniffi_testing",
"uniffi_udl",
2020-08-05 21:26:16 +03:00
"uniffi",
2022-04-22 14:19:39 +03:00
"weedle2",
"examples/app/uniffi-bindgen-cli",
"examples/arithmetic",
Add callback interfaces for Kotlin (#344) r=rfk * Add callback interfaces for Kotlin We'd like to have a Rust trait: ```rust trait FetchClient { fn fetch(url: String) -> String } // later impl Nimbus { fn set_fetch_client(client: Box<dyn FetchClient>) {} } ``` Declared in the IDL: ```idl interface Nimbus { set_fetch_client(FetchClient client); update_experiments(); } callback interface FetchClient { string fetch(string url); }; ``` And used in Kotlin: ```kotlin class ConceptFetchClient: FetchClient { override fun fetch(url: String): String { ... } } nimbus.setFetchClient(ConceptFetchClient()) nimbus.updateExperiments() // uses ConceptFetchClient ``` This commit sends JNA Callbacks to send a callback interface to Rust (a.k.a. `ForeignCallback`). This implementation of the `ForeignCallback` is individual to the callback interface— on the kotlin side; in this case this is called: `CallbackInterfaceFetchClientFFI`. As the `ConceptFetchClient` is sent from kotlin, it is placed in a kotlin `ConcurrentHandleMap`. A Rust `impl` of corresponding `FetchClient` trait is generated which proxies all calls through the `ForeignCallback` to kotlin, i.e. `CallbackInterfaceFetchClientProxy` in Rust calls to `CallbackInterfaceFetchClientFFI` in kotlin. The callback object i.e. the `ConceptFetchClient` is then found, and then methods are called from `CallbackInterfaceFetchClientFFI` to the client code `ConceptFetchClient`. * Address first pass review comments * Address reviewer comments * Review 3 comments * Final review comments
2021-01-22 15:31:05 +03:00
"examples/callbacks",
"examples/custom-types",
"examples/futures",
"examples/geometry",
2020-07-31 00:34:36 +03:00
"examples/rondpoint",
"examples/sprites",
"examples/todolist",
"examples/traits",
"fixtures/benchmarks",
"fixtures/coverall",
"fixtures/callbacks",
"fixtures/ext-types/guid",
"fixtures/ext-types/http-headermap",
"fixtures/ext-types/uniffi-one",
"fixtures/ext-types/lib",
"fixtures/ext-types/proc-macro-lib",
"fixtures/foreign-executor",
"fixtures/keywords/kotlin",
"fixtures/keywords/rust",
"fixtures/keywords/swift",
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.
2023-02-02 19:19:14 +03:00
"fixtures/metadata",
"fixtures/proc-macro",
"fixtures/reexport-scaffolding-macro",
"fixtures/regressions/enum-without-i32-helpers",
"fixtures/regressions/fully-qualified-types",
"fixtures/regressions/kotlin-experimental-unsigned-types",
"fixtures/regressions/cdylib-crate-type-dependency/ffi-crate",
"fixtures/regressions/cdylib-crate-type-dependency/cdylib-dependency",
"fixtures/regressions/logging-callback-interface",
"fixtures/regressions/missing-newline",
"fixtures/regressions/swift-callbacks-omit-labels",
"fixtures/regressions/swift-dictionary-nesting",
Fully qualify uses of `Result` in scaffolding/macro code PR #1469 introduced an incompatibility with a local `type Result<T> = std::result::Result<T, MyError>` type alias. As can be seen with the included test without the fix applied: ``` error[E0107]: this type alias takes 1 generic argument but 2 generic arguments were supplied --> /mounted_workdir/target/debug/build/unary-result-alias-f408c03f1955dadd/out/unary-result-alias.uniffi.rs:79:1 | 79 | / #[::uniffi::ffi_converter_error( 80 | | tag = crate::UniFfiTag, 81 | | flat_error, 82 | | 83 | | )] | | ^ | | | | |__expected 1 generic argument | help: remove this generic argument | note: type alias defined here, with 1 generic parameter: `T` --> fixtures/regressions/unary-result-alias/src/lib.rs:7:10 | 7 | pub type Result<T> = std::result::Result<T, MyError>; | ^^^^^^ - = note: this error originates in the macro `::uniffi::ffi_converter_default_return` which comes from the expansion of the attribute macro `::uniffi::ffi_converter_error` (in Nightly builds, run with -Z macro-backtrace for more info) ``` Fixing the macros in `uniffi_core` to use `::std::result::Result` fixes that. This exposes a further case in the generated code: ``` error[E0107]: this type alias takes 1 generic argument but 2 generic arguments were supplied --> /mounted_workdir/target/debug/build/unary-result-alias-f408c03f1955dadd/out/unary-result-alias.uniffi.rs:108:40 | 108 | uniffi::rust_call(call_status, || <Result<(), r#MyError> as ::uniffi::FfiConverter<crate::UniFfiTag>>::lower_return( | ^^^^^^ --------- help: remove this generic argument | | | expected 1 generic argument | note: type alias defined here, with 1 generic parameter: `T` --> fixtures/regressions/unary-result-alias/src/lib.rs:7:10 | 7 | pub type Result<T> = std::result::Result<T, MyError>; | ^^^^^^ - ``` So the same change is required to the output produced by bindgen.
2023-04-05 18:40:57 +03:00
"fixtures/regressions/unary-result-alias",
"fixtures/trait-methods",
"fixtures/uitests",
"fixtures/uniffi-fixture-time",
"fixtures/version-mismatch",
"fixtures/simple-fns",
2022-06-01 19:33:59 +03:00
"fixtures/simple-iface",
"fixtures/swift-omit-labels",
"fixtures/futures",
"fixtures/swift-bridging-header-compile",
"fixtures/type-limits",
2023-07-05 08:40:21 +03:00
"fixtures/large-enum",
]
resolver = "2"