Commit 917f459e authored by Kenton Varda's avatar Kenton Varda

Mass rename 'reference' -> 'pointer'. Been meaning to do this for a while --…

Mass rename 'reference' -> 'pointer'.  Been meaning to do this for a while -- all the documentation talks about 'pointers', not 'references'.
parent e550bee1
This diff is collapsed.
...@@ -656,13 +656,13 @@ struct PointerHelpers<DynamicStruct, Kind::UNKNOWN> { ...@@ -656,13 +656,13 @@ struct PointerHelpers<DynamicStruct, Kind::UNKNOWN> {
// non-dynamic types PointerHelpers::get() takes a default value as the third argument, and we // non-dynamic types PointerHelpers::get() takes a default value as the third argument, and we
// don't want people to accidentally be able to provide their own default value. // don't want people to accidentally be able to provide their own default value.
static DynamicStruct::Reader getDynamic( static DynamicStruct::Reader getDynamic(
StructReader reader, WireReferenceCount index, StructSchema schema); StructReader reader, WirePointerCount index, StructSchema schema);
static DynamicStruct::Builder getDynamic( static DynamicStruct::Builder getDynamic(
StructBuilder builder, WireReferenceCount index, StructSchema schema); StructBuilder builder, WirePointerCount index, StructSchema schema);
static void set( static void set(
StructBuilder builder, WireReferenceCount index, DynamicStruct::Reader value); StructBuilder builder, WirePointerCount index, DynamicStruct::Reader value);
static DynamicStruct::Builder init( static DynamicStruct::Builder init(
StructBuilder builder, WireReferenceCount index, StructSchema schema); StructBuilder builder, WirePointerCount index, StructSchema schema);
}; };
template <> template <>
...@@ -671,13 +671,13 @@ struct PointerHelpers<DynamicList, Kind::UNKNOWN> { ...@@ -671,13 +671,13 @@ struct PointerHelpers<DynamicList, Kind::UNKNOWN> {
// non-dynamic types PointerHelpers::get() takes a default value as the third argument, and we // non-dynamic types PointerHelpers::get() takes a default value as the third argument, and we
// don't want people to accidentally be able to provide their own default value. // don't want people to accidentally be able to provide their own default value.
static DynamicList::Reader getDynamic( static DynamicList::Reader getDynamic(
StructReader reader, WireReferenceCount index, ListSchema schema); StructReader reader, WirePointerCount index, ListSchema schema);
static DynamicList::Builder getDynamic( static DynamicList::Builder getDynamic(
StructBuilder builder, WireReferenceCount index, ListSchema schema); StructBuilder builder, WirePointerCount index, ListSchema schema);
static void set( static void set(
StructBuilder builder, WireReferenceCount index, DynamicList::Reader value); StructBuilder builder, WirePointerCount index, DynamicList::Reader value);
static DynamicList::Builder init( static DynamicList::Builder init(
StructBuilder builder, WireReferenceCount index, ListSchema schema, uint size); StructBuilder builder, WirePointerCount index, ListSchema schema, uint size);
}; };
} // namespace internal } // namespace internal
......
...@@ -40,64 +40,64 @@ namespace internal { ...@@ -40,64 +40,64 @@ namespace internal {
template <typename T> template <typename T>
struct PointerHelpers<T, Kind::STRUCT> { struct PointerHelpers<T, Kind::STRUCT> {
static inline typename T::Reader get(StructReader reader, WireReferenceCount index, static inline typename T::Reader get(StructReader reader, WirePointerCount index,
const word* defaultValue = nullptr) { const word* defaultValue = nullptr) {
return typename T::Reader(reader.getStructField(index, defaultValue)); return typename T::Reader(reader.getStructField(index, defaultValue));
} }
static inline typename T::Builder get(StructBuilder builder, WireReferenceCount index, static inline typename T::Builder get(StructBuilder builder, WirePointerCount index,
const word* defaultValue = nullptr) { const word* defaultValue = nullptr) {
return typename T::Builder(builder.getStructField(index, structSize<T>(), defaultValue)); return typename T::Builder(builder.getStructField(index, structSize<T>(), defaultValue));
} }
static inline void set(StructBuilder builder, WireReferenceCount index, static inline void set(StructBuilder builder, WirePointerCount index,
typename T::Reader value) { typename T::Reader value) {
// TODO(now): schemaless copy // TODO(now): schemaless copy
CAPNPROTO_INLINE_PRECOND(false, "Not implemented: set() for struct fields."); CAPNPROTO_INLINE_PRECOND(false, "Not implemented: set() for struct fields.");
} }
static inline typename T::Builder init(StructBuilder builder, WireReferenceCount index) { static inline typename T::Builder init(StructBuilder builder, WirePointerCount index) {
return typename T::Builder(builder.initStructField(index, structSize<T>())); return typename T::Builder(builder.initStructField(index, structSize<T>()));
} }
}; };
template <typename T> template <typename T>
struct PointerHelpers<List<T>, Kind::LIST> { struct PointerHelpers<List<T>, Kind::LIST> {
static inline typename List<T>::Reader get(StructReader reader, WireReferenceCount index, static inline typename List<T>::Reader get(StructReader reader, WirePointerCount index,
const word* defaultValue = nullptr) { const word* defaultValue = nullptr) {
return typename List<T>::Reader(List<T>::getAsFieldOf(reader, index, defaultValue)); return typename List<T>::Reader(List<T>::getAsFieldOf(reader, index, defaultValue));
} }
static inline typename List<T>::Builder get(StructBuilder builder, WireReferenceCount index, static inline typename List<T>::Builder get(StructBuilder builder, WirePointerCount index,
const word* defaultValue = nullptr) { const word* defaultValue = nullptr) {
return typename List<T>::Builder(List<T>::getAsFieldOf(builder, index, defaultValue)); return typename List<T>::Builder(List<T>::getAsFieldOf(builder, index, defaultValue));
} }
static inline void set(StructBuilder builder, WireReferenceCount index, static inline void set(StructBuilder builder, WirePointerCount index,
typename List<T>::Reader value) { typename List<T>::Reader value) {
init(builder, index, value.size()).copyFrom(value); init(builder, index, value.size()).copyFrom(value);
} }
static inline void set(StructBuilder builder, WireReferenceCount index, static inline void set(StructBuilder builder, WirePointerCount index,
std::initializer_list<ReaderFor<T>> value) { std::initializer_list<ReaderFor<T>> value) {
init(builder, index, value.size()).copyFrom(value); init(builder, index, value.size()).copyFrom(value);
} }
static inline typename List<T>::Builder init( static inline typename List<T>::Builder init(
StructBuilder builder, WireReferenceCount index, uint size) { StructBuilder builder, WirePointerCount index, uint size) {
return typename List<T>::Builder(List<T>::initAsFieldOf(builder, index, size)); return typename List<T>::Builder(List<T>::initAsFieldOf(builder, index, size));
} }
}; };
template <typename T> template <typename T>
struct PointerHelpers<T, Kind::BLOB> { struct PointerHelpers<T, Kind::BLOB> {
static inline typename T::Reader get(StructReader reader, WireReferenceCount index, static inline typename T::Reader get(StructReader reader, WirePointerCount index,
const void* defaultValue = nullptr, const void* defaultValue = nullptr,
uint defaultBytes = 0) { uint defaultBytes = 0) {
return reader.getBlobField<T>(index, defaultValue, defaultBytes * BYTES); return reader.getBlobField<T>(index, defaultValue, defaultBytes * BYTES);
} }
static inline typename T::Builder get(StructBuilder builder, WireReferenceCount index, static inline typename T::Builder get(StructBuilder builder, WirePointerCount index,
const void* defaultValue = nullptr, const void* defaultValue = nullptr,
uint defaultBytes = 0) { uint defaultBytes = 0) {
return builder.getBlobField<T>(index, defaultValue, defaultBytes * BYTES); return builder.getBlobField<T>(index, defaultValue, defaultBytes * BYTES);
} }
static inline void set(StructBuilder builder, WireReferenceCount index, typename T::Reader value) { static inline void set(StructBuilder builder, WirePointerCount index, typename T::Reader value) {
builder.setBlobField<T>(index, value); builder.setBlobField<T>(index, value);
} }
static inline typename T::Builder init(StructBuilder builder, WireReferenceCount index, uint size) { static inline typename T::Builder init(StructBuilder builder, WirePointerCount index, uint size) {
return builder.initBlobField<T>(index, size * BYTES); return builder.initBlobField<T>(index, size * BYTES);
} }
}; };
...@@ -114,7 +114,7 @@ struct PointerHelpers<TrustedMessage> { ...@@ -114,7 +114,7 @@ struct PointerHelpers<TrustedMessage> {
// itself trusted. This hack is currently private. It is used to locate default values within // itself trusted. This hack is currently private. It is used to locate default values within
// encoded schemas. // encoded schemas.
static inline const word* get(StructReader reader, WireReferenceCount index) { static inline const word* get(StructReader reader, WirePointerCount index) {
return reader.getTrustedPointer(index); return reader.getTrustedPointer(index);
} }
}; };
...@@ -177,7 +177,7 @@ inline constexpr uint64_t typeId() { return internal::TypeIdFor<T>::typeId; } ...@@ -177,7 +177,7 @@ inline constexpr uint64_t typeId() { return internal::TypeIdFor<T>::typeId; }
template <> struct KindOf<type> { static constexpr Kind kind = Kind::STRUCT; }; \ template <> struct KindOf<type> { static constexpr Kind kind = Kind::STRUCT; }; \
template <> struct StructSizeFor<type> { \ template <> struct StructSizeFor<type> { \
static constexpr StructSize value = StructSize( \ static constexpr StructSize value = StructSize( \
dataWordSize * WORDS, pointerCount * REFERENCES, FieldSize::preferredElementEncoding); \ dataWordSize * WORDS, pointerCount * POINTERS, FieldSize::preferredElementEncoding); \
}; \ }; \
template <> struct TypeIdFor<type> { static constexpr uint64_t typeId = 0x##id; }; \ template <> struct TypeIdFor<type> { static constexpr uint64_t typeId = 0x##id; }; \
template <> struct RawSchemaFor<type> { \ template <> struct RawSchemaFor<type> { \
......
...@@ -40,7 +40,7 @@ namespace { ...@@ -40,7 +40,7 @@ namespace {
TEST(WireFormat, SimpleRawDataStruct) { TEST(WireFormat, SimpleRawDataStruct) {
AlignedData<2> data = {{ AlignedData<2> data = {{
// Struct ref, offset = 1, dataSize = 1, referenceCount = 0 // Struct ref, offset = 1, dataSize = 1, pointerCount = 0
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
// Content for the data segment. // Content for the data segment.
0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef
...@@ -103,7 +103,7 @@ static const AlignedData<2> STRUCTLIST_ELEMENT_SUBSTRUCT_DEFAULT = ...@@ -103,7 +103,7 @@ static const AlignedData<2> STRUCTLIST_ELEMENT_SUBSTRUCT_DEFAULT =
{{0,0,0,0,1,0,0,0, 0,0,0,0,0,0,0,0}}; {{0,0,0,0,1,0,0,0, 0,0,0,0,0,0,0,0}};
static constexpr StructSize STRUCTLIST_ELEMENT_SIZE( static constexpr StructSize STRUCTLIST_ELEMENT_SIZE(
1 * WORDS, 1 * REFERENCES, FieldSize::INLINE_COMPOSITE); 1 * WORDS, 1 * POINTERS, FieldSize::INLINE_COMPOSITE);
static void setupStruct(StructBuilder builder) { static void setupStruct(StructBuilder builder) {
builder.setDataField<uint64_t>(0 * ELEMENTS, 0x1011121314151617ull); builder.setDataField<uint64_t>(0 * ELEMENTS, 0x1011121314151617ull);
...@@ -121,12 +121,12 @@ static void setupStruct(StructBuilder builder) { ...@@ -121,12 +121,12 @@ static void setupStruct(StructBuilder builder) {
{ {
StructBuilder subStruct = builder.initStructField( StructBuilder subStruct = builder.initStructField(
0 * REFERENCES, StructSize(1 * WORDS, 0 * REFERENCES, FieldSize::EIGHT_BYTES)); 0 * POINTERS, StructSize(1 * WORDS, 0 * POINTERS, FieldSize::EIGHT_BYTES));
subStruct.setDataField<uint32_t>(0 * ELEMENTS, 123); subStruct.setDataField<uint32_t>(0 * ELEMENTS, 123);
} }
{ {
ListBuilder list = builder.initListField(1 * REFERENCES, FieldSize::FOUR_BYTES, 3 * ELEMENTS); ListBuilder list = builder.initListField(1 * POINTERS, FieldSize::FOUR_BYTES, 3 * ELEMENTS);
EXPECT_EQ(3 * ELEMENTS, list.size()); EXPECT_EQ(3 * ELEMENTS, list.size());
list.setDataElement<int32_t>(0 * ELEMENTS, 200); list.setDataElement<int32_t>(0 * ELEMENTS, 200);
list.setDataElement<int32_t>(1 * ELEMENTS, 201); list.setDataElement<int32_t>(1 * ELEMENTS, 201);
...@@ -135,19 +135,19 @@ static void setupStruct(StructBuilder builder) { ...@@ -135,19 +135,19 @@ static void setupStruct(StructBuilder builder) {
{ {
ListBuilder list = builder.initStructListField( ListBuilder list = builder.initStructListField(
2 * REFERENCES, 4 * ELEMENTS, STRUCTLIST_ELEMENT_SIZE); 2 * POINTERS, 4 * ELEMENTS, STRUCTLIST_ELEMENT_SIZE);
EXPECT_EQ(4 * ELEMENTS, list.size()); EXPECT_EQ(4 * ELEMENTS, list.size());
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
StructBuilder element = list.getStructElement(i * ELEMENTS); StructBuilder element = list.getStructElement(i * ELEMENTS);
element.setDataField<int32_t>(0 * ELEMENTS, 300 + i); element.setDataField<int32_t>(0 * ELEMENTS, 300 + i);
element.initStructField(0 * REFERENCES, element.initStructField(0 * POINTERS,
StructSize(1 * WORDS, 0 * REFERENCES, FieldSize::EIGHT_BYTES)) StructSize(1 * WORDS, 0 * POINTERS, FieldSize::EIGHT_BYTES))
.setDataField<int32_t>(0 * ELEMENTS, 400 + i); .setDataField<int32_t>(0 * ELEMENTS, 400 + i);
} }
} }
{ {
ListBuilder list = builder.initListField(3 * REFERENCES, FieldSize::REFERENCE, 5 * ELEMENTS); ListBuilder list = builder.initListField(3 * POINTERS, FieldSize::POINTER, 5 * ELEMENTS);
EXPECT_EQ(5 * ELEMENTS, list.size()); EXPECT_EQ(5 * ELEMENTS, list.size());
for (uint i = 0; i < 5; i++) { for (uint i = 0; i < 5; i++) {
ListBuilder element = list.initListElement( ListBuilder element = list.initListElement(
...@@ -176,13 +176,13 @@ static void checkStruct(StructBuilder builder) { ...@@ -176,13 +176,13 @@ static void checkStruct(StructBuilder builder) {
{ {
StructBuilder subStruct = builder.getStructField( StructBuilder subStruct = builder.getStructField(
0 * REFERENCES, StructSize(1 * WORDS, 0 * REFERENCES, FieldSize::EIGHT_BYTES), 0 * POINTERS, StructSize(1 * WORDS, 0 * POINTERS, FieldSize::EIGHT_BYTES),
SUBSTRUCT_DEFAULT.words); SUBSTRUCT_DEFAULT.words);
EXPECT_EQ(123u, subStruct.getDataField<uint32_t>(0 * ELEMENTS)); EXPECT_EQ(123u, subStruct.getDataField<uint32_t>(0 * ELEMENTS));
} }
{ {
ListBuilder list = builder.getListField(1 * REFERENCES, nullptr); ListBuilder list = builder.getListField(1 * POINTERS, nullptr);
ASSERT_EQ(3 * ELEMENTS, list.size()); ASSERT_EQ(3 * ELEMENTS, list.size());
EXPECT_EQ(200, list.getDataElement<int32_t>(0 * ELEMENTS)); EXPECT_EQ(200, list.getDataElement<int32_t>(0 * ELEMENTS));
EXPECT_EQ(201, list.getDataElement<int32_t>(1 * ELEMENTS)); EXPECT_EQ(201, list.getDataElement<int32_t>(1 * ELEMENTS));
...@@ -190,21 +190,21 @@ static void checkStruct(StructBuilder builder) { ...@@ -190,21 +190,21 @@ static void checkStruct(StructBuilder builder) {
} }
{ {
ListBuilder list = builder.getListField(2 * REFERENCES, nullptr); ListBuilder list = builder.getListField(2 * POINTERS, nullptr);
ASSERT_EQ(4 * ELEMENTS, list.size()); ASSERT_EQ(4 * ELEMENTS, list.size());
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
StructBuilder element = list.getStructElement(i * ELEMENTS); StructBuilder element = list.getStructElement(i * ELEMENTS);
EXPECT_EQ(300 + i, element.getDataField<int32_t>(0 * ELEMENTS)); EXPECT_EQ(300 + i, element.getDataField<int32_t>(0 * ELEMENTS));
EXPECT_EQ(400 + i, EXPECT_EQ(400 + i,
element.getStructField(0 * REFERENCES, element.getStructField(0 * POINTERS,
StructSize(1 * WORDS, 0 * REFERENCES, FieldSize::EIGHT_BYTES), StructSize(1 * WORDS, 0 * POINTERS, FieldSize::EIGHT_BYTES),
STRUCTLIST_ELEMENT_SUBSTRUCT_DEFAULT.words) STRUCTLIST_ELEMENT_SUBSTRUCT_DEFAULT.words)
.getDataField<int32_t>(0 * ELEMENTS)); .getDataField<int32_t>(0 * ELEMENTS));
} }
} }
{ {
ListBuilder list = builder.getListField(3 * REFERENCES, nullptr); ListBuilder list = builder.getListField(3 * POINTERS, nullptr);
ASSERT_EQ(5 * ELEMENTS, list.size()); ASSERT_EQ(5 * ELEMENTS, list.size());
for (uint i = 0; i < 5; i++) { for (uint i = 0; i < 5; i++) {
ListBuilder element = list.getListElement(i * ELEMENTS); ListBuilder element = list.getListElement(i * ELEMENTS);
...@@ -231,12 +231,12 @@ static void checkStruct(StructReader reader) { ...@@ -231,12 +231,12 @@ static void checkStruct(StructReader reader) {
EXPECT_FALSE(reader.getDataField<bool>(127 * ELEMENTS)); EXPECT_FALSE(reader.getDataField<bool>(127 * ELEMENTS));
{ {
StructReader subStruct = reader.getStructField(0 * REFERENCES, SUBSTRUCT_DEFAULT.words); StructReader subStruct = reader.getStructField(0 * POINTERS, SUBSTRUCT_DEFAULT.words);
EXPECT_EQ(123u, subStruct.getDataField<uint32_t>(0 * ELEMENTS)); EXPECT_EQ(123u, subStruct.getDataField<uint32_t>(0 * ELEMENTS));
} }
{ {
ListReader list = reader.getListField(1 * REFERENCES, FieldSize::FOUR_BYTES, nullptr); ListReader list = reader.getListField(1 * POINTERS, FieldSize::FOUR_BYTES, nullptr);
ASSERT_EQ(3 * ELEMENTS, list.size()); ASSERT_EQ(3 * ELEMENTS, list.size());
EXPECT_EQ(200, list.getDataElement<int32_t>(0 * ELEMENTS)); EXPECT_EQ(200, list.getDataElement<int32_t>(0 * ELEMENTS));
EXPECT_EQ(201, list.getDataElement<int32_t>(1 * ELEMENTS)); EXPECT_EQ(201, list.getDataElement<int32_t>(1 * ELEMENTS));
...@@ -244,20 +244,20 @@ static void checkStruct(StructReader reader) { ...@@ -244,20 +244,20 @@ static void checkStruct(StructReader reader) {
} }
{ {
ListReader list = reader.getListField(2 * REFERENCES, FieldSize::INLINE_COMPOSITE, nullptr); ListReader list = reader.getListField(2 * POINTERS, FieldSize::INLINE_COMPOSITE, nullptr);
ASSERT_EQ(4 * ELEMENTS, list.size()); ASSERT_EQ(4 * ELEMENTS, list.size());
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
StructReader element = list.getStructElement(i * ELEMENTS); StructReader element = list.getStructElement(i * ELEMENTS);
EXPECT_EQ(300 + i, element.getDataField<int32_t>(0 * ELEMENTS)); EXPECT_EQ(300 + i, element.getDataField<int32_t>(0 * ELEMENTS));
EXPECT_EQ(400 + i, EXPECT_EQ(400 + i,
element.getStructField(0 * REFERENCES, STRUCTLIST_ELEMENT_SUBSTRUCT_DEFAULT.words) element.getStructField(0 * POINTERS, STRUCTLIST_ELEMENT_SUBSTRUCT_DEFAULT.words)
.getDataField<int32_t>(0 * ELEMENTS)); .getDataField<int32_t>(0 * ELEMENTS));
} }
} }
{ {
// TODO: Use valid default value. // TODO: Use valid default value.
ListReader list = reader.getListField(3 * REFERENCES, FieldSize::REFERENCE, nullptr); ListReader list = reader.getListField(3 * POINTERS, FieldSize::POINTER, nullptr);
ASSERT_EQ(5 * ELEMENTS, list.size()); ASSERT_EQ(5 * ELEMENTS, list.size());
for (uint i = 0; i < 5; i++) { for (uint i = 0; i < 5; i++) {
ListReader element = list.getListElement(i * ELEMENTS, FieldSize::TWO_BYTES); ListReader element = list.getListElement(i * ELEMENTS, FieldSize::TWO_BYTES);
...@@ -276,11 +276,11 @@ TEST(WireFormat, StructRoundTrip_OneSegment) { ...@@ -276,11 +276,11 @@ TEST(WireFormat, StructRoundTrip_OneSegment) {
word* rootLocation = segment->allocate(1 * WORDS); word* rootLocation = segment->allocate(1 * WORDS);
StructBuilder builder = StructBuilder::initRoot( StructBuilder builder = StructBuilder::initRoot(
segment, rootLocation, StructSize(2 * WORDS, 4 * REFERENCES, FieldSize::INLINE_COMPOSITE)); segment, rootLocation, StructSize(2 * WORDS, 4 * POINTERS, FieldSize::INLINE_COMPOSITE));
setupStruct(builder); setupStruct(builder);
// word count: // word count:
// 1 root reference // 1 root pointer
// 6 root struct // 6 root struct
// 1 sub message // 1 sub message
// 2 3-element int32 list // 2 3-element int32 list
...@@ -288,10 +288,10 @@ TEST(WireFormat, StructRoundTrip_OneSegment) { ...@@ -288,10 +288,10 @@ TEST(WireFormat, StructRoundTrip_OneSegment) {
// 1 tag // 1 tag
// 12 4x struct // 12 4x struct
// 1 data segment // 1 data segment
// 1 reference segment // 1 pointer segment
// 1 sub-struct // 1 sub-struct
// 11 list list // 11 list list
// 5 references to sub-lists // 5 pointers to sub-lists
// 6 sub-lists (4x 1 word, 1x 2 words) // 6 sub-lists (4x 1 word, 1x 2 words)
// ----- // -----
// 34 // 34
...@@ -312,7 +312,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation) { ...@@ -312,7 +312,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation) {
word* rootLocation = segment->allocate(1 * WORDS); word* rootLocation = segment->allocate(1 * WORDS);
StructBuilder builder = StructBuilder::initRoot( StructBuilder builder = StructBuilder::initRoot(
segment, rootLocation, StructSize(2 * WORDS, 4 * REFERENCES, FieldSize::INLINE_COMPOSITE)); segment, rootLocation, StructSize(2 * WORDS, 4 * POINTERS, FieldSize::INLINE_COMPOSITE));
setupStruct(builder); setupStruct(builder);
// Verify that we made 15 segments. // Verify that we made 15 segments.
...@@ -320,7 +320,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation) { ...@@ -320,7 +320,7 @@ TEST(WireFormat, StructRoundTrip_OneSegmentPerAllocation) {
ASSERT_EQ(15u, segments.size()); ASSERT_EQ(15u, segments.size());
// Check that each segment has the expected size. Recall that the first word of each segment will // Check that each segment has the expected size. Recall that the first word of each segment will
// actually be a reference to the first thing allocated within that segment. // actually be a pointer to the first thing allocated within that segment.
EXPECT_EQ( 1u, segments[ 0].size()); // root ref EXPECT_EQ( 1u, segments[ 0].size()); // root ref
EXPECT_EQ( 7u, segments[ 1].size()); // root struct EXPECT_EQ( 7u, segments[ 1].size()); // root struct
EXPECT_EQ( 2u, segments[ 2].size()); // sub-struct EXPECT_EQ( 2u, segments[ 2].size()); // sub-struct
...@@ -349,7 +349,7 @@ TEST(WireFormat, StructRoundTrip_MultipleSegmentsWithMultipleAllocations) { ...@@ -349,7 +349,7 @@ TEST(WireFormat, StructRoundTrip_MultipleSegmentsWithMultipleAllocations) {
word* rootLocation = segment->allocate(1 * WORDS); word* rootLocation = segment->allocate(1 * WORDS);
StructBuilder builder = StructBuilder::initRoot( StructBuilder builder = StructBuilder::initRoot(
segment, rootLocation, StructSize(2 * WORDS, 4 * REFERENCES, FieldSize::INLINE_COMPOSITE)); segment, rootLocation, StructSize(2 * WORDS, 4 * POINTERS, FieldSize::INLINE_COMPOSITE));
setupStruct(builder); setupStruct(builder);
// Verify that we made 6 segments. // Verify that we made 6 segments.
......
This diff is collapsed.
This diff is collapsed.
...@@ -94,22 +94,22 @@ template <typename T> struct FieldSizeForType { ...@@ -94,22 +94,22 @@ template <typename T> struct FieldSizeForType {
kind<T>() == Kind::STRUCT ? FieldSize::INLINE_COMPOSITE : kind<T>() == Kind::STRUCT ? FieldSize::INLINE_COMPOSITE :
// Everything else is a pointer. // Everything else is a pointer.
FieldSize::REFERENCE; FieldSize::POINTER;
}; };
// Void and bool are special. // Void and bool are special.
template <> struct FieldSizeForType<Void> { static constexpr FieldSize value = FieldSize::VOID; }; template <> struct FieldSizeForType<Void> { static constexpr FieldSize value = FieldSize::VOID; };
template <> struct FieldSizeForType<bool> { static constexpr FieldSize value = FieldSize::BIT; }; template <> struct FieldSizeForType<bool> { static constexpr FieldSize value = FieldSize::BIT; };
// Lists and blobs are references, not structs. // Lists and blobs are pointers, not structs.
template <typename T, bool b> struct FieldSizeForType<List<T, b>> { template <typename T, bool b> struct FieldSizeForType<List<T, b>> {
static constexpr FieldSize value = FieldSize::REFERENCE; static constexpr FieldSize value = FieldSize::POINTER;
}; };
template <> struct FieldSizeForType<Text> { template <> struct FieldSizeForType<Text> {
static constexpr FieldSize value = FieldSize::REFERENCE; static constexpr FieldSize value = FieldSize::POINTER;
}; };
template <> struct FieldSizeForType<Data> { template <> struct FieldSizeForType<Data> {
static constexpr FieldSize value = FieldSize::REFERENCE; static constexpr FieldSize value = FieldSize::POINTER;
}; };
template <typename T> template <typename T>
...@@ -265,15 +265,15 @@ private: ...@@ -265,15 +265,15 @@ private:
} }
inline static internal::ListBuilder initAsFieldOf( inline static internal::ListBuilder initAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index, uint size) { internal::StructBuilder& builder, WirePointerCount index, uint size) {
return builder.initListField(index, internal::FieldSizeForType<T>::value, size * ELEMENTS); return builder.initListField(index, internal::FieldSizeForType<T>::value, size * ELEMENTS);
} }
inline static internal::ListBuilder getAsFieldOf( inline static internal::ListBuilder getAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index, const word* defaultValue) { internal::StructBuilder& builder, WirePointerCount index, const word* defaultValue) {
return builder.getListField(index, defaultValue); return builder.getListField(index, defaultValue);
} }
inline static internal::ListReader getAsFieldOf( inline static internal::ListReader getAsFieldOf(
internal::StructReader& reader, WireReferenceCount index, const word* defaultValue) { internal::StructReader& reader, WirePointerCount index, const word* defaultValue) {
return reader.getListField(index, internal::FieldSizeForType<T>::value, defaultValue); return reader.getListField(index, internal::FieldSizeForType<T>::value, defaultValue);
} }
...@@ -351,15 +351,15 @@ private: ...@@ -351,15 +351,15 @@ private:
} }
inline static internal::ListBuilder initAsFieldOf( inline static internal::ListBuilder initAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index, uint size) { internal::StructBuilder& builder, WirePointerCount index, uint size) {
return builder.initStructListField(index, size * ELEMENTS, internal::structSize<T>()); return builder.initStructListField(index, size * ELEMENTS, internal::structSize<T>());
} }
inline static internal::ListBuilder getAsFieldOf( inline static internal::ListBuilder getAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index, const word* defaultValue) { internal::StructBuilder& builder, WirePointerCount index, const word* defaultValue) {
return builder.getListField(index, defaultValue); return builder.getListField(index, defaultValue);
} }
inline static internal::ListReader getAsFieldOf( inline static internal::ListReader getAsFieldOf(
internal::StructReader& reader, WireReferenceCount index, const word* defaultValue) { internal::StructReader& reader, WirePointerCount index, const word* defaultValue) {
return reader.getListField(index, internal::FieldSize::INLINE_COMPOSITE, defaultValue); return reader.getListField(index, internal::FieldSize::INLINE_COMPOSITE, defaultValue);
} }
...@@ -425,7 +425,7 @@ private: ...@@ -425,7 +425,7 @@ private:
inline static internal::ListBuilder initAsElementOf( inline static internal::ListBuilder initAsElementOf(
const internal::ListBuilder& builder, uint index, uint size) { const internal::ListBuilder& builder, uint index, uint size) {
return builder.initListElement( return builder.initListElement(
index * ELEMENTS, internal::FieldSize::REFERENCE, size * ELEMENTS); index * ELEMENTS, internal::FieldSize::POINTER, size * ELEMENTS);
} }
inline static internal::ListBuilder getAsElementOf( inline static internal::ListBuilder getAsElementOf(
const internal::ListBuilder& builder, uint index) { const internal::ListBuilder& builder, uint index) {
...@@ -433,20 +433,20 @@ private: ...@@ -433,20 +433,20 @@ private:
} }
inline static internal::ListReader getAsElementOf( inline static internal::ListReader getAsElementOf(
const internal::ListReader& reader, uint index) { const internal::ListReader& reader, uint index) {
return reader.getListElement(index * ELEMENTS, internal::FieldSize::REFERENCE); return reader.getListElement(index * ELEMENTS, internal::FieldSize::POINTER);
} }
inline static internal::ListBuilder initAsFieldOf( inline static internal::ListBuilder initAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index, uint size) { internal::StructBuilder& builder, WirePointerCount index, uint size) {
return builder.initListField(index, internal::FieldSize::REFERENCE, size * ELEMENTS); return builder.initListField(index, internal::FieldSize::POINTER, size * ELEMENTS);
} }
inline static internal::ListBuilder getAsFieldOf( inline static internal::ListBuilder getAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index, const word* defaultValue) { internal::StructBuilder& builder, WirePointerCount index, const word* defaultValue) {
return builder.getListField(index, defaultValue); return builder.getListField(index, defaultValue);
} }
inline static internal::ListReader getAsFieldOf( inline static internal::ListReader getAsFieldOf(
internal::StructReader& reader, WireReferenceCount index, const word* defaultValue) { internal::StructReader& reader, WirePointerCount index, const word* defaultValue) {
return reader.getListField(index, internal::FieldSize::REFERENCE, defaultValue); return reader.getListField(index, internal::FieldSize::POINTER, defaultValue);
} }
template <typename U, Kind k> template <typename U, Kind k>
...@@ -526,7 +526,7 @@ private: ...@@ -526,7 +526,7 @@ private:
inline static internal::ListBuilder initAsElementOf( inline static internal::ListBuilder initAsElementOf(
const internal::ListBuilder& builder, uint index, uint size) { const internal::ListBuilder& builder, uint index, uint size) {
return builder.initListElement( return builder.initListElement(
index * ELEMENTS, internal::FieldSize::REFERENCE, size * ELEMENTS); index * ELEMENTS, internal::FieldSize::POINTER, size * ELEMENTS);
} }
inline static internal::ListBuilder getAsElementOf( inline static internal::ListBuilder getAsElementOf(
const internal::ListBuilder& builder, uint index) { const internal::ListBuilder& builder, uint index) {
...@@ -534,20 +534,20 @@ private: ...@@ -534,20 +534,20 @@ private:
} }
inline static internal::ListReader getAsElementOf( inline static internal::ListReader getAsElementOf(
const internal::ListReader& reader, uint index) { const internal::ListReader& reader, uint index) {
return reader.getListElement(index * ELEMENTS, internal::FieldSize::REFERENCE); return reader.getListElement(index * ELEMENTS, internal::FieldSize::POINTER);
} }
inline static internal::ListBuilder initAsFieldOf( inline static internal::ListBuilder initAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index, uint size) { internal::StructBuilder& builder, WirePointerCount index, uint size) {
return builder.initListField(index, internal::FieldSize::REFERENCE, size * ELEMENTS); return builder.initListField(index, internal::FieldSize::POINTER, size * ELEMENTS);
} }
inline static internal::ListBuilder getAsFieldOf( inline static internal::ListBuilder getAsFieldOf(
internal::StructBuilder& builder, WireReferenceCount index, const word* defaultValue) { internal::StructBuilder& builder, WirePointerCount index, const word* defaultValue) {
return builder.getListField(index, defaultValue); return builder.getListField(index, defaultValue);
} }
inline static internal::ListReader getAsFieldOf( inline static internal::ListReader getAsFieldOf(
internal::StructReader& reader, WireReferenceCount index, const word* defaultValue) { internal::StructReader& reader, WirePointerCount index, const word* defaultValue) {
return reader.getListField(index, internal::FieldSize::REFERENCE, defaultValue); return reader.getListField(index, internal::FieldSize::POINTER, defaultValue);
} }
template <typename U, Kind k> template <typename U, Kind k>
......
...@@ -78,11 +78,11 @@ internal::SegmentBuilder* MessageBuilder::getRootSegment() { ...@@ -78,11 +78,11 @@ internal::SegmentBuilder* MessageBuilder::getRootSegment() {
new(arena()) internal::BuilderArena(this); new(arena()) internal::BuilderArena(this);
allocatedArena = true; allocatedArena = true;
WordCount refSize = 1 * REFERENCES * WORDS_PER_REFERENCE; WordCount ptrSize = 1 * POINTERS * WORDS_PER_POINTER;
internal::SegmentBuilder* segment = arena()->getSegmentWithAvailable(refSize); internal::SegmentBuilder* segment = arena()->getSegmentWithAvailable(ptrSize);
CHECK(segment->getSegmentId() == internal::SegmentId(0), CHECK(segment->getSegmentId() == internal::SegmentId(0),
"First allocated word of new arena was not in segment ID 0."); "First allocated word of new arena was not in segment ID 0.");
word* location = segment->allocate(refSize); word* location = segment->allocate(ptrSize);
CHECK(location == segment->getPtrUnchecked(0 * WORDS), CHECK(location == segment->getPtrUnchecked(0 * WORDS),
"First allocated word of new arena was not the first word in its segment."); "First allocated word of new arena was not the first word in its segment.");
return segment; return segment;
......
...@@ -391,7 +391,7 @@ TEST(Packed, RoundTripAllZero) { ...@@ -391,7 +391,7 @@ TEST(Packed, RoundTripAllZero) {
checkTestMessageAllZero(reader.getRoot<TestAllTypes>()); checkTestMessageAllZero(reader.getRoot<TestAllTypes>());
// Segment table packs to 2 bytes. // Segment table packs to 2 bytes.
// Root reference packs to 3 bytes. // Root pointer packs to 3 bytes.
// Content packs to 2 bytes (zero span). // Content packs to 2 bytes (zero span).
EXPECT_LE(pipe.getData().size(), 7u); EXPECT_LE(pipe.getData().size(), 7u);
} }
......
...@@ -787,7 +787,7 @@ class word { uint64_t content; CAPNPROTO_DISALLOW_COPY(word); public: word() = d ...@@ -787,7 +787,7 @@ class word { uint64_t content; CAPNPROTO_DISALLOW_COPY(word); public: word() = d
static_assert(sizeof(byte) == 1, "uint8_t is not one byte?"); static_assert(sizeof(byte) == 1, "uint8_t is not one byte?");
static_assert(sizeof(word) == 8, "uint64_t is not 8 bytes?"); static_assert(sizeof(word) == 8, "uint64_t is not 8 bytes?");
namespace internal { class BitLabel; class ElementLabel; class WireReference; } namespace internal { class BitLabel; class ElementLabel; class WirePointer; }
#ifndef CAPNPROTO_DEBUG_TYPES #ifndef CAPNPROTO_DEBUG_TYPES
#define CAPNPROTO_DEBUG_TYPES 1 #define CAPNPROTO_DEBUG_TYPES 1
...@@ -828,11 +828,11 @@ typedef Quantity<uint16_t, internal::ElementLabel> ElementCount16; ...@@ -828,11 +828,11 @@ typedef Quantity<uint16_t, internal::ElementLabel> ElementCount16;
typedef Quantity<uint32_t, internal::ElementLabel> ElementCount32; typedef Quantity<uint32_t, internal::ElementLabel> ElementCount32;
typedef Quantity<uint64_t, internal::ElementLabel> ElementCount64; typedef Quantity<uint64_t, internal::ElementLabel> ElementCount64;
typedef Quantity<uint, internal::WireReference> WireReferenceCount; typedef Quantity<uint, internal::WirePointer> WirePointerCount;
typedef Quantity<uint8_t, internal::WireReference> WireReferenceCount8; typedef Quantity<uint8_t, internal::WirePointer> WirePointerCount8;
typedef Quantity<uint16_t, internal::WireReference> WireReferenceCount16; typedef Quantity<uint16_t, internal::WirePointer> WirePointerCount16;
typedef Quantity<uint32_t, internal::WireReference> WireReferenceCount32; typedef Quantity<uint32_t, internal::WirePointer> WirePointerCount32;
typedef Quantity<uint64_t, internal::WireReference> WireReferenceCount64; typedef Quantity<uint64_t, internal::WirePointer> WirePointerCount64;
#else #else
...@@ -860,11 +860,11 @@ typedef uint16_t ElementCount16; ...@@ -860,11 +860,11 @@ typedef uint16_t ElementCount16;
typedef uint32_t ElementCount32; typedef uint32_t ElementCount32;
typedef uint64_t ElementCount64; typedef uint64_t ElementCount64;
typedef uint WireReferenceCount; typedef uint WirePointerCount;
typedef uint8_t WireReferenceCount8; typedef uint8_t WirePointerCount8;
typedef uint16_t WireReferenceCount16; typedef uint16_t WirePointerCount16;
typedef uint32_t WireReferenceCount32; typedef uint32_t WirePointerCount32;
typedef uint64_t WireReferenceCount64; typedef uint64_t WirePointerCount64;
#endif #endif
...@@ -872,17 +872,17 @@ constexpr BitCount BITS = unit<BitCount>(); ...@@ -872,17 +872,17 @@ constexpr BitCount BITS = unit<BitCount>();
constexpr ByteCount BYTES = unit<ByteCount>(); constexpr ByteCount BYTES = unit<ByteCount>();
constexpr WordCount WORDS = unit<WordCount>(); constexpr WordCount WORDS = unit<WordCount>();
constexpr ElementCount ELEMENTS = unit<ElementCount>(); constexpr ElementCount ELEMENTS = unit<ElementCount>();
constexpr WireReferenceCount REFERENCES = unit<WireReferenceCount>(); constexpr WirePointerCount POINTERS = unit<WirePointerCount>();
constexpr auto BITS_PER_BYTE = 8 * BITS / BYTES; constexpr auto BITS_PER_BYTE = 8 * BITS / BYTES;
constexpr auto BITS_PER_WORD = 64 * BITS / WORDS; constexpr auto BITS_PER_WORD = 64 * BITS / WORDS;
constexpr auto BYTES_PER_WORD = 8 * BYTES / WORDS; constexpr auto BYTES_PER_WORD = 8 * BYTES / WORDS;
constexpr auto BITS_PER_REFERENCE = 64 * BITS / REFERENCES; constexpr auto BITS_PER_POINTER = 64 * BITS / POINTERS;
constexpr auto BYTES_PER_REFERENCE = 8 * BYTES / REFERENCES; constexpr auto BYTES_PER_POINTER = 8 * BYTES / POINTERS;
constexpr auto WORDS_PER_REFERENCE = 1 * WORDS / REFERENCES; constexpr auto WORDS_PER_POINTER = 1 * WORDS / POINTERS;
constexpr WordCount REFERENCE_SIZE_IN_WORDS = 1 * REFERENCES * WORDS_PER_REFERENCE; constexpr WordCount POINTER_SIZE_IN_WORDS = 1 * POINTERS * WORDS_PER_POINTER;
template <typename T> template <typename T>
inline constexpr decltype(BYTES / ELEMENTS) bytesPerElement() { inline constexpr decltype(BYTES / ELEMENTS) bytesPerElement() {
......
...@@ -481,26 +481,26 @@ extractFieldNumbers decls = concat ...@@ -481,26 +481,26 @@ extractFieldNumbers decls = concat
data PackingState = PackingState data PackingState = PackingState
{ packingHoles :: Map.Map DataSize Integer { packingHoles :: Map.Map DataSize Integer
, packingDataSize :: Integer , packingDataSize :: Integer
, packingReferenceCount :: Integer , packingPointerCount :: Integer
} }
initialPackingState = PackingState Map.empty 0 0 initialPackingState = PackingState Map.empty 0 0
packValue :: FieldSize -> PackingState -> (FieldOffset, PackingState) packValue :: FieldSize -> PackingState -> (FieldOffset, PackingState)
packValue SizeVoid s = (VoidOffset, s) packValue SizeVoid s = (VoidOffset, s)
packValue SizeReference s@(PackingState { packingReferenceCount = rc }) = packValue SizePointer s@(PackingState { packingPointerCount = rc }) =
(PointerOffset rc, s { packingReferenceCount = rc + 1 }) (PointerOffset rc, s { packingPointerCount = rc + 1 })
packValue (SizeInlineComposite (DataSectionWords inlineDs) inlineRc) packValue (SizeInlineComposite (DataSectionWords inlineDs) inlineRc)
s@(PackingState { packingDataSize = ds, packingReferenceCount = rc }) = s@(PackingState { packingDataSize = ds, packingPointerCount = rc }) =
(InlineCompositeOffset ds rc (DataSectionWords inlineDs) inlineRc, (InlineCompositeOffset ds rc (DataSectionWords inlineDs) inlineRc,
s { packingDataSize = ds + inlineDs s { packingDataSize = ds + inlineDs
, packingReferenceCount = rc + inlineRc }) , packingPointerCount = rc + inlineRc })
packValue (SizeInlineComposite inlineDs inlineRc) packValue (SizeInlineComposite inlineDs inlineRc)
s@(PackingState { packingReferenceCount = rc }) = let s@(PackingState { packingPointerCount = rc }) = let
size = (dataSectionAlignment inlineDs) size = (dataSectionAlignment inlineDs)
(offset, s2) = packData size s (offset, s2) = packData size s
in (InlineCompositeOffset offset rc inlineDs inlineRc, in (InlineCompositeOffset offset rc inlineDs inlineRc,
s2 { packingReferenceCount = rc + inlineRc }) s2 { packingPointerCount = rc + inlineRc })
packValue (SizeData size) s = let (o, s2) = packData size s in (DataOffset size o, s2) packValue (SizeData size) s = let (o, s2) = packData size s in (DataOffset size o, s2)
packData :: DataSize -> PackingState -> (Integer, PackingState) packData :: DataSize -> PackingState -> (Integer, PackingState)
...@@ -569,14 +569,14 @@ packUnionizedValue (SizeData size) (UnionPackingState (UnionSlot slotSize slotOf ...@@ -569,14 +569,14 @@ packUnionizedValue (SizeData size) (UnionPackingState (UnionSlot slotSize slotOf
Nothing -> packUnionizedValue (SizeData size) Nothing -> packUnionizedValue (SizeData size)
(UnionPackingState (UnionSlot (DataSectionWords 0) 0) p) s (UnionPackingState (UnionSlot (DataSectionWords 0) 0) p) s
-- Pack reference when we don't have a reference slot. -- Pack pointer when we don't have a pointer slot.
packUnionizedValue SizeReference u@(UnionPackingState _ (UnionSlot 0 _)) s = let packUnionizedValue SizePointer u@(UnionPackingState _ (UnionSlot 0 _)) s = let
(PointerOffset offset, s2) = packValue SizeReference s (PointerOffset offset, s2) = packValue SizePointer s
u2 = u { unionPointerSlot = UnionSlot 1 offset } u2 = u { unionPointerSlot = UnionSlot 1 offset }
in (PointerOffset offset, u2, s2) in (PointerOffset offset, u2, s2)
-- Pack reference when we already have a reference slot allocated. -- Pack pointer when we already have a pointer slot allocated.
packUnionizedValue SizeReference u@(UnionPackingState _ (UnionSlot _ offset)) s = packUnionizedValue SizePointer u@(UnionPackingState _ (UnionSlot _ offset)) s =
(PointerOffset offset, u, s) (PointerOffset offset, u, s)
-- Pack inline composite. -- Pack inline composite.
...@@ -621,14 +621,14 @@ packUnionizedValue (SizeInlineComposite dataSize pointerCount) ...@@ -621,14 +621,14 @@ packUnionizedValue (SizeInlineComposite dataSize pointerCount)
-- Pack the pointer section. -- Pack the pointer section.
(pointerOffset, u3, s3) (pointerOffset, u3, s3)
| pointerCount <= pointerSlotSize = (pointerSlotOffset, u2, s2) | pointerCount <= pointerSlotSize = (pointerSlotOffset, u2, s2)
| pointerSlotOffset + pointerSlotSize == packingReferenceCount s2 = | pointerSlotOffset + pointerSlotSize == packingPointerCount s2 =
(pointerSlotOffset, (pointerSlotOffset,
u2 { unionPointerSlot = UnionSlot pointerCount pointerSlotOffset }, u2 { unionPointerSlot = UnionSlot pointerCount pointerSlotOffset },
s2 { packingReferenceCount = pointerSlotOffset + pointerCount }) s2 { packingPointerCount = pointerSlotOffset + pointerCount })
| otherwise = | otherwise =
(packingReferenceCount s2, (packingPointerCount s2,
u2 { unionPointerSlot = UnionSlot pointerCount (packingReferenceCount s2) }, u2 { unionPointerSlot = UnionSlot pointerCount (packingPointerCount s2) },
s2 { packingReferenceCount = packingReferenceCount s2 + pointerCount }) s2 { packingPointerCount = packingPointerCount s2 + pointerCount })
combinedOffset = InlineCompositeOffset combinedOffset = InlineCompositeOffset
{ inlineCompositeDataOffset = dataOffset { inlineCompositeDataOffset = dataOffset
...@@ -738,7 +738,7 @@ packFields fields unions = let ...@@ -738,7 +738,7 @@ packFields fields unions = let
then dataSizeToSectionSize $ stripHolesFromFirstWord Size64 $ packingHoles finalState then dataSizeToSectionSize $ stripHolesFromFirstWord Size64 $ packingHoles finalState
else DataSectionWords $ packingDataSize finalState else DataSectionWords $ packingDataSize finalState
in (dataSectionSize, packingReferenceCount finalState, Map.fromList packedItems) in (dataSectionSize, packingPointerCount finalState, Map.fromList packedItems)
enforceFixed Nothing sizes = return sizes enforceFixed Nothing sizes = return sizes
enforceFixed (Just (Located pos (requestedDataSize, requestedPointerCount))) enforceFixed (Just (Located pos (requestedDataSize, requestedPointerCount)))
......
...@@ -195,7 +195,7 @@ cxxFieldSizeString (SizeData Size8) = "BYTE"; ...@@ -195,7 +195,7 @@ cxxFieldSizeString (SizeData Size8) = "BYTE";
cxxFieldSizeString (SizeData Size16) = "TWO_BYTES"; cxxFieldSizeString (SizeData Size16) = "TWO_BYTES";
cxxFieldSizeString (SizeData Size32) = "FOUR_BYTES"; cxxFieldSizeString (SizeData Size32) = "FOUR_BYTES";
cxxFieldSizeString (SizeData Size64) = "EIGHT_BYTES"; cxxFieldSizeString (SizeData Size64) = "EIGHT_BYTES";
cxxFieldSizeString SizeReference = "REFERENCE"; cxxFieldSizeString SizePointer = "POINTER";
cxxFieldSizeString (SizeInlineComposite _ _) = "INLINE_COMPOSITE"; cxxFieldSizeString (SizeInlineComposite _ _) = "INLINE_COMPOSITE";
fieldOffsetInteger VoidOffset = "0" fieldOffsetInteger VoidOffset = "0"
...@@ -207,7 +207,7 @@ fieldOffsetInteger (InlineCompositeOffset d p ds ps) = let ...@@ -207,7 +207,7 @@ fieldOffsetInteger (InlineCompositeOffset d p ds ps) = let
DataSectionWords _ -> d * 8 DataSectionWords _ -> d * 8
_ -> d * byteSize _ -> d * byteSize
in printf "%d * ::capnproto::BYTES, %d * ::capnproto::BYTES, \ in printf "%d * ::capnproto::BYTES, %d * ::capnproto::BYTES, \
\%d * ::capnproto::REFERENCES, %d * ::capnproto::REFERENCES" byteOffset byteSize p ps \%d * ::capnproto::POINTERS, %d * ::capnproto::POINTERS" byteOffset byteSize p ps
isDefaultZero VoidDesc = True isDefaultZero VoidDesc = True
isDefaultZero (BoolDesc b) = not b isDefaultZero (BoolDesc b) = not b
...@@ -473,7 +473,7 @@ outerFileContext schemaNodes = fileContext where ...@@ -473,7 +473,7 @@ outerFileContext schemaNodes = fileContext where
context "structFields" = MuList $ map (fieldContext context) $ structFields desc context "structFields" = MuList $ map (fieldContext context) $ structFields desc
context "structUnions" = MuList $ map (unionContext context) $ structUnions desc context "structUnions" = MuList $ map (unionContext context) $ structUnions desc
context "structDataSize" = MuVariable $ dataSectionWordSize $ structDataSize desc context "structDataSize" = MuVariable $ dataSectionWordSize $ structDataSize desc
context "structReferenceCount" = MuVariable $ structPointerCount desc context "structPointerCount" = MuVariable $ structPointerCount desc
context "structPreferredListEncoding" = case (structDataSize desc, structPointerCount desc) of context "structPreferredListEncoding" = case (structDataSize desc, structPointerCount desc) of
(DataSectionWords 0, 0) -> MuVariable "VOID" (DataSectionWords 0, 0) -> MuVariable "VOID"
(DataSection1, 0) -> MuVariable "BIT" (DataSection1, 0) -> MuVariable "BIT"
...@@ -481,7 +481,7 @@ outerFileContext schemaNodes = fileContext where ...@@ -481,7 +481,7 @@ outerFileContext schemaNodes = fileContext where
(DataSection16, 0) -> MuVariable "TWO_BYTES" (DataSection16, 0) -> MuVariable "TWO_BYTES"
(DataSection32, 0) -> MuVariable "FOUR_BYTES" (DataSection32, 0) -> MuVariable "FOUR_BYTES"
(DataSectionWords 1, 0) -> MuVariable "EIGHT_BYTES" (DataSectionWords 1, 0) -> MuVariable "EIGHT_BYTES"
(DataSectionWords 0, 1) -> MuVariable "REFERENCE" (DataSectionWords 0, 1) -> MuVariable "POINTER"
_ -> MuVariable "INLINE_COMPOSITE" _ -> MuVariable "INLINE_COMPOSITE"
context "structNestedEnums" = context "structNestedEnums" =
MuList $ map (enumContext context) [m | DescEnum m <- structMembers desc] MuList $ map (enumContext context) [m | DescEnum m <- structMembers desc]
......
...@@ -272,12 +272,12 @@ dataSizeInBits Size64 = 64 ...@@ -272,12 +272,12 @@ dataSizeInBits Size64 = 64
data FieldSize = SizeVoid data FieldSize = SizeVoid
| SizeData DataSize | SizeData DataSize
| SizeReference | SizePointer
| SizeInlineComposite DataSectionSize Integer | SizeInlineComposite DataSectionSize Integer
fieldSizeInBits SizeVoid = 0 fieldSizeInBits SizeVoid = 0
fieldSizeInBits (SizeData d) = dataSizeInBits d fieldSizeInBits (SizeData d) = dataSizeInBits d
fieldSizeInBits SizeReference = 64 fieldSizeInBits SizePointer = 64
fieldSizeInBits (SizeInlineComposite ds pc) = dataSectionBits ds + pc * 64 fieldSizeInBits (SizeInlineComposite ds pc) = dataSectionBits ds + pc * 64
data FieldOffset = VoidOffset data FieldOffset = VoidOffset
...@@ -293,7 +293,7 @@ data FieldOffset = VoidOffset ...@@ -293,7 +293,7 @@ data FieldOffset = VoidOffset
offsetToSize :: FieldOffset -> FieldSize offsetToSize :: FieldOffset -> FieldSize
offsetToSize VoidOffset = SizeVoid offsetToSize VoidOffset = SizeVoid
offsetToSize (DataOffset s _) = SizeData s offsetToSize (DataOffset s _) = SizeData s
offsetToSize (PointerOffset _) = SizeReference offsetToSize (PointerOffset _) = SizePointer
offsetToSize (InlineCompositeOffset _ _ d p) = SizeInlineComposite d p offsetToSize (InlineCompositeOffset _ _ d p) = SizeInlineComposite d p
fieldSize (BuiltinType BuiltinVoid) = SizeVoid fieldSize (BuiltinType BuiltinVoid) = SizeVoid
...@@ -308,15 +308,15 @@ fieldSize (BuiltinType BuiltinUInt32) = SizeData Size32 ...@@ -308,15 +308,15 @@ fieldSize (BuiltinType BuiltinUInt32) = SizeData Size32
fieldSize (BuiltinType BuiltinUInt64) = SizeData Size64 fieldSize (BuiltinType BuiltinUInt64) = SizeData Size64
fieldSize (BuiltinType BuiltinFloat32) = SizeData Size32 fieldSize (BuiltinType BuiltinFloat32) = SizeData Size32
fieldSize (BuiltinType BuiltinFloat64) = SizeData Size64 fieldSize (BuiltinType BuiltinFloat64) = SizeData Size64
fieldSize (BuiltinType BuiltinText) = SizeReference fieldSize (BuiltinType BuiltinText) = SizePointer
fieldSize (BuiltinType BuiltinData) = SizeReference fieldSize (BuiltinType BuiltinData) = SizePointer
fieldSize (BuiltinType BuiltinObject) = SizeReference fieldSize (BuiltinType BuiltinObject) = SizePointer
fieldSize (EnumType _) = SizeData Size16 fieldSize (EnumType _) = SizeData Size16
fieldSize (StructType _) = SizeReference fieldSize (StructType _) = SizePointer
fieldSize (InlineStructType StructDesc { structDataSize = ds, structPointerCount = ps }) = fieldSize (InlineStructType StructDesc { structDataSize = ds, structPointerCount = ps }) =
SizeInlineComposite ds ps SizeInlineComposite ds ps
fieldSize (InterfaceType _) = SizeReference fieldSize (InterfaceType _) = SizePointer
fieldSize (ListType _) = SizeReference fieldSize (ListType _) = SizePointer
fieldSize (InlineListType element size) = let fieldSize (InlineListType element size) = let
minDataSectionForBits bits minDataSectionForBits bits
| bits <= 0 = DataSectionWords 0 | bits <= 0 = DataSectionWords 0
...@@ -328,12 +328,12 @@ fieldSize (InlineListType element size) = let ...@@ -328,12 +328,12 @@ fieldSize (InlineListType element size) = let
dataSection = case fieldSize element of dataSection = case fieldSize element of
SizeVoid -> DataSectionWords 0 SizeVoid -> DataSectionWords 0
SizeData s -> minDataSectionForBits $ dataSizeInBits s * size SizeData s -> minDataSectionForBits $ dataSizeInBits s * size
SizeReference -> DataSectionWords 0 SizePointer -> DataSectionWords 0
SizeInlineComposite ds _ -> minDataSectionForBits $ dataSectionBits ds * size SizeInlineComposite ds _ -> minDataSectionForBits $ dataSectionBits ds * size
pointerCount = case fieldSize element of pointerCount = case fieldSize element of
SizeVoid -> 0 SizeVoid -> 0
SizeData _ -> 0 SizeData _ -> 0
SizeReference -> size SizePointer -> size
SizeInlineComposite _ pc -> pc * size SizeInlineComposite _ pc -> pc * size
in SizeInlineComposite dataSection pointerCount in SizeInlineComposite dataSection pointerCount
fieldSize (InlineDataType size) fieldSize (InlineDataType size)
......
This diff is collapsed.
...@@ -113,7 +113,7 @@ namespace internal { ...@@ -113,7 +113,7 @@ namespace internal {
{{#typeStruct}} {{#typeStruct}}
CAPNPROTO_DECLARE_STRUCT( CAPNPROTO_DECLARE_STRUCT(
::{{#fileNamespaces}}{{namespaceName}}::{{/fileNamespaces}}{{typeFullName}}, {{structId}}, ::{{#fileNamespaces}}{{namespaceName}}::{{/fileNamespaces}}{{typeFullName}}, {{structId}},
{{structDataSize}}, {{structReferenceCount}}, {{structPreferredListEncoding}}); {{structDataSize}}, {{structPointerCount}}, {{structPreferredListEncoding}});
{{#structNestedEnums}} {{#structNestedEnums}}
CAPNPROTO_DECLARE_ENUM( CAPNPROTO_DECLARE_ENUM(
::{{#fileNamespaces}}{{namespaceName}}::{{/fileNamespaces}}{{typeFullName}}::{{enumName}}, {{enumId}}); ::{{#fileNamespaces}}{{namespaceName}}::{{/fileNamespaces}}{{typeFullName}}::{{enumName}}, {{enumId}});
...@@ -302,7 +302,7 @@ inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() { ...@@ -302,7 +302,7 @@ inline {{fieldType}}::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
"Must check which() before get()ing a union member."); "Must check which() before get()ing a union member.");
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<{{fieldType}}>::get( return ::capnproto::internal::PointerHelpers<{{fieldType}}>::get(
_reader, {{fieldOffset}} * ::capnproto::REFERENCES{{#fieldDefaultBytes}}, _reader, {{fieldOffset}} * ::capnproto::POINTERS{{#fieldDefaultBytes}},
DEFAULT_{{fieldUpperCase}}.words{{#fieldIsBlob}}, {{defaultBlobSize}}{{/fieldIsBlob}}{{/fieldDefaultBytes}}); DEFAULT_{{fieldUpperCase}}.words{{#fieldIsBlob}}, {{defaultBlobSize}}{{/fieldIsBlob}}{{/fieldDefaultBytes}});
} }
...@@ -312,7 +312,7 @@ inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() ...@@ -312,7 +312,7 @@ inline {{fieldType}}::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}()
"Must check which() before get()ing a union member."); "Must check which() before get()ing a union member.");
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<{{fieldType}}>::get( return ::capnproto::internal::PointerHelpers<{{fieldType}}>::get(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES{{#fieldDefaultBytes}}, _builder, {{fieldOffset}} * ::capnproto::POINTERS{{#fieldDefaultBytes}},
DEFAULT_{{fieldUpperCase}}.words{{#fieldIsBlob}}, {{defaultBlobSize}}{{/fieldIsBlob}}{{/fieldDefaultBytes}}); DEFAULT_{{fieldUpperCase}}.words{{#fieldIsBlob}}, {{defaultBlobSize}}{{/fieldIsBlob}}{{/fieldDefaultBytes}});
} }
...@@ -322,7 +322,7 @@ inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}({{fieldType}}::Read ...@@ -322,7 +322,7 @@ inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}({{fieldType}}::Read
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}}); {{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}} {{/fieldUnion}}
::capnproto::internal::PointerHelpers<{{fieldType}}>::set( ::capnproto::internal::PointerHelpers<{{fieldType}}>::set(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, value); _builder, {{fieldOffset}} * ::capnproto::POINTERS, value);
} }
{{#fieldIsList}} {{#fieldIsList}}
...@@ -333,7 +333,7 @@ inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}( ...@@ -333,7 +333,7 @@ inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}}); {{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}} {{/fieldUnion}}
::capnproto::internal::PointerHelpers<{{fieldType}}>::set( ::capnproto::internal::PointerHelpers<{{fieldType}}>::set(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, value); _builder, {{fieldOffset}} * ::capnproto::POINTERS, value);
} }
{{/fieldIsList}} {{/fieldIsList}}
...@@ -344,7 +344,7 @@ inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}( ...@@ -344,7 +344,7 @@ inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}}); {{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<{{fieldType}}>::init( return ::capnproto::internal::PointerHelpers<{{fieldType}}>::init(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, size); _builder, {{fieldOffset}} * ::capnproto::POINTERS, size);
} }
{{/fieldIsListOrBlob}} {{/fieldIsListOrBlob}}
...@@ -355,7 +355,7 @@ inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}( ...@@ -355,7 +355,7 @@ inline {{fieldType}}::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}}); {{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<{{fieldType}}>::init( return ::capnproto::internal::PointerHelpers<{{fieldType}}>::init(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES); _builder, {{fieldOffset}} * ::capnproto::POINTERS);
} }
{{/fieldIsStruct}} {{/fieldIsStruct}}
...@@ -370,7 +370,7 @@ inline typename T::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() { ...@@ -370,7 +370,7 @@ inline typename T::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}() {
"Must check which() before get()ing a union member."); "Must check which() before get()ing a union member.");
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<T>::get( return ::capnproto::internal::PointerHelpers<T>::get(
_reader, {{fieldOffset}} * ::capnproto::REFERENCES); _reader, {{fieldOffset}} * ::capnproto::POINTERS);
} }
template <typename T> template <typename T>
...@@ -380,7 +380,7 @@ inline typename T::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() { ...@@ -380,7 +380,7 @@ inline typename T::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}() {
"Must check which() before get()ing a union member."); "Must check which() before get()ing a union member.");
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<T>::get( return ::capnproto::internal::PointerHelpers<T>::get(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES); _builder, {{fieldOffset}} * ::capnproto::POINTERS);
} }
template <typename T, typename Param> template <typename T, typename Param>
...@@ -390,7 +390,7 @@ inline typename T::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}(Param& ...@@ -390,7 +390,7 @@ inline typename T::Reader {{typeFullName}}::Reader::get{{fieldTitleCase}}(Param&
"Must check which() before get()ing a union member."); "Must check which() before get()ing a union member.");
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<T>::getDynamic( return ::capnproto::internal::PointerHelpers<T>::getDynamic(
_reader, {{fieldOffset}} * ::capnproto::REFERENCES, ::capnproto::forward<Param>(param)); _reader, {{fieldOffset}} * ::capnproto::POINTERS, ::capnproto::forward<Param>(param));
} }
template <typename T, typename Param> template <typename T, typename Param>
...@@ -400,7 +400,7 @@ inline typename T::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}(Para ...@@ -400,7 +400,7 @@ inline typename T::Builder {{typeFullName}}::Builder::get{{fieldTitleCase}}(Para
"Must check which() before get()ing a union member."); "Must check which() before get()ing a union member.");
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<T>::getDynamic( return ::capnproto::internal::PointerHelpers<T>::getDynamic(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, ::capnproto::forward<Param>(param)); _builder, {{fieldOffset}} * ::capnproto::POINTERS, ::capnproto::forward<Param>(param));
} }
template <typename T> template <typename T>
...@@ -410,7 +410,7 @@ inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(typename T::Reader ...@@ -410,7 +410,7 @@ inline void {{typeFullName}}::Builder::set{{fieldTitleCase}}(typename T::Reader
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}}); {{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}} {{/fieldUnion}}
::capnproto::internal::PointerHelpers<T>::set( ::capnproto::internal::PointerHelpers<T>::set(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, value); _builder, {{fieldOffset}} * ::capnproto::POINTERS, value);
} }
template <typename T, typename... Params> template <typename T, typename... Params>
...@@ -420,7 +420,7 @@ inline typename T::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(Par ...@@ -420,7 +420,7 @@ inline typename T::Builder {{typeFullName}}::Builder::init{{fieldTitleCase}}(Par
{{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}}); {{unionTagOffset}} * ::capnproto::ELEMENTS, {{unionTitleCase}}::{{fieldUpperCase}});
{{/fieldUnion}} {{/fieldUnion}}
return ::capnproto::internal::PointerHelpers<T>::init( return ::capnproto::internal::PointerHelpers<T>::init(
_builder, {{fieldOffset}} * ::capnproto::REFERENCES, ::capnproto::forward<Params>(params)...); _builder, {{fieldOffset}} * ::capnproto::POINTERS, ::capnproto::forward<Params>(params)...);
} }
{{/fieldIsGenericObject}} {{/fieldIsGenericObject}}
......
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