Mercurial > hg > sv-dependency-builds
comparison win32-mingw/include/capnp/capability.h @ 64:eccd51b72864
Update Win32 capnp builds to v0.6
author | Chris Cannam |
---|---|
date | Tue, 23 May 2017 09:16:54 +0100 |
parents | 37d53a7e8262 |
children |
comparison
equal
deleted
inserted
replaced
63:0f2d93caa50c | 64:eccd51b72864 |
---|---|
30 #error "RPC APIs, including this header, are not available in lite mode." | 30 #error "RPC APIs, including this header, are not available in lite mode." |
31 #endif | 31 #endif |
32 | 32 |
33 #include <kj/async.h> | 33 #include <kj/async.h> |
34 #include <kj/vector.h> | 34 #include <kj/vector.h> |
35 #include "raw-schema.h" | |
35 #include "any.h" | 36 #include "any.h" |
36 #include "pointer-helpers.h" | 37 #include "pointer-helpers.h" |
37 | 38 |
38 namespace capnp { | 39 namespace capnp { |
39 | 40 |
62 RemotePromise& operator=(RemotePromise&& other) = default; | 63 RemotePromise& operator=(RemotePromise&& other) = default; |
63 }; | 64 }; |
64 | 65 |
65 class LocalClient; | 66 class LocalClient; |
66 namespace _ { // private | 67 namespace _ { // private |
67 struct RawSchema; | |
68 struct RawBrandedSchema; | |
69 extern const RawSchema NULL_INTERFACE_SCHEMA; // defined in schema.c++ | 68 extern const RawSchema NULL_INTERFACE_SCHEMA; // defined in schema.c++ |
70 class CapabilityServerSetBase; | 69 class CapabilityServerSetBase; |
71 } // namespace _ (private) | 70 } // namespace _ (private) |
72 | 71 |
73 struct Capability { | 72 struct Capability { |
81 struct IsInterface; | 80 struct IsInterface; |
82 static constexpr uint64_t typeId = 0x3; | 81 static constexpr uint64_t typeId = 0x3; |
83 static constexpr Kind kind = Kind::INTERFACE; | 82 static constexpr Kind kind = Kind::INTERFACE; |
84 static constexpr _::RawSchema const* schema = &_::NULL_INTERFACE_SCHEMA; | 83 static constexpr _::RawSchema const* schema = &_::NULL_INTERFACE_SCHEMA; |
85 | 84 |
86 static const _::RawBrandedSchema* const brand; | 85 static const _::RawBrandedSchema* brand() { |
87 // Can't quite declare this one inline without including generated-header-support.h. Avoiding | 86 return &_::NULL_INTERFACE_SCHEMA.defaultBrand; |
88 // for now by declaring out-of-line. | 87 } |
89 // TODO(cleanup): Split RawSchema stuff into its own header that can be included here, or | |
90 // something. | |
91 }; | 88 }; |
92 }; | 89 }; |
93 | 90 |
94 // ======================================================================================= | 91 // ======================================================================================= |
95 // Capability clients | 92 // Capability clients |
651 typedef List<T> Reads; | 648 typedef List<T> Reads; |
652 | 649 |
653 Reader() = default; | 650 Reader() = default; |
654 inline explicit Reader(_::ListReader reader): reader(reader) {} | 651 inline explicit Reader(_::ListReader reader): reader(reader) {} |
655 | 652 |
656 inline uint size() const { return reader.size() / ELEMENTS; } | 653 inline uint size() const { return unbound(reader.size() / ELEMENTS); } |
657 inline typename T::Client operator[](uint index) const { | 654 inline typename T::Client operator[](uint index) const { |
658 KJ_IREQUIRE(index < size()); | 655 KJ_IREQUIRE(index < size()); |
659 return typename T::Client(reader.getPointerElement(index * ELEMENTS).getCapability()); | 656 return typename T::Client(reader.getPointerElement( |
657 bounded(index) * ELEMENTS).getCapability()); | |
660 } | 658 } |
661 | 659 |
662 typedef _::IndexingIterator<const Reader, typename T::Client> Iterator; | 660 typedef _::IndexingIterator<const Reader, typename T::Client> Iterator; |
663 inline Iterator begin() const { return Iterator(this, 0); } | 661 inline Iterator begin() const { return Iterator(this, 0); } |
664 inline Iterator end() const { return Iterator(this, size()); } | 662 inline Iterator end() const { return Iterator(this, size()); } |
683 inline explicit Builder(_::ListBuilder builder): builder(builder) {} | 681 inline explicit Builder(_::ListBuilder builder): builder(builder) {} |
684 | 682 |
685 inline operator Reader() const { return Reader(builder.asReader()); } | 683 inline operator Reader() const { return Reader(builder.asReader()); } |
686 inline Reader asReader() const { return Reader(builder.asReader()); } | 684 inline Reader asReader() const { return Reader(builder.asReader()); } |
687 | 685 |
688 inline uint size() const { return builder.size() / ELEMENTS; } | 686 inline uint size() const { return unbound(builder.size() / ELEMENTS); } |
689 inline typename T::Client operator[](uint index) { | 687 inline typename T::Client operator[](uint index) { |
690 KJ_IREQUIRE(index < size()); | 688 KJ_IREQUIRE(index < size()); |
691 return typename T::Client(builder.getPointerElement(index * ELEMENTS).getCapability()); | 689 return typename T::Client(builder.getPointerElement( |
690 bounded(index) * ELEMENTS).getCapability()); | |
692 } | 691 } |
693 inline void set(uint index, typename T::Client value) { | 692 inline void set(uint index, typename T::Client value) { |
694 KJ_IREQUIRE(index < size()); | 693 KJ_IREQUIRE(index < size()); |
695 builder.getPointerElement(index * ELEMENTS).setCapability(kj::mv(value.hook)); | 694 builder.getPointerElement(bounded(index) * ELEMENTS).setCapability(kj::mv(value.hook)); |
696 } | 695 } |
697 inline void adopt(uint index, Orphan<T>&& value) { | 696 inline void adopt(uint index, Orphan<T>&& value) { |
698 KJ_IREQUIRE(index < size()); | 697 KJ_IREQUIRE(index < size()); |
699 builder.getPointerElement(index * ELEMENTS).adopt(kj::mv(value)); | 698 builder.getPointerElement(bounded(index) * ELEMENTS).adopt(kj::mv(value)); |
700 } | 699 } |
701 inline Orphan<T> disown(uint index) { | 700 inline Orphan<T> disown(uint index) { |
702 KJ_IREQUIRE(index < size()); | 701 KJ_IREQUIRE(index < size()); |
703 return Orphan<T>(builder.getPointerElement(index * ELEMENTS).disown()); | 702 return Orphan<T>(builder.getPointerElement(bounded(index) * ELEMENTS).disown()); |
704 } | 703 } |
705 | 704 |
706 typedef _::IndexingIterator<Builder, typename T::Client> Iterator; | 705 typedef _::IndexingIterator<Builder, typename T::Client> Iterator; |
707 inline Iterator begin() { return Iterator(this, 0); } | 706 inline Iterator begin() { return Iterator(this, 0); } |
708 inline Iterator end() { return Iterator(this, size()); } | 707 inline Iterator end() { return Iterator(this, size()); } |
714 friend struct ToDynamic_; | 713 friend struct ToDynamic_; |
715 }; | 714 }; |
716 | 715 |
717 private: | 716 private: |
718 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { | 717 inline static _::ListBuilder initPointer(_::PointerBuilder builder, uint size) { |
719 return builder.initList(ElementSize::POINTER, size * ELEMENTS); | 718 return builder.initList(ElementSize::POINTER, bounded(size) * ELEMENTS); |
720 } | 719 } |
721 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { | 720 inline static _::ListBuilder getFromPointer(_::PointerBuilder builder, const word* defaultValue) { |
722 return builder.getList(ElementSize::POINTER, defaultValue); | 721 return builder.getList(ElementSize::POINTER, defaultValue); |
723 } | 722 } |
724 inline static _::ListReader getFromPointer( | 723 inline static _::ListReader getFromPointer( |