blob: 153d6f4fd4724fc9738ce07f1e7fe79f7b9eee22 [file] [log] [blame]
Nirav Atreb4186162018-06-08 16:51:29 -07001/*
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
Nirav Atre894556c2018-07-01 13:48:44 -070019import IOtherInterface;
20
Nirav Atreb4186162018-06-08 16:51:29 -070021interface ISafeUnion {
Nirav Atre894556c2018-07-01 13:48:44 -070022
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 EmptySafeUnion {
37 };
38
39 safe_union SmallSafeUnion {
40 uint8_t a;
41 };
42
43 safe_union LargeSafeUnion {
44 int8_t a;
45 uint16_t b;
46 int32_t c;
47 uint64_t d;
48
49 int8_t[13] e;
50 int64_t[5] f;
51
52 string g;
53 vec<bool> h;
54 vec<uint64_t> i;
55
56 J j;
57 struct K {
58 uint8_t k1;
59 uint64_t k2;
60 } k;
61
62 SmallSafeUnion l;
63 };
64
65 // TODO(b/110269925): Test more HIDL types. Missing:
66 // death_recipient, fmq_{sync,unsync}, pointer, ref.
67 safe_union MiscTypesSafeUnion {
68 memory a;
69 handle b;
70 bitfield<BitField> c;
71 };
72
73 safe_union InterfaceTypeSafeUnion {
74 uint32_t a;
75 int8_t[7] b;
76 IOtherInterface c;
77 };
78
Nirav Atreb4186162018-06-08 16:51:29 -070079 newLargeSafeUnion() generates (LargeSafeUnion myUnion);
80 setA(LargeSafeUnion myUnion, int8_t a) generates (LargeSafeUnion myUnion);
81 setB(LargeSafeUnion myUnion, uint16_t b) generates (LargeSafeUnion myUnion);
82 setC(LargeSafeUnion myUnion, int32_t c) generates (LargeSafeUnion myUnion);
83 setD(LargeSafeUnion myUnion, uint64_t d) generates (LargeSafeUnion myUnion);
84 setE(LargeSafeUnion myUnion, int8_t[13] e) generates (LargeSafeUnion myUnion);
85 setF(LargeSafeUnion myUnion, int64_t[5] f) generates (LargeSafeUnion myUnion);
86 setG(LargeSafeUnion myUnion, string g) generates (LargeSafeUnion myUnion);
87 setH(LargeSafeUnion myUnion, vec<bool> h) generates (LargeSafeUnion myUnion);
88 setI(LargeSafeUnion myUnion, vec<uint64_t> i) generates (LargeSafeUnion myUnion);
89 setJ(LargeSafeUnion myUnion, J j) generates (LargeSafeUnion myUnion);
Nirav Atre894556c2018-07-01 13:48:44 -070090 setK(LargeSafeUnion myUnion, LargeSafeUnion.K k) generates (LargeSafeUnion myUnion);
Nirav Atreb4186162018-06-08 16:51:29 -070091 setL(LargeSafeUnion myUnion, SmallSafeUnion l) generates (LargeSafeUnion myUnion);
92
93 newMiscTypesSafeUnion() generates (MiscTypesSafeUnion myUnion);
94 setMiscA(MiscTypesSafeUnion myUnion, memory a) generates (MiscTypesSafeUnion myUnion);
95 setMiscB(MiscTypesSafeUnion myUnion, handle b) generates (MiscTypesSafeUnion myUnion);
96 setMiscC(MiscTypesSafeUnion myUnion, bitfield<BitField> c) generates (MiscTypesSafeUnion myUnion);
Nirav Atre894556c2018-07-01 13:48:44 -070097
98 newInterfaceTypeSafeUnion() generates (InterfaceTypeSafeUnion myUnion);
99 setInterfaceA(InterfaceTypeSafeUnion myUnion, uint32_t a) generates (InterfaceTypeSafeUnion myUnion);
100 setInterfaceB(InterfaceTypeSafeUnion myUnion, int8_t[7] b) generates (InterfaceTypeSafeUnion myUnion);
101 setInterfaceC(InterfaceTypeSafeUnion myUnion, IOtherInterface c) generates (InterfaceTypeSafeUnion myUnion);
Nirav Atreb4186162018-06-08 16:51:29 -0700102};