Skip to content

Commit 753422d

Browse files
authored
Merge pull request #38 from chavic/chavic/streams-ext
Added Stream as Export Attribute Macro
2 parents 46f9f7b + 8fc7273 commit 753422d

File tree

24 files changed

+647
-31
lines changed

24 files changed

+647
-31
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@
22
/uniffi-rs
33
/Cargo.lock
44
.aider*
5+
rust-toolchain.toml
6+
internal_todo.md

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ anyhow = "1"
3333
paste = "1"
3434
heck = "0.5"
3535
uniffi = { workspace = true, features = [
36-
"build",
36+
"build", "tokio"
3737
] }
38+
uniffi_dart_macro = { path = "./uniffi_dart_macro" }
3839
uniffi_bindgen = { workspace = true }
3940
camino = "1"
4041
serde = "1"
@@ -51,22 +52,24 @@ uniffi_testing = { workspace = true, optional = true }
5152
fs_extra = { version = "1.3.0", optional = true }
5253
camino-tempfile = { version = "1.0.2", optional = true }
5354
glob = { version = "0.3.1", optional = true }
55+
lazy_static = "1.5.0"
56+
stringcase = "0.3.0"
5457

5558
[workspace]
5659

5760
members = [
5861
".",
5962

6063
# for testing
61-
"fixtures/*",
64+
"fixtures/*", "uniffi_dart_macro",
6265
]
6366
# Ignore a few tests for now
6467
exclude = [
6568
"fixtures/coverall",
6669
"fixtures/custom_types",
6770
"fixtuers/callbacks",
6871
"fixtuers/dispose",
69-
"fixtuers/futures",
72+
"fixtuers/dart_async",
7073
]
7174

7275
[workspace.dependencies]

fixtures/futures/Cargo.toml renamed to fixtures/dart_async/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[package]
2-
name = "futures"
2+
name = "dart_async"
33
version = "0.1.0"
44
edition = "2021"
55
publish = false
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88

99
[lib]
10-
name = "futures"
10+
name = "dart_async"
1111
crate-type = ["lib", "cdylib"]
1212

1313
[dependencies]
File renamed without changes.

fixtures/dart_async/src/api.udl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
namespace dart_async { };
File renamed without changes.

fixtures/futures/test/futures_test.dart renamed to fixtures/dart_async/test/futures_test.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import 'package:test/test.dart';
2-
import '../futures.dart';
2+
import '../dart_async.dart';
33

44
Future<Duration> measureTime(Future<void> Function() action) async {
55
final start = DateTime.now();
@@ -35,13 +35,13 @@ void main() {
3535
expect(time.inMilliseconds <= 10, true);
3636
});
3737

38-
// test('sleep', () async {
39-
// final time = await measureTime(() async {
40-
// await sleep(200);
41-
// });
38+
test('sleep', () async {
39+
final time = await measureTime(() async {
40+
await sleep(200);
41+
});
4242

43-
// expect(time.inMilliseconds > 200 && time.inMilliseconds < 300, true);
44-
// });
43+
expect(time.inMilliseconds > 200 && time.inMilliseconds < 300, true);
44+
});
4545

4646
test('sequential_future', () async {
4747
final time = await measureTime(() async {

fixtures/dart_async/tests/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
use anyhow::Result;
2+
3+
#[test]
4+
fn dart_async() -> Result<()> {
5+
uniffi_dart::testing::run_test("dart_async", "src/api.udl", None)
6+
}

fixtures/futures/src/api.udl

Lines changed: 0 additions & 1 deletion
This file was deleted.

fixtures/futures/tests/mod.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

fixtures/hello_world/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,3 @@ pub fn hello(input: String) -> String {
8080
}
8181

8282
uniffi::include_scaffolding!("api");
83-
84-
mod uniffi_types {
85-
pub use crate::{World, WorldState};
86-
}

fixtures/streams_ext/Cargo.toml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[package]
2+
name = "streams_ext"
3+
version = "0.1.0"
4+
edition = "2021"
5+
publish = false
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
9+
[lib]
10+
name = "streams_ext"
11+
crate-type = ["lib", "cdylib"]
12+
13+
[dependencies]
14+
uniffi = { workspace = true }
15+
uniffi-dart = { path = "../../" }
16+
uniffi_dart_macro = { path = "../../uniffi_dart_macro" }
17+
lazy_static = "1.4.0"
18+
futures = "0.3"
19+
async-stream = "0.3"
20+
tokio = { version = "1.0", features = ["full"] }
21+
thiserror = "1.0.66"
22+
23+
[build-dependencies]
24+
uniffi-dart = { path = "../../", features = ["build"] }
25+
26+
[dev-dependencies]
27+
uniffi-dart = { path = "../../", features = ["bindgen-tests"] }
28+
uniffi = { workspace = true, features = [
29+
"bindgen-tests",
30+
] }
31+
anyhow = "1"

fixtures/streams_ext/build.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
uniffi_dart::generate_scaffolding("./src/api.udl".into()).unwrap();
3+
}

fixtures/streams_ext/src/api copy.udl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[Error]
2+
enum StreamErrorInt {
3+
"IntegerError",
4+
};
5+
6+
[Error]
7+
enum StreamErrorString {
8+
"StringError",
9+
};
10+
11+
namespace streams_ext {
12+
[Throws=StreamErrorInt]
13+
i32? error_stream();
14+
15+
[Throws=StreamErrorString]
16+
string? combined_error_streams();
17+
};
18+

fixtures/streams_ext/src/api.udl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
namespace streams_ext { };

0 commit comments

Comments
 (0)