File tree Expand file tree Collapse file tree 11 files changed +151
-278
lines changed
runtime-new/resource_alias_redux Expand file tree Collapse file tree 11 files changed +151
-278
lines changed Original file line number Diff line number Diff line change @@ -59,10 +59,6 @@ test = false
59
59
name = " resource_borrow_export"
60
60
test = false
61
61
62
- [[bin ]]
63
- name = " resource_alias_redux"
64
- test = false
65
-
66
62
[[bin ]]
67
63
name = " resource_alias"
68
64
test = false
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ namespace TestWorld . wit . exports . test . resourceAliasRedux
2
+ {
3
+ public class ResourceAlias1Impl : IResourceAlias1 {
4
+ public class Thing : IResourceAlias1 . Thing , IResourceAlias1 . IThing {
5
+ public string val ;
6
+
7
+ public Thing ( string v ) {
8
+ this . val = v + " GuestThing" ;
9
+ }
10
+
11
+ public string Get ( ) {
12
+ return this . val + " GuestThing.get" ;
13
+ }
14
+ }
15
+
16
+ public static List < IResourceAlias1 . Thing > A ( IResourceAlias1 . Foo f ) {
17
+ var newList = new List < IResourceAlias1 . Thing > ( ) ;
18
+ newList . Add ( f . thing ) ;
19
+ return newList ;
20
+ }
21
+ }
22
+
23
+ public class ResourceAlias2Impl : IResourceAlias2 {
24
+ public static List < IResourceAlias1 . Thing > B ( IResourceAlias2 . Foo f , IResourceAlias1 . Foo g ) {
25
+ var newList = new List < IResourceAlias1 . Thing > ( ) ;
26
+ newList . Add ( f . thing ) ;
27
+ newList . Add ( g . thing ) ;
28
+ return newList ;
29
+ }
30
+ }
31
+ }
32
+
33
+ namespace TestWorld {
34
+ using TestWorld . wit . exports . test . resourceAliasRedux ;
35
+
36
+ public class TestWorldImpl : ITestWorld {
37
+ public static List < IResourceAlias1 . Thing > Test ( List < IResourceAlias1 . Thing > things ) {
38
+ return things ;
39
+ }
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ using System ;
2
+ using System . Runtime . InteropServices ;
3
+ using System . Diagnostics ;
4
+ using RunnerWorld . wit . imports . test . resourceAliasRedux ;
5
+ using RunnerWorld . wit . imports ;
6
+ using System . Text ;
7
+
8
+ public class Program {
9
+ public static void Main ( ) {
10
+ IResourceAlias1 . Thing thing1 = new IResourceAlias1 . Thing ( "Ni Hao" ) ;
11
+ List < IResourceAlias1 . Thing > myList = new List < IResourceAlias1 . Thing > ( ) ;
12
+ myList . Add ( thing1 ) ;
13
+ List < IResourceAlias1 . Thing > ret = TheTestInterop . Test ( myList ) ;
14
+ Debug . Assert ( ret [ 0 ] . Get ( ) == "Ni Hao GuestThing GuestThing.get" ) ;
15
+
16
+ ret = ResourceAlias1Interop . A (
17
+ new IResourceAlias1 . Foo ( new IResourceAlias1 . Thing ( "Ciao" ) ) ) ;
18
+ Debug . Assert ( ret [ 0 ] . Get ( ) == "Ciao GuestThing GuestThing.get" ) ;
19
+
20
+ ret = ResourceAlias2Interop . B (
21
+ new IResourceAlias2 . Foo ( new IResourceAlias1 . Thing ( "Ciao" ) ) ,
22
+ new IResourceAlias1 . Foo ( new IResourceAlias1 . Thing ( "Aloha" ) )
23
+ ) ;
24
+ Debug . Assert ( ret [ 0 ] . Get ( ) == "Ciao GuestThing GuestThing.get" ) ;
25
+ Debug . Assert ( ret [ 1 ] . Get ( ) == "Aloha GuestThing GuestThing.get" ) ;
26
+ }
27
+ }
Original file line number Diff line number Diff line change
1
+ include ! ( env!( "BINDINGS" ) ) ;
2
+
3
+ use crate :: test:: resource_alias_redux:: resource_alias1 as a1;
4
+ use crate :: test:: resource_alias_redux:: resource_alias2 as a2;
5
+ use crate :: the_test:: test;
6
+
7
+ fn main ( ) {
8
+ let thing1 = crate :: the_test:: Thing :: new ( "Ni Hao" ) ;
9
+ let result = test ( vec ! [ thing1] ) ;
10
+ assert_eq ! ( result. len( ) , 1 ) ;
11
+ assert_eq ! ( result[ 0 ] . get( ) , "Ni Hao GuestThing GuestThing.get" ) ;
12
+
13
+ let thing2 = crate :: test:: resource_alias_redux:: resource_alias1:: Thing :: new ( "Ciao" ) ;
14
+ let result = a1:: a ( a1:: Foo { thing : thing2 } ) ;
15
+ assert_eq ! ( result. len( ) , 1 ) ;
16
+ assert_eq ! ( result[ 0 ] . get( ) , "Ciao GuestThing GuestThing.get" ) ;
17
+
18
+ let thing3 = crate :: test:: resource_alias_redux:: resource_alias1:: Thing :: new ( "Ciao" ) ;
19
+ let thing4 = crate :: test:: resource_alias_redux:: resource_alias1:: Thing :: new ( "Aloha" ) ;
20
+
21
+ let result = a2:: b ( a2:: Foo { thing : thing3 } , a2:: Bar { thing : thing4 } ) ;
22
+ assert_eq ! ( result. len( ) , 2 ) ;
23
+ assert_eq ! ( result[ 0 ] . get( ) , "Ciao GuestThing GuestThing.get" ) ;
24
+ assert_eq ! ( result[ 1 ] . get( ) , "Aloha GuestThing GuestThing.get" ) ;
25
+ }
Original file line number Diff line number Diff line change
1
+ include ! ( env!( "BINDINGS" ) ) ;
2
+
3
+ use crate :: exports:: test:: resource_alias_redux:: resource_alias1 as a1;
4
+ use crate :: exports:: test:: resource_alias_redux:: resource_alias2 as a2;
5
+ use crate :: exports:: the_test:: { Guest , Thing } ;
6
+
7
+ struct Component ;
8
+
9
+ export ! ( Component ) ;
10
+
11
+ struct MyThing ( String ) ;
12
+
13
+ impl Guest for Component {
14
+ fn test ( things : Vec < Thing > ) -> Vec < Thing > {
15
+ things
16
+ }
17
+ }
18
+
19
+ impl a1:: Guest for Component {
20
+ type Thing = MyThing ;
21
+
22
+ fn a ( f : a1:: Foo ) -> Vec < Thing > {
23
+ vec ! [ f. thing]
24
+ }
25
+ }
26
+
27
+ impl a2:: Guest for Component {
28
+ fn b ( f : a2:: Foo , g : a2:: Bar ) -> Vec < Thing > {
29
+ vec ! [ f. thing, g. thing]
30
+ }
31
+ }
32
+
33
+ impl a1:: GuestThing for MyThing {
34
+ fn new ( mut msg : String ) -> MyThing {
35
+ msg. push_str ( " GuestThing" ) ;
36
+ MyThing ( msg)
37
+ }
38
+
39
+ fn get ( & self ) -> String {
40
+ let mut ret = self . 0 . clone ( ) ;
41
+ ret. push_str ( " GuestThing.get" ) ;
42
+ ret
43
+ }
44
+ }
Original file line number Diff line number Diff line change @@ -19,13 +19,22 @@ interface resource-alias2 {
19
19
b : func (f : foo , g : bar ) -> list <thing >;
20
20
}
21
21
22
- world resource-alias-redux {
23
- use resource-alias1 . {thing };
22
+ world test {
23
+ export resource-alias1 ;
24
+ export resource-alias2 ;
25
+
26
+ export the-test : interface {
27
+ use resource-alias1 . {thing };
28
+ test : func (things : list <thing >) -> list <thing >;
29
+ }
30
+ }
24
31
32
+ world runner {
25
33
import resource-alias1 ;
26
34
import resource-alias2 ;
27
- export resource-alias1 ;
28
- export resource-alias2 ;
29
35
30
- export test : func (things : list <thing >) -> list <thing >;
36
+ import the-test : interface {
37
+ use resource-alias1 . {thing };
38
+ test : func (things : list <thing >) -> list <thing >;
39
+ }
31
40
}
Original file line number Diff line number Diff line change @@ -17,7 +17,6 @@ mod flavorful;
17
17
mod options;
18
18
mod ownership;
19
19
mod resource_alias;
20
- mod resource_alias_redux;
21
20
mod resource_borrow_export;
22
21
mod resource_borrow_import;
23
22
mod resource_borrow_simple;
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments