File tree Expand file tree Collapse file tree 5 files changed +32
-38
lines changed Expand file tree Collapse file tree 5 files changed +32
-38
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,3 @@ pub fn hello(input: String) -> String {
80
80
}
81
81
82
82
uniffi:: include_scaffolding!( "api" ) ;
83
-
84
- mod uniffi_types {
85
- pub use crate :: { World , WorldState } ;
86
- }
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ use async_stream::stream;
2
2
use futures:: stream:: { self , Stream , StreamExt } ;
3
3
use std:: pin:: Pin ;
4
4
use tokio:: time:: { interval, Duration } ;
5
- use uniffi_dart:: * ;
6
5
7
6
#[ uniffi_dart:: export_stream( i32 ) ]
8
7
pub fn simple_stream ( ) -> impl Stream < Item = i32 > {
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ use crate::gen::oracle::{AsCodeType, DartCodeOracle};
6
6
use crate :: gen:: render:: AsRenderable ;
7
7
use crate :: gen:: render:: { Renderable , TypeHelperRenderer } ;
8
8
9
- use super :: stream:: stream :: generate_stream;
9
+ use super :: stream:: generate_stream;
10
10
11
11
#[ derive( Debug ) ]
12
12
pub struct ObjectCodeType {
Original file line number Diff line number Diff line change 1
- pub mod stream;
1
+ use genco:: prelude:: * ;
2
+ use uniffi_bindgen:: interface:: Object ;
3
+
4
+ use crate :: gen:: oracle:: DartCodeOracle ;
5
+ use crate :: gen:: render:: TypeHelperRenderer ;
6
+
7
+ pub fn generate_stream ( obj : & Object , _type_helper : & dyn TypeHelperRenderer ) -> dart:: Tokens {
8
+ let obj_name = obj. name ( ) ;
9
+ let fn_name = DartCodeOracle :: fn_name ( & obj_name. replace ( "StreamExt" , "" ) ) ;
10
+ let obj_var_name = & DartCodeOracle :: var_name ( & fn_name) ;
11
+ let create_obj_fn_name = format ! ( "createStream{}" , & obj_name. replace( "StreamExt" , "" ) ) ;
12
+
13
+ quote ! {
14
+ $fn_name( ) async * {
15
+ final $obj_var_name = $create_obj_fn_name( ) ;
16
+ try {
17
+ while ( true ) {
18
+ final value = await $obj_var_name. next( ) ;
19
+ if ( value == null) {
20
+ break ;
21
+ }
22
+ yield value;
23
+ }
24
+ } catch ( e) {
25
+ // Handle exceptions if necessary
26
+ rethrow;
27
+ }
28
+ // No need to call drop(), Finalizer will handle it
29
+ }
30
+ }
31
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments