From 29cf2ada75ea60ab29c367cf3b90d7f119a37e8b Mon Sep 17 00:00:00 2001 From: Novo Date: Wed, 1 Oct 2025 17:24:06 +0200 Subject: [PATCH 1/2] test default PassField impl handles output parameters Tests that output parameter result is captured from server call and added to response. --- test/mp/test/foo.capnp | 1 + test/mp/test/foo.h | 1 + test/mp/test/test.cpp | 3 +++ 3 files changed, 5 insertions(+) diff --git a/test/mp/test/foo.capnp b/test/mp/test/foo.capnp index 75e4617d..d42bba05 100644 --- a/test/mp/test/foo.capnp +++ b/test/mp/test/foo.capnp @@ -13,6 +13,7 @@ $Proxy.includeTypes("mp/test/foo-types.h"); interface FooInterface $Proxy.wrap("mp::test::FooImplementation") { add @0 (a :Int32, b :Int32) -> (result :Int32); + addOut @19 (a :Int32, b :Int32) -> (ret :Int32); mapSize @1 (map :List(Pair(Text, Text))) -> (result :Int32); pass @2 (arg :FooStruct) -> (result :FooStruct); raise @3 (arg :FooStruct) -> (error :FooStruct $Proxy.exception("mp::test::FooStruct")); diff --git a/test/mp/test/foo.h b/test/mp/test/foo.h index 70bf4ff1..dbbce36a 100644 --- a/test/mp/test/foo.h +++ b/test/mp/test/foo.h @@ -62,6 +62,7 @@ class FooImplementation { public: int add(int a, int b) { return a + b; } + void addOut(int a, int b, int& out) { out = a + b; } int mapSize(const std::map& map) { return map.size(); } FooStruct pass(FooStruct foo) { return foo; } void raise(FooStruct foo) { throw foo; } diff --git a/test/mp/test/test.cpp b/test/mp/test/test.cpp index 225d00d5..35ca4d6c 100644 --- a/test/mp/test/test.cpp +++ b/test/mp/test/test.cpp @@ -113,6 +113,9 @@ KJ_TEST("Call FooInterface methods") ProxyClient* foo = setup.client.get(); KJ_EXPECT(foo->add(1, 2) == 3); + int ret; + foo->addOut(3, 4, ret); + KJ_EXPECT(ret == 7); FooStruct in; in.name = "name"; From 6db669628387b481b0d5726f011eb45025f31ccf Mon Sep 17 00:00:00 2001 From: Novo Date: Wed, 1 Oct 2025 22:02:32 +0200 Subject: [PATCH 2/2] test In|Out parameter --- test/mp/test/foo.capnp | 1 + test/mp/test/foo.h | 1 + test/mp/test/test.cpp | 2 ++ 3 files changed, 4 insertions(+) diff --git a/test/mp/test/foo.capnp b/test/mp/test/foo.capnp index d42bba05..67bc8e4f 100644 --- a/test/mp/test/foo.capnp +++ b/test/mp/test/foo.capnp @@ -14,6 +14,7 @@ $Proxy.includeTypes("mp/test/foo-types.h"); interface FooInterface $Proxy.wrap("mp::test::FooImplementation") { add @0 (a :Int32, b :Int32) -> (result :Int32); addOut @19 (a :Int32, b :Int32) -> (ret :Int32); + addInOut @20 (x :Int32, sum :Int32) -> (sum :Int32); mapSize @1 (map :List(Pair(Text, Text))) -> (result :Int32); pass @2 (arg :FooStruct) -> (result :FooStruct); raise @3 (arg :FooStruct) -> (error :FooStruct $Proxy.exception("mp::test::FooStruct")); diff --git a/test/mp/test/foo.h b/test/mp/test/foo.h index dbbce36a..8415f6f0 100644 --- a/test/mp/test/foo.h +++ b/test/mp/test/foo.h @@ -63,6 +63,7 @@ class FooImplementation public: int add(int a, int b) { return a + b; } void addOut(int a, int b, int& out) { out = a + b; } + void addInOut(int x, int& sum) { sum += x; } int mapSize(const std::map& map) { return map.size(); } FooStruct pass(FooStruct foo) { return foo; } void raise(FooStruct foo) { throw foo; } diff --git a/test/mp/test/test.cpp b/test/mp/test/test.cpp index 35ca4d6c..9273dfae 100644 --- a/test/mp/test/test.cpp +++ b/test/mp/test/test.cpp @@ -116,6 +116,8 @@ KJ_TEST("Call FooInterface methods") int ret; foo->addOut(3, 4, ret); KJ_EXPECT(ret == 7); + foo->addInOut(3, ret); + KJ_EXPECT(ret == 10); FooStruct in; in.name = "name";