Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/mp/type-function.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ template <typename Value, typename FnR, typename... FnParams, typename Output>
void CustomBuildField(TypeList<std::function<FnR(FnParams...)>>,
Priority<1>,
InvokeContext& invoke_context,
Value& value,
Value&& value,
Output&& output)
{
if (value) {
Expand Down
1 change: 1 addition & 0 deletions test/mp/test/foo-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <mp/proxy-types.h>
#include <mp/type-context.h>
#include <mp/type-decay.h>
#include <mp/type-function.h>
#include <mp/type-interface.h>
#include <mp/type-map.h>
#include <mp/type-message.h>
Expand Down
6 changes: 6 additions & 0 deletions test/mp/test/foo.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand All @@ -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<std::function<int()>>") {
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);
Expand Down
2 changes: 2 additions & 0 deletions test/mp/test/foo.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#ifndef MP_TEST_FOO_H
#define MP_TEST_FOO_H

#include <functional>
#include <map>
#include <memory>
#include <string>
Expand Down Expand Up @@ -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<int()> fn) { return fn(); }
std::shared_ptr<FooCallback> m_callback;
};

Expand Down
2 changes: 2 additions & 0 deletions test/mp/test/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down