blob: 1b648acea2035d0e8a35b3e1d9640f125e3f462f [file] [log] [blame]
// 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;
type Uint32Bits = strict bits : uint32 {
ONE = 0x1;
TWO = 0x2;
};
type StrictBits = strict bits : uint8 {
B = 2;
D = 4;
E = 8;
};
/// The members should be kept in sync with those in [`StrictBits`], as we have
/// tests parameterized on both bits types.
type FlexibleBits = flexible bits : uint8 {
B = 2;
D = 4;
E = 8;
};
type Int64Struct = struct {
x int64;
};
type HasOptionalFieldStruct = struct {
x box<Int64Struct>;
};
type Has2OptionalFieldStruct = struct {
x box<Int64Struct>;
y box<Int64Struct>;
};
type Empty = struct {};
type XUnionContainingEmptyStruct = flexible union {
1: empty Empty;
};
type EmptyStructSandwich = struct {
before string;
e Empty;
after string;
};
type SimpleUnion = strict union {
1: i32 int32;
2: i64 int64;
3: s Int64Struct;
4: reserved_ordinal_3 uint64;
5: str string;
};
type SimpleTable = table {
1: x int64;
2: reserved;
3: reserved;
4: reserved;
5: y int64;
};
// A variant of SimpleTable that has just the first few fields.
// Think of this as an older variant of that type!
type OlderSimpleTable = table {
1: x int64;
2: reserved;
};
// A variant of SimpleTable that has some additional new fields.
// Think of this as an newer variant of that type!
type NewerSimpleTable = table {
1: x int64;
2: reserved;
3: reserved;
4: reserved;
5: y int64;
6: z int64;
7: reserved;
};
type ComplexTable = table {
1: simple SimpleTable;
2: u SampleXUnion;
3: strings vector<string>;
};
type SampleXUnion = flexible union {
1: i int32;
2: su SimpleUnion;
3: st SimpleTable;
};
type SampleXUnionInStruct = struct {
xu SampleXUnion;
};
type InlineXUnionInStruct = struct {
before string;
xu SampleXUnion;
after string;
};
type OptionalXUnionInStruct = struct {
before string;
xu SampleXUnion:optional;
after string;
};
type XUnionInTable = table {
1: before string;
2: xu SampleXUnion;
3: after string;
};
type PrimitiveArrayInTable = table {
1: before string;
2: arr array<int32, 9>;
3: after string;
};
type StrictEnum = strict enum {
MEMBER_A = 23;
MEMBER_B = 34;
MEMBER_C = 45;
};
type FlexibleEnum = flexible enum {
MEMBER_A = 23;
MEMBER_B = 34;
MEMBER_C = 45;
@unknown
MEMBER_CUSTOM_UNKNOWN = 89;
};
type EmptyFlexibleEnum = flexible enum {};
type VariousDefaults = struct {
@allow_deprecated_struct_defaults
int64_with_default int64 = 5;
@allow_deprecated_struct_defaults
string_with_default string = "stuff";
@allow_deprecated_struct_defaults
strict_enum_with_default StrictEnum = StrictEnum.MEMBER_B;
@allow_deprecated_struct_defaults
flexible_enum_with_default FlexibleEnum = FlexibleEnum.MEMBER_B;
@allow_deprecated_struct_defaults
bool_with_default bool = true;
};
protocol Echo {
EchoString(struct {
value string:optional;
}) -> (struct {
response string:optional;
});
};