File tree Expand file tree Collapse file tree 4 files changed +11
-0
lines changed Expand file tree Collapse file tree 4 files changed +11
-0
lines changed Original file line number Diff line number Diff line change 8
8
#include < mp/proxy-types.h>
9
9
#include < mp/type-context.h>
10
10
#include < mp/type-decay.h>
11
+ #include < mp/type-function.h>
11
12
#include < mp/type-interface.h>
12
13
#include < mp/type-map.h>
13
14
#include < mp/type-message.h>
Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ interface FooInterface $Proxy.wrap("mp::test::FooImplementation") {
28
28
passMessage @13 (arg :FooMessage) -> (result :FooMessage) ;
29
29
passMutable @14 (arg :FooMutable) -> (arg :FooMutable) ;
30
30
passEnum @15 (arg :Int32 ) -> (result :Int32 );
31
+ passFn @16 (context :Proxy.Context , fn :FooFn) -> (result :Int32 );
31
32
}
32
33
33
34
interface FooCallback $Proxy.wrap("mp::test::FooCallback" ) {
@@ -39,6 +40,11 @@ interface ExtendedCallback extends(FooCallback) $Proxy.wrap("mp::test::ExtendedC
39
40
callExtended @0 (context :Proxy.Context , arg :Int32 ) -> (result :Int32 );
40
41
}
41
42
43
+ interface FooFn $Proxy.wrap("ProxyCallback<std::function<int()>>" ) {
44
+ destroy @0 (context :Proxy.Context) -> ();
45
+ call @1 (context :Proxy.Context) -> (result :Int32 );
46
+ }
47
+
42
48
struct FooStruct $Proxy.wrap("mp::test::FooStruct" ) {
43
49
name @0 :Text ;
44
50
setint @1 :List(Int32) ;
Original file line number Diff line number Diff line change 5
5
#ifndef MP_TEST_FOO_H
6
6
#define MP_TEST_FOO_H
7
7
8
+ #include < functional>
8
9
#include < map>
9
10
#include < memory>
10
11
#include < string>
@@ -75,6 +76,7 @@ class FooImplementation
75
76
FooMessage passMessage (FooMessage foo) { foo.message += " call" ; return foo; }
76
77
void passMutable (FooMutable& foo) { foo.message += " call" ; }
77
78
FooEnum passEnum (FooEnum foo) { return foo; }
79
+ int passFn (std::function<int ()> fn) { return fn (); }
78
80
std::shared_ptr<FooCallback> m_callback;
79
81
};
80
82
Original file line number Diff line number Diff line change @@ -128,6 +128,8 @@ KJ_TEST("Call FooInterface methods")
128
128
foo->passMutable (mut);
129
129
KJ_EXPECT (mut.message == " init build pass call return read" );
130
130
131
+ KJ_EXPECT (foo->passFn ([]{ return 10 ; }) == 10 );
132
+
131
133
disconnect_client ();
132
134
thread.join ();
133
135
You can’t perform that action at this time.
0 commit comments