blob: 7baf623971a1af8a01630c8c9e5768eb06bbc713 [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.
// A set of structs and interface methods designed to exercise FIDL code.
// For now covering fidl_linearize.
// TODO(fxbug.dev/48186) Auto-generate extra_messages.h
library fidl.test.coding;
struct IntStruct {
int64 v;
};
table SimpleTable {
1: IntStruct x;
2: reserved;
3: reserved;
4: reserved;
5: IntStruct y;
};
resource table ResourceSimpleTable {
1: IntStruct x;
2: reserved;
3: reserved;
4: reserved;
5: IntStruct y;
};
table OlderSimpleTable {
1: IntStruct x;
2: reserved;
};
table NewerSimpleTable {
1: IntStruct x;
2: reserved;
3: reserved;
4: reserved;
5: IntStruct y;
6: IntStruct z;
7: reserved;
};
union SampleUnion {
1: IntStruct i;
2: SimpleTable st;
3: int32 raw_int;
};
flexible union SampleXUnion {
1: IntStruct i;
2: SimpleTable st;
3: int32 raw_int;
};
union SampleStrictXUnion {
1: IntStruct i;
2: SimpleTable st;
3: int32 raw_int;
};
struct SampleStrictXUnionStruct {
SampleStrictXUnion xu;
};
struct SampleXUnionStruct {
SampleXUnion xu;
};
struct SampleNullableXUnionStruct {
SampleXUnion? opt_xu;
};
flexible union LLCPPStyleUnion {
1: int32 primitive;
};
struct LLCPPStyleUnionStruct {
LLCPPStyleUnion u;
};
bits Int16Bits : uint16 {
BIT_1 = 1;
BIT_3 = 4;
BIT_5 = 16;
};
struct Int16BitsStruct {
Int16Bits bits;
};
bits Int32Bits : uint32 {
BIT_7 = 64;
BIT_12 = 2048;
BIT_27 = 67108864;
};
struct Int32BitsStruct {
Int32Bits bits;
};
// For the enum validation tests, we will define enums of all the possible
// underlying types, and for each of them, create three valid elements:
// - std::numeric_limits<UnderlyingType>::min()
// - std::numeric_limits<UnderlyingType>::max()
// - 42
enum Int8Enum : int8 {
VALID_MIN = -128;
VALID_MAX = 127;
VALID_42 = 42;
};
struct Int8EnumStruct {
Int8Enum e;
};
enum Uint8Enum : uint8 {
VALID_MIN = 0;
VALID_MAX = 255;
VALID_42 = 42;
};
struct Uint8EnumStruct {
Uint8Enum e;
};
enum Int16Enum : int16 {
VALID_MIN = -32768;
VALID_MAX = 32767;
VALID_42 = 42;
};
struct Int16EnumStruct {
Int16Enum e;
};
enum Uint16Enum : uint16 {
VALID_MIN = 0;
VALID_MAX = 65535;
VALID_42 = 42;
};
struct Uint16EnumStruct {
Uint16Enum e;
};
enum Int32Enum : int32 {
VALID_MIN = -2147483648;
VALID_MAX = 2147483647;
VALID_42 = 42;
};
struct Int32EnumStruct {
Int32Enum e;
};
enum Uint32Enum : uint32 {
VALID_MIN = 0;
VALID_MAX = 4294967295;
VALID_42 = 42;
};
struct Uint32EnumStruct {
Uint32Enum e;
};
enum Int64Enum : int64 {
VALID_MIN = -9223372036854775808;
VALID_MAX = 9223372036854775807;
VALID_42 = 42;
};
struct Int64EnumStruct {
Int64Enum e;
};
enum Uint64Enum : uint64 {
VALID_MIN = 0;
VALID_MAX = 18446744073709551615;
VALID_42 = 42;
};
struct Uint64EnumStruct {
Uint64Enum e;
};
struct Uint32VectorStruct {
vector<uint32> vec;
};
struct StringStruct {
string str;
};
struct RecursiveOptional {
RecursiveOptional? inner;
};
table RecursiveTable {
1: RecursiveOptional inner;
};
struct BoolStruct {
bool val;
};