Skip to content
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

Added Stream as Export Attribute Macro #38

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@
/uniffi-rs
/Cargo.lock
.aider*
rust-toolchain.toml
internal_todo.md
9 changes: 6 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ anyhow = "1"
paste = "1"
heck = "0.5"
uniffi = { workspace = true, features = [
"build",
"build", "tokio"
] }
uniffi_dart_macro = { path = "./uniffi_dart_macro" }
uniffi_bindgen = { workspace = true }
camino = "1"
serde = "1"
Expand All @@ -51,22 +52,24 @@ uniffi_testing = { workspace = true, optional = true }
fs_extra = { version = "1.3.0", optional = true }
camino-tempfile = { version = "1.0.2", optional = true }
glob = { version = "0.3.1", optional = true }
lazy_static = "1.5.0"
stringcase = "0.3.0"

[workspace]

members = [
".",

# for testing
"fixtures/*",
"fixtures/*", "uniffi_dart_macro",
]
# Ignore a few tests for now
exclude = [
"fixtures/coverall",
"fixtures/custom_types",
"fixtuers/callbacks",
"fixtuers/dispose",
"fixtuers/futures",
"fixtuers/dart_async",
]

[workspace.dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "futures"
name = "dart_async"
version = "0.1.0"
edition = "2021"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[lib]
name = "futures"
name = "dart_async"
crate-type = ["lib", "cdylib"]

[dependencies]
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions fixtures/dart_async/src/api.udl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace dart_async { };
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import 'package:test/test.dart';
import '../futures.dart';
import '../dart_async.dart';

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

// test('sleep', () async {
// final time = await measureTime(() async {
// await sleep(200);
// });
test('sleep', () async {
final time = await measureTime(() async {
await sleep(200);
});

// expect(time.inMilliseconds > 200 && time.inMilliseconds < 300, true);
// });
expect(time.inMilliseconds > 200 && time.inMilliseconds < 300, true);
});

test('sequential_future', () async {
final time = await measureTime(() async {
Expand Down
6 changes: 6 additions & 0 deletions fixtures/dart_async/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use anyhow::Result;

#[test]
fn dart_async() -> Result<()> {
uniffi_dart::testing::run_test("dart_async", "src/api.udl", None)
}
1 change: 0 additions & 1 deletion fixtures/futures/src/api.udl

This file was deleted.

6 changes: 0 additions & 6 deletions fixtures/futures/tests/mod.rs

This file was deleted.

4 changes: 0 additions & 4 deletions fixtures/hello_world/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,3 @@ pub fn hello(input: String) -> String {
}

uniffi::include_scaffolding!("api");

mod uniffi_types {
pub use crate::{World, WorldState};
}
31 changes: 31 additions & 0 deletions fixtures/streams_ext/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[package]
name = "streams_ext"
version = "0.1.0"
edition = "2021"
publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html


[lib]
name = "streams_ext"
crate-type = ["lib", "cdylib"]

[dependencies]
uniffi = { workspace = true }
uniffi-dart = { path = "../../" }
uniffi_dart_macro = { path = "../../uniffi_dart_macro" }
lazy_static = "1.4.0"
futures = "0.3"
async-stream = "0.3"
tokio = { version = "1.0", features = ["full"] }
thiserror = "1.0.66"

[build-dependencies]
uniffi-dart = { path = "../../", features = ["build"] }

[dev-dependencies]
uniffi-dart = { path = "../../", features = ["bindgen-tests"] }
uniffi = { workspace = true, features = [
"bindgen-tests",
] }
anyhow = "1"
3 changes: 3 additions & 0 deletions fixtures/streams_ext/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
uniffi_dart::generate_scaffolding("./src/api.udl".into()).unwrap();
}
18 changes: 18 additions & 0 deletions fixtures/streams_ext/src/api copy.udl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Error]
enum StreamErrorInt {
"IntegerError",
};

[Error]
enum StreamErrorString {
"StringError",
};

namespace streams_ext {
[Throws=StreamErrorInt]
i32? error_stream();

[Throws=StreamErrorString]
string? combined_error_streams();
};

1 change: 1 addition & 0 deletions fixtures/streams_ext/src/api.udl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
namespace streams_ext { };
Loading
Loading