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