Commit db7ca960 authored by Kenton Varda's avatar Kenton Varda

Fixes #219, with POSSIBLE (but obscure) WIRE FORMAT BREAKAGE.

Unfortunately, the layout algorithm had a bug which caused incorrect layout when declaring a union whose lowest-ordinal field was of type Void and nested in an inner union. That is:

    union {
      a :union {
        b @0 :Void
        ...
      }
      ...
    }

In this case, all the fields in the struct after the Void field -- including both unions' discriminants -- would end up misplaced. Although they did not end up overlapping (and therefore the incorrect layout "worked"), the result broke schema evolution rules around "retroactive unionization".

Unfortunately, we must break compatibility with any protocol that happened to contain the above pattern. Luckily, it's a fairly obscure case. Unluckily, Cap'n Proto's own schema format contains such a pattern. Luckily, the use of this pattern was introduced in v0.6.x and therefore has not been in any release build so far.
parent 1d0b60c8
...@@ -427,15 +427,25 @@ public: ...@@ -427,15 +427,25 @@ public:
inline Group(Union& parent): parent(parent) {} inline Group(Union& parent): parent(parent) {}
KJ_DISALLOW_COPY(Group); KJ_DISALLOW_COPY(Group);
void addVoid() override { void addMember() {
if (!hasMembers) { if (!hasMembers) {
hasMembers = true; hasMembers = true;
parent.newGroupAddingFirstMember(); parent.newGroupAddingFirstMember();
} }
} }
void addVoid() override {
addMember();
// Make sure that if this is a member of a union which is in turn a member of another union,
// that we let the outer union know that a field is being added, even though it is a
// zero-size field. This is important because the union needs to allocate its discriminant
// just before its second member is added.
parent.parent.addVoid();
}
uint addData(uint lgSize) override { uint addData(uint lgSize) override {
addVoid(); addMember();
uint bestSize = kj::maxValue; uint bestSize = kj::maxValue;
kj::Maybe<uint> bestLocation = nullptr; kj::Maybe<uint> bestLocation = nullptr;
...@@ -476,7 +486,7 @@ public: ...@@ -476,7 +486,7 @@ public:
} }
uint addPointer() override { uint addPointer() override {
addVoid(); addMember();
if (parentPointerLocationUsage < parent.pointerLocations.size()) { if (parentPointerLocationUsage < parent.pointerLocations.size()) {
return parent.pointerLocations[parentPointerLocationUsage++]; return parent.pointerLocations[parentPointerLocationUsage++];
......
...@@ -1228,6 +1228,22 @@ TEST(Encoding, UpgradeListInBuilder) { ...@@ -1228,6 +1228,22 @@ TEST(Encoding, UpgradeListInBuilder) {
EXPECT_NONFATAL_FAILURE(root.getAnyPointerField().getAs<List<Text>>()); EXPECT_NONFATAL_FAILURE(root.getAnyPointerField().getAs<List<Text>>());
} }
TEST(Encoding, UpgradeUnion) {
// This tests for a specific case that was broken originally.
MallocMessageBuilder builder;
{
auto root = builder.getRoot<test::TestOldUnionVersion>();
root.setB(123);
}
{
auto root = builder.getRoot<test::TestNewUnionVersion>();
ASSERT_TRUE(root.isB())
EXPECT_EQ(123, root.getB());
}
}
// ======================================================================================= // =======================================================================================
// Tests of generated code, not really of the encoding. // Tests of generated code, not really of the encoding.
// TODO(cleanup): Move to a different test? // TODO(cleanup): Move to a different test?
......
...@@ -1550,7 +1550,7 @@ const ::capnp::_::RawSchema s_9500cce23b334d80 = { ...@@ -1550,7 +1550,7 @@ const ::capnp::_::RawSchema s_9500cce23b334d80 = {
static const ::capnp::_::AlignedData<255> b_d07378ede1f9cc60 = { static const ::capnp::_::AlignedData<255> b_d07378ede1f9cc60 = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
96, 204, 249, 225, 237, 120, 115, 208, 96, 204, 249, 225, 237, 120, 115, 208,
19, 0, 0, 0, 1, 0, 2, 0, 19, 0, 0, 0, 1, 0, 3, 0,
217, 114, 76, 98, 9, 197, 63, 169, 217, 114, 76, 98, 9, 197, 63, 169,
1, 0, 7, 0, 0, 0, 19, 0, 1, 0, 7, 0, 0, 0, 19, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -1823,7 +1823,7 @@ const ::capnp::_::RawSchema s_d07378ede1f9cc60 = { ...@@ -1823,7 +1823,7 @@ const ::capnp::_::RawSchema s_d07378ede1f9cc60 = {
static const ::capnp::_::AlignedData<32> b_87e739250a60ea97 = { static const ::capnp::_::AlignedData<32> b_87e739250a60ea97 = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
151, 234, 96, 10, 37, 57, 231, 135, 151, 234, 96, 10, 37, 57, 231, 135,
24, 0, 0, 0, 1, 0, 2, 0, 24, 0, 0, 0, 1, 0, 3, 0,
96, 204, 249, 225, 237, 120, 115, 208, 96, 204, 249, 225, 237, 120, 115, 208,
1, 0, 7, 0, 1, 0, 0, 0, 1, 0, 7, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -1869,7 +1869,7 @@ const ::capnp::_::RawSchema s_87e739250a60ea97 = { ...@@ -1869,7 +1869,7 @@ const ::capnp::_::RawSchema s_87e739250a60ea97 = {
static const ::capnp::_::AlignedData<45> b_9e0e78711a7f87a9 = { static const ::capnp::_::AlignedData<45> b_9e0e78711a7f87a9 = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
169, 135, 127, 26, 113, 120, 14, 158, 169, 135, 127, 26, 113, 120, 14, 158,
24, 0, 0, 0, 1, 0, 2, 0, 24, 0, 0, 0, 1, 0, 3, 0,
96, 204, 249, 225, 237, 120, 115, 208, 96, 204, 249, 225, 237, 120, 115, 208,
1, 0, 7, 0, 1, 0, 0, 0, 1, 0, 7, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -1929,7 +1929,7 @@ const ::capnp::_::RawSchema s_9e0e78711a7f87a9 = { ...@@ -1929,7 +1929,7 @@ const ::capnp::_::RawSchema s_9e0e78711a7f87a9 = {
static const ::capnp::_::AlignedData<45> b_ac3a6f60ef4cc6d3 = { static const ::capnp::_::AlignedData<45> b_ac3a6f60ef4cc6d3 = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
211, 198, 76, 239, 96, 111, 58, 172, 211, 198, 76, 239, 96, 111, 58, 172,
24, 0, 0, 0, 1, 0, 2, 0, 24, 0, 0, 0, 1, 0, 3, 0,
96, 204, 249, 225, 237, 120, 115, 208, 96, 204, 249, 225, 237, 120, 115, 208,
1, 0, 7, 0, 1, 0, 0, 0, 1, 0, 7, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -1989,7 +1989,7 @@ const ::capnp::_::RawSchema s_ac3a6f60ef4cc6d3 = { ...@@ -1989,7 +1989,7 @@ const ::capnp::_::RawSchema s_ac3a6f60ef4cc6d3 = {
static const ::capnp::_::AlignedData<46> b_ed8bca69f7fb0cbf = { static const ::capnp::_::AlignedData<46> b_ed8bca69f7fb0cbf = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
191, 12, 251, 247, 105, 202, 139, 237, 191, 12, 251, 247, 105, 202, 139, 237,
24, 0, 0, 0, 1, 0, 2, 0, 24, 0, 0, 0, 1, 0, 3, 0,
96, 204, 249, 225, 237, 120, 115, 208, 96, 204, 249, 225, 237, 120, 115, 208,
1, 0, 7, 0, 1, 0, 0, 0, 1, 0, 7, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -2050,10 +2050,10 @@ const ::capnp::_::RawSchema s_ed8bca69f7fb0cbf = { ...@@ -2050,10 +2050,10 @@ const ::capnp::_::RawSchema s_ed8bca69f7fb0cbf = {
static const ::capnp::_::AlignedData<46> b_c2573fe8a23e49f1 = { static const ::capnp::_::AlignedData<46> b_c2573fe8a23e49f1 = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
241, 73, 62, 162, 232, 63, 87, 194, 241, 73, 62, 162, 232, 63, 87, 194,
24, 0, 0, 0, 1, 0, 2, 0, 24, 0, 0, 0, 1, 0, 3, 0,
96, 204, 249, 225, 237, 120, 115, 208, 96, 204, 249, 225, 237, 120, 115, 208,
1, 0, 7, 0, 1, 0, 3, 0, 1, 0, 7, 0, 1, 0, 3, 0,
2, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0,
21, 0, 0, 0, 26, 1, 0, 0, 21, 0, 0, 0, 26, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -2113,10 +2113,10 @@ const ::capnp::_::RawSchema s_c2573fe8a23e49f1 = { ...@@ -2113,10 +2113,10 @@ const ::capnp::_::RawSchema s_c2573fe8a23e49f1 = {
static const ::capnp::_::AlignedData<77> b_8e3b5f79fe593656 = { static const ::capnp::_::AlignedData<77> b_8e3b5f79fe593656 = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
86, 54, 89, 254, 121, 95, 59, 142, 86, 54, 89, 254, 121, 95, 59, 142,
35, 0, 0, 0, 1, 0, 2, 0, 35, 0, 0, 0, 1, 0, 3, 0,
241, 73, 62, 162, 232, 63, 87, 194, 241, 73, 62, 162, 232, 63, 87, 194,
1, 0, 7, 0, 1, 0, 4, 0, 1, 0, 7, 0, 1, 0, 4, 0,
1, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0,
21, 0, 0, 0, 138, 1, 0, 0, 21, 0, 0, 0, 138, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -2204,7 +2204,7 @@ const ::capnp::_::RawSchema s_8e3b5f79fe593656 = { ...@@ -2204,7 +2204,7 @@ const ::capnp::_::RawSchema s_8e3b5f79fe593656 = {
static const ::capnp::_::AlignedData<48> b_9dd1f724f4614a85 = { static const ::capnp::_::AlignedData<48> b_9dd1f724f4614a85 = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
133, 74, 97, 244, 36, 247, 209, 157, 133, 74, 97, 244, 36, 247, 209, 157,
35, 0, 0, 0, 1, 0, 2, 0, 35, 0, 0, 0, 1, 0, 3, 0,
241, 73, 62, 162, 232, 63, 87, 194, 241, 73, 62, 162, 232, 63, 87, 194,
1, 0, 7, 0, 1, 0, 0, 0, 1, 0, 7, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -2221,14 +2221,14 @@ static const ::capnp::_::AlignedData<48> b_9dd1f724f4614a85 = { ...@@ -2221,14 +2221,14 @@ static const ::capnp::_::AlignedData<48> b_9dd1f724f4614a85 = {
101, 114, 46, 112, 97, 114, 97, 109, 101, 114, 46, 112, 97, 114, 97, 109,
101, 116, 101, 114, 0, 0, 0, 0, 101, 116, 101, 114, 0, 0, 0, 0,
8, 0, 0, 0, 3, 0, 4, 0, 8, 0, 0, 0, 3, 0, 4, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0,
0, 0, 1, 0, 19, 0, 0, 0, 0, 0, 1, 0, 19, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 66, 0, 0, 0, 41, 0, 0, 0, 66, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
36, 0, 0, 0, 2, 0, 1, 0, 36, 0, 0, 0, 2, 0, 1, 0,
44, 0, 0, 0, 2, 0, 1, 0, 44, 0, 0, 0, 2, 0, 1, 0,
1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 5, 0, 0, 0,
0, 0, 1, 0, 20, 0, 0, 0, 0, 0, 1, 0, 20, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
41, 0, 0, 0, 122, 0, 0, 0, 41, 0, 0, 0, 122, 0, 0, 0,
...@@ -2266,7 +2266,7 @@ const ::capnp::_::RawSchema s_9dd1f724f4614a85 = { ...@@ -2266,7 +2266,7 @@ const ::capnp::_::RawSchema s_9dd1f724f4614a85 = {
static const ::capnp::_::AlignedData<36> b_baefc9120c56e274 = { static const ::capnp::_::AlignedData<36> b_baefc9120c56e274 = {
{ 0, 0, 0, 0, 5, 0, 6, 0, { 0, 0, 0, 0, 5, 0, 6, 0,
116, 226, 86, 12, 18, 201, 239, 186, 116, 226, 86, 12, 18, 201, 239, 186,
35, 0, 0, 0, 1, 0, 2, 0, 35, 0, 0, 0, 1, 0, 3, 0,
241, 73, 62, 162, 232, 63, 87, 194, 241, 73, 62, 162, 232, 63, 87, 194,
1, 0, 7, 0, 1, 0, 0, 0, 1, 0, 7, 0, 1, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
...@@ -2285,7 +2285,7 @@ static const ::capnp::_::AlignedData<36> b_baefc9120c56e274 = { ...@@ -2285,7 +2285,7 @@ static const ::capnp::_::AlignedData<36> b_baefc9120c56e274 = {
100, 80, 97, 114, 97, 109, 101, 116, 100, 80, 97, 114, 97, 109, 101, 116,
101, 114, 0, 0, 0, 0, 0, 0, 101, 114, 0, 0, 0, 0, 0, 0,
4, 0, 0, 0, 3, 0, 4, 0, 4, 0, 0, 0, 3, 0, 4, 0,
0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0,
0, 0, 1, 0, 24, 0, 0, 0, 0, 0, 1, 0, 24, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
13, 0, 0, 0, 122, 0, 0, 0, 13, 0, 0, 0, 122, 0, 0, 0,
......
...@@ -352,7 +352,7 @@ struct Type { ...@@ -352,7 +352,7 @@ struct Type {
struct AnyPointer; struct AnyPointer;
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(d07378ede1f9cc60, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(d07378ede1f9cc60, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -367,7 +367,7 @@ struct Type::List { ...@@ -367,7 +367,7 @@ struct Type::List {
class Pipeline; class Pipeline;
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(87e739250a60ea97, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(87e739250a60ea97, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -382,7 +382,7 @@ struct Type::Enum { ...@@ -382,7 +382,7 @@ struct Type::Enum {
class Pipeline; class Pipeline;
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(9e0e78711a7f87a9, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(9e0e78711a7f87a9, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -397,7 +397,7 @@ struct Type::Struct { ...@@ -397,7 +397,7 @@ struct Type::Struct {
class Pipeline; class Pipeline;
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(ac3a6f60ef4cc6d3, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(ac3a6f60ef4cc6d3, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -412,7 +412,7 @@ struct Type::Interface { ...@@ -412,7 +412,7 @@ struct Type::Interface {
class Pipeline; class Pipeline;
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(ed8bca69f7fb0cbf, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(ed8bca69f7fb0cbf, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -435,7 +435,7 @@ struct Type::AnyPointer { ...@@ -435,7 +435,7 @@ struct Type::AnyPointer {
struct ImplicitMethodParameter; struct ImplicitMethodParameter;
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(c2573fe8a23e49f1, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(c2573fe8a23e49f1, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -456,7 +456,7 @@ struct Type::AnyPointer::Unconstrained { ...@@ -456,7 +456,7 @@ struct Type::AnyPointer::Unconstrained {
}; };
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(8e3b5f79fe593656, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(8e3b5f79fe593656, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -471,7 +471,7 @@ struct Type::AnyPointer::Parameter { ...@@ -471,7 +471,7 @@ struct Type::AnyPointer::Parameter {
class Pipeline; class Pipeline;
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(9dd1f724f4614a85, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(9dd1f724f4614a85, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -486,7 +486,7 @@ struct Type::AnyPointer::ImplicitMethodParameter { ...@@ -486,7 +486,7 @@ struct Type::AnyPointer::ImplicitMethodParameter {
class Pipeline; class Pipeline;
struct _capnpPrivate { struct _capnpPrivate {
CAPNP_DECLARE_STRUCT_HEADER(baefc9120c56e274, 2, 1) CAPNP_DECLARE_STRUCT_HEADER(baefc9120c56e274, 3, 1)
#if !CAPNP_LITE #if !CAPNP_LITE
static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand; static constexpr ::capnp::_::RawBrandedSchema const* brand = &schema->defaultBrand;
#endif // !CAPNP_LITE #endif // !CAPNP_LITE
...@@ -6061,9 +6061,9 @@ inline Type::AnyPointer::Builder Type::Builder::getAnyPointer() { ...@@ -6061,9 +6061,9 @@ inline Type::AnyPointer::Builder Type::Builder::getAnyPointer() {
inline Type::AnyPointer::Builder Type::Builder::initAnyPointer() { inline Type::AnyPointer::Builder Type::Builder::initAnyPointer() {
_builder.setDataField<Type::Which>( _builder.setDataField<Type::Which>(
0 * ::capnp::ELEMENTS, Type::ANY_POINTER); 0 * ::capnp::ELEMENTS, Type::ANY_POINTER);
_builder.setDataField< ::uint16_t>(1 * ::capnp::ELEMENTS, 0); _builder.setDataField< ::uint16_t>(4 * ::capnp::ELEMENTS, 0);
_builder.setDataField< ::uint16_t>(2 * ::capnp::ELEMENTS, 0); _builder.setDataField< ::uint16_t>(5 * ::capnp::ELEMENTS, 0);
_builder.setDataField< ::uint64_t>(1 * ::capnp::ELEMENTS, 0); _builder.setDataField< ::uint64_t>(2 * ::capnp::ELEMENTS, 0);
return Type::AnyPointer::Builder(_builder); return Type::AnyPointer::Builder(_builder);
} }
inline bool Type::List::Reader::hasElementType() const { inline bool Type::List::Reader::hasElementType() const {
...@@ -6257,10 +6257,10 @@ inline ::capnp::Orphan< ::capnp::schema::Brand> Type::Interface::Builder::disown ...@@ -6257,10 +6257,10 @@ inline ::capnp::Orphan< ::capnp::schema::Brand> Type::Interface::Builder::disown
} }
inline ::capnp::schema::Type::AnyPointer::Which Type::AnyPointer::Reader::which() const { inline ::capnp::schema::Type::AnyPointer::Which Type::AnyPointer::Reader::which() const {
return _reader.getDataField<Which>(2 * ::capnp::ELEMENTS); return _reader.getDataField<Which>(4 * ::capnp::ELEMENTS);
} }
inline ::capnp::schema::Type::AnyPointer::Which Type::AnyPointer::Builder::which() { inline ::capnp::schema::Type::AnyPointer::Which Type::AnyPointer::Builder::which() {
return _builder.getDataField<Which>(2 * ::capnp::ELEMENTS); return _builder.getDataField<Which>(4 * ::capnp::ELEMENTS);
} }
inline bool Type::AnyPointer::Reader::isUnconstrained() const { inline bool Type::AnyPointer::Reader::isUnconstrained() const {
...@@ -6281,8 +6281,8 @@ inline Type::AnyPointer::Unconstrained::Builder Type::AnyPointer::Builder::getUn ...@@ -6281,8 +6281,8 @@ inline Type::AnyPointer::Unconstrained::Builder Type::AnyPointer::Builder::getUn
} }
inline Type::AnyPointer::Unconstrained::Builder Type::AnyPointer::Builder::initUnconstrained() { inline Type::AnyPointer::Unconstrained::Builder Type::AnyPointer::Builder::initUnconstrained() {
_builder.setDataField<Type::AnyPointer::Which>( _builder.setDataField<Type::AnyPointer::Which>(
2 * ::capnp::ELEMENTS, Type::AnyPointer::UNCONSTRAINED); 4 * ::capnp::ELEMENTS, Type::AnyPointer::UNCONSTRAINED);
_builder.setDataField< ::uint16_t>(1 * ::capnp::ELEMENTS, 0); _builder.setDataField< ::uint16_t>(5 * ::capnp::ELEMENTS, 0);
return Type::AnyPointer::Unconstrained::Builder(_builder); return Type::AnyPointer::Unconstrained::Builder(_builder);
} }
inline bool Type::AnyPointer::Reader::isParameter() const { inline bool Type::AnyPointer::Reader::isParameter() const {
...@@ -6303,9 +6303,9 @@ inline Type::AnyPointer::Parameter::Builder Type::AnyPointer::Builder::getParame ...@@ -6303,9 +6303,9 @@ inline Type::AnyPointer::Parameter::Builder Type::AnyPointer::Builder::getParame
} }
inline Type::AnyPointer::Parameter::Builder Type::AnyPointer::Builder::initParameter() { inline Type::AnyPointer::Parameter::Builder Type::AnyPointer::Builder::initParameter() {
_builder.setDataField<Type::AnyPointer::Which>( _builder.setDataField<Type::AnyPointer::Which>(
2 * ::capnp::ELEMENTS, Type::AnyPointer::PARAMETER); 4 * ::capnp::ELEMENTS, Type::AnyPointer::PARAMETER);
_builder.setDataField< ::uint16_t>(1 * ::capnp::ELEMENTS, 0); _builder.setDataField< ::uint16_t>(5 * ::capnp::ELEMENTS, 0);
_builder.setDataField< ::uint64_t>(1 * ::capnp::ELEMENTS, 0); _builder.setDataField< ::uint64_t>(2 * ::capnp::ELEMENTS, 0);
return Type::AnyPointer::Parameter::Builder(_builder); return Type::AnyPointer::Parameter::Builder(_builder);
} }
inline bool Type::AnyPointer::Reader::isImplicitMethodParameter() const { inline bool Type::AnyPointer::Reader::isImplicitMethodParameter() const {
...@@ -6326,15 +6326,15 @@ inline Type::AnyPointer::ImplicitMethodParameter::Builder Type::AnyPointer::Buil ...@@ -6326,15 +6326,15 @@ inline Type::AnyPointer::ImplicitMethodParameter::Builder Type::AnyPointer::Buil
} }
inline Type::AnyPointer::ImplicitMethodParameter::Builder Type::AnyPointer::Builder::initImplicitMethodParameter() { inline Type::AnyPointer::ImplicitMethodParameter::Builder Type::AnyPointer::Builder::initImplicitMethodParameter() {
_builder.setDataField<Type::AnyPointer::Which>( _builder.setDataField<Type::AnyPointer::Which>(
2 * ::capnp::ELEMENTS, Type::AnyPointer::IMPLICIT_METHOD_PARAMETER); 4 * ::capnp::ELEMENTS, Type::AnyPointer::IMPLICIT_METHOD_PARAMETER);
_builder.setDataField< ::uint16_t>(1 * ::capnp::ELEMENTS, 0); _builder.setDataField< ::uint16_t>(5 * ::capnp::ELEMENTS, 0);
return Type::AnyPointer::ImplicitMethodParameter::Builder(_builder); return Type::AnyPointer::ImplicitMethodParameter::Builder(_builder);
} }
inline ::capnp::schema::Type::AnyPointer::Unconstrained::Which Type::AnyPointer::Unconstrained::Reader::which() const { inline ::capnp::schema::Type::AnyPointer::Unconstrained::Which Type::AnyPointer::Unconstrained::Reader::which() const {
return _reader.getDataField<Which>(1 * ::capnp::ELEMENTS); return _reader.getDataField<Which>(5 * ::capnp::ELEMENTS);
} }
inline ::capnp::schema::Type::AnyPointer::Unconstrained::Which Type::AnyPointer::Unconstrained::Builder::which() { inline ::capnp::schema::Type::AnyPointer::Unconstrained::Which Type::AnyPointer::Unconstrained::Builder::which() {
return _builder.getDataField<Which>(1 * ::capnp::ELEMENTS); return _builder.getDataField<Which>(5 * ::capnp::ELEMENTS);
} }
inline bool Type::AnyPointer::Unconstrained::Reader::isAnyKind() const { inline bool Type::AnyPointer::Unconstrained::Reader::isAnyKind() const {
...@@ -6358,7 +6358,7 @@ inline ::capnp::Void Type::AnyPointer::Unconstrained::Builder::getAnyKind() { ...@@ -6358,7 +6358,7 @@ inline ::capnp::Void Type::AnyPointer::Unconstrained::Builder::getAnyKind() {
} }
inline void Type::AnyPointer::Unconstrained::Builder::setAnyKind( ::capnp::Void value) { inline void Type::AnyPointer::Unconstrained::Builder::setAnyKind( ::capnp::Void value) {
_builder.setDataField<Type::AnyPointer::Unconstrained::Which>( _builder.setDataField<Type::AnyPointer::Unconstrained::Which>(
1 * ::capnp::ELEMENTS, Type::AnyPointer::Unconstrained::ANY_KIND); 5 * ::capnp::ELEMENTS, Type::AnyPointer::Unconstrained::ANY_KIND);
_builder.setDataField< ::capnp::Void>( _builder.setDataField< ::capnp::Void>(
0 * ::capnp::ELEMENTS, value); 0 * ::capnp::ELEMENTS, value);
} }
...@@ -6384,7 +6384,7 @@ inline ::capnp::Void Type::AnyPointer::Unconstrained::Builder::getStruct() { ...@@ -6384,7 +6384,7 @@ inline ::capnp::Void Type::AnyPointer::Unconstrained::Builder::getStruct() {
} }
inline void Type::AnyPointer::Unconstrained::Builder::setStruct( ::capnp::Void value) { inline void Type::AnyPointer::Unconstrained::Builder::setStruct( ::capnp::Void value) {
_builder.setDataField<Type::AnyPointer::Unconstrained::Which>( _builder.setDataField<Type::AnyPointer::Unconstrained::Which>(
1 * ::capnp::ELEMENTS, Type::AnyPointer::Unconstrained::STRUCT); 5 * ::capnp::ELEMENTS, Type::AnyPointer::Unconstrained::STRUCT);
_builder.setDataField< ::capnp::Void>( _builder.setDataField< ::capnp::Void>(
0 * ::capnp::ELEMENTS, value); 0 * ::capnp::ELEMENTS, value);
} }
...@@ -6410,7 +6410,7 @@ inline ::capnp::Void Type::AnyPointer::Unconstrained::Builder::getList() { ...@@ -6410,7 +6410,7 @@ inline ::capnp::Void Type::AnyPointer::Unconstrained::Builder::getList() {
} }
inline void Type::AnyPointer::Unconstrained::Builder::setList( ::capnp::Void value) { inline void Type::AnyPointer::Unconstrained::Builder::setList( ::capnp::Void value) {
_builder.setDataField<Type::AnyPointer::Unconstrained::Which>( _builder.setDataField<Type::AnyPointer::Unconstrained::Which>(
1 * ::capnp::ELEMENTS, Type::AnyPointer::Unconstrained::LIST); 5 * ::capnp::ELEMENTS, Type::AnyPointer::Unconstrained::LIST);
_builder.setDataField< ::capnp::Void>( _builder.setDataField< ::capnp::Void>(
0 * ::capnp::ELEMENTS, value); 0 * ::capnp::ELEMENTS, value);
} }
...@@ -6436,51 +6436,51 @@ inline ::capnp::Void Type::AnyPointer::Unconstrained::Builder::getCapability() ...@@ -6436,51 +6436,51 @@ inline ::capnp::Void Type::AnyPointer::Unconstrained::Builder::getCapability()
} }
inline void Type::AnyPointer::Unconstrained::Builder::setCapability( ::capnp::Void value) { inline void Type::AnyPointer::Unconstrained::Builder::setCapability( ::capnp::Void value) {
_builder.setDataField<Type::AnyPointer::Unconstrained::Which>( _builder.setDataField<Type::AnyPointer::Unconstrained::Which>(
1 * ::capnp::ELEMENTS, Type::AnyPointer::Unconstrained::CAPABILITY); 5 * ::capnp::ELEMENTS, Type::AnyPointer::Unconstrained::CAPABILITY);
_builder.setDataField< ::capnp::Void>( _builder.setDataField< ::capnp::Void>(
0 * ::capnp::ELEMENTS, value); 0 * ::capnp::ELEMENTS, value);
} }
inline ::uint64_t Type::AnyPointer::Parameter::Reader::getScopeId() const { inline ::uint64_t Type::AnyPointer::Parameter::Reader::getScopeId() const {
return _reader.getDataField< ::uint64_t>( return _reader.getDataField< ::uint64_t>(
1 * ::capnp::ELEMENTS); 2 * ::capnp::ELEMENTS);
} }
inline ::uint64_t Type::AnyPointer::Parameter::Builder::getScopeId() { inline ::uint64_t Type::AnyPointer::Parameter::Builder::getScopeId() {
return _builder.getDataField< ::uint64_t>( return _builder.getDataField< ::uint64_t>(
1 * ::capnp::ELEMENTS); 2 * ::capnp::ELEMENTS);
} }
inline void Type::AnyPointer::Parameter::Builder::setScopeId( ::uint64_t value) { inline void Type::AnyPointer::Parameter::Builder::setScopeId( ::uint64_t value) {
_builder.setDataField< ::uint64_t>( _builder.setDataField< ::uint64_t>(
1 * ::capnp::ELEMENTS, value); 2 * ::capnp::ELEMENTS, value);
} }
inline ::uint16_t Type::AnyPointer::Parameter::Reader::getParameterIndex() const { inline ::uint16_t Type::AnyPointer::Parameter::Reader::getParameterIndex() const {
return _reader.getDataField< ::uint16_t>( return _reader.getDataField< ::uint16_t>(
1 * ::capnp::ELEMENTS); 5 * ::capnp::ELEMENTS);
} }
inline ::uint16_t Type::AnyPointer::Parameter::Builder::getParameterIndex() { inline ::uint16_t Type::AnyPointer::Parameter::Builder::getParameterIndex() {
return _builder.getDataField< ::uint16_t>( return _builder.getDataField< ::uint16_t>(
1 * ::capnp::ELEMENTS); 5 * ::capnp::ELEMENTS);
} }
inline void Type::AnyPointer::Parameter::Builder::setParameterIndex( ::uint16_t value) { inline void Type::AnyPointer::Parameter::Builder::setParameterIndex( ::uint16_t value) {
_builder.setDataField< ::uint16_t>( _builder.setDataField< ::uint16_t>(
1 * ::capnp::ELEMENTS, value); 5 * ::capnp::ELEMENTS, value);
} }
inline ::uint16_t Type::AnyPointer::ImplicitMethodParameter::Reader::getParameterIndex() const { inline ::uint16_t Type::AnyPointer::ImplicitMethodParameter::Reader::getParameterIndex() const {
return _reader.getDataField< ::uint16_t>( return _reader.getDataField< ::uint16_t>(
1 * ::capnp::ELEMENTS); 5 * ::capnp::ELEMENTS);
} }
inline ::uint16_t Type::AnyPointer::ImplicitMethodParameter::Builder::getParameterIndex() { inline ::uint16_t Type::AnyPointer::ImplicitMethodParameter::Builder::getParameterIndex() {
return _builder.getDataField< ::uint16_t>( return _builder.getDataField< ::uint16_t>(
1 * ::capnp::ELEMENTS); 5 * ::capnp::ELEMENTS);
} }
inline void Type::AnyPointer::ImplicitMethodParameter::Builder::setParameterIndex( ::uint16_t value) { inline void Type::AnyPointer::ImplicitMethodParameter::Builder::setParameterIndex( ::uint16_t value) {
_builder.setDataField< ::uint16_t>( _builder.setDataField< ::uint16_t>(
1 * ::capnp::ELEMENTS, value); 5 * ::capnp::ELEMENTS, value);
} }
inline bool Brand::Reader::hasScopes() const { inline bool Brand::Reader::hasScopes() const {
......
...@@ -478,6 +478,23 @@ struct TestNewVersion { ...@@ -478,6 +478,23 @@ struct TestNewVersion {
new2 @4 :Text = "baz"; new2 @4 :Text = "baz";
} }
struct TestOldUnionVersion {
union {
a @0 :Void;
b @1 :UInt64;
}
}
struct TestNewUnionVersion {
union {
a :union {
a0 @0 :Void;
a1 @2 :UInt64;
}
b @1 :UInt64;
}
}
struct TestStructUnion { struct TestStructUnion {
un @0! :union { un @0! :union {
struct @1 :SomeStruct; struct @1 :SomeStruct;
......
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