From 59977b53fe450a35408a339eb2bc2fc44f22a1f6 Mon Sep 17 00:00:00 2001 From: Vaci Koblizek Date: Thu, 8 Oct 2020 14:17:02 +0100 Subject: [PATCH] generate client methods and add streaming --- compiler/src/main/cpp/capnpc-java.c++ | 77 +++-- .../main/java/org/capnproto/CallContext.java | 2 +- .../main/java/org/capnproto/Capability.java | 27 +- .../java/org/capnproto/RemotePromise.java | 5 + .../src/main/java/org/capnproto/Request.java | 11 +- .../main/java/org/capnproto/RequestHook.java | 3 + .../org/capnproto/StreamingCallContext.java | 13 + .../java/org/capnproto/StreamingRequest.java | 25 ++ .../test/java/org/capnproto/TwoPartyTest.java | 9 +- .../test/java/org/capnproto/demo/Demo.java | 270 ++++++++++++++++- .../test/java/org/capnproto/demo/demo.capnp | 4 +- .../java/org/capnproto/demo/demo.capnp.c++ | 190 +++++++++++- .../test/java/org/capnproto/demo/demo.capnp.h | 275 ++++++++++++++++++ 13 files changed, 848 insertions(+), 63 deletions(-) create mode 100644 runtime/src/main/java/org/capnproto/StreamingCallContext.java create mode 100644 runtime/src/main/java/org/capnproto/StreamingRequest.java diff --git a/compiler/src/main/cpp/capnpc-java.c++ b/compiler/src/main/cpp/capnpc-java.c++ index 4a4691c..3c3b39d 100644 --- a/compiler/src/main/cpp/capnpc-java.c++ +++ b/compiler/src/main/cpp/capnpc-java.c++ @@ -1607,6 +1607,8 @@ private: spaces(indent), " public Client(java.util.concurrent.CompletableFuture promise) {\n", spaces(indent), " super(promise);\n", spaces(indent), " }\n", + spaces(indent), "\n", + KJ_MAP(m, methods) { return kj::mv(m.clientDefs); }, spaces(indent), " }\n", spaces(indent), " public static abstract class Server extends org.capnproto.Capability.Server {\n", spaces(indent), " protected org.capnproto.DispatchCallResult dispatchCall(\n", @@ -1627,7 +1629,7 @@ private: spaces(indent), " org.capnproto.Capability.Server.internalUnimplemented(\"", name, "\", 0x", hexId, "L, methodId));\n", spaces(indent), " }\n", spaces(indent), " }\n\n", - KJ_MAP(m, methods) { return kj::mv(m.sourceDefs); }, + KJ_MAP(m, methods) { return kj::mv(m.serverDefs); }, spaces(indent), " }\n", spaces(indent), "\n", KJ_MAP(n, nestedTypeDecls) { return kj::mv(n); }, @@ -1640,17 +1642,18 @@ private: // ----------------------------------------------------------------- struct MethodText { - kj::StringTree sourceDefs; + kj::StringTree clientDefs; + kj::StringTree serverDefs; kj::StringTree dispatchCase; }; MethodText makeMethodText(kj::StringPtr interfaceName, InterfaceSchema::Method method) { auto proto = method.getProto(); - auto name = proto.getName(); - auto titleCase = toTitleCase(name); + auto methodName = proto.getName(); + auto titleCase = toTitleCase(methodName); auto paramSchema = method.getParamType(); auto resultSchema = method.getResultType(); - auto identifierName = safeIdentifier(name); + auto identifierName = safeIdentifier(methodName); auto paramProto = paramSchema.getProto(); auto resultProto = resultSchema.getProto(); @@ -1710,42 +1713,62 @@ private: if (paramProto.getScopeId() == 0) { paramType = kj::str(javaFullName(paramSchema, method)); } + if (resultProto.getScopeId() == 0) { paramType = kj::str(javaFullName(resultSchema, method)); } + kj::String paramFactory = kj::str(shortParamType, ".factory"); + kj::String resultFactory = kj::str(shortResultType, ".factory"); + auto interfaceProto = method.getContainingInterface().getProto(); uint64_t interfaceId = interfaceProto.getId(); auto interfaceIdHex = kj::hex(interfaceId); uint16_t methodId = method.getIndex(); - auto requestMethodImpl = kj::strTree( - isStreaming ? kj::strTree("org.capnproto.StreamingRequest<", paramType, ">") - : kj::strTree("org.capnproto.Request<", paramType, ", ", resultType, ">"), - name, "Request() {\n", - isStreaming - ? kj::strTree(" return newStreamingCall<", paramType, ">(\n") - : kj::strTree(" return newCall<", paramType, ", ", resultType, ">(\n"), - " 0x", interfaceIdHex, "L, ", methodId, ");\n" - "}\n"); + if (isStreaming) { + return MethodText { + kj::strTree( + " public org.capnproto.StreamingRequest<", shortParamType, ".Builder> ", methodName, "Request() {\n", + " return newStreamingCall(", paramFactory, ", 0x", interfaceIdHex, "L, (short)", methodId, ");\n" + " }\n"), - return MethodText { - - kj::strTree( - " protected java.util.concurrent.CompletableFuture ", identifierName, "(org.capnproto.CallContext<", titleCase, "Params.Reader, ", titleCase, "Results.Builder> context) {\n" - " return org.capnproto.Capability.Server.internalUnimplemented(\n" - " \"", interfaceProto.getDisplayName(), "\", \"", name, "\",\n" + kj::strTree( + " protected java.util.concurrent.CompletableFuture ", identifierName, "(org.capnproto.StreamingCallContext<", shortParamType, ".Reader> context) {\n" + " return org.capnproto.Capability.Server.internalUnimplemented(\n" + " \"", interfaceProto.getDisplayName(), "\", \"", methodName, "\",\n" " 0x", interfaceIdHex, "L, (short)", methodId, ");\n" " }\n\n"), - kj::strTree( + kj::strTree( " case ", methodId, ":\n", - " return org.capnproto.Capability.Server.", - isStreaming ? "streamResult" : "result", "(\n", - " this.", identifierName, "(org.capnproto.Capability.Server.typedContext(\n" - " ", genericParamType, ".factory,\n", - " ", genericResultType, ".factory, context)));\n") - }; + " return org.capnproto.Capability.Server.streamResult(\n", + " this.", identifierName, "(org.capnproto.Capability.Server.internalGetTypedStreamingContext(\n" + " ", paramFactory, ", context)));\n") + }; + + } else { + return MethodText { + + kj::strTree( + " public org.capnproto.Request<", shortParamType, ".Builder, ", shortResultType, ".Reader> ", methodName, "Request() {\n", + " return newCall(", paramFactory, ", ", resultFactory, ", 0x", interfaceIdHex, "L, (short)", methodId, ");\n" + " }\n"), + + kj::strTree( + " protected java.util.concurrent.CompletableFuture ", identifierName, "(org.capnproto.CallContext<", shortParamType, ".Reader, ", shortResultType, ".Builder> context) {\n" + " return org.capnproto.Capability.Server.internalUnimplemented(\n" + " \"", interfaceProto.getDisplayName(), "\", \"", methodName, "\",\n" + " 0x", interfaceIdHex, "L, (short)", methodId, ");\n" + " }\n\n"), + + kj::strTree( + " case ", methodId, ":\n", + " return org.capnproto.Capability.Server.result (\n", + " this.", identifierName, "(org.capnproto.Capability.Server.internalGetTypedContext(\n" + " ", paramFactory, ", ", resultFactory, ", context)));\n") + }; + } } // ----------------------------------------------------------------- diff --git a/runtime/src/main/java/org/capnproto/CallContext.java b/runtime/src/main/java/org/capnproto/CallContext.java index 49279f0..8a73e97 100644 --- a/runtime/src/main/java/org/capnproto/CallContext.java +++ b/runtime/src/main/java/org/capnproto/CallContext.java @@ -4,9 +4,9 @@ import java.util.concurrent.CompletableFuture; public class CallContext { - final CallContextHook hook; private final FromPointerReader params; private final FromPointerBuilder results; + final CallContextHook hook; public CallContext(FromPointerReader params, FromPointerBuilder results, diff --git a/runtime/src/main/java/org/capnproto/Capability.java b/runtime/src/main/java/org/capnproto/Capability.java index ad75eb7..277e5fa 100644 --- a/runtime/src/main/java/org/capnproto/Capability.java +++ b/runtime/src/main/java/org/capnproto/Capability.java @@ -79,10 +79,16 @@ public final class Capability { } protected Request newCall(FromPointerBuilder builder, - FromPointerReader reader, - long interfaceId, short methodId) { + FromPointerReader reader, + long interfaceId, short methodId) { var request = hook.newCall(interfaceId, methodId); - return new Request (builder, reader, request.params, request.hook); + return new Request<> (builder, reader, request.params, request.hook); + } + + protected StreamingRequest newStreamingCall(FromPointerBuilder builder, + long interfaceId, short methodId) { + var request = hook.newCall(interfaceId, methodId); + return new StreamingRequest<> (builder, request.params, request.hook); } } @@ -183,13 +189,19 @@ public final class Capability { return new Client(this.hook); } - protected static CallContext typedContext( + protected static CallContext internalGetTypedContext( FromPointerReader paramsFactory, FromPointerBuilder resultsFactory, CallContext typeless) { return new CallContext<>(paramsFactory, resultsFactory, typeless.hook); } + protected static StreamingCallContext internalGetTypedStreamingContext( + FromPointerReader paramsFactory, + CallContext typeless) { + return new StreamingCallContext<>(paramsFactory, typeless.hook); + } + protected abstract DispatchCallResult dispatchCall( long interfaceId, short methodId, CallContext context); @@ -258,6 +270,13 @@ public final class Capability { return new RemotePromise(promise, promiseAndPipeline.pipeline); } + @Override + public CompletableFuture sendStreaming() { + // We don't do any special handling of streaming in RequestHook for local requests, because + // there is no latency to compensate for between the client and server in this case. + return send().ignoreResult(); + } + @Override public Object getBrand() { return null; diff --git a/runtime/src/main/java/org/capnproto/RemotePromise.java b/runtime/src/main/java/org/capnproto/RemotePromise.java index 9664942..a9acd6e 100644 --- a/runtime/src/main/java/org/capnproto/RemotePromise.java +++ b/runtime/src/main/java/org/capnproto/RemotePromise.java @@ -16,6 +16,11 @@ class RemotePromise { return response; } + public CompletableFuture ignoreResult() { + return this.response.thenCompose( + result -> CompletableFuture.completedFuture(null)); + } + public PipelineHook getHook() { return pipeline; } diff --git a/runtime/src/main/java/org/capnproto/Request.java b/runtime/src/main/java/org/capnproto/Request.java index 38c931c..dd6d580 100644 --- a/runtime/src/main/java/org/capnproto/Request.java +++ b/runtime/src/main/java/org/capnproto/Request.java @@ -25,9 +25,8 @@ public class Request { CompletableFuture send() { var typelessPromise = hook.send(); hook = null; // prevent reuse - return typelessPromise.getResponse().thenApply(response -> { - return response.getAs(resultsReader); - }); + return typelessPromise.getResponse().thenApply( + response -> response.getAs(resultsReader)); } static Request newBrokenRequest(Throwable exc) { @@ -39,6 +38,11 @@ public class Request { return new RemotePromise<>(CompletableFuture.failedFuture(exc), null); } + @Override + public CompletableFuture sendStreaming() { + return CompletableFuture.failedFuture(exc); + } + @Override public Object getBrand() { return null; @@ -59,4 +63,3 @@ public class Request { return new Request<>(params, results, typeless.params(), typeless.hook); } } - diff --git a/runtime/src/main/java/org/capnproto/RequestHook.java b/runtime/src/main/java/org/capnproto/RequestHook.java index 290aece..1ba5df7 100644 --- a/runtime/src/main/java/org/capnproto/RequestHook.java +++ b/runtime/src/main/java/org/capnproto/RequestHook.java @@ -1,6 +1,9 @@ package org.capnproto; +import java.util.concurrent.CompletableFuture; + interface RequestHook { RemotePromise send(); + CompletableFuture sendStreaming(); Object getBrand(); } diff --git a/runtime/src/main/java/org/capnproto/StreamingCallContext.java b/runtime/src/main/java/org/capnproto/StreamingCallContext.java new file mode 100644 index 0000000..750d8dc --- /dev/null +++ b/runtime/src/main/java/org/capnproto/StreamingCallContext.java @@ -0,0 +1,13 @@ +package org.capnproto; + +public class StreamingCallContext { + + private final FromPointerReader params; + final CallContextHook hook; + + public StreamingCallContext(FromPointerReader params, + CallContextHook hook) { + this.params = params; + this.hook = hook; + } +} diff --git a/runtime/src/main/java/org/capnproto/StreamingRequest.java b/runtime/src/main/java/org/capnproto/StreamingRequest.java new file mode 100644 index 0000000..81943ce --- /dev/null +++ b/runtime/src/main/java/org/capnproto/StreamingRequest.java @@ -0,0 +1,25 @@ +package org.capnproto; + + +import java.util.concurrent.CompletableFuture; + +public class StreamingRequest { + + private final FromPointerBuilder paramsBuilder; + AnyPointer.Builder params; + RequestHook hook; + + StreamingRequest(FromPointerBuilder paramsBuilder, + AnyPointer.Builder params, RequestHook hook) { + this.paramsBuilder = paramsBuilder; + this.params = params; + this.hook = hook; + } + + CompletableFuture send() { + var promise = hook.sendStreaming(); + hook = null; // prevent reuse + return promise; + } +} + diff --git a/runtime/src/test/java/org/capnproto/TwoPartyTest.java b/runtime/src/test/java/org/capnproto/TwoPartyTest.java index a946e43..56b01b6 100644 --- a/runtime/src/test/java/org/capnproto/TwoPartyTest.java +++ b/runtime/src/test/java/org/capnproto/TwoPartyTest.java @@ -1,7 +1,6 @@ package org.capnproto; import org.capnproto.demo.Demo; -import org.capnproto.demo.DemoFoo; import org.junit.After; import org.junit.Assert; import org.junit.Before; @@ -44,9 +43,9 @@ class TestCap0 { DispatchCallResult dispatchCallInternal(short methodId, CallContext ctx) { switch (methodId) { case 0: - return result(testMethod0(typedContext(Demo.TestParams0.factory, Demo.TestResults0.factory, ctx))); + return result(testMethod0(internalGetTypedContext(Demo.TestParams0.factory, Demo.TestResults0.factory, ctx))); case 1: - return result(testMethod1(typedContext(Demo.TestParams1.factory, Demo.TestResults1.factory, ctx))); + return result(testMethod1(internalGetTypedContext(Demo.TestParams1.factory, Demo.TestResults1.factory, ctx))); default: return result(internalUnimplemented(Demo.class.getName(), 0xa27d3c231c7b9202L, methodId)); } @@ -194,10 +193,6 @@ public class TwoPartyTest { Assert.assertFalse(cap1.isNull()); var cap2 = results.getResult2(); Assert.assertFalse(cap2.isNull()); - - var cap3 = results.getResult2().getAs(Demo.Iface0.factory); - Assert.assertFalse(cap2.isNull()); - //Assert.assertFalse(cap2.hook.isError()); } @Test diff --git a/runtime/src/test/java/org/capnproto/demo/Demo.java b/runtime/src/test/java/org/capnproto/demo/Demo.java index 820e36e..1f70ba4 100644 --- a/runtime/src/test/java/org/capnproto/demo/Demo.java +++ b/runtime/src/test/java/org/capnproto/demo/Demo.java @@ -328,6 +328,13 @@ public final class Demo { public Client(java.util.concurrent.CompletableFuture promise) { super(promise); } + + public org.capnproto.Request method0Request() { + return newCall(Method0Params.factory, Method0Results.factory, 0xac6d126c2fac16ebL, (short)0); + } + public org.capnproto.StreamingRequest method1Request() { + return newStreamingCall(Method1Params.factory, 0xac6d126c2fac16ebL, (short)1); + } } public static abstract class Server extends org.capnproto.Capability.Server { protected org.capnproto.DispatchCallResult dispatchCall( @@ -342,14 +349,154 @@ public final class Demo { protected org.capnproto.DispatchCallResult dispatchCallInternal(short methodId, org.capnproto.CallContext context) { switch (methodId) { + case 0: + return org.capnproto.Capability.Server.result ( + this.method0(org.capnproto.Capability.Server.internalGetTypedContext( + Method0Params.factory, Method0Results.factory, context))); + case 1: + return org.capnproto.Capability.Server.streamResult( + this.method1(org.capnproto.Capability.Server.internalGetTypedStreamingContext( + Method1Params.factory, context))); default: return org.capnproto.Capability.Server.result( org.capnproto.Capability.Server.internalUnimplemented("Iface0", 0xac6d126c2fac16ebL, methodId)); } } + protected java.util.concurrent.CompletableFuture method0(org.capnproto.CallContext context) { + return org.capnproto.Capability.Server.internalUnimplemented( + "runtime/src/test/java/org/capnproto/demo/demo.capnp:Iface0", "method0", + 0xac6d126c2fac16ebL, (short)0); + } + + protected java.util.concurrent.CompletableFuture method1(org.capnproto.StreamingCallContext context) { + return org.capnproto.Capability.Server.internalUnimplemented( + "runtime/src/test/java/org/capnproto/demo/demo.capnp:Iface0", "method1", + 0xac6d126c2fac16ebL, (short)1); + } + } + public static class Method0Params { + public static final org.capnproto.StructSize STRUCT_SIZE = new org.capnproto.StructSize((short)0,(short)0); + public static final class Factory extends org.capnproto.StructFactory { + public Factory() { + } + public final Reader constructReader(org.capnproto.SegmentReader segment, int data,int pointers, int dataSize, short pointerCount, int nestingLimit) { + return new Reader(segment,data,pointers,dataSize,pointerCount,nestingLimit); + } + public final Builder constructBuilder(org.capnproto.SegmentBuilder segment, int data,int pointers, int dataSize, short pointerCount) { + return new Builder(segment, data, pointers, dataSize, pointerCount); + } + public final org.capnproto.StructSize structSize() { + return Iface0.Method0Params.STRUCT_SIZE; + } + public final Reader asReader(Builder builder) { + return builder.asReader(); + } + } + public static final Factory factory = new Factory(); + public static final org.capnproto.StructList.Factory listFactory = + new org.capnproto.StructList.Factory(factory); + public static final class Builder extends org.capnproto.StructBuilder { + Builder(org.capnproto.SegmentBuilder segment, int data, int pointers,int dataSize, short pointerCount){ + super(segment, data, pointers, dataSize, pointerCount); + } + public final Reader asReader() { + return new Reader(segment, data, pointers, dataSize, pointerCount, 0x7fffffff); + } + } + + public static final class Reader extends org.capnproto.StructReader { + Reader(org.capnproto.SegmentReader segment, int data, int pointers,int dataSize, short pointerCount, int nestingLimit){ + super(segment, data, pointers, dataSize, pointerCount, nestingLimit); + } + + } + + } + + + public static class Method0Results { + public static final org.capnproto.StructSize STRUCT_SIZE = new org.capnproto.StructSize((short)0,(short)0); + public static final class Factory extends org.capnproto.StructFactory { + public Factory() { + } + public final Reader constructReader(org.capnproto.SegmentReader segment, int data,int pointers, int dataSize, short pointerCount, int nestingLimit) { + return new Reader(segment,data,pointers,dataSize,pointerCount,nestingLimit); + } + public final Builder constructBuilder(org.capnproto.SegmentBuilder segment, int data,int pointers, int dataSize, short pointerCount) { + return new Builder(segment, data, pointers, dataSize, pointerCount); + } + public final org.capnproto.StructSize structSize() { + return Iface0.Method0Results.STRUCT_SIZE; + } + public final Reader asReader(Builder builder) { + return builder.asReader(); + } + } + public static final Factory factory = new Factory(); + public static final org.capnproto.StructList.Factory listFactory = + new org.capnproto.StructList.Factory(factory); + public static final class Builder extends org.capnproto.StructBuilder { + Builder(org.capnproto.SegmentBuilder segment, int data, int pointers,int dataSize, short pointerCount){ + super(segment, data, pointers, dataSize, pointerCount); + } + public final Reader asReader() { + return new Reader(segment, data, pointers, dataSize, pointerCount, 0x7fffffff); + } + } + + public static final class Reader extends org.capnproto.StructReader { + Reader(org.capnproto.SegmentReader segment, int data, int pointers,int dataSize, short pointerCount, int nestingLimit){ + super(segment, data, pointers, dataSize, pointerCount, nestingLimit); + } + + } + + } + + + public static class Method1Params { + public static final org.capnproto.StructSize STRUCT_SIZE = new org.capnproto.StructSize((short)0,(short)0); + public static final class Factory extends org.capnproto.StructFactory { + public Factory() { + } + public final Reader constructReader(org.capnproto.SegmentReader segment, int data,int pointers, int dataSize, short pointerCount, int nestingLimit) { + return new Reader(segment,data,pointers,dataSize,pointerCount,nestingLimit); + } + public final Builder constructBuilder(org.capnproto.SegmentBuilder segment, int data,int pointers, int dataSize, short pointerCount) { + return new Builder(segment, data, pointers, dataSize, pointerCount); + } + public final org.capnproto.StructSize structSize() { + return Iface0.Method1Params.STRUCT_SIZE; + } + public final Reader asReader(Builder builder) { + return builder.asReader(); + } + } + public static final Factory factory = new Factory(); + public static final org.capnproto.StructList.Factory listFactory = + new org.capnproto.StructList.Factory(factory); + public static final class Builder extends org.capnproto.StructBuilder { + Builder(org.capnproto.SegmentBuilder segment, int data, int pointers,int dataSize, short pointerCount){ + super(segment, data, pointers, dataSize, pointerCount); + } + public final Reader asReader() { + return new Reader(segment, data, pointers, dataSize, pointerCount, 0x7fffffff); + } + } + + public static final class Reader extends org.capnproto.StructReader { + Reader(org.capnproto.SegmentReader segment, int data, int pointers,int dataSize, short pointerCount, int nestingLimit){ + super(segment, data, pointers, dataSize, pointerCount, nestingLimit); + } + + } + + } + + } @@ -443,6 +590,13 @@ public final class Demo { public Client(java.util.concurrent.CompletableFuture promise) { super(promise); } + + public org.capnproto.Request method0Request() { + return newCall(Method0Params.factory, Method0Results.factory, 0xd52dcf38c9f6f7c0L, (short)0); + } + public org.capnproto.Request method1Request() { + return newCall(Method1Params.factory, Method1Results.factory, 0xd52dcf38c9f6f7c0L, (short)1); + } } public static abstract class Server extends org.capnproto.Capability.Server { protected org.capnproto.DispatchCallResult dispatchCall( @@ -458,15 +612,13 @@ public final class Demo { protected org.capnproto.DispatchCallResult dispatchCallInternal(short methodId, org.capnproto.CallContext context) { switch (methodId) { case 0: - return org.capnproto.Capability.Server.result( - this.method0(org.capnproto.Capability.Server.typedContext( - Method0Params.factory, - Method0Results.factory, context))); + return org.capnproto.Capability.Server.result ( + this.method0(org.capnproto.Capability.Server.internalGetTypedContext( + Method0Params.factory, Method0Results.factory, context))); case 1: - return org.capnproto.Capability.Server.result( - this.method1(org.capnproto.Capability.Server.typedContext( - Method1Params.factory, - Method1Results.factory, context))); + return org.capnproto.Capability.Server.result ( + this.method1(org.capnproto.Capability.Server.internalGetTypedContext( + Method1Params.factory, Method1Results.factory, context))); default: return org.capnproto.Capability.Server.result( org.capnproto.Capability.Server.internalUnimplemented("Iface1", 0xd52dcf38c9f6f7c0L, methodId)); @@ -474,13 +626,13 @@ public final class Demo { } protected java.util.concurrent.CompletableFuture method0(org.capnproto.CallContext context) { - return org.capnproto.Capability.Server.internalUnimplemented( + return org.capnproto.Capability.Server.internalUnimplemented( "runtime/src/test/java/org/capnproto/demo/demo.capnp:Iface1", "method0", 0xd52dcf38c9f6f7c0L, (short)0); } protected java.util.concurrent.CompletableFuture method1(org.capnproto.CallContext context) { - return org.capnproto.Capability.Server.internalUnimplemented( + return org.capnproto.Capability.Server.internalUnimplemented( "runtime/src/test/java/org/capnproto/demo/demo.capnp:Iface1", "method1", 0xd52dcf38c9f6f7c0L, (short)1); } @@ -1008,8 +1160,8 @@ public static final org.capnproto.SegmentReader b_ac6d126c2fac16eb = "\u0015\u0000\u0000\u0000\u00da\u0001\u0000\u0000" + "\u0031\u0000\u0000\u0000\u0007\u0000\u0000\u0000" + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + - "\u002d\u0000\u0000\u0000\u0007\u0000\u0000\u0000" + - "\u002d\u0000\u0000\u0000\u0007\u0000\u0000\u0000" + + "\u002d\u0000\u0000\u0000\u0087\u0000\u0000\u0000" + + "\u007d\u0000\u0000\u0000\u0007\u0000\u0000\u0000" + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + "\u0072\u0075\u006e\u0074\u0069\u006d\u0065\u002f" + "\u0073\u0072\u0063\u002f\u0074\u0065\u0073\u0074" + @@ -1020,8 +1172,100 @@ public static final org.capnproto.SegmentReader b_ac6d126c2fac16eb = "\u0070\u006e\u0070\u003a\u0049\u0066\u0061\u0063" + "\u0065\u0030\u0000\u0000\u0000\u0000\u0000\u0000" + "\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000" + - "\u0000\u0000\u0000\u0000\u0003\u0000\u0005\u0000" + + "\u0008\u0000\u0000\u0000\u0003\u0000\u0005\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u004b\u0029\u0076\u00aa\u00ed\u0077\u008d\u00bc" + + "\u003e\u0067\u0084\u00a6\u004a\u00e2\u0044\u00f7" + + "\u0031\u0000\u0000\u0000\u0042\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0025\u0000\u0000\u0000\u0007\u0000\u0000\u0000" + + "\u0001\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0024\u00f3\u0034\u00d2\u0078\u005b\u00c2\u00c8" + + "\u006e\u00b1\u00c0\u0077\u0033\u009a\u005f\u0099" + + "\u0019\u0000\u0000\u0000\u0042\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\r\u0000\u0000\u0000\u0007\u0000\u0000\u0000" + + "\u006d\u0065\u0074\u0068\u006f\u0064\u0030\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000" + + "\u006d\u0065\u0074\u0068\u006f\u0064\u0031\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0001\u0000" + "\u0000\u0000\u0000\u0000\u0001\u0000\u0001\u0000" + ""); +public static final org.capnproto.SegmentReader b_bc8d77edaa76294b = + org.capnproto.GeneratedClassSupport.decodeRawBytes( + "\u0000\u0000\u0000\u0000\u0005\u0000\u0006\u0000" + + "\u004b\u0029\u0076\u00aa\u00ed\u0077\u008d\u00bc" + + "\u003b\u0000\u0000\u0000\u0001\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0007\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0015\u0000\u0000\u0000\u0052\u0002\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0072\u0075\u006e\u0074\u0069\u006d\u0065\u002f" + + "\u0073\u0072\u0063\u002f\u0074\u0065\u0073\u0074" + + "\u002f\u006a\u0061\u0076\u0061\u002f\u006f\u0072" + + "\u0067\u002f\u0063\u0061\u0070\u006e\u0070\u0072" + + "\u006f\u0074\u006f\u002f\u0064\u0065\u006d\u006f" + + "\u002f\u0064\u0065\u006d\u006f\u002e\u0063\u0061" + + "\u0070\u006e\u0070\u003a\u0049\u0066\u0061\u0063" + + "\u0065\u0030\u002e\u006d\u0065\u0074\u0068\u006f" + + "\u0064\u0030\u0024\u0050\u0061\u0072\u0061\u006d" + + "\u0073\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + ""); +public static final org.capnproto.SegmentReader b_f744e24aa684673e = + org.capnproto.GeneratedClassSupport.decodeRawBytes( + "\u0000\u0000\u0000\u0000\u0005\u0000\u0006\u0000" + + "\u003e\u0067\u0084\u00a6\u004a\u00e2\u0044\u00f7" + + "\u003b\u0000\u0000\u0000\u0001\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0007\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0015\u0000\u0000\u0000\u005a\u0002\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0072\u0075\u006e\u0074\u0069\u006d\u0065\u002f" + + "\u0073\u0072\u0063\u002f\u0074\u0065\u0073\u0074" + + "\u002f\u006a\u0061\u0076\u0061\u002f\u006f\u0072" + + "\u0067\u002f\u0063\u0061\u0070\u006e\u0070\u0072" + + "\u006f\u0074\u006f\u002f\u0064\u0065\u006d\u006f" + + "\u002f\u0064\u0065\u006d\u006f\u002e\u0063\u0061" + + "\u0070\u006e\u0070\u003a\u0049\u0066\u0061\u0063" + + "\u0065\u0030\u002e\u006d\u0065\u0074\u0068\u006f" + + "\u0064\u0030\u0024\u0052\u0065\u0073\u0075\u006c" + + "\u0074\u0073\u0000\u0000\u0000\u0000\u0000\u0000" + ""); +public static final org.capnproto.SegmentReader b_c8c25b78d234f324 = + org.capnproto.GeneratedClassSupport.decodeRawBytes( + "\u0000\u0000\u0000\u0000\u0005\u0000\u0006\u0000" + + "\u0024\u00f3\u0034\u00d2\u0078\u005b\u00c2\u00c8" + + "\u003b\u0000\u0000\u0000\u0001\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0007\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0015\u0000\u0000\u0000\u0052\u0002\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + + "\u0072\u0075\u006e\u0074\u0069\u006d\u0065\u002f" + + "\u0073\u0072\u0063\u002f\u0074\u0065\u0073\u0074" + + "\u002f\u006a\u0061\u0076\u0061\u002f\u006f\u0072" + + "\u0067\u002f\u0063\u0061\u0070\u006e\u0070\u0072" + + "\u006f\u0074\u006f\u002f\u0064\u0065\u006d\u006f" + + "\u002f\u0064\u0065\u006d\u006f\u002e\u0063\u0061" + + "\u0070\u006e\u0070\u003a\u0049\u0066\u0061\u0063" + + "\u0065\u0030\u002e\u006d\u0065\u0074\u0068\u006f" + + "\u0064\u0031\u0024\u0050\u0061\u0072\u0061\u006d" + + "\u0073\u0000\u0000\u0000\u0000\u0000\u0000\u0000" + ""); public static final org.capnproto.SegmentReader b_a9395663e97ca3af = org.capnproto.GeneratedClassSupport.decodeRawBytes( "\u0000\u0000\u0000\u0000\u0005\u0000\u0006\u0000" + diff --git a/runtime/src/test/java/org/capnproto/demo/demo.capnp b/runtime/src/test/java/org/capnproto/demo/demo.capnp index a9676ed..0b67c3e 100644 --- a/runtime/src/test/java/org/capnproto/demo/demo.capnp +++ b/runtime/src/test/java/org/capnproto/demo/demo.capnp @@ -27,6 +27,8 @@ struct Struct0 { } interface Iface0 { + method0 @0 (); + method1 @1 () -> stream; } struct Struct2 { @@ -37,7 +39,7 @@ struct Struct2 { interface Iface1 { struct Struct1 { - f0 @0 :Bool; + f0 @0 :Bool; f1 @1 :AnyPointer; } diff --git a/runtime/src/test/java/org/capnproto/demo/demo.capnp.c++ b/runtime/src/test/java/org/capnproto/demo/demo.capnp.c++ index db120da..53d50f4 100644 --- a/runtime/src/test/java/org/capnproto/demo/demo.capnp.c++ +++ b/runtime/src/test/java/org/capnproto/demo/demo.capnp.c++ @@ -277,7 +277,7 @@ const ::capnp::_::RawSchema s_b1af51b6aef0e7bc = { 0, 1, i_b1af51b6aef0e7bc, nullptr, nullptr, { &s_b1af51b6aef0e7bc, nullptr, nullptr, 0, 0, nullptr } }; #endif // !CAPNP_LITE -static const ::capnp::_::AlignedData<23> b_ac6d126c2fac16eb = { +static const ::capnp::_::AlignedData<43> b_ac6d126c2fac16eb = { { 0, 0, 0, 0, 5, 0, 6, 0, 235, 22, 172, 47, 108, 18, 109, 172, 52, 0, 0, 0, 3, 0, 0, 0, @@ -287,8 +287,8 @@ static const ::capnp::_::AlignedData<23> b_ac6d126c2fac16eb = { 21, 0, 0, 0, 218, 1, 0, 0, 49, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 45, 0, 0, 0, 7, 0, 0, 0, - 45, 0, 0, 0, 7, 0, 0, 0, + 45, 0, 0, 0, 135, 0, 0, 0, + 125, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 117, 110, 116, 105, 109, 101, 47, 115, 114, 99, 47, 116, 101, 115, 116, @@ -299,14 +299,134 @@ static const ::capnp::_::AlignedData<23> b_ac6d126c2fac16eb = { 112, 110, 112, 58, 73, 102, 97, 99, 101, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, - 0, 0, 0, 0, 3, 0, 5, 0, + 8, 0, 0, 0, 3, 0, 5, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 75, 41, 118, 170, 237, 119, 141, 188, + 62, 103, 132, 166, 74, 226, 68, 247, + 49, 0, 0, 0, 66, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 37, 0, 0, 0, 7, 0, 0, 0, + 1, 0, 0, 0, 0, 0, 0, 0, + 36, 243, 52, 210, 120, 91, 194, 200, + 110, 177, 192, 119, 51, 154, 95, 153, + 25, 0, 0, 0, 66, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 13, 0, 0, 0, 7, 0, 0, 0, + 109, 101, 116, 104, 111, 100, 48, 0, + 0, 0, 0, 0, 0, 0, 1, 0, + 109, 101, 116, 104, 111, 100, 49, 0, + 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, } }; ::capnp::word const* const bp_ac6d126c2fac16eb = b_ac6d126c2fac16eb.words; #if !CAPNP_LITE +static const ::capnp::_::RawSchema* const d_ac6d126c2fac16eb[] = { + &s_995f9a3377c0b16e, + &s_bc8d77edaa76294b, + &s_c8c25b78d234f324, + &s_f744e24aa684673e, +}; +static const uint16_t m_ac6d126c2fac16eb[] = {0, 1}; const ::capnp::_::RawSchema s_ac6d126c2fac16eb = { - 0xac6d126c2fac16eb, b_ac6d126c2fac16eb.words, 23, nullptr, nullptr, - 0, 0, nullptr, nullptr, nullptr, { &s_ac6d126c2fac16eb, nullptr, nullptr, 0, 0, nullptr } + 0xac6d126c2fac16eb, b_ac6d126c2fac16eb.words, 43, d_ac6d126c2fac16eb, m_ac6d126c2fac16eb, + 4, 2, nullptr, nullptr, nullptr, { &s_ac6d126c2fac16eb, nullptr, nullptr, 0, 0, nullptr } +}; +#endif // !CAPNP_LITE +static const ::capnp::_::AlignedData<22> b_bc8d77edaa76294b = { + { 0, 0, 0, 0, 5, 0, 6, 0, + 75, 41, 118, 170, 237, 119, 141, 188, + 59, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 82, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 114, 117, 110, 116, 105, 109, 101, 47, + 115, 114, 99, 47, 116, 101, 115, 116, + 47, 106, 97, 118, 97, 47, 111, 114, + 103, 47, 99, 97, 112, 110, 112, 114, + 111, 116, 111, 47, 100, 101, 109, 111, + 47, 100, 101, 109, 111, 46, 99, 97, + 112, 110, 112, 58, 73, 102, 97, 99, + 101, 48, 46, 109, 101, 116, 104, 111, + 100, 48, 36, 80, 97, 114, 97, 109, + 115, 0, 0, 0, 0, 0, 0, 0, } +}; +::capnp::word const* const bp_bc8d77edaa76294b = b_bc8d77edaa76294b.words; +#if !CAPNP_LITE +const ::capnp::_::RawSchema s_bc8d77edaa76294b = { + 0xbc8d77edaa76294b, b_bc8d77edaa76294b.words, 22, nullptr, nullptr, + 0, 0, nullptr, nullptr, nullptr, { &s_bc8d77edaa76294b, nullptr, nullptr, 0, 0, nullptr } +}; +#endif // !CAPNP_LITE +static const ::capnp::_::AlignedData<22> b_f744e24aa684673e = { + { 0, 0, 0, 0, 5, 0, 6, 0, + 62, 103, 132, 166, 74, 226, 68, 247, + 59, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 90, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 114, 117, 110, 116, 105, 109, 101, 47, + 115, 114, 99, 47, 116, 101, 115, 116, + 47, 106, 97, 118, 97, 47, 111, 114, + 103, 47, 99, 97, 112, 110, 112, 114, + 111, 116, 111, 47, 100, 101, 109, 111, + 47, 100, 101, 109, 111, 46, 99, 97, + 112, 110, 112, 58, 73, 102, 97, 99, + 101, 48, 46, 109, 101, 116, 104, 111, + 100, 48, 36, 82, 101, 115, 117, 108, + 116, 115, 0, 0, 0, 0, 0, 0, } +}; +::capnp::word const* const bp_f744e24aa684673e = b_f744e24aa684673e.words; +#if !CAPNP_LITE +const ::capnp::_::RawSchema s_f744e24aa684673e = { + 0xf744e24aa684673e, b_f744e24aa684673e.words, 22, nullptr, nullptr, + 0, 0, nullptr, nullptr, nullptr, { &s_f744e24aa684673e, nullptr, nullptr, 0, 0, nullptr } +}; +#endif // !CAPNP_LITE +static const ::capnp::_::AlignedData<22> b_c8c25b78d234f324 = { + { 0, 0, 0, 0, 5, 0, 6, 0, + 36, 243, 52, 210, 120, 91, 194, 200, + 59, 0, 0, 0, 1, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 7, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 21, 0, 0, 0, 82, 2, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 114, 117, 110, 116, 105, 109, 101, 47, + 115, 114, 99, 47, 116, 101, 115, 116, + 47, 106, 97, 118, 97, 47, 111, 114, + 103, 47, 99, 97, 112, 110, 112, 114, + 111, 116, 111, 47, 100, 101, 109, 111, + 47, 100, 101, 109, 111, 46, 99, 97, + 112, 110, 112, 58, 73, 102, 97, 99, + 101, 48, 46, 109, 101, 116, 104, 111, + 100, 49, 36, 80, 97, 114, 97, 109, + 115, 0, 0, 0, 0, 0, 0, 0, } +}; +::capnp::word const* const bp_c8c25b78d234f324 = b_c8c25b78d234f324.words; +#if !CAPNP_LITE +const ::capnp::_::RawSchema s_c8c25b78d234f324 = { + 0xc8c25b78d234f324, b_c8c25b78d234f324.words, 22, nullptr, nullptr, + 0, 0, nullptr, nullptr, nullptr, { &s_c8c25b78d234f324, nullptr, nullptr, 0, 0, nullptr } }; #endif // !CAPNP_LITE static const ::capnp::_::AlignedData<52> b_a9395663e97ca3af = { @@ -730,6 +850,26 @@ constexpr ::capnp::_::RawSchema const* Struct0::_capnpPrivate::schema; #endif // !CAPNP_LITE #if !CAPNP_LITE +::capnp::Request< ::Iface0::Method0Params, ::Iface0::Method0Results> +Iface0::Client::method0Request(::kj::Maybe< ::capnp::MessageSize> sizeHint) { + return newCall< ::Iface0::Method0Params, ::Iface0::Method0Results>( + 0xac6d126c2fac16ebull, 0, sizeHint); +} +::kj::Promise Iface0::Server::method0(Method0Context) { + return ::capnp::Capability::Server::internalUnimplemented( + "runtime/src/test/java/org/capnproto/demo/demo.capnp:Iface0", "method0", + 0xac6d126c2fac16ebull, 0); +} +::capnp::StreamingRequest< ::Iface0::Method1Params> +Iface0::Client::method1Request(::kj::Maybe< ::capnp::MessageSize> sizeHint) { + return newStreamingCall< ::Iface0::Method1Params>( + 0xac6d126c2fac16ebull, 1, sizeHint); +} +::kj::Promise Iface0::Server::method1(Method1Context) { + return ::capnp::Capability::Server::internalUnimplemented( + "runtime/src/test/java/org/capnproto/demo/demo.capnp:Iface0", "method1", + 0xac6d126c2fac16ebull, 1); +} ::capnp::Capability::Server::DispatchCallResult Iface0::Server::dispatchCall( uint64_t interfaceId, uint16_t methodId, ::capnp::CallContext< ::capnp::AnyPointer, ::capnp::AnyPointer> context) { @@ -744,6 +884,20 @@ constexpr ::capnp::_::RawSchema const* Struct0::_capnpPrivate::schema; uint16_t methodId, ::capnp::CallContext< ::capnp::AnyPointer, ::capnp::AnyPointer> context) { switch (methodId) { + case 0: + return { + method0(::capnp::Capability::Server::internalGetTypedContext< + ::Iface0::Method0Params, ::Iface0::Method0Results>(context)), + false + }; + case 1: + return { + kj::evalNow([&]() { + return method1(::capnp::Capability::Server::internalGetTypedStreamingContext< + ::Iface0::Method1Params>(context)); + }), + true + }; default: (void)context; return ::capnp::Capability::Server::internalUnimplemented( @@ -759,6 +913,30 @@ constexpr ::capnp::Kind Iface0::_capnpPrivate::kind; constexpr ::capnp::_::RawSchema const* Iface0::_capnpPrivate::schema; #endif // !CAPNP_LITE +// Iface0::Method0Params +constexpr uint16_t Iface0::Method0Params::_capnpPrivate::dataWordSize; +constexpr uint16_t Iface0::Method0Params::_capnpPrivate::pointerCount; +#if !CAPNP_LITE +constexpr ::capnp::Kind Iface0::Method0Params::_capnpPrivate::kind; +constexpr ::capnp::_::RawSchema const* Iface0::Method0Params::_capnpPrivate::schema; +#endif // !CAPNP_LITE + +// Iface0::Method0Results +constexpr uint16_t Iface0::Method0Results::_capnpPrivate::dataWordSize; +constexpr uint16_t Iface0::Method0Results::_capnpPrivate::pointerCount; +#if !CAPNP_LITE +constexpr ::capnp::Kind Iface0::Method0Results::_capnpPrivate::kind; +constexpr ::capnp::_::RawSchema const* Iface0::Method0Results::_capnpPrivate::schema; +#endif // !CAPNP_LITE + +// Iface0::Method1Params +constexpr uint16_t Iface0::Method1Params::_capnpPrivate::dataWordSize; +constexpr uint16_t Iface0::Method1Params::_capnpPrivate::pointerCount; +#if !CAPNP_LITE +constexpr ::capnp::Kind Iface0::Method1Params::_capnpPrivate::kind; +constexpr ::capnp::_::RawSchema const* Iface0::Method1Params::_capnpPrivate::schema; +#endif // !CAPNP_LITE + // Struct2 constexpr uint16_t Struct2::_capnpPrivate::dataWordSize; constexpr uint16_t Struct2::_capnpPrivate::pointerCount; diff --git a/runtime/src/test/java/org/capnproto/demo/demo.capnp.h b/runtime/src/test/java/org/capnproto/demo/demo.capnp.h index a595334..f98b092 100644 --- a/runtime/src/test/java/org/capnproto/demo/demo.capnp.h +++ b/runtime/src/test/java/org/capnproto/demo/demo.capnp.h @@ -23,6 +23,9 @@ CAPNP_DECLARE_SCHEMA(b20f33e412339049); CAPNP_DECLARE_SCHEMA(d1342392ab536963); CAPNP_DECLARE_SCHEMA(b1af51b6aef0e7bc); CAPNP_DECLARE_SCHEMA(ac6d126c2fac16eb); +CAPNP_DECLARE_SCHEMA(bc8d77edaa76294b); +CAPNP_DECLARE_SCHEMA(f744e24aa684673e); +CAPNP_DECLARE_SCHEMA(c8c25b78d234f324); CAPNP_DECLARE_SCHEMA(a9395663e97ca3af); CAPNP_DECLARE_SCHEMA(d52dcf38c9f6f7c0); CAPNP_DECLARE_SCHEMA(800ca862fbfddd38); @@ -118,6 +121,9 @@ struct Iface0 { class Server; #endif // !CAPNP_LITE + struct Method0Params; + struct Method0Results; + struct Method1Params; #if !CAPNP_LITE struct _capnpPrivate { @@ -127,6 +133,51 @@ struct Iface0 { #endif // !CAPNP_LITE }; +struct Iface0::Method0Params { + Method0Params() = delete; + + class Reader; + class Builder; + class Pipeline; + + struct _capnpPrivate { + CAPNP_DECLARE_STRUCT_HEADER(bc8d77edaa76294b, 0, 0) + #if !CAPNP_LITE + static constexpr ::capnp::_::RawBrandedSchema const* brand() { return &schema->defaultBrand; } + #endif // !CAPNP_LITE + }; +}; + +struct Iface0::Method0Results { + Method0Results() = delete; + + class Reader; + class Builder; + class Pipeline; + + struct _capnpPrivate { + CAPNP_DECLARE_STRUCT_HEADER(f744e24aa684673e, 0, 0) + #if !CAPNP_LITE + static constexpr ::capnp::_::RawBrandedSchema const* brand() { return &schema->defaultBrand; } + #endif // !CAPNP_LITE + }; +}; + +struct Iface0::Method1Params { + Method1Params() = delete; + + class Reader; + class Builder; + class Pipeline; + + struct _capnpPrivate { + CAPNP_DECLARE_STRUCT_HEADER(c8c25b78d234f324, 0, 0) + #if !CAPNP_LITE + static constexpr ::capnp::_::RawBrandedSchema const* brand() { return &schema->defaultBrand; } + #endif // !CAPNP_LITE + }; +}; + struct Struct2 { Struct2() = delete; @@ -658,6 +709,10 @@ public: Client& operator=(Client& other); Client& operator=(Client&& other); + ::capnp::Request< ::Iface0::Method0Params, ::Iface0::Method0Results> method0Request( + ::kj::Maybe< ::capnp::MessageSize> sizeHint = nullptr); + ::capnp::StreamingRequest< ::Iface0::Method1Params> method1Request( + ::kj::Maybe< ::capnp::MessageSize> sizeHint = nullptr); protected: Client() = default; @@ -674,6 +729,13 @@ public: override; protected: + typedef ::Iface0::Method0Params Method0Params; + typedef ::Iface0::Method0Results Method0Results; + typedef ::capnp::CallContext Method0Context; + virtual ::kj::Promise method0(Method0Context context); + typedef ::Iface0::Method1Params Method1Params; + typedef ::capnp::StreamingCallContext Method1Context; + virtual ::kj::Promise method1(Method1Context context); inline ::Iface0::Client thisCap() { return ::capnp::Capability::Server::thisCap() @@ -686,6 +748,219 @@ protected: }; #endif // !CAPNP_LITE +class Iface0::Method0Params::Reader { +public: + typedef Method0Params Reads; + + Reader() = default; + inline explicit Reader(::capnp::_::StructReader base): _reader(base) {} + + inline ::capnp::MessageSize totalSize() const { + return _reader.totalSize().asPublic(); + } + +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { + return ::capnp::_::structString(_reader, *_capnpPrivate::brand()); + } +#endif // !CAPNP_LITE + +private: + ::capnp::_::StructReader _reader; + template + friend struct ::capnp::ToDynamic_; + template + friend struct ::capnp::_::PointerHelpers; + template + friend struct ::capnp::List; + friend class ::capnp::MessageBuilder; + friend class ::capnp::Orphanage; +}; + +class Iface0::Method0Params::Builder { +public: + typedef Method0Params Builds; + + Builder() = delete; // Deleted to discourage incorrect usage. + // You can explicitly initialize to nullptr instead. + inline Builder(decltype(nullptr)) {} + inline explicit Builder(::capnp::_::StructBuilder base): _builder(base) {} + inline operator Reader() const { return Reader(_builder.asReader()); } + inline Reader asReader() const { return *this; } + + inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); } +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { return asReader().toString(); } +#endif // !CAPNP_LITE + +private: + ::capnp::_::StructBuilder _builder; + template + friend struct ::capnp::ToDynamic_; + friend class ::capnp::Orphanage; + template + friend struct ::capnp::_::PointerHelpers; +}; + +#if !CAPNP_LITE +class Iface0::Method0Params::Pipeline { +public: + typedef Method0Params Pipelines; + + inline Pipeline(decltype(nullptr)): _typeless(nullptr) {} + inline explicit Pipeline(::capnp::AnyPointer::Pipeline&& typeless) + : _typeless(kj::mv(typeless)) {} + +private: + ::capnp::AnyPointer::Pipeline _typeless; + friend class ::capnp::PipelineHook; + template + friend struct ::capnp::ToDynamic_; +}; +#endif // !CAPNP_LITE + +class Iface0::Method0Results::Reader { +public: + typedef Method0Results Reads; + + Reader() = default; + inline explicit Reader(::capnp::_::StructReader base): _reader(base) {} + + inline ::capnp::MessageSize totalSize() const { + return _reader.totalSize().asPublic(); + } + +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { + return ::capnp::_::structString(_reader, *_capnpPrivate::brand()); + } +#endif // !CAPNP_LITE + +private: + ::capnp::_::StructReader _reader; + template + friend struct ::capnp::ToDynamic_; + template + friend struct ::capnp::_::PointerHelpers; + template + friend struct ::capnp::List; + friend class ::capnp::MessageBuilder; + friend class ::capnp::Orphanage; +}; + +class Iface0::Method0Results::Builder { +public: + typedef Method0Results Builds; + + Builder() = delete; // Deleted to discourage incorrect usage. + // You can explicitly initialize to nullptr instead. + inline Builder(decltype(nullptr)) {} + inline explicit Builder(::capnp::_::StructBuilder base): _builder(base) {} + inline operator Reader() const { return Reader(_builder.asReader()); } + inline Reader asReader() const { return *this; } + + inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); } +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { return asReader().toString(); } +#endif // !CAPNP_LITE + +private: + ::capnp::_::StructBuilder _builder; + template + friend struct ::capnp::ToDynamic_; + friend class ::capnp::Orphanage; + template + friend struct ::capnp::_::PointerHelpers; +}; + +#if !CAPNP_LITE +class Iface0::Method0Results::Pipeline { +public: + typedef Method0Results Pipelines; + + inline Pipeline(decltype(nullptr)): _typeless(nullptr) {} + inline explicit Pipeline(::capnp::AnyPointer::Pipeline&& typeless) + : _typeless(kj::mv(typeless)) {} + +private: + ::capnp::AnyPointer::Pipeline _typeless; + friend class ::capnp::PipelineHook; + template + friend struct ::capnp::ToDynamic_; +}; +#endif // !CAPNP_LITE + +class Iface0::Method1Params::Reader { +public: + typedef Method1Params Reads; + + Reader() = default; + inline explicit Reader(::capnp::_::StructReader base): _reader(base) {} + + inline ::capnp::MessageSize totalSize() const { + return _reader.totalSize().asPublic(); + } + +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { + return ::capnp::_::structString(_reader, *_capnpPrivate::brand()); + } +#endif // !CAPNP_LITE + +private: + ::capnp::_::StructReader _reader; + template + friend struct ::capnp::ToDynamic_; + template + friend struct ::capnp::_::PointerHelpers; + template + friend struct ::capnp::List; + friend class ::capnp::MessageBuilder; + friend class ::capnp::Orphanage; +}; + +class Iface0::Method1Params::Builder { +public: + typedef Method1Params Builds; + + Builder() = delete; // Deleted to discourage incorrect usage. + // You can explicitly initialize to nullptr instead. + inline Builder(decltype(nullptr)) {} + inline explicit Builder(::capnp::_::StructBuilder base): _builder(base) {} + inline operator Reader() const { return Reader(_builder.asReader()); } + inline Reader asReader() const { return *this; } + + inline ::capnp::MessageSize totalSize() const { return asReader().totalSize(); } +#if !CAPNP_LITE + inline ::kj::StringTree toString() const { return asReader().toString(); } +#endif // !CAPNP_LITE + +private: + ::capnp::_::StructBuilder _builder; + template + friend struct ::capnp::ToDynamic_; + friend class ::capnp::Orphanage; + template + friend struct ::capnp::_::PointerHelpers; +}; + +#if !CAPNP_LITE +class Iface0::Method1Params::Pipeline { +public: + typedef Method1Params Pipelines; + + inline Pipeline(decltype(nullptr)): _typeless(nullptr) {} + inline explicit Pipeline(::capnp::AnyPointer::Pipeline&& typeless) + : _typeless(kj::mv(typeless)) {} + +private: + ::capnp::AnyPointer::Pipeline _typeless; + friend class ::capnp::PipelineHook; + template + friend struct ::capnp::ToDynamic_; +}; +#endif // !CAPNP_LITE + class Struct2::Reader { public: typedef Struct2 Reads;