blob: 61704b57c5864b41d550b46216e55ca8f099f29e [file] [log] [blame]
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
deprecated_syntax;
library bindingstest;
using zx;
struct TestSimple {
int64 x;
};
struct TestSimpleBool {
bool x;
};
struct TestAlignment1 {
int8 x;
int8 y;
uint32 z;
};
struct TestAlignment2 {
uint32 a;
uint32 b;
int8 c;
int8 d;
int8 e;
uint8 f;
uint32 g;
uint16 h;
uint16 i;
};
struct TestFloat1 {
float32 a;
};
struct TestFloat2 {
float64 a;
};
struct TestFloat3 {
float32 a;
float64 b;
uint64 c;
float32 d;
};
struct TestArray1 {
array<int8>:5 a;
};
struct TestArray2 {
float64 a;
array<float32>:1 b;
};
struct TestArray3 {
int32 a;
array<uint16>:3 b;
uint64 c;
};
struct TestArray4 {
array<bool>:9 a;
};
struct TestString1 {
string a;
string? b;
};
struct TestString2 {
array<string>:2 a;
};
struct TestString3 {
array<string:4>:2 a;
array<string:4?>:2 b;
};
struct TestStringWithBound {
string:8 a;
};
struct TestOptStringWithBound {
string:8? a;
};
struct TestVector1 {
vector<int8> a;
vector<int16>? b;
vector<int32>:2 c;
vector<int64>:2? d;
};
struct TestVector2 {
array<vector<int8>>:2 a;
vector<vector<int8>>:2 b;
vector<vector<string:5>:2?>:2 c;
};
struct TestStruct1 {
TestSimple a;
TestSimple? b;
};
struct TestStruct2 {
TestArray1 a;
TestFloat1 b;
TestVector1 c;
TestString1? d;
};
struct EmptyStruct {
};
struct TestRecursiveStruct {
TestRecursiveStruct? s;
};
struct TestRecursiveVectorStruct {
vector<TestRecursiveVectorStruct?> v;
};
flexible union TestRecursiveVectorUnion {
1: float32 a;
2: vector<TestRecursiveVectorUnion?> b;
};
struct TestRecursiveUnionStruct {
TestRecursiveVectorUnion? u;
};
union Union1 {
1: array<int8>:3 a;
2: TestSimple b;
3: float32 d;
};
struct TestUnion1 {
Union1 a;
Union1? b;
};
struct TestUnion2 {
vector<Union1> a;
vector<Union1?> b;
};
flexible union XUnion1 {
1: array<int8>:3 a;
2: TestSimple b;
3: float32 d;
};
struct XUnion1Struct {
XUnion1 xu;
};
union XUnion1AsUnion {
1: array<int8>:3 a;
2: TestSimple b;
3: float32 d;
};
struct XUnion1AsUnionStruct {
XUnion1AsUnion xuau;
};
union UnionInsideUnion {
1: float32 a;
2: XUnion1AsUnion b;
};
struct UnionInsideUnionStruct {
UnionInsideUnion u;
};
flexible union XUnionInsideXUnion {
1: float32 a;
2: XUnion1 b;
};
struct XUnionInsideXUnionStruct {
XUnionInsideXUnion u;
};
struct TestXUnion1 {
XUnion1 a;
XUnion1? b;
};
struct TestXUnion2 {
vector<XUnion1> a;
vector<XUnion1?> b;
};
union StrictXUnion1 {
1: array<int8>:3 a;
2: TestSimple b;
3: float32 d;
};
struct StrictXUnion1Struct {
StrictXUnion1 xu;
};
struct TestStrictXUnion1 {
StrictXUnion1 a;
StrictXUnion1? b;
};
struct TestStrictXUnion2 {
vector<StrictXUnion1> a;
vector<StrictXUnion1?> b;
};
resource struct TestHandle1 {
zx.handle a;
zx.handle? b;
zx.handle:VMO c;
zx.handle:VMO? d;
};
resource struct TestHandle2 {
vector<zx.handle>:1 a;
vector<zx.handle:VMO?>:1 b;
};
protocol Test1 {
Echo(string? in) -> (string? out);
NoResponse();
EmptyResponse() -> ();
-> Surprise(string foo);
EchoHandleRights(zx.handle:<PORT, zx.rights.READ | zx.rights.TRANSFER | zx.rights.DUPLICATE> h) -> (uint32 rights);
};
protocol ExampleProtocol {};
resource struct HasClientEnd {
ExampleProtocol client_end;
};
resource struct HasServerEnd {
request<ExampleProtocol> server_end;
};
resource struct TestInterface1 {
Test1 a;
Test1? b;
request<Test1> c;
request<Test1>? d;
};
table SimpleTable {
1: int64 x;
2: reserved;
3: reserved;
4: reserved;
5: int64 y;
};
struct TestSimpleTable {
SimpleTable table;
};
// 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;
};
struct TestOlderSimpleTable {
OlderSimpleTable table;
};
// 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;
};
struct TestNewerSimpleTable {
NewerSimpleTable table;
};
struct TestWithTableAndInt {
SimpleTable table;
uint64 foo;
};
union SimpleUnion {
1: int32 i32;
2: int64 i64;
3: Int64Struct s;
4: string str;
};
struct Int64Struct {
int64 x;
};
// examples from fuchsia world.
const uint64 kMaxBuf = 8192;
struct TestFuchsiaIoReadAtResponse {
zx.status s;
vector<uint8>:kMaxBuf data;
};
struct TestFuchsiaIoWriteAtRequest {
vector<uint8>:kMaxBuf data;
uint64 offset;
};
struct TestFuchsiaPosixSocketSendMsgRequest {
bytes:128 sockaddr;
vector<bytes>:MAX data;
bytes control;
int16 flags;
};
protocol EthernetDevice {
};
struct InterfaceConfig {
string name;
IpAddressConfig ip_address_config;
};
union IpAddressConfig {
1: array<uint32>:6 padding_size_24_align_4;
2: bool dhcp;
};
resource struct TestAddEthernetDeviceRequest {
string topological_path;
InterfaceConfig config;
EthernetDevice device;
};
resource struct TestPackageResolverResolveRequest {
string package_url;
vector<string> selectors;
UpdatePolicy update_policy;
request<EthernetDevice> dir;
};
struct UpdatePolicy {
bool fetch_if_absent;
bool allow_old_versions;
};
enum TestUcharEnum : uint8 {
UcharEnum1 = 1;
UcharEnum2 = 2;
};
// TODO(pascallouis): Move to GIDL
struct TestUcharEnumVec {
vector<TestUcharEnum>:10 values;
};
resource struct HandleRightsSubtypeTestStruct {
vector<zx.handle:<VMO, zx.rights.DUPLICATE | zx.rights.TRANSFER>> h;
};
resource struct PlainHandleTestStruct {
zx.handle h;
};
bits StrictBits {
ONE = 0b01;
TWO = 0b10;
};
flexible bits FlexibleBits {
ONE = 0b01;
TWO = 0b10;
};