1/*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.hardware.tests.safeunion@1.0;
18
19import android.hidl.safe_union@1.0::Monostate;
20
21interface ISafeUnion {
22
23    enum BitField : uint8_t {
24        V0 = 1 << 0,
25        V1 = 1 << 1,
26        V2 = 1 << 2,
27        V3 = 1 << 3,
28    };
29
30    struct J {
31        vec<uint32_t> j1;
32        uint8_t[65] j2;
33        string j3;
34    };
35
36    safe_union SmallSafeUnion {
37        Monostate noinit;
38
39        uint8_t a;
40    };
41
42    safe_union LargeSafeUnion {
43        Monostate noinit;
44
45        int8_t a;
46        uint16_t b;
47        int32_t c;
48        uint64_t d;
49
50        int8_t[13] e;
51        int64_t[5] f;
52
53        string g;
54        vec<bool> h;
55        vec<uint64_t> i;
56
57        J j;
58        struct K {
59            uint8_t k1;
60            uint64_t k2;
61        } k;
62
63        SmallSafeUnion l;
64
65        BitField m;
66        bitfield<BitField> n;
67    };
68
69    safe_union InterfaceTypeSafeUnion {
70        Monostate noinit;
71
72        uint32_t a;
73        int8_t[7] b;
74        interface c;
75        string d;
76        vec<string> e;
77        handle f;
78        vec<handle> g;
79    };
80
81    safe_union HandleTypeSafeUnion {
82        Monostate noinit;
83
84        handle a;
85        handle[5] b;
86        vec<handle> c;
87    };
88
89    newLargeSafeUnion() generates (LargeSafeUnion myUnion);
90    setA(LargeSafeUnion myUnion, int8_t a) generates (LargeSafeUnion myUnion);
91    setB(LargeSafeUnion myUnion, uint16_t b) generates (LargeSafeUnion myUnion);
92    setC(LargeSafeUnion myUnion, int32_t c) generates (LargeSafeUnion myUnion);
93    setD(LargeSafeUnion myUnion, uint64_t d) generates (LargeSafeUnion myUnion);
94    setE(LargeSafeUnion myUnion, int8_t[13] e) generates (LargeSafeUnion myUnion);
95    setF(LargeSafeUnion myUnion, int64_t[5] f) generates (LargeSafeUnion myUnion);
96    setG(LargeSafeUnion myUnion, string g) generates (LargeSafeUnion myUnion);
97    setH(LargeSafeUnion myUnion, vec<bool> h) generates (LargeSafeUnion myUnion);
98    setI(LargeSafeUnion myUnion, vec<uint64_t> i) generates (LargeSafeUnion myUnion);
99    setJ(LargeSafeUnion myUnion, J j) generates (LargeSafeUnion myUnion);
100    setK(LargeSafeUnion myUnion, LargeSafeUnion.K k) generates (LargeSafeUnion myUnion);
101    setL(LargeSafeUnion myUnion, SmallSafeUnion l) generates (LargeSafeUnion myUnion);
102    setM(LargeSafeUnion myUnion, BitField m) generates (LargeSafeUnion myUnion);
103    setN(LargeSafeUnion myUnion, bitfield<BitField> m) generates (LargeSafeUnion myUnion);
104
105    newInterfaceTypeSafeUnion() generates (InterfaceTypeSafeUnion myUnion);
106    setInterfaceA(InterfaceTypeSafeUnion myUnion, uint32_t a) generates (InterfaceTypeSafeUnion myUnion);
107    setInterfaceB(InterfaceTypeSafeUnion myUnion, int8_t[7] b) generates (InterfaceTypeSafeUnion myUnion);
108    setInterfaceC(InterfaceTypeSafeUnion myUnion, interface c) generates (InterfaceTypeSafeUnion myUnion);
109    setInterfaceD(InterfaceTypeSafeUnion myUnion, string d) generates (InterfaceTypeSafeUnion myUnion);
110    setInterfaceE(InterfaceTypeSafeUnion myUnion, vec<string> e) generates (InterfaceTypeSafeUnion myUnion);
111    setInterfaceF(InterfaceTypeSafeUnion myUnion, handle f) generates (InterfaceTypeSafeUnion myUnion);
112    setInterfaceG(InterfaceTypeSafeUnion myUnion, vec<handle> g) generates (InterfaceTypeSafeUnion myUnion);
113
114    newHandleTypeSafeUnion() generates (HandleTypeSafeUnion myUnion);
115    setHandleA(HandleTypeSafeUnion myUnion, handle a) generates (HandleTypeSafeUnion myUnion);
116    setHandleB(HandleTypeSafeUnion myUnion, handle[5] b) generates (HandleTypeSafeUnion myUnion);
117    setHandleC(HandleTypeSafeUnion myUnion, vec<handle> c) generates (HandleTypeSafeUnion myUnion);
118};
119