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 88#include < mp/proxy-types.h>
99#include < mp/type-context.h>
1010#include < mp/type-decay.h>
11+ #include < mp/type-function.h>
1112#include < mp/type-interface.h>
1213#include < mp/type-map.h>
1314#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") {
2828 passMessage @13 (arg :FooMessage) -> (result :FooMessage) ;
2929 passMutable @14 (arg :FooMutable) -> (arg :FooMutable) ;
3030 passEnum @15 (arg :Int32 ) -> (result :Int32 );
31+ passFn @16 (context :Proxy.Context , fn :FooFn) -> (result :Int32 );
3132}
3233
3334interface FooCallback $Proxy.wrap("mp::test::FooCallback" ) {
@@ -39,6 +40,11 @@ interface ExtendedCallback extends(FooCallback) $Proxy.wrap("mp::test::ExtendedC
3940 callExtended @0 (context :Proxy.Context , arg :Int32 ) -> (result :Int32 );
4041}
4142
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+
4248struct FooStruct $Proxy.wrap("mp::test::FooStruct" ) {
4349 name @0 :Text ;
4450 setint @1 :List(Int32) ;
Original file line number Diff line number Diff line change 55#ifndef MP_TEST_FOO_H
66#define MP_TEST_FOO_H
77
8+ #include < functional>
89#include < map>
910#include < memory>
1011#include < string>
@@ -75,6 +76,7 @@ class FooImplementation
7576 FooMessage passMessage (FooMessage foo) { foo.message += " call" ; return foo; }
7677 void passMutable (FooMutable& foo) { foo.message += " call" ; }
7778 FooEnum passEnum (FooEnum foo) { return foo; }
79+ int passFn (std::function<int ()> fn) { return fn (); }
7880 std::shared_ptr<FooCallback> m_callback;
7981};
8082
Original file line number Diff line number Diff line change @@ -128,6 +128,8 @@ KJ_TEST("Call FooInterface methods")
128128 foo->passMutable (mut);
129129 KJ_EXPECT (mut.message == " init build pass call return read" );
130130
131+ KJ_EXPECT (foo->passFn ([]{ return 10 ; }) == 10 );
132+
131133 disconnect_client ();
132134 thread.join ();
133135
You can’t perform that action at this time.
0 commit comments