Commit de9f323e authored by Kenton Varda's avatar Kenton Varda

Fix Orphan<AnyStruct>.

parent cb17739b
...@@ -447,6 +447,8 @@ struct List<AnyPointer, Kind::OTHER> { ...@@ -447,6 +447,8 @@ struct List<AnyPointer, Kind::OTHER> {
class AnyStruct::Reader { class AnyStruct::Reader {
public: public:
typedef AnyStruct Reads;
Reader() = default; Reader() = default;
inline Reader(_::StructReader reader): _reader(reader) {} inline Reader(_::StructReader reader): _reader(reader) {}
...@@ -479,10 +481,13 @@ private: ...@@ -479,10 +481,13 @@ private:
template <typename, Kind> template <typename, Kind>
friend struct _::PointerHelpers; friend struct _::PointerHelpers;
friend class Orphanage;
}; };
class AnyStruct::Builder { class AnyStruct::Builder {
public: public:
typedef AnyStruct Builds;
inline Builder(decltype(nullptr)) {} inline Builder(decltype(nullptr)) {}
inline Builder(_::StructBuilder builder): _builder(builder) {} inline Builder(_::StructBuilder builder): _builder(builder) {}
...@@ -604,6 +609,8 @@ private: ...@@ -604,6 +609,8 @@ private:
class AnyList::Reader { class AnyList::Reader {
public: public:
typedef AnyList Reads;
inline Reader(): _reader(ElementSize::VOID) {} inline Reader(): _reader(ElementSize::VOID) {}
inline Reader(_::ListReader reader): _reader(reader) {} inline Reader(_::ListReader reader): _reader(reader) {}
...@@ -633,10 +640,13 @@ private: ...@@ -633,10 +640,13 @@ private:
template <typename, Kind> template <typename, Kind>
friend struct _::PointerHelpers; friend struct _::PointerHelpers;
friend class Orphanage;
}; };
class AnyList::Builder { class AnyList::Builder {
public: public:
typedef AnyList Builds;
inline Builder(decltype(nullptr)): _builder(ElementSize::VOID) {} inline Builder(decltype(nullptr)): _builder(ElementSize::VOID) {}
inline Builder(_::ListBuilder builder): _builder(builder) {} inline Builder(_::ListBuilder builder): _builder(builder) {}
...@@ -667,6 +677,8 @@ public: ...@@ -667,6 +677,8 @@ public:
private: private:
_::ListBuilder _builder; _::ListBuilder _builder;
friend class Orphanage;
}; };
// ======================================================================================= // =======================================================================================
...@@ -820,6 +832,34 @@ struct Orphanage::GetInnerBuilder<AnyPointer, Kind::OTHER> { ...@@ -820,6 +832,34 @@ struct Orphanage::GetInnerBuilder<AnyPointer, Kind::OTHER> {
} }
}; };
template <>
struct Orphanage::GetInnerReader<AnyStruct, Kind::OTHER> {
static inline _::StructReader apply(const AnyStruct::Reader& t) {
return t._reader;
}
};
template <>
struct Orphanage::GetInnerBuilder<AnyStruct, Kind::OTHER> {
static inline _::StructBuilder apply(AnyStruct::Builder& t) {
return t._builder;
}
};
template <>
struct Orphanage::GetInnerReader<AnyList, Kind::OTHER> {
static inline _::ListReader apply(const AnyList::Reader& t) {
return t._reader;
}
};
template <>
struct Orphanage::GetInnerBuilder<AnyList, Kind::OTHER> {
static inline _::ListBuilder apply(AnyList::Builder& t) {
return t._builder;
}
};
template <typename T> template <typename T>
inline BuilderFor<T> Orphan<AnyPointer>::getAs() { inline BuilderFor<T> Orphan<AnyPointer>::getAs() {
return _::OrphanGetImpl<T>::apply(builder); return _::OrphanGetImpl<T>::apply(builder);
...@@ -952,6 +992,19 @@ struct PointerHelpers<AnyList, Kind::OTHER> { ...@@ -952,6 +992,19 @@ struct PointerHelpers<AnyList, Kind::OTHER> {
static Orphan<AnyList> disown(PointerBuilder builder); static Orphan<AnyList> disown(PointerBuilder builder);
}; };
template <>
struct OrphanGetImpl<AnyStruct, Kind::OTHER> {
static inline AnyStruct::Builder apply(_::OrphanBuilder& builder) {
return AnyStruct::Builder(builder.asStruct(_::StructSize(0 * WORDS, 0 * POINTERS)));
}
static inline AnyStruct::Reader applyReader(const _::OrphanBuilder& builder) {
return AnyStruct::Reader(builder.asStructReader(_::StructSize(0 * WORDS, 0 * POINTERS)));
}
static inline void truncateListOf(_::OrphanBuilder& builder, ElementCount size) {
builder.truncate(size, _::StructSize(0 * WORDS, 0 * POINTERS));
}
};
} // namespace _ (private) } // namespace _ (private)
#if !CAPNP_LITE #if !CAPNP_LITE
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment