blob: d0fe6c4d5bd67803c1866ef9a4a5d778a7b87e6e [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.
// NOTE: Refer to README.md to regenerate the coding tables whenever these definitions change.
library fidl.test.coding;
protocol LinearizerTest {
VectorOfUint32(vector<uint32> v);
VectorOfString(vector<string> v);
};
struct IntStruct {
int64 v;
};
table SimpleTable {
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;
};
struct StructWithHandle {
handle h;
int32 foo;
};
struct StructWithManyHandles {
handle h1;
handle h2;
vector<handle>:2 hs;
};
table TableOfStructWithHandle {
1: StructWithHandle a;
2: StructWithManyHandles b;
};
table SmallerTableOfStructWithHandle {
1: reserved;
2: StructWithManyHandles b;
};
union SampleUnion {
1: IntStruct i;
2: SimpleTable st;
3: int32 raw_int;
};
xunion SampleXUnion {
IntStruct i;
SimpleTable st;
int32 raw_int;
};
strict xunion SampleStrictXUnion {
IntStruct i;
SimpleTable st;
int32 raw_int;
};
struct SampleStrictXUnionStruct {
SampleStrictXUnion xu;
};
struct SampleXUnionStruct {
SampleXUnion xu;
};
struct SampleNullableXUnionStruct {
SampleXUnion? opt_xu;
};
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;
};