annotate win32-mingw/include/capnp/rpc-prelude.h @ 50:37d53a7e8262

Headers for KJ/Capnp Win32
author Chris Cannam
date Wed, 26 Oct 2016 13:18:45 +0100
parents
children eccd51b72864
rev   line source
Chris@50 1 // Copyright (c) 2013-2014 Sandstorm Development Group, Inc. and contributors
Chris@50 2 // Licensed under the MIT License:
Chris@50 3 //
Chris@50 4 // Permission is hereby granted, free of charge, to any person obtaining a copy
Chris@50 5 // of this software and associated documentation files (the "Software"), to deal
Chris@50 6 // in the Software without restriction, including without limitation the rights
Chris@50 7 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
Chris@50 8 // copies of the Software, and to permit persons to whom the Software is
Chris@50 9 // furnished to do so, subject to the following conditions:
Chris@50 10 //
Chris@50 11 // The above copyright notice and this permission notice shall be included in
Chris@50 12 // all copies or substantial portions of the Software.
Chris@50 13 //
Chris@50 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
Chris@50 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
Chris@50 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Chris@50 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Chris@50 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
Chris@50 19 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
Chris@50 20 // THE SOFTWARE.
Chris@50 21
Chris@50 22 // This file contains a bunch of internal declarations that must appear before rpc.h can start.
Chris@50 23 // We don't define these directly in rpc.h because it makes the file hard to read.
Chris@50 24
Chris@50 25 #ifndef CAPNP_RPC_PRELUDE_H_
Chris@50 26 #define CAPNP_RPC_PRELUDE_H_
Chris@50 27
Chris@50 28 #if defined(__GNUC__) && !defined(CAPNP_HEADER_WARNINGS)
Chris@50 29 #pragma GCC system_header
Chris@50 30 #endif
Chris@50 31
Chris@50 32 #include "capability.h"
Chris@50 33 #include "persistent.capnp.h"
Chris@50 34
Chris@50 35 namespace capnp {
Chris@50 36
Chris@50 37 class OutgoingRpcMessage;
Chris@50 38 class IncomingRpcMessage;
Chris@50 39
Chris@50 40 template <typename SturdyRefHostId>
Chris@50 41 class RpcSystem;
Chris@50 42
Chris@50 43 namespace _ { // private
Chris@50 44
Chris@50 45 class VatNetworkBase {
Chris@50 46 // Non-template version of VatNetwork. Ignore this class; see VatNetwork in rpc.h.
Chris@50 47
Chris@50 48 public:
Chris@50 49 class Connection;
Chris@50 50
Chris@50 51 struct ConnectionAndProvisionId {
Chris@50 52 kj::Own<Connection> connection;
Chris@50 53 kj::Own<OutgoingRpcMessage> firstMessage;
Chris@50 54 Orphan<AnyPointer> provisionId;
Chris@50 55 };
Chris@50 56
Chris@50 57 class Connection {
Chris@50 58 public:
Chris@50 59 virtual kj::Own<OutgoingRpcMessage> newOutgoingMessage(uint firstSegmentWordSize) = 0;
Chris@50 60 virtual kj::Promise<kj::Maybe<kj::Own<IncomingRpcMessage>>> receiveIncomingMessage() = 0;
Chris@50 61 virtual kj::Promise<void> shutdown() = 0;
Chris@50 62 virtual AnyStruct::Reader baseGetPeerVatId() = 0;
Chris@50 63 };
Chris@50 64 virtual kj::Maybe<kj::Own<Connection>> baseConnect(AnyStruct::Reader vatId) = 0;
Chris@50 65 virtual kj::Promise<kj::Own<Connection>> baseAccept() = 0;
Chris@50 66 };
Chris@50 67
Chris@50 68 class SturdyRefRestorerBase {
Chris@50 69 public:
Chris@50 70 virtual Capability::Client baseRestore(AnyPointer::Reader ref) = 0;
Chris@50 71 };
Chris@50 72
Chris@50 73 class BootstrapFactoryBase {
Chris@50 74 // Non-template version of BootstrapFactory. Ignore this class; see BootstrapFactory in rpc.h.
Chris@50 75 public:
Chris@50 76 virtual Capability::Client baseCreateFor(AnyStruct::Reader clientId) = 0;
Chris@50 77 };
Chris@50 78
Chris@50 79 class RpcSystemBase {
Chris@50 80 // Non-template version of RpcSystem. Ignore this class; see RpcSystem in rpc.h.
Chris@50 81
Chris@50 82 public:
Chris@50 83 RpcSystemBase(VatNetworkBase& network, kj::Maybe<Capability::Client> bootstrapInterface,
Chris@50 84 kj::Maybe<RealmGateway<>::Client> gateway);
Chris@50 85 RpcSystemBase(VatNetworkBase& network, BootstrapFactoryBase& bootstrapFactory,
Chris@50 86 kj::Maybe<RealmGateway<>::Client> gateway);
Chris@50 87 RpcSystemBase(VatNetworkBase& network, SturdyRefRestorerBase& restorer);
Chris@50 88 RpcSystemBase(RpcSystemBase&& other) noexcept;
Chris@50 89 ~RpcSystemBase() noexcept(false);
Chris@50 90
Chris@50 91 private:
Chris@50 92 class Impl;
Chris@50 93 kj::Own<Impl> impl;
Chris@50 94
Chris@50 95 Capability::Client baseBootstrap(AnyStruct::Reader vatId);
Chris@50 96 Capability::Client baseRestore(AnyStruct::Reader vatId, AnyPointer::Reader objectId);
Chris@50 97 void baseSetFlowLimit(size_t words);
Chris@50 98
Chris@50 99 template <typename>
Chris@50 100 friend class capnp::RpcSystem;
Chris@50 101 };
Chris@50 102
Chris@50 103 template <typename T> struct InternalRefFromRealmGateway_;
Chris@50 104 template <typename InternalRef, typename ExternalRef, typename InternalOwner,
Chris@50 105 typename ExternalOwner>
Chris@50 106 struct InternalRefFromRealmGateway_<RealmGateway<InternalRef, ExternalRef, InternalOwner,
Chris@50 107 ExternalOwner>> {
Chris@50 108 typedef InternalRef Type;
Chris@50 109 };
Chris@50 110 template <typename T>
Chris@50 111 using InternalRefFromRealmGateway = typename InternalRefFromRealmGateway_<T>::Type;
Chris@50 112 template <typename T>
Chris@50 113 using InternalRefFromRealmGatewayClient = InternalRefFromRealmGateway<typename T::Calls>;
Chris@50 114
Chris@50 115 template <typename T> struct ExternalRefFromRealmGateway_;
Chris@50 116 template <typename InternalRef, typename ExternalRef, typename InternalOwner,
Chris@50 117 typename ExternalOwner>
Chris@50 118 struct ExternalRefFromRealmGateway_<RealmGateway<InternalRef, ExternalRef, InternalOwner,
Chris@50 119 ExternalOwner>> {
Chris@50 120 typedef ExternalRef Type;
Chris@50 121 };
Chris@50 122 template <typename T>
Chris@50 123 using ExternalRefFromRealmGateway = typename ExternalRefFromRealmGateway_<T>::Type;
Chris@50 124 template <typename T>
Chris@50 125 using ExternalRefFromRealmGatewayClient = ExternalRefFromRealmGateway<typename T::Calls>;
Chris@50 126
Chris@50 127 } // namespace _ (private)
Chris@50 128 } // namespace capnp
Chris@50 129
Chris@50 130 #endif // CAPNP_RPC_PRELUDE_H_