-
Notifications
You must be signed in to change notification settings - Fork 233
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Stop supporting
typedef extern
, [ExternalInterface=...]
in UDL et…
…c. (#2355) This consolidates how external types are expressed in UDL. Instead of ``` [External="crate_name"] typedef extern MyEnum [ExternalInterface="crate_name"] typedef extern MyInterface ``` you would use: ``` [External="crate_name"] typedef enum MyEnum [External="crate_name"] typedef interface MyInterface ``` See the docs and upgrading notes in this commit for more.
- Loading branch information
Showing
15 changed files
with
318 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Using types defined outside a UDL. | ||
|
||
Often you need to refer to types described outside of this UDL - they | ||
may be defined in a proc-macro in this crate or defined in an external crate. | ||
|
||
You declare such types using: | ||
```idl | ||
typedef [type] [TypeName]; | ||
``` | ||
`TypeName` is then able to be used as a normal type in this UDL (ie, be returned from functions, in records, etc) | ||
|
||
`type` indicates the actual type of `TypeName` and can be any of the following values: | ||
* "enum" for Enums. | ||
* "record", "dictionary" or "struct" for Records. | ||
* "object", "impl" or "interface" for objects. | ||
* "trait", "callback" or "trait_with_foreign" for traits. | ||
* "custom" for Custom Types. | ||
|
||
for example, if this crate has: | ||
```rust | ||
#[derive(::uniffi::Object)] | ||
struct MyObject { ... } | ||
``` | ||
our UDL could use this type with: | ||
``` | ||
typedef interface MyObject; | ||
``` | ||
|
||
# External Crates | ||
|
||
The `[External="crate_name"]` attribute can be used whenever the type is in another crate - whether in UDL or in a proc-macro. | ||
|
||
``` | ||
[External = "other_crate"] | ||
typedef interface OtherObject; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace uitests {}; | ||
|
||
typedef extern Foo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Unfortunately, path is relative to a temporary build directory :-/ | ||
uniffi_macros::generate_and_include_scaffolding!("../../../../fixtures/uitests/src/typedef_extern.udl"); | ||
|
||
fn main() { /* empty main required by `trybuild` */} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error: Failed to generate scaffolding from UDL file at ../../../../fixtures/uitests/src/typedef_extern.udl: `typedef extern` is no longer supported. | ||
You must replace `extern` with the type of the object: | ||
* "enum" for Enums. | ||
* "record", "dictionary" or "struct" for Records. | ||
* "object", "impl" or "interface" for objects. | ||
* "trait", "callback" or "trait_with_foreign" for traits. | ||
* "custom" for Custom Types. | ||
|
||
For example: | ||
[External="crate_name"] | ||
typedef extern ExternalEnum; | ||
|
||
Would be replaced with: | ||
[External="crate_name"] | ||
typedef enum ExternalEnum; | ||
|
||
See https://mozilla.github.io/uniffi-rs/next/types/remote_ext_types.html for more. | ||
--> tests/ui/typedef_extern.rs:2:1 | ||
| | ||
2 | uniffi_macros::generate_and_include_scaffolding!("../../../../fixtures/uitests/src/typedef_extern.udl"); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this error originates in the macro `uniffi_macros::generate_and_include_scaffolding` (in Nightly builds, run with -Z macro-backtrace for more info) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.