| // 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. |
| |
| // NOTE: Refer to README.md to regenerate the coding tables whenever these |
| // definitions change. |
| |
| // Most types in this file have been ported to GIDL: |
| // |
| // tools/fidl/gidl-conformance-suite/transformer.gidl |
| // tools/fidl/gidl-conformance-suite/transformer.test.fidl |
| // |
| // New transformer tests should go there. We keep only the definitions needed |
| // for tests in transformer_tests.c that cannot be expressed in GIDL. |
| |
| library example; |
| |
| union UnionSize8Aligned4 { |
| 1: uint8 unused1; // makes `variant` tagged 2 |
| 2: uint8 unused2; // since it is the third |
| 3: uint32 variant; // xunion_ordinal = 0x7fc2f0db |
| }; |
| |
| union UnionSize12Aligned4 { |
| 1: uint8 unused1; // avoid tag 0 |
| 2: uint8 unused2; // avoid tag 1 |
| 3: uint8 unused3; // avoid tag 2 |
| 4: array<uint8>:6 variant; |
| }; |
| |
| struct StructSize16Alignment8 { |
| uint64 f1; |
| uint64 f2; |
| }; |
| |
| union UnionSize24Alignment8 { |
| 1: uint8 unused1; // avoid tag 0 |
| 2: uint8 unused2; // avoid tag 1 |
| 3: uint8 unused3; // avoid tag 2 |
| 4: StructSize16Alignment8 variant; // 0x3404559b |
| }; |
| |
| struct Sandwich1 { |
| uint32 before; |
| UnionSize8Aligned4 the_union; |
| uint32 after; |
| }; |
| |
| union UnionSize36Alignment4 { |
| 1: uint8 unused1; // avoid tag 0 |
| 2: uint8 unused2; // avoid tag 1 |
| 3: uint8 unused3; // avoid tag 2 |
| 4: array<uint8>:32 variant; // 0x5e411019 |
| }; |
| |
| struct Sandwich4 { |
| uint32 before; |
| UnionSize36Alignment4 the_union; |
| uint32 after; |
| }; |
| |
| union UnionOfUnion { |
| 1: uint8 unused; // avoid tag 0 |
| 2: UnionSize8Aligned4 size8aligned4; // 0x20AADD60 |
| 3: UnionSize12Aligned4 size16aligned4; // 0x2D7665CD |
| 4: UnionSize24Alignment8 size24aligned8; // 0x06722D1F |
| }; |
| |
| struct StructSize3Alignment1 { |
| array<uint8>:3 three_bytes; |
| }; |
| |
| struct StructSize3Alignment2 { |
| uint16 f1; |
| uint8 f2; |
| }; |
| |
| // We name Sandwich6 cases by the tag number, i.e. Sandwich6 case 2 is |
| // testing the `string` variant. |
| union UnionWithVector { |
| 1: uint8 unused; // 0: unused |
| 2: vector<uint8> vector_of_uint8; // 1: 0x79C3CCAD |
| 3: string string; // 2: 0x3B314338 |
| 4: vector<StructSize3Alignment1> vector_s3_a1; // 3: 0x4BC13CDC |
| 5: vector<StructSize3Alignment2> vector_s3_a2; // 4: 0x1D08AA3C |
| 6: vector<handle> handles; // 5: 0x471EAA76 |
| 7: array<StructSize3Alignment1>:2 array_s3_a1; // 6: 0x5EA0A810 |
| 8: array<StructSize3Alignment2>:2 array_s3_a2; // 7: 0x5CF8B70D |
| 9: vector<UnionSize8Aligned4> vector_union; // 8: 0x2B768C31 |
| }; |
| |
| struct Sandwich6 { |
| uint32 before; |
| UnionWithVector the_union; |
| uint32 after; |
| }; |
| |
| enum EnumUint32 { |
| 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 { |
| 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; |
| }; |
| |
| table SimpleTable { |
| 1: uint32 value; |
| }; |
| |
| struct SimpleTableArrayStruct { |
| array<SimpleTable>:2 the_array; |
| }; |
| |
| // compatibility_test turned up problems with these StringUnion-associated definitions. |
| |
| union StringUnion { |
| 1: string s; |
| 2: bool b; |
| }; |
| |
| struct StringUnionStruct { |
| StringUnion u; |
| StringUnion? nullable_u; |
| }; |
| |
| struct StringUnionStructWrapper { |
| StringUnionStruct sus; |
| }; |
| |
| protocol StringUnionStructWrapperProtocol { |
| TheMethod(StringUnionStructWrapper value) -> (StringUnionStructWrapper value); |
| }; |
| |
| // TODO(apang): Union containing a table (to test out-of-line sizing) |
| |
| struct EmptyStruct { |
| }; |
| |
| struct LauncherInfo { |
| string:200 url; |
| vector<string>? arguments; |
| EmptyStruct? out; |
| EmptyStruct? err; |
| handle<channel>? directory_request; |
| EmptyStruct? flat_namespace; |
| EmptyStruct? additional_services; |
| }; |
| |
| struct Regression9Value { |
| StringUnion u; |
| StringUnion? nullable_u; |
| }; |
| |
| protocol FakeProtocol { |
| // TODO(apang): Make this consistent. |
| WrapSandwich4(Sandwich4 sandwich); |
| |
| SendSandwich1(uint32 before, UnionSize8Aligned4 the_union, uint32 after); |
| SendSandwich5(uint32 before, UnionOfUnion union_of_union, uint32 after); |
| SendSandwich7(uint32 before, Sandwich1? opt_sandwich1, uint32 after); |
| // this method tests having omitted fields in various positions within the struct |
| SendMixedFields( |
| uint32 before, |
| UnionSize8Aligned4 first_union, |
| uint16 middle_start, |
| uint64 middle_end, |
| UnionSize8Aligned4 second_union, |
| uint32 after); |
| |
| SendFakeLauncherCreateComponentRequest(LauncherInfo info, handle h); |
| |
| // This method tests a simplified version of the result returned in the |
| // EchoStructWithErrorSuccessCase test in the compatibility tests |
| Regression9() -> (Regression9Value value) error uint32; |
| }; |