| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| library conformance; |
| |
| struct TransactionHeader { |
| uint32 tx_id; |
| array<uint8>:3 flags; |
| uint8 magic_number; |
| uint64 ordinal; |
| }; |
| |
| union UnionSize8Align4 { |
| 1: uint8 unused1; |
| 2: uint8 unused2; |
| 3: uint32 variant; |
| }; |
| |
| union UnionSize12Align4 { |
| 1: uint8 unused1; |
| 2: uint8 unused2; |
| 3: uint8 unused3; |
| 4: array<uint8>:6 variant; |
| }; |
| |
| struct StructSize16Align8 { |
| uint64 f1; |
| uint64 f2; |
| }; |
| |
| union UnionSize24Align8 { |
| 1: uint8 unused1; |
| 2: uint8 unused2; |
| 3: uint8 unused3; |
| 4: StructSize16Align8 variant; |
| }; |
| |
| struct Sandwich1 { |
| uint32 before; |
| UnionSize8Align4 the_union; |
| uint32 after; |
| }; |
| |
| struct Sandwich1Message { |
| TransactionHeader header; |
| Sandwich1 body; |
| }; |
| |
| struct Sandwich1WithOptUnion { |
| uint32 before; |
| UnionSize8Align4? opt_union; |
| uint32 after; |
| }; |
| |
| struct Sandwich2 { |
| uint32 before; |
| UnionSize12Align4 the_union; |
| uint32 after; |
| }; |
| |
| struct Sandwich3 { |
| uint32 before; |
| UnionSize24Align8 the_union; |
| uint32 after; |
| }; |
| |
| union UnionSize36Align4 { |
| 1: uint8 unused1; |
| 2: uint8 unused2; |
| 3: uint8 unused3; |
| 4: array<uint8>:32 variant; |
| }; |
| |
| struct Sandwich4 { |
| uint32 before; |
| UnionSize36Align4 the_union; |
| uint32 after; |
| }; |
| |
| struct Sandwich4Message { |
| TransactionHeader header; |
| Sandwich4 body; |
| }; |
| |
| union UnionOfUnion { |
| 1: uint8 unused1; |
| 2: UnionSize8Align4 size8align4; // used in Sandwich5Case1, Sandwich8Case1 |
| 3: UnionSize12Align4 size12align4; |
| 4: uint8 unused2; |
| 5: UnionSize24Align8 size24align8; // used in Sandwich5Case2 |
| }; |
| |
| struct Sandwich5 { |
| uint32 before; |
| UnionOfUnion union_of_union; |
| uint32 after; |
| }; |
| |
| struct Sandwich5Message { |
| TransactionHeader header; |
| Sandwich5 body; |
| }; |
| |
| struct StructSize3Align1 { |
| array<uint8>:3 three_bytes; |
| }; |
| |
| struct StructSize3Align2 { |
| uint16 f1; |
| uint8 f2; |
| }; |
| |
| union UnionWithVector { |
| 1: uint8 unused; |
| 2: vector<uint8> vector_of_uint8; |
| 3: string s; |
| 4: vector<StructSize3Align1> vector_s3_a1; |
| 5: vector<StructSize3Align2> vector_s3_a2; |
| // 6: vector<handle> handles; // TODO(fxbug.dev/36441): Support handles in GIDL. |
| 6: vector<uint32> handles; |
| 7: array<StructSize3Align1>:2 array_s3_a1; |
| 8: array<StructSize3Align2>:2 array_s3_a2; |
| 9: vector<UnionSize8Align4> vector_union; |
| }; |
| |
| struct Sandwich6 { |
| uint32 before; |
| UnionWithVector the_union; |
| uint32 after; |
| }; |
| |
| struct Sandwich7 { |
| uint32 before; |
| Sandwich1? opt_sandwich1; |
| uint32 after; |
| }; |
| |
| struct Sandwich7Message { |
| TransactionHeader header; |
| Sandwich7 body; |
| }; |
| |
| // Same as Sandwich5 except `before` is uint64 (so no padding before the union). |
| struct Sandwich8 { |
| uint64 before; |
| UnionOfUnion union_of_union; |
| uint32 after; |
| }; |
| |
| struct Regression1 { |
| uint8 f1; |
| uint32 f2; |
| uint8 f3; |
| uint16 f4; |
| uint64 f5; |
| uint8 f6; |
| }; |
| |
| struct Regression2 { |
| Regression1 head; |
| uint8 f7; |
| }; |
| |
| struct Regression3 { |
| Regression2? opt_value; |
| }; |
| |
| table Table_NoFields { |
| }; |
| |
| struct Struct_Table_NoFields { |
| Table_NoFields t; |
| }; |
| |
| table Table_TwoReservedFields { |
| 1: reserved; |
| 2: reserved; |
| }; |
| |
| struct Struct_Table_TwoReservedFields { |
| Table_TwoReservedFields t; |
| }; |
| |
| table Table_StructWithReservedSandwich { |
| 1: reserved; |
| 2: StructSize3Align1 s1; |
| 3: StructSize3Align1 s2; |
| 4: reserved; |
| }; |
| |
| struct Table_StructWithReservedSandwichStruct { |
| Table_StructWithReservedSandwich table; |
| }; |
| |
| table Table_StructWithUint32Sandwich { |
| 1: uint32 i; |
| 2: StructSize3Align1 s1; |
| 3: StructSize3Align1 s2; |
| 4: uint32 i2; |
| }; |
| |
| struct Table_StructWithUint32SandwichStruct { |
| Table_StructWithUint32Sandwich table; |
| }; |
| |
| table Table_UnionWithVector_ReservedSandwich { |
| 1: reserved; |
| 2: UnionWithVector uv; |
| 3: reserved; |
| }; |
| |
| struct Table_UnionWithVector_ReservedSandwichStruct { |
| Table_UnionWithVector_ReservedSandwich table; |
| }; |
| |
| table Table_UnionWithVector_StructSandwich { |
| 1: StructSize3Align1 s1; |
| 2: UnionWithVector uv; |
| 3: StructSize3Align1 s2; |
| }; |
| |
| struct Table_UnionWithVector_StructSandwichStruct { |
| Table_UnionWithVector_StructSandwich table; |
| }; |
| |
| flexible union XUnionWithStruct { |
| 1: StructSize3Align1 s; |
| }; |
| |
| struct XUnionWithStructStruct { |
| XUnionWithStruct xu; |
| }; |
| |
| flexible union XUnionWithXUnion { |
| 1: XUnionWithStruct xu; |
| }; |
| |
| struct XUnionWithXUnionStruct { |
| XUnionWithXUnion xu; |
| }; |
| |
| flexible union XUnionWithUnions { |
| 1: UnionSize8Align4 u1; |
| 2: UnionSize12Align4 u2; |
| }; |
| |
| struct Size5Alignment1 { |
| array<uint8>:5 data; |
| }; |
| |
| struct Size5Alignment4 { |
| uint32 four; |
| uint8 one; |
| }; |
| |
| struct Size5Alignment1Vector { |
| vector<Size5Alignment1> v; |
| }; |
| |
| struct Size5Alignment4Vector { |
| vector<Size5Alignment4> v; |
| }; |
| |
| struct Size5Alignment1Array { |
| array<Size5Alignment1>:3 a; |
| }; |
| |
| struct Size5Alignment4Array { |
| array<Size5Alignment4>:3 a; |
| }; |
| |
| union StringUnion { |
| 1: uint8 unused; |
| 2: string s; |
| 3: uint8 u8; |
| }; |
| |
| struct ArrayStruct { |
| array<StringUnion>:3 unions; |
| array<StringUnion?>:3 optional_unions; |
| }; |
| |
| struct TransformerEmptyStruct { |
| }; |
| |
| union EmptyStructUnion { |
| 1: uint8 unused; // force the union tag to be non-zero |
| 2: TransformerEmptyStruct es; |
| }; |
| |
| struct EmptyStructUnionStruct { |
| EmptyStructUnion u; |
| }; |
| |
| struct Size8Align8 { |
| uint64 data; |
| }; |
| |
| struct NoCodingTablesStressor { |
| uint64 f1; |
| uint64 f2; |
| UnionSize36Align4 u1; |
| uint64 f3; |
| uint64 f4; |
| UnionSize36Align4 u2; |
| uint64 f5; |
| uint64 f6; |
| UnionSize36Align4 u3; |
| uint64 f7; |
| Size8Align8? p1; |
| uint64 f8; |
| Size8Align8? p2; |
| uint64 f9; |
| }; |
| |
| struct OutOfLineSandwich1 { |
| string before; |
| vector<Sandwich1>:1 v; |
| string after; |
| }; |
| |
| struct OutOfLineSandwich1WithOptUnion { |
| string before; |
| vector<Sandwich1WithOptUnion>:1 v; |
| string after; |
| }; |
| |
| // Regression1, but has at least one non primitive field |
| struct Regression4 { |
| uint8 f1; |
| uint32 f2; |
| StructSize3Align1 s1; |
| uint8 f3; |
| uint16 f4; |
| uint64 f5; |
| uint8 f6; |
| }; |
| |
| enum EnumUint32 : uint32 { |
| MEMBER = 0x3231302F; |
| }; |
| |
| enum EnumUint8 : uint8 { |
| MEMBER = 0x08; |
| }; |
| |
| // Regression1, but with enums. |
| struct Regression5 { |
| uint8 f1; |
| EnumUint32 f2; |
| EnumUint8 f3; |
| uint16 f4; |
| uint64 f5; |
| uint8 f6; |
| }; |
| |
| bits BitsUint32 : uint32 { |
| MEMBER_LOW_1 = 0x00000001; |
| MEMBER_LOW_2 = 0x00000002; |
| MEMBER_HIG_1 = 0x10000000; |
| MEMBER_HIG_2 = 0x20000000; |
| }; |
| |
| bits BitsUint8 : uint8 { |
| MEMBER = 0x08; |
| }; |
| |
| // Regression1, but with bits. |
| struct Regression6 { |
| uint8 f1; |
| BitsUint32 f2; |
| BitsUint8 f3; |
| uint16 f4; |
| uint64 f5; |
| uint8 f6; |
| }; |
| |
| union UnionAtTheBottom { |
| 1: uint8 unused1; |
| 2: uint8 unused2; |
| 3: uint8 tiny; |
| }; |
| |
| flexible union XUnionOfUnion { |
| 1: UnionAtTheBottom variant; // 0x5F67105B |
| }; |
| |
| table TableOfXUnionThenUnion { |
| 1: reserved; |
| 2: XUnionOfUnion member; |
| }; |
| |
| flexible union XUnionOfTableThenXUnionThenUnion { |
| 1: TableOfXUnionThenUnion variant; //0x5B15934E |
| }; |
| |
| union UnionOfXUnionThenTableThenXUnionThenUnion { |
| 1: uint8 unused1; // avoid tag 0 |
| 2: reserved; // no tag correspondance |
| 3: XUnionOfTableThenXUnionThenUnion variant; // tag = 1 |
| }; |
| |
| table TableOfUnionThenXUnionThenTableThenXUnionThenUnion { |
| 1: reserved; |
| 2: reserved; |
| 3: UnionOfXUnionThenTableThenXUnionThenUnion member; |
| }; |
| |
| struct Regression7TableUnionXUnion { |
| TableOfUnionThenXUnionThenTableThenXUnionThenUnion value; |
| }; |
| |
| struct Regression8OptUnionSize12Align4 { |
| UnionSize12Align4? opt_union1; |
| UnionSize12Align4? opt_union2; |
| UnionSize12Align4? opt_union3; |
| }; |
| |
| struct Regression8VectorOfOptUnionSize12Align4 { |
| vector<UnionSize12Align4?> value; |
| }; |
| |
| table TableWithUnionSize12Align4 { |
| 1: uint8 before; |
| 2: reserved; |
| 3: UnionSize12Align4 member; |
| 4: reserved; |
| 5: uint8 after; |
| }; |
| |
| struct Regression8TableWithUnionSize12Align4 { |
| TableWithUnionSize12Align4 value; |
| }; |
| |
| union StringBoolUnion { |
| 1: string s; |
| 2: bool b; |
| }; |
| |
| struct StringUnionStruct { |
| StringBoolUnion u; |
| StringBoolUnion? nullable_u; |
| }; |
| |
| struct StringUnionStructWrapper { |
| StringUnionStruct sus; |
| }; |
| |
| struct StringUnionStructWrapperResponse { |
| TransactionHeader header; |
| StringUnionStructWrapper body; |
| }; |
| |
| struct Regression9Value { |
| StringBoolUnion u; |
| StringBoolUnion? nullable_u; |
| }; |
| |
| // Simulate an error result type. |
| union Regression9Result { |
| 1: Regression9Value ok; |
| 2: uint32 error; |
| }; |
| |
| struct Regression9Message { |
| TransactionHeader header; |
| Regression9Result body; |
| }; |
| |
| // At first, only one member. |
| table Regression10TableV1 { |
| 1: uint64 member1; |
| }; |
| |
| // Then, we add a second member in 5th position. |
| table Regression10TableV2 { |
| 1: uint64 member1; |
| 2: reserved; |
| 3: reserved; |
| 4: reserved; |
| 5: uint64 member2; |
| }; |
| |
| // Third, we add a third member in 6th position, and reserve the 7th. |
| table Regression10TableV3 { |
| 1: int64 x; |
| 2: reserved; |
| 3: reserved; |
| 4: reserved; |
| 5: int64 y; |
| 6: int64 z; |
| 7: reserved; |
| }; |
| |
| struct Regression10V1 { |
| Regression10TableV1 table; |
| }; |
| |
| struct Regression10V2 { |
| Regression10TableV2 table; |
| }; |
| |
| struct Regression10V3 { |
| Regression10TableV3 table; |
| }; |
| |
| union UnionWithRegression10Table { |
| 1: uint8 unused; // avoid tag 0 |
| 2: reserved; |
| 3: Regression10TableV2 at_v2; // but consider the evolution v1, v2, v3, ... |
| }; |
| |
| struct Regression11 { |
| UnionWithRegression10Table table_of_table; |
| }; |
| |
| struct Sandwich4Align8 { |
| Sandwich4 sandwich4; |
| uint64 alignment8_enforcement; |
| }; |
| |
| struct Sandwich4Align8WithPointer { |
| Sandwich4 sandwich4; |
| Size8Align8? alignment8_enforcement; |
| }; |
| |
| // This is designed to test out-of-line handling. |
| union UnionWithVectorOfVectors { |
| 1: vector<vector<StructSize3Align1?>> v; |
| }; |
| |
| struct Sandwich9 { |
| uint16 before; |
| UnionWithVectorOfVectors the_union; |
| uint16 after; |
| }; |
| |
| table TransformerSimpleTable { |
| 1: uint32 value; |
| }; |
| |
| struct SimpleTableArrayStruct { |
| array<TransformerSimpleTable>:2 the_array; |
| }; |
| |
| struct StringUnionVector { |
| vector<StringUnion?>:3 the_vector; |
| }; |
| |
| struct LaunchInfo { |
| string:200 url; |
| vector<string>? arguments; |
| TransformerEmptyStruct? out; |
| TransformerEmptyStruct? err; |
| // zx.handle:CHANNEL? directory_request; // TODO(fxbug.dev/36441): Support handles in GIDL. |
| uint32 directory_request; |
| TransformerEmptyStruct? flat_namespace; |
| TransformerEmptyStruct? additional_services; |
| }; |
| |
| struct CreateComponentRequest { |
| LaunchInfo launch_info; |
| // request<ComponentController>? controller; // TODO(fxbug.dev/36441): Support handles in GIDL. |
| uint32 controller; |
| }; |
| |
| union CompatUnion { |
| 1: string s; |
| 2: bool b; |
| }; |
| |
| table CompatTableString { |
| 1: string s; |
| }; |
| |
| union UnionOfTable { |
| // Test out-of-line sizing via a table contained inside a union. |
| 1: SimpleTable t; |
| }; |
| |
| struct StructOfUnionOfTable { |
| UnionOfTable u; |
| }; |
| |
| flexible union CompatXUnion { |
| 1: string s; // hashed ordinal 0x5af8efa8 |
| 2: bool b; |
| }; |
| |
| table CompatTableValue { |
| 1: CompatUnion union_member; |
| 2: array<uint32>:3 array_member; |
| 3: CompatTableString table_member; |
| 4: CompatXUnion xunion_member; |
| }; |
| |
| struct CompatTable { |
| CompatTableValue value; |
| string empty; |
| }; |
| |
| struct MixedFieldsBody { |
| uint32 before; |
| UnionSize8Align4 first_union; |
| uint16 middle_start; |
| uint64 middle_end; |
| UnionSize8Align4 second_union; |
| uint32 after; |
| }; |
| |
| struct MixedFieldsMessage { |
| TransactionHeader header; |
| MixedFieldsBody body; |
| }; |
| |
| table TableWithXUnion { |
| 1: CompatXUnion member; |
| }; |
| |
| struct StructOfTableWithXUnion { |
| TableWithXUnion value; |
| }; |