| // 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 { |
| }; |
| |
| struct TestEmptyStructSandwich { |
| string before; |
| EmptyStruct es; |
| string after; |
| }; |
| |
| 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; |
| }; |
| |
| 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); |
| -> 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; |
| }; |
| |
| table TableWithStringAndVector { |
| 1: string foo; |
| 2: int32 bar; |
| 3: vector<uint8> baz; |
| }; |
| |
| struct TestTableWithStringAndVector { |
| TableWithStringAndVector table; |
| }; |
| |
| union SimpleUnion { |
| int32 i32; |
| int64 i64; |
| Int64Struct s; |
| Int64Struct? os; |
| string str; |
| }; |
| |
| struct Int64Struct { |
| int64 x; |
| }; |
| |
| xunion SampleXUnion { |
| uint32 u; |
| SimpleUnion su; |
| SimpleTable st; |
| }; |
| |
| struct TestInlineXUnionInStruct { |
| string before; |
| SampleXUnion xu; |
| string after; |
| }; |
| |
| struct TestOptionalXUnionInStruct { |
| string before; |
| SampleXUnion? xu; |
| string after; |
| }; |
| |
| table XUnionInTable { |
| 1: string before; |
| 2: SampleXUnion xu; |
| 3: string after; |
| }; |
| |
| struct TestXUnionInTable { |
| XUnionInTable value; |
| }; |
| |
| // 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; |
| }; |