blob: 43c75a6eeaa1e72db612b87ac8925827ee1e2871 [file] [log] [blame] [edit]
// Copyright 2020 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.types.test;
struct CopyableStruct {
int32 x;
};
resource struct MoveOnlyStruct {
handle? h;
};
/// Verifies that user code can manipulate these union payloads.
resource union TestUnion {
1: int32 primitive;
2: CopyableStruct copyable;
3: MoveOnlyStruct move_only;
};
resource flexible union TestXUnion {
1: int32 primitive;
2: CopyableStruct copyable;
3: handle h;
};
union TestStrictXUnion {
1: int32 primitive;
2: CopyableStruct copyable;
};
/// Verifies that user code can manipulate these bits.
///
/// We use a uint8 since most bitwise operations will cast their operands to
/// int, and therefore special casting is required to properly compile.
bits SampleBits : uint8 {
B = 2;
D = 4;
E = 8;
};
/// Verifies that user code can build and access tables.
table SampleTable {
1: uint8 x;
2: uint8 y;
3: vector<CopyableStruct> vector_of_struct;
};
/// Verifies that an empty table compiles.
table SampleEmptyTable {
};
protocol TestInterface {
TestMethod(TestUnion u) -> (TestUnion u);
};
/// Verifies that method argument types don't conflict with user-defined types.
struct FooRequest {
int32 bar;
};
struct FooResponse {
int32 bar;
};
protocol Baz {
Foo(FooRequest req) -> (FooResponse res);
};
table TableWithSubTables {
1: SampleTable t;
2: vector<SampleTable> vt;
3: array<SampleTable>:3 at;
};
enum Enum : uint32 {
VALUE_0 = 0;
};
struct EmptyStruct {
};