| // 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 test.conformance; |
| |
| // TODO(fxbug.dev/36441): Allow bindings to compile on host with handles. |
| |
| type SingleHandle = resource struct { |
| h handle; |
| }; |
| |
| type SingleOptionalHandle = resource struct { |
| h handle:optional; |
| }; |
| |
| type ArrayOfHandles = resource struct { |
| a array<handle, 3>; |
| }; |
| |
| type ArrayOfOptionalHandles = resource struct { |
| a array<handle:optional, 3>; |
| }; |
| |
| type VectorOfHandles = resource struct { |
| v vector<handle>; |
| }; |
| |
| type VectorOfUpTo2Handles = resource struct { |
| v vector<handle>:2; |
| }; |
| |
| type ShortStringThenHandle = resource struct { |
| s string:1; |
| h handle; |
| }; |
| |
| type VectorOfOptionalHandles = resource struct { |
| v vector<handle:optional>; |
| }; |
| |
| type BoxOfSingleHandle = resource struct { |
| b box<SingleHandle>; |
| }; |
| |
| type BoxOfSingleOptionalHandle = resource struct { |
| b box<SingleOptionalHandle>; |
| }; |
| |
| type UnionOfHandle = strict resource union { |
| 1: h handle; |
| }; |
| |
| type StructOfOptionalUnionOfHandle = resource struct { |
| u UnionOfHandle:optional; |
| }; |
| |
| type AlternatingHandlesAndFailures = resource struct { |
| h1 handle; |
| failure_trigger1 string:1; // values will have length > 1 |
| h2 handle; |
| failure_trigger2 string:1; // values will have length > 1 |
| h3 handle; |
| }; |
| |
| // This is not a reference to library zx to avoid complexity in the test data. |
| // A local handle is defined here that contains subtypes that this test cares |
| // about. |
| type obj_type = strict enum : uint32 { |
| NONE = 0; |
| CHANNEL = 4; |
| EVENT = 5; |
| }; |
| |
| type rights = strict bits : uint32 { |
| DUPLICATE = 0x00000001; |
| TRANSFER = 0x00000002; |
| WAIT = 0x00004000; |
| INSPECT = 0x00008000; |
| SIGNAL = 0x00001000; |
| }; |
| |
| const RIGHTS_BASIC rights = rights.TRANSFER | rights.DUPLICATE | rights.WAIT | rights.INSPECT; |
| const DEFAULT_EVENT_RIGHTS rights = RIGHTS_BASIC | rights.SIGNAL; |
| |
| resource_definition handle : uint32 { |
| properties { |
| subtype obj_type; |
| rights rights; |
| }; |
| }; |
| |
| type MultipleHandleSubtypes = resource struct { |
| untyped handle; |
| event handle:EVENT; |
| channel handle:CHANNEL; |
| }; |
| |
| type ReservedFieldTable = resource table { |
| 1: reserved; |
| }; |
| |
| type ReservedFieldTableStruct = resource struct { |
| table ReservedFieldTable; |
| }; |
| |
| type EventWithDefaultRights = resource struct { |
| h handle:<EVENT, DEFAULT_EVENT_RIGHTS>; |
| }; |
| |
| type EventWithReducedRights = resource struct { |
| h handle:<EVENT, RIGHTS_BASIC>; |
| }; |
| |
| type ArrayOfVectorOfEventInStructWithReducedRights = resource struct { |
| h array<vector<handle:<EVENT, RIGHTS_BASIC>>:1, 1>; |
| }; |
| |
| type VectorOfArrayOfEventInStructWithReducedRights = resource struct { |
| h vector<array<handle:<EVENT, RIGHTS_BASIC>, 1>>:1; |
| }; |
| |
| type ArrayOfVectorOfEventInTableWithReducedRights = resource table { |
| 1: h array<vector<handle:<EVENT, RIGHTS_BASIC>>:1, 1>; |
| }; |
| |
| type ArrayOfVectorOfEventInTableWithReducedRightsStruct = resource struct { |
| t ArrayOfVectorOfEventInTableWithReducedRights; |
| }; |
| |
| type VectorOfArrayOfEventInTableWithReducedRights = resource table { |
| 1: h vector<array<handle:<EVENT, RIGHTS_BASIC>, 1>>:1; |
| }; |
| |
| type VectorOfArrayOfEventInTableWithReducedRightsStruct = resource struct { |
| t VectorOfArrayOfEventInTableWithReducedRights; |
| }; |
| |
| type ArrayOfVectorOfEventInUnionWithReducedRights = strict resource union { |
| 1: h array<vector<handle:<EVENT, RIGHTS_BASIC>>:1, 1>; |
| }; |
| |
| type ArrayOfVectorOfEventInUnionWithReducedRightsStruct = resource struct { |
| u ArrayOfVectorOfEventInUnionWithReducedRights; |
| }; |
| |
| type VectorOfArrayOfEventInUnionWithReducedRights = strict resource union { |
| 1: h vector<array<handle:<EVENT, RIGHTS_BASIC>, 1>>:1; |
| }; |
| |
| type VectorOfArrayOfEventInUnionWithReducedRightsStruct = resource struct { |
| u VectorOfArrayOfEventInUnionWithReducedRights; |
| }; |
| |
| type ArrayOfVectorOfEventInStructWithDefaultRights = resource struct { |
| h array<vector<handle:<EVENT, DEFAULT_EVENT_RIGHTS>>:1, 1>; |
| }; |
| |
| type VectorOfArrayOfEventInStructWithDefaultRights = resource struct { |
| h vector<array<handle:<EVENT, DEFAULT_EVENT_RIGHTS>, 1>>:1; |
| }; |
| |
| type ArrayOfVectorOfEventInTableWithDefaultRights = resource table { |
| 1: h array<vector<handle:<EVENT, DEFAULT_EVENT_RIGHTS>>:1, 1>; |
| }; |
| |
| type ArrayOfVectorOfEventInTableWithDefaultRightsStruct = resource struct { |
| t ArrayOfVectorOfEventInTableWithDefaultRights; |
| }; |
| |
| type ArrayOfVectorOfEventInUnionWithDefaultRights = strict resource union { |
| 1: h array<vector<handle:<EVENT, DEFAULT_EVENT_RIGHTS>>:1, 1>; |
| }; |
| |
| type ArrayOfVectorOfEventInUnionWithDefaultRightsStruct = resource struct { |
| u ArrayOfVectorOfEventInUnionWithDefaultRights; |
| }; |