diff --git a/include/mp/type-function.h b/include/mp/type-function.h index bf00c581..df7b280e 100644 --- a/include/mp/type-function.h +++ b/include/mp/type-function.h @@ -24,7 +24,7 @@ template void CustomBuildField(TypeList>, Priority<1>, InvokeContext& invoke_context, - Value& value, + Value&& value, Output&& output) { if (value) { diff --git a/test/mp/test/foo-types.h b/test/mp/test/foo-types.h index 246b1948..aec5e49d 100644 --- a/test/mp/test/foo-types.h +++ b/test/mp/test/foo-types.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include diff --git a/test/mp/test/foo.capnp b/test/mp/test/foo.capnp index df0d4361..68104088 100644 --- a/test/mp/test/foo.capnp +++ b/test/mp/test/foo.capnp @@ -28,6 +28,7 @@ interface FooInterface $Proxy.wrap("mp::test::FooImplementation") { passMessage @13 (arg :FooMessage) -> (result :FooMessage); passMutable @14 (arg :FooMutable) -> (arg :FooMutable); passEnum @15 (arg :Int32) -> (result :Int32); + passFn @16 (context :Proxy.Context, fn :FooFn) -> (result :Int32); } interface FooCallback $Proxy.wrap("mp::test::FooCallback") { @@ -39,6 +40,11 @@ interface ExtendedCallback extends(FooCallback) $Proxy.wrap("mp::test::ExtendedC callExtended @0 (context :Proxy.Context, arg :Int32) -> (result :Int32); } +interface FooFn $Proxy.wrap("ProxyCallback>") { + destroy @0 (context :Proxy.Context) -> (); + call @1 (context :Proxy.Context) -> (result :Int32); +} + struct FooStruct $Proxy.wrap("mp::test::FooStruct") { name @0 :Text; setint @1 :List(Int32); diff --git a/test/mp/test/foo.h b/test/mp/test/foo.h index 1c5ee79f..468438fc 100644 --- a/test/mp/test/foo.h +++ b/test/mp/test/foo.h @@ -5,6 +5,7 @@ #ifndef MP_TEST_FOO_H #define MP_TEST_FOO_H +#include #include #include #include @@ -75,6 +76,7 @@ class FooImplementation FooMessage passMessage(FooMessage foo) { foo.message += " call"; return foo; } void passMutable(FooMutable& foo) { foo.message += " call"; } FooEnum passEnum(FooEnum foo) { return foo; } + int passFn(std::function fn) { return fn(); } std::shared_ptr m_callback; }; diff --git a/test/mp/test/test.cpp b/test/mp/test/test.cpp index 7fc64f67..b0635c4f 100644 --- a/test/mp/test/test.cpp +++ b/test/mp/test/test.cpp @@ -128,6 +128,8 @@ KJ_TEST("Call FooInterface methods") foo->passMutable(mut); KJ_EXPECT(mut.message == "init build pass call return read"); + KJ_EXPECT(foo->passFn([]{ return 10; }) == 10); + disconnect_client(); thread.join();