| // Copyright 2018 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 fidl.test.misc; |
| |
| bits Uint32Bits : uint32 { |
| ONE = 0x1; |
| TWO = 0x2; |
| }; |
| |
| bits SampleBits { |
| B = 2; |
| D = 4; |
| E = 8; |
| }; |
| |
| struct Int64Struct { |
| int64 x; |
| }; |
| |
| struct HasOptionalFieldStruct { |
| Int64Struct? x; |
| }; |
| |
| struct Has2OptionalFieldStruct { |
| Int64Struct? x; |
| Int64Struct? y; |
| }; |
| |
| struct Empty { |
| }; |
| |
| struct EmptyStructSandwich { |
| string before; |
| Empty e; |
| string after; |
| }; |
| |
| union SimpleUnion { |
| int32 i32; |
| int64 i64; |
| Int64Struct s; |
| Int64Struct? os; |
| string str; |
| }; |
| |
| table SimpleTable { |
| 1: int64 x; |
| 2: reserved; |
| 3: reserved; |
| 4: reserved; |
| 5: int64 y; |
| }; |
| |
| // A variant of SimpleTable that has just the first few fields. |
| // Think of this as an older variant of that type! |
| table OlderSimpleTable { |
| 1: int64 x; |
| 2: reserved; |
| }; |
| |
| // A variant of SimpleTable that has some additional new fields. |
| // Think of this as an newer variant of that type! |
| table NewerSimpleTable { |
| 1: int64 x; |
| 2: reserved; |
| 3: reserved; |
| 4: reserved; |
| 5: int64 y; |
| 6: int64 z; |
| 7: reserved; |
| }; |
| |
| table ComplexTable { |
| 1: SimpleTable simple; |
| 2: SampleXUnion u; |
| 3: vector<string> strings; |
| }; |
| |
| xunion SampleXUnion { |
| int32 i; |
| SimpleUnion su; |
| SimpleTable st; |
| }; |
| |
| struct InlineXUnionInStruct { |
| string before; |
| SampleXUnion xu; |
| string after; |
| }; |
| |
| struct OptionalXUnionInStruct { |
| string before; |
| SampleXUnion? xu; |
| string after; |
| }; |
| |
| table XUnionInTable { |
| 1: string before; |
| 2: SampleXUnion xu; |
| 3: string after; |
| }; |
| |
| table PrimitiveArrayInTable { |
| 1: string before; |
| 2: array<int32>:9 arr; |
| 3: string after; |
| }; |
| |
| enum SampleEnum { |
| MEMBER_A = 23; |
| MEMBER_B = 34; |
| MEMBER_C = 45; |
| }; |
| |
| struct VariousDefaults { |
| int64 int64_with_default = 5; |
| string string_with_default = "stuff"; |
| // TODO(FIDL-486): This works, but is a happy accident. |
| SampleEnum enum_with_default = MEMBER_B; |
| bool bool_with_default = true; |
| }; |