Commit 1a515be7 authored by Kenton Varda's avatar Kenton Varda

Simplify generated code by using PointerHelpers templates.

parent e4784bc8
......@@ -36,12 +36,19 @@ class DynamicStruct; // So that it can be declared a friend.
namespace internal {
template <typename T>
struct PointerHelpers {
static inline typename T::Reader get(StructReader reader, WireReferenceCount index) {
return typename T::Reader(reader.getStructField(index, nullptr));
struct PointerHelpers<T, Kind::STRUCT> {
static inline typename T::Reader get(StructReader reader, WireReferenceCount index,
const word* defaultValue = nullptr) {
return typename T::Reader(reader.getStructField(index, defaultValue));
}
static inline typename T::Builder get(StructBuilder builder, WireReferenceCount index) {
return typename T::Builder(builder.getStructField(index, structSize<T>(), nullptr));
static inline typename T::Builder get(StructBuilder builder, WireReferenceCount index,
const word* defaultValue = nullptr) {
return typename T::Builder(builder.getStructField(index, structSize<T>(), defaultValue));
}
static inline void set(StructBuilder builder, WireReferenceCount index,
typename T::Reader value) {
// TODO(soon)
CAPNPROTO_INLINE_PRECOND(false, "Not implemented: set() for struct fields.");
}
static inline typename T::Builder init(StructBuilder builder, WireReferenceCount index) {
return typename T::Builder(builder.initStructField(index, structSize<T>()));
......@@ -49,48 +56,46 @@ struct PointerHelpers {
};
template <typename T>
struct PointerHelpers<List<T>> {
static inline typename List<T>::Reader get(StructReader reader, WireReferenceCount index) {
return typename List<T>::Reader(List<T>::getAsFieldOf(reader, index));
}
static inline typename List<T>::Builder get(StructBuilder builder, WireReferenceCount index) {
return typename List<T>::Builder(List<T>::getAsFieldOf(builder, index));
}
static inline typename List<T>::Builder init(
StructBuilder builder, WireReferenceCount index, int size) {
return typename List<T>::Builder(List<T>::initAsFieldOf(builder, index, size));
struct PointerHelpers<List<T>, Kind::LIST> {
static inline typename List<T>::Reader get(StructReader reader, WireReferenceCount index,
const word* defaultValue = nullptr) {
return typename List<T>::Reader(List<T>::getAsFieldOf(reader, index, defaultValue));
}
};
template <>
struct PointerHelpers<Text> {
static inline Text::Reader get(StructReader reader, WireReferenceCount index) {
return reader.getBlobField<Text>(index, nullptr, 0 * BYTES);
static inline typename List<T>::Builder get(StructBuilder builder, WireReferenceCount index,
const word* defaultValue = nullptr) {
return typename List<T>::Builder(List<T>::getAsFieldOf(builder, index, defaultValue));
}
static inline Text::Builder get(StructBuilder builder, WireReferenceCount index) {
return builder.getBlobField<Text>(index, nullptr, 0 * BYTES);
static inline void set(StructBuilder builder, WireReferenceCount index,
typename List<T>::Reader value) {
init(builder, index, value.size()).copyFrom(value);
}
static inline void set(StructBuilder builder, WireReferenceCount index, Text::Reader value) {
builder.setBlobField<Text>(index, value);
static inline void set(StructBuilder builder, WireReferenceCount index,
std::initializer_list<ReaderFor<T>> value) {
init(builder, index, value.size()).copyFrom(value);
}
static inline Text::Builder init(StructBuilder builder, WireReferenceCount index, int size) {
return builder.initBlobField<Text>(index, size * BYTES);
static inline typename List<T>::Builder init(
StructBuilder builder, WireReferenceCount index, uint size) {
return typename List<T>::Builder(List<T>::initAsFieldOf(builder, index, size));
}
};
template <>
struct PointerHelpers<Data> {
static inline Data::Reader get(StructReader reader, WireReferenceCount index) {
return reader.getBlobField<Data>(index, nullptr, 0 * BYTES);
template <typename T>
struct PointerHelpers<T, Kind::BLOB> {
static inline typename T::Reader get(StructReader reader, WireReferenceCount index,
const void* defaultValue = nullptr,
uint defaultBytes = 0) {
return reader.getBlobField<T>(index, defaultValue, defaultBytes * BYTES);
}
static inline Data::Builder get(StructBuilder builder, WireReferenceCount index) {
return builder.getBlobField<Data>(index, nullptr, 0 * BYTES);
static inline typename T::Builder get(StructBuilder builder, WireReferenceCount index,
const void* defaultValue = nullptr,
uint defaultBytes = 0) {
return builder.getBlobField<T>(index, defaultValue, defaultBytes * BYTES);
}
static inline void set(StructBuilder builder, WireReferenceCount index, Data::Reader value) {
builder.setBlobField<Data>(index, value);
static inline void set(StructBuilder builder, WireReferenceCount index, typename T::Reader value) {
builder.setBlobField<T>(index, value);
}
static inline Data::Builder init(StructBuilder builder, WireReferenceCount index, int size) {
return builder.initBlobField<Data>(index, size * BYTES);
static inline typename T::Builder init(StructBuilder builder, WireReferenceCount index, uint size) {
return builder.initBlobField<T>(index, size * BYTES);
}
};
......
......@@ -486,7 +486,7 @@ public:
: segment(nullptr), ptr(nullptr), elementCount(0 * ELEMENTS),
step(0 * BITS / ELEMENTS) {}
inline ElementCount size();
inline ElementCount size() const;
// The number of elements in the list.
Text::Builder asText();
......@@ -570,7 +570,7 @@ public:
: segment(nullptr), ptr(nullptr), elementCount(0), step(0 * BITS / ELEMENTS),
structDataSize(0), structReferenceCount(0), nestingLimit(0) {}
inline ElementCount size();
inline ElementCount size() const;
// The number of elements in the list.
Text::Reader asText();
......@@ -767,7 +767,7 @@ T StructReader::getDataField(ElementCount offset, Mask<T> mask) const {
// -------------------------------------------------------------------
inline ElementCount ListBuilder::size() { return elementCount; }
inline ElementCount ListBuilder::size() const { return elementCount; }
template <typename T>
inline T ListBuilder::getDataElement(ElementCount index) const {
......@@ -814,7 +814,7 @@ inline void ListBuilder::setDataElement<Void>(ElementCount index, Void value) co
// -------------------------------------------------------------------
inline ElementCount ListReader::size() { return elementCount; }
inline ElementCount ListReader::size() const { return elementCount; }
template <typename T>
inline T ListReader::getDataElement(ElementCount index) const {
......
......@@ -40,8 +40,13 @@ struct MaybeReaderBuilder<T, Kind::PRIMITIVE> {
typedef T Reader;
typedef T Builder;
};
template <typename T>
struct MaybeReaderBuilder<T, Kind::ENUM> {
typedef T Reader;
typedef T Builder;
};
template <typename t>
template <typename T, Kind k = kind<T>()>
struct PointerHelpers;
} // namespace internal
......@@ -148,11 +153,12 @@ public:
inline bool operator> (const IndexingIterator& other) const { return index > other.index; }
private:
Container* container;
const Container* container;
uint index;
friend Container;
inline IndexingIterator(Container* container, uint index): container(container), index(index) {}
inline IndexingIterator(const Container* container, uint index)
: container(container), index(index) {}
};
} // namespace internal
......@@ -166,12 +172,14 @@ struct List<T, Kind::PRIMITIVE> {
Reader() = default;
inline explicit Reader(internal::ListReader reader): reader(reader) {}
inline uint size() { return reader.size() / ELEMENTS; }
inline T operator[](uint index) { return reader.template getDataElement<T>(index * ELEMENTS); }
inline uint size() const { return reader.size() / ELEMENTS; }
inline T operator[](uint index) const {
return reader.template getDataElement<T>(index * ELEMENTS);
}
typedef internal::IndexingIterator<Reader, T> iterator;
inline iterator begin() { return iterator(this, 0); }
inline iterator end() { return iterator(this, size()); }
inline iterator begin() const { return iterator(this, 0); }
inline iterator end() const { return iterator(this, size()); }
private:
internal::ListReader reader;
......@@ -182,8 +190,8 @@ struct List<T, Kind::PRIMITIVE> {
Builder() = default;
inline explicit Builder(internal::ListBuilder builder): builder(builder) {}
inline uint size() { return builder.size() / ELEMENTS; }
inline T operator[](uint index) {
inline uint size() const { return builder.size() / ELEMENTS; }
inline T operator[](uint index) const {
return builder.template getDataElement<T>(index * ELEMENTS);
}
inline void set(uint index, T value) {
......@@ -197,8 +205,8 @@ struct List<T, Kind::PRIMITIVE> {
}
typedef internal::IndexingIterator<Builder, T> iterator;
inline iterator begin() { return iterator(this, 0); }
inline iterator end() { return iterator(this, size()); }
inline iterator begin() const { return iterator(this, 0); }
inline iterator end() const { return iterator(this, size()); }
template <typename Other>
void copyFrom(const Other& other) {
......@@ -225,16 +233,16 @@ struct List<T, Kind::PRIMITIVE> {
private:
inline static internal::ListBuilder initAsElementOf(
internal::ListBuilder& builder, uint index, uint size) {
const internal::ListBuilder& builder, uint index, uint size) {
return builder.initListElement(
index * ELEMENTS, internal::FieldSizeForType<T>::value, size * ELEMENTS);
}
inline static internal::ListBuilder getAsElementOf(
internal::ListBuilder& builder, uint index) {
const internal::ListBuilder& builder, uint index) {
return builder.getListElement(index * ELEMENTS);
}
inline static internal::ListReader getAsElementOf(
internal::ListReader& reader, uint index) {
const internal::ListReader& reader, uint index) {
return reader.getListElement(index * ELEMENTS, internal::FieldSizeForType<T>::value);
}
......@@ -243,17 +251,17 @@ private:
return builder.initListField(index, internal::FieldSizeForType<T>::value, size * ELEMENTS);
}
inline static internal::ListBuilder getAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index) {
return builder.getListField(index, nullptr);
internal::StructBuilder& builder, WireReferenceCount index, const word* defaultValue) {
return builder.getListField(index, defaultValue);
}
inline static internal::ListReader getAsFieldOf(
internal::StructReader& reader, WireReferenceCount index) {
return reader.getListField(index, internal::FieldSizeForType<T>::value, nullptr);
internal::StructReader& reader, WireReferenceCount index, const word* defaultValue) {
return reader.getListField(index, internal::FieldSizeForType<T>::value, defaultValue);
}
template <typename U, Kind k>
friend class List;
template <typename U>
template <typename U, Kind K>
friend struct internal::PointerHelpers;
};
......@@ -269,14 +277,14 @@ struct List<T, Kind::STRUCT> {
Reader() = default;
inline explicit Reader(internal::ListReader reader): reader(reader) {}
inline uint size() { return reader.size() / ELEMENTS; }
inline typename T::Reader operator[](uint index) {
inline uint size() const { return reader.size() / ELEMENTS; }
inline typename T::Reader operator[](uint index) const {
return typename T::Reader(reader.getStructElement(index * ELEMENTS));
}
typedef internal::IndexingIterator<Reader, typename T::Reader> iterator;
inline iterator begin() { return iterator(this, 0); }
inline iterator end() { return iterator(this, size()); }
inline iterator begin() const { return iterator(this, 0); }
inline iterator end() const { return iterator(this, size()); }
private:
internal::ListReader reader;
......@@ -287,15 +295,15 @@ struct List<T, Kind::STRUCT> {
Builder() = default;
inline explicit Builder(internal::ListBuilder builder): builder(builder) {}
inline uint size() { return builder.size() / ELEMENTS; }
inline typename T::Builder operator[](uint index) {
inline uint size() const { return builder.size() / ELEMENTS; }
inline typename T::Builder operator[](uint index) const {
return typename T::Builder(builder.getStructElement(
index * ELEMENTS, internal::structSize<T>()));
}
typedef internal::IndexingIterator<Builder, typename T::Builder> iterator;
inline iterator begin() { return iterator(this, 0); }
inline iterator end() { return iterator(this, size()); }
inline iterator begin() const { return iterator(this, 0); }
inline iterator end() const { return iterator(this, size()); }
template <typename Other>
void copyFrom(const Other& other);
......@@ -308,16 +316,16 @@ struct List<T, Kind::STRUCT> {
private:
inline static internal::ListBuilder initAsElementOf(
internal::ListBuilder& builder, uint index, uint size) {
const internal::ListBuilder& builder, uint index, uint size) {
return builder.initStructListElement(
index * ELEMENTS, size * ELEMENTS, internal::structSize<T>());
}
inline static internal::ListBuilder getAsElementOf(
internal::ListBuilder& builder, uint index) {
const internal::ListBuilder& builder, uint index) {
return builder.getListElement(index * ELEMENTS);
}
inline static internal::ListReader getAsElementOf(
internal::ListReader& reader, uint index) {
const internal::ListReader& reader, uint index) {
return reader.getListElement(index * ELEMENTS, internal::FieldSize::INLINE_COMPOSITE);
}
......@@ -326,17 +334,17 @@ private:
return builder.initStructListField(index, size * ELEMENTS, internal::structSize<T>());
}
inline static internal::ListBuilder getAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index) {
return builder.getListField(index, nullptr);
internal::StructBuilder& builder, WireReferenceCount index, const word* defaultValue) {
return builder.getListField(index, defaultValue);
}
inline static internal::ListReader getAsFieldOf(
internal::StructReader& reader, WireReferenceCount index) {
return reader.getListField(index, internal::FieldSize::INLINE_COMPOSITE, nullptr);
internal::StructReader& reader, WireReferenceCount index, const word* defaultValue) {
return reader.getListField(index, internal::FieldSize::INLINE_COMPOSITE, defaultValue);
}
template <typename U, Kind k>
friend class List;
template <typename U>
template <typename U, Kind K>
friend struct internal::PointerHelpers;
};
......@@ -349,14 +357,14 @@ struct List<List<T>, Kind::LIST> {
Reader() = default;
inline explicit Reader(internal::ListReader reader): reader(reader) {}
inline uint size() { return reader.size() / ELEMENTS; }
inline typename List<T>::Reader operator[](uint index) {
inline uint size() const { return reader.size() / ELEMENTS; }
inline typename List<T>::Reader operator[](uint index) const {
return typename List<T>::Reader(List<T>::getAsElementOf(reader, index));
}
typedef internal::IndexingIterator<Reader, typename List<T>::Reader> iterator;
inline iterator begin() { return iterator(this, 0); }
inline iterator end() { return iterator(this, size()); }
inline iterator begin() const { return iterator(this, 0); }
inline iterator end() const { return iterator(this, size()); }
private:
internal::ListReader reader;
......@@ -367,8 +375,8 @@ struct List<List<T>, Kind::LIST> {
Builder() = default;
inline explicit Builder(internal::ListBuilder builder): builder(builder) {}
inline uint size() { return builder.size() / ELEMENTS; }
inline typename List<T>::Builder operator[](uint index) {
inline uint size() const { return builder.size() / ELEMENTS; }
inline typename List<T>::Builder operator[](uint index) const {
return typename List<T>::Builder(List<T>::getAsElementOf(builder, index));
}
inline typename List<T>::Builder init(uint index, uint size) {
......@@ -376,8 +384,8 @@ struct List<List<T>, Kind::LIST> {
}
typedef internal::IndexingIterator<Builder, typename List<T>::Builder> iterator;
inline iterator begin() { return iterator(this, 0); }
inline iterator end() { return iterator(this, size()); }
inline iterator begin() const { return iterator(this, 0); }
inline iterator end() const { return iterator(this, size()); }
template <typename Other>
void copyFrom(const Other& other);
......@@ -390,16 +398,16 @@ struct List<List<T>, Kind::LIST> {
private:
inline static internal::ListBuilder initAsElementOf(
internal::ListBuilder& builder, uint index, uint size) {
const internal::ListBuilder& builder, uint index, uint size) {
return builder.initListElement(
index * ELEMENTS, internal::FieldSize::REFERENCE, size * ELEMENTS);
}
inline static internal::ListBuilder getAsElementOf(
internal::ListBuilder& builder, uint index) {
const internal::ListBuilder& builder, uint index) {
return builder.getListElement(index * ELEMENTS);
}
inline static internal::ListReader getAsElementOf(
internal::ListReader& reader, uint index) {
const internal::ListReader& reader, uint index) {
return reader.getListElement(index * ELEMENTS, internal::FieldSize::REFERENCE);
}
......@@ -408,17 +416,17 @@ private:
return builder.initListField(index, internal::FieldSize::REFERENCE, size * ELEMENTS);
}
inline static internal::ListBuilder getAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index) {
return builder.getListField(index, nullptr);
internal::StructBuilder& builder, WireReferenceCount index, const word* defaultValue) {
return builder.getListField(index, defaultValue);
}
inline static internal::ListReader getAsFieldOf(
internal::StructReader& reader, WireReferenceCount index) {
return reader.getListField(index, internal::FieldSize::REFERENCE, nullptr);
internal::StructReader& reader, WireReferenceCount index, const word* defaultValue) {
return reader.getListField(index, internal::FieldSize::REFERENCE, defaultValue);
}
template <typename U, Kind k>
friend class List;
template <typename U>
template <typename U, Kind K>
friend struct internal::PointerHelpers;
};
......@@ -429,14 +437,14 @@ struct List<T, Kind::BLOB> {
Reader() = default;
inline explicit Reader(internal::ListReader reader): reader(reader) {}
inline uint size() { return reader.size() / ELEMENTS; }
inline typename T::Reader operator[](uint index) {
inline uint size() const { return reader.size() / ELEMENTS; }
inline typename T::Reader operator[](uint index) const {
return reader.getBlobElement<T>(index * ELEMENTS);
}
typedef internal::IndexingIterator<Reader, typename T::Reader> iterator;
inline iterator begin() { return iterator(this, 0); }
inline iterator end() { return iterator(this, size()); }
inline iterator begin() const { return iterator(this, 0); }
inline iterator end() const { return iterator(this, size()); }
private:
internal::ListReader reader;
......@@ -447,8 +455,8 @@ struct List<T, Kind::BLOB> {
Builder() = default;
inline explicit Builder(internal::ListBuilder builder): builder(builder) {}
inline uint size() { return builder.size() / ELEMENTS; }
inline typename T::Builder operator[](uint index) {
inline uint size() const { return builder.size() / ELEMENTS; }
inline typename T::Builder operator[](uint index) const {
return builder.getBlobElement<T>(index * ELEMENTS);
}
inline void set(uint index, typename T::Reader value) {
......@@ -459,8 +467,8 @@ struct List<T, Kind::BLOB> {
}
typedef internal::IndexingIterator<Builder, typename T::Builder> iterator;
inline iterator begin() { return iterator(this, 0); }
inline iterator end() { return iterator(this, size()); }
inline iterator begin() const { return iterator(this, 0); }
inline iterator end() const { return iterator(this, size()); }
template <typename Other>
void copyFrom(const Other& other) {
......@@ -487,16 +495,16 @@ struct List<T, Kind::BLOB> {
private:
inline static internal::ListBuilder initAsElementOf(
internal::ListBuilder& builder, uint index, uint size) {
const internal::ListBuilder& builder, uint index, uint size) {
return builder.initListElement(
index * ELEMENTS, internal::FieldSize::REFERENCE, size * ELEMENTS);
}
inline static internal::ListBuilder getAsElementOf(
internal::ListBuilder& builder, uint index) {
const internal::ListBuilder& builder, uint index) {
return builder.getListElement(index * ELEMENTS);
}
inline static internal::ListReader getAsElementOf(
internal::ListReader& reader, uint index) {
const internal::ListReader& reader, uint index) {
return reader.getListElement(index * ELEMENTS, internal::FieldSize::REFERENCE);
}
......@@ -505,17 +513,17 @@ private:
return builder.initListField(index, internal::FieldSize::REFERENCE, size * ELEMENTS);
}
inline static internal::ListBuilder getAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index) {
return builder.getListField(index, nullptr);
internal::StructBuilder& builder, WireReferenceCount index, const word* defaultValue) {
return builder.getListField(index, defaultValue);
}
inline static internal::ListReader getAsFieldOf(
internal::StructReader& reader, WireReferenceCount index) {
return reader.getListField(index, internal::FieldSize::REFERENCE, nullptr);
internal::StructReader& reader, WireReferenceCount index, const word* defaultValue) {
return reader.getListField(index, internal::FieldSize::REFERENCE, defaultValue);
}
template <typename U, Kind k>
friend class List;
template <typename U>
template <typename U, Kind K>
friend struct internal::PointerHelpers;
};
......
......@@ -287,6 +287,9 @@ fieldContext parent desc = mkStrContext context where
context "fieldTitleCase" = MuVariable $ toTitleCase $ fieldName desc
context "fieldUpperCase" = MuVariable $ toUpperCaseWithUnderscores $ fieldName desc
context "fieldIsPrimitive" = MuBool $ isPrimitive $ fieldType desc
context "fieldIsListOrBlob" = MuBool $ isBlob (fieldType desc) || isList (fieldType desc)
context "fieldIsBlob" = MuBool $ isBlob $ fieldType desc
context "fieldIsInlineBlob" = MuBool $ isInlineBlob $ fieldType desc
context "fieldIsStruct" = MuBool $ isStruct $ fieldType desc
......@@ -332,6 +335,11 @@ fieldContext parent desc = mkStrContext context where
MuVariable $ cxxFieldSizeString $ fieldSize $ inlineElementType $ fieldType desc
context "fieldElementType" =
MuVariable $ cxxTypeString $ elementType $ fieldType desc
context "fieldElementReaderType" = MuVariable readerString where
readerString = if isPrimitiveList $ fieldType desc
then tString
else tString ++ "::Reader"
tString = cxxTypeString $ elementType $ fieldType desc
context "fieldInlineElementType" =
MuVariable $ cxxTypeString $ inlineElementType $ fieldType desc
context "fieldUnion" = case fieldUnion desc of
......
......@@ -148,15 +148,11 @@ public:
{{#fieldIsPrimitive}}
inline {{fieldType}} get{{fieldTitleCase}}();
{{/fieldIsPrimitive}}
{{#fieldIsBlob}}
{{^fieldIsPrimitive}}
{{^fieldIsGenericObject}}
inline {{fieldType}}::Reader get{{fieldTitleCase}}();
{{/fieldIsBlob}}
{{#fieldIsStruct}}
inline {{fieldType}}::Reader get{{fieldTitleCase}}();
{{/fieldIsStruct}}
{{#fieldIsList}}
inline {{fieldType}}::Reader get{{fieldTitleCase}}();
{{/fieldIsList}}
{{/fieldIsGenericObject}}
{{/fieldIsPrimitive}}
{{#fieldIsGenericObject}}
template <typename T> inline typename T::Reader get{{fieldTitleCase}}();
{{/fieldIsGenericObject}}
......@@ -190,35 +186,25 @@ public:
inline {{fieldType}} get{{fieldTitleCase}}();
inline void set{{fieldTitleCase}}({{fieldType}} value);
{{/fieldIsPrimitive}}
{{#fieldIsBlob}}
{{^fieldIsPrimitive}}
{{^fieldIsGenericObject}}
inline {{fieldType}}::Builder get{{fieldTitleCase}}();
inline void set{{fieldTitleCase}}({{fieldType}}::Reader value);
inline {{fieldType}}::Builder init{{fieldTitleCase}}({{^fieldIsInlineBlob}}unsigned int size{{/fieldIsInlineBlob}});
{{/fieldIsBlob}}
inline void set{{fieldTitleCase}}({{fieldType}}::Reader other);
{{#fieldIsList}}
inline void set{{fieldTitleCase}}(
std::initializer_list<{{fieldElementReaderType}}> other);
{{/fieldIsList}}
{{#fieldIsListOrBlob}}
inline {{fieldType}}::Builder init{{fieldTitleCase}}(unsigned int size);
{{/fieldIsListOrBlob}}
{{#fieldIsStruct}}
inline {{fieldType}}::Builder init{{fieldTitleCase}}();
inline {{fieldType}}::Builder get{{fieldTitleCase}}();
{{/fieldIsStruct}}
{{#fieldIsList}}
{{#fieldIsInlineList}}
inline {{fieldType}}::Builder init{{fieldTitleCase}}();
{{/fieldIsInlineList}}
{{^fieldIsInlineList}}
inline {{fieldType}}::Builder init{{fieldTitleCase}}(unsigned int size);
{{/fieldIsInlineList}}
inline {{fieldType}}::Builder get{{fieldTitleCase}}();
template <typename _t>
inline void set{{fieldTitleCase}}(const _t& other);
{{#fieldIsPrimitiveList}}
inline void set{{fieldTitleCase}}(std::initializer_list<{{fieldElementType}}> other);
{{/fieldIsPrimitiveList}}
{{^fieldIsPrimitiveList}}
inline void set{{fieldTitleCase}}(std::initializer_list<{{fieldElementType}}::Reader> other);
{{/fieldIsPrimitiveList}}
{{/fieldIsList}}
{{/fieldIsGenericObject}}
{{/fieldIsPrimitive}}
{{#fieldIsGenericObject}}
template <typename T> inline typename T::Builder get{{fieldTitleCase}}();
template <typename T> inline void set{{fieldTitleCase}}(const typename T::Reader& value);
template <typename T> inline void set{{fieldTitleCase}}(typename T::Reader value);
template <typename T> inline typename T::Builder init{{fieldTitleCase}}();
template <typename T> inline typename T::Builder init{{fieldTitleCase}}(unsigned int size);
{{/fieldIsGenericObject}}
......@@ -282,21 +268,21 @@ inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}({{fieldType}} value
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return _builder.setDataField<{{fieldType}}>(
_builder.setDataField<{{fieldType}}>(
{{fieldOffset}} * ::capnproto::ELEMENTS, value{{fieldDefaultMask}});
}
{{/fieldIsPrimitive}}
{{! ------------------------------------------------------------------------------------------- }}
{{#fieldIsBlob}}
{{#fieldIsInlineBlob}}
{{^fieldIsGenericObject}}
{{^fieldIsPrimitive}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return _reader.getInlineBlobField<{{fieldType}}>(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlineListSize}} * ::capnproto::BYTES);
return ::capnproto::internal::PointerHelpers<{{fieldType}}>::get(
_reader, {{fieldOffset}} * ::capnproto::REFERENCES{{#fieldDefaultBytes}},
DEFAULT_{{fieldUpperCase}}.words{{#fieldIsBlob}}, {{defaultBlobSize}}{{/fieldIsBlob}}{{/fieldDefaultBytes}});
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
......@@ -304,400 +290,104 @@ inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}()
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return _builder.getInlineBlobField<{{fieldType}}>(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlineListSize}} * ::capnproto::BYTES);
}
inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}({{fieldType}}::Reader value) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
_builder.setInlineBlobField<{{fieldType}}>(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlineListSize}} * ::capnproto::BYTES,
value);
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}() {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return _builder.initInlineBlobField<{{fieldType}}>(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlineListSize}} * ::capnproto::BYTES);
}
{{/fieldIsInlineBlob}}
{{^fieldIsInlineBlob}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return _reader.getBlobField<{{fieldType}}>(
{{fieldOffset}} * ::capnproto::REFERENCES,
{{#fieldDefaultBytes}}
DEFAULT_{{fieldUpperCase}}.words, {{defaultBlobSize}} * ::capnproto::BYTES
{{/fieldDefaultBytes}}
{{^fieldDefaultBytes}}nullptr, 0 * ::capnproto::BYTES{{/fieldDefaultBytes}});
return ::capnproto::internal::PointerHelpers<{{fieldType}}>::get(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES{{#fieldDefaultBytes}},
DEFAULT_{{fieldUpperCase}}.words{{#fieldIsBlob}}, {{defaultBlobSize}}{{/fieldIsBlob}}{{/fieldDefaultBytes}});
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return _builder.getBlobField<{{fieldType}}>({{fieldOffset}} * ::capnproto::REFERENCES,
{{#fieldDefaultBytes}}
DEFAULT_{{fieldUpperCase}}.words, {{defaultBlobSize}} * ::capnproto::BYTES
{{/fieldDefaultBytes}}
{{^fieldDefaultBytes}}nullptr, 0 * ::capnproto::BYTES{{/fieldDefaultBytes}});
}
inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}({{fieldType}}::Reader value) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
_builder.setBlobField<{{fieldType}}>({{fieldOffset}} * ::capnproto::REFERENCES, value);
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(unsigned int size) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return _builder.initBlobField<{{fieldType}}>(
{{fieldOffset}} * ::capnproto::REFERENCES, size * ::capnproto::BYTES);
}
{{/fieldIsInlineBlob}}
{{/fieldIsBlob}}
{{! ------------------------------------------------------------------------------------------- }}
{{#fieldIsStruct}}
{{^fieldIsInlineStruct}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Reader(_reader.getStructField(
{{fieldOffset}} * ::capnproto::REFERENCES,
{{#fieldDefaultBytes}}DEFAULT_{{fieldUpperCase}}.words{{/fieldDefaultBytes}}
{{^fieldDefaultBytes}}nullptr{{/fieldDefaultBytes}}));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}() {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.initStructField(
{{fieldOffset}} * ::capnproto::REFERENCES,
::capnproto::internal::structSize<{{fieldType}}>()));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.getStructField(
{{fieldOffset}} * ::capnproto::REFERENCES,
::capnproto::internal::structSize<{{fieldType}}>(),
{{#fieldDefaultBytes}}DEFAULT_{{fieldUpperCase}}.words{{/fieldDefaultBytes}}
{{^fieldDefaultBytes}}nullptr{{/fieldDefaultBytes}}));
}
{{/fieldIsInlineStruct}}
{{#fieldIsInlineStruct}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Reader(_reader.getInlineStructField(
{{fieldOffset}}));
::capnproto::internal::PointerHelpers<{{fieldType}}>::set(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, value);
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}() {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.initInlineStructField(
{{fieldOffset}}));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.getInlineStructField(
{{fieldOffset}}));
}
{{/fieldIsInlineStruct}}
{{/fieldIsStruct}}
{{! ------------------------------------------------------------------------------------------- }}
{{#fieldIsList}}
{{#fieldIsInlineList}}
{{#fieldIsPrimitiveList}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Reader(_reader.getInlineDataListField(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS,
::capnproto::internal::FieldSize::{{fieldElementSize}}));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}() {
inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(
std::initializer_list<{{fieldElementReaderType}}> value) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.initInlineDataListField(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlineDataSize}} * ::capnproto::BYTES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS,
::capnproto::internal::FieldSize::{{fieldElementSize}}));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.getInlineDataListField(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS,
::capnproto::internal::FieldSize::{{fieldElementSize}}));
}
{{/fieldIsPrimitiveList}}
{{#fieldIsPointerList}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Reader(_reader.getInlinePointerListField(
{{fieldInlinePointerOffset}} * ::capnproto::REFERENCES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS));
::capnproto::internal::PointerHelpers<{{fieldType}}>::set(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, value);
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}() {
{{/fieldIsList}}
{{#fieldIsListOrBlob}}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(unsigned int size) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.initInlinePointerListField(
{{fieldInlinePointerOffset}} * ::capnproto::REFERENCES,
{{fieldInlinePointerSize}} * ::capnproto::REFERENCES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.getInlinePointerListField(
{{fieldInlinePointerOffset}} * ::capnproto::REFERENCES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS));
}
{{/fieldIsPointerList}}
{{#fieldIsStructList}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Reader(_reader.getInlineStructListField(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlinePointerOffset}} * ::capnproto::REFERENCES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS,
::capnproto::internal::structSize<{{fieldInlineElementType}}>()));
return ::capnproto::internal::PointerHelpers<{{fieldType}}>::init(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, size);
}
{{/fieldIsListOrBlob}}
{{#fieldIsStruct}}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}() {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.initInlineStructListField(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlinePointerOffset}} * ::capnproto::REFERENCES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS,
::capnproto::internal::structSize<{{fieldInlineElementType}}>()));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.getInlineStructListField(
{{fieldInlineDataOffset}} * ::capnproto::BYTES,
{{fieldInlinePointerOffset}} * ::capnproto::REFERENCES,
{{fieldInlineListSize}} * ::capnproto::ELEMENTS,
::capnproto::internal::structSize<{{fieldInlineElementType}}>()));
}
{{/fieldIsStructList}}
{{/fieldIsInlineList}}
{{! --------------------------------- }}
{{^fieldIsInlineList}}
{{^fieldIsStructList}}
{{^fieldIsInlineBlobList}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Reader(_reader.getListField(
{{fieldOffset}} * ::capnproto::REFERENCES,
::capnproto::internal::FieldSize::{{fieldElementSize}},
{{#fieldDefaultBytes}}DEFAULT_{{fieldUpperCase}}.words{{/fieldDefaultBytes}}
{{^fieldDefaultBytes}}nullptr{{/fieldDefaultBytes}}));
return ::capnproto::internal::PointerHelpers<{{fieldType}}>::init(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES);
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(unsigned int size) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.initListField(
{{fieldOffset}} * ::capnproto::REFERENCES,
::capnproto::internal::FieldSize::{{fieldElementSize}},
size{{fieldInlineMultiplier}} * ::capnproto::ELEMENTS));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.getListField(
{{fieldOffset}} * ::capnproto::REFERENCES,
{{#fieldDefaultBytes}}DEFAULT_{{fieldUpperCase}}.words{{/fieldDefaultBytes}}
{{^fieldDefaultBytes}}nullptr{{/fieldDefaultBytes}}));
}
{{/fieldIsInlineBlobList}}
{{/fieldIsStructList}}
{{#fieldIsInlineBlobList}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{/fieldIsStruct}}
{{/fieldIsPrimitive}}
{{/fieldIsGenericObject}}
{{! ------------------------------------------------------------------------------------------- }}
{{#fieldIsGenericObject}}
template <typename T>
inline typename T::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Reader(_reader.getBlobField<{{fieldType}}>(
{{fieldOffset}} * ::capnproto::REFERENCES, nullptr, 0 * ::capnproto::BYTES));
return ::capnproto::internal::PointerHelpers<T>::get(
_reader, {{fieldOffset}} * ::capnproto::REFERENCES);
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(unsigned int size) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.initBlobField<{{fieldType}}>(
{{fieldOffset}} * ::capnproto::REFERENCES,
size{{fieldInlineMultiplier}} * ::capnproto::BYTES));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.getBlobField<{{fieldType}}>(
{{fieldOffset}} * ::capnproto::REFERENCES, nullptr, 0 * ::capnproto::BYTES));
}
{{/fieldIsInlineBlobList}}
{{#fieldIsStructList}}
inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
template <typename T>
inline typename T::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Reader(_reader.getListField(
{{fieldOffset}} * ::capnproto::REFERENCES,
::capnproto::internal::FieldSize::INLINE_COMPOSITE,
{{#fieldDefaultBytes}}DEFAULT_{{fieldUpperCase}}.words{{/fieldDefaultBytes}}
{{^fieldDefaultBytes}}nullptr{{/fieldDefaultBytes}}));
return ::capnproto::internal::PointerHelpers<T>::get(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES);
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(unsigned int size) {
template <typename T>
inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(typename T::Reader value) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.initStructListField(
{{fieldOffset}} * ::capnproto::REFERENCES,
size{{fieldInlineMultiplier}} * ::capnproto::ELEMENTS,
::capnproto::internal::structSize<{{fieldInlineElementType}}>()));
}
inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
{{#fieldUnion}}
CAPNPROTO_INLINE_DPRECOND(which() == {{unionTitleCase}}::{{fieldUpperCase}},
"Must check which() before get()ing a union member.");
{{/fieldUnion}}
return {{fieldType}}::Builder(_builder.getListField(
{{fieldOffset}} * ::capnproto::REFERENCES,
{{#fieldDefaultBytes}}DEFAULT_{{fieldUpperCase}}.words{{/fieldDefaultBytes}}
{{^fieldDefaultBytes}}nullptr{{/fieldDefaultBytes}}));
::capnproto::internal::PointerHelpers<T>::set(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, value);
}
{{/fieldIsStructList}}
{{/fieldIsInlineList}}
{{! --------------------------------- }}
template <typename _t>
inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(const _t& other) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
init{{fieldTitleCase}}({{^fieldIsInlineList}}other.size(){{/fieldIsInlineList}}).copyFrom(other);
}
{{#fieldIsPrimitiveList}}
inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(
std::initializer_list<{{fieldElementType}}> other) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
init{{fieldTitleCase}}({{^fieldIsInlineList}}other.size(){{/fieldIsInlineList}}).copyFrom(other);
}
{{/fieldIsPrimitiveList}}
{{^fieldIsPrimitiveList}}
inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(
std::initializer_list<{{fieldElementType}}::Reader> other) {
template <typename T>
inline typename T::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}() {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
init{{fieldTitleCase}}({{^fieldIsInlineList}}other.size(){{/fieldIsInlineList}}).copyFrom(other);
}
{{/fieldIsPrimitiveList}}
{{/fieldIsList}}
{{! ------------------------------------------------------------------------------------------- }}
{{#fieldIsGenericObject}}
template <typename T>
inline typename T::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
return ::capnproto::internal::PointerHelpers<T>::get(
_reader, {{fieldOffset}} * ::capnproto::REFERENCES);
}
template <typename T>
inline typename T::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
return ::capnproto::internal::PointerHelpers<T>::get(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES);
}
template <typename T>
inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(const typename T::Reader& value) {
return ::capnproto::internal::PointerHelpers<T>::set(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, value);
}
template <typename T>
inline typename T::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}() {
return ::capnproto::internal::PointerHelpers<T>::init(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES);
}
template <typename T>
inline typename T::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(unsigned int size) {
{{#fieldUnion}}
_builder.setDataField<{{unionTitleCase}}::Which>(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<T>::init(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, size);
}
......
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