blob: 1ade4a78f17954161ccb3567a629ac72b784a869 [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.
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 {
};
union Union1 {
array<int8>:3 a;
TestSimple b;
TestSimple? c;
float32 d;
};
struct TestUnion1 {
Union1 a;
Union1? b;
};
struct TestUnion2 {
vector<Union1> a;
vector<Union1?> b;
};
xunion XUnion1 {
array<int8>:3 a;
TestSimple b;
float32 d;
};
struct XUnion1Struct {
XUnion1 xu;
};
union XUnion1AsUnion {
array<int8>:3 a;
TestSimple b;
float32 d;
};
struct XUnion1AsUnionStruct {
XUnion1AsUnion xuau;
};
struct TestXUnion1 {
XUnion1 a;
XUnion1? b;
};
struct TestXUnion2 {
vector<XUnion1> a;
vector<XUnion1?> b;
};
strict xunion StrictXUnion1 {
array<int8>:3 a;
TestSimple b;
float32 d;
};
struct StrictXUnion1Struct {
StrictXUnion1 xu;
};
struct TestStrictXUnion1 {
StrictXUnion1 a;
StrictXUnion1? b;
};
struct TestStrictXUnion2 {
vector<StrictXUnion1> a;
vector<StrictXUnion1?> b;
};
struct TestHandle1 {
handle a;
handle? b;
handle<vmo> c;
handle<vmo>? d;
};
struct TestHandle2 {
vector<handle>:1 a;
vector<handle<vmo>?>:1 b;
};
protocol Test1 {
Echo(string? in) -> (string? out);
NoResponse();
EmptyResponse() -> ();
-> Surprise(string foo);
};
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 {
int32 i32;
int64 i64;
Int64Struct s;
Int64Struct? os;
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;
};
protocol EthernetDevice {
};
struct InterfaceConfig {
string name;
IpAddressConfig ip_address_config;
};
union IpAddressConfig {
array<uint32>:6 padding_size_24_align_4;
bool dhcp;
};
struct TestAddEthernetDeviceRequest {
string topological_path;
InterfaceConfig config;
EthernetDevice device;
};