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 IOtherInterface; 20 21import android.hidl.safe_union@1.0::Monostate; 22 23interface ISafeUnion { 24 25 enum BitField : uint8_t { 26 V0 = 1 << 0, 27 V1 = 1 << 1, 28 V2 = 1 << 2, 29 V3 = 1 << 3, 30 }; 31 32 struct J { 33 vec<uint32_t> j1; 34 uint8_t[65] j2; 35 string j3; 36 }; 37 38 safe_union SmallSafeUnion { 39 Monostate noinit; 40 41 uint8_t a; 42 }; 43 44 safe_union LargeSafeUnion { 45 Monostate noinit; 46 47 int8_t a; 48 uint16_t b; 49 int32_t c; 50 uint64_t d; 51 52 int8_t[13] e; 53 int64_t[5] f; 54 55 string g; 56 vec<bool> h; 57 vec<uint64_t> i; 58 59 J j; 60 struct K { 61 uint8_t k1; 62 uint64_t k2; 63 } k; 64 65 SmallSafeUnion l; 66 67 BitField m; 68 bitfield<BitField> n; 69 }; 70 71 safe_union InterfaceTypeSafeUnion { 72 Monostate noinit; 73 74 uint32_t a; 75 int8_t[7] b; 76 IOtherInterface c; 77 string d; 78 vec<string> e; 79 handle f; 80 vec<handle> g; 81 }; 82 83 safe_union HandleTypeSafeUnion { 84 Monostate noinit; 85 86 handle a; 87 handle[5] b; 88 vec<handle> c; 89 }; 90 91 newLargeSafeUnion() generates (LargeSafeUnion myUnion); 92 setA(LargeSafeUnion myUnion, int8_t a) generates (LargeSafeUnion myUnion); 93 setB(LargeSafeUnion myUnion, uint16_t b) generates (LargeSafeUnion myUnion); 94 setC(LargeSafeUnion myUnion, int32_t c) generates (LargeSafeUnion myUnion); 95 setD(LargeSafeUnion myUnion, uint64_t d) generates (LargeSafeUnion myUnion); 96 setE(LargeSafeUnion myUnion, int8_t[13] e) generates (LargeSafeUnion myUnion); 97 setF(LargeSafeUnion myUnion, int64_t[5] f) generates (LargeSafeUnion myUnion); 98 setG(LargeSafeUnion myUnion, string g) generates (LargeSafeUnion myUnion); 99 setH(LargeSafeUnion myUnion, vec<bool> h) generates (LargeSafeUnion myUnion); 100 setI(LargeSafeUnion myUnion, vec<uint64_t> i) generates (LargeSafeUnion myUnion); 101 setJ(LargeSafeUnion myUnion, J j) generates (LargeSafeUnion myUnion); 102 setK(LargeSafeUnion myUnion, LargeSafeUnion.K k) generates (LargeSafeUnion myUnion); 103 setL(LargeSafeUnion myUnion, SmallSafeUnion l) generates (LargeSafeUnion myUnion); 104 setM(LargeSafeUnion myUnion, BitField m) generates (LargeSafeUnion myUnion); 105 setN(LargeSafeUnion myUnion, bitfield<BitField> m) generates (LargeSafeUnion myUnion); 106 107 newInterfaceTypeSafeUnion() generates (InterfaceTypeSafeUnion myUnion); 108 setInterfaceA(InterfaceTypeSafeUnion myUnion, uint32_t a) generates (InterfaceTypeSafeUnion myUnion); 109 setInterfaceB(InterfaceTypeSafeUnion myUnion, int8_t[7] b) generates (InterfaceTypeSafeUnion myUnion); 110 setInterfaceC(InterfaceTypeSafeUnion myUnion, IOtherInterface c) generates (InterfaceTypeSafeUnion myUnion); 111 setInterfaceD(InterfaceTypeSafeUnion myUnion, string d) generates (InterfaceTypeSafeUnion myUnion); 112 setInterfaceE(InterfaceTypeSafeUnion myUnion, vec<string> e) generates (InterfaceTypeSafeUnion myUnion); 113 setInterfaceF(InterfaceTypeSafeUnion myUnion, handle f) generates (InterfaceTypeSafeUnion myUnion); 114 setInterfaceG(InterfaceTypeSafeUnion myUnion, vec<handle> g) generates (InterfaceTypeSafeUnion myUnion); 115 116 newHandleTypeSafeUnion() generates (HandleTypeSafeUnion myUnion); 117 setHandleA(HandleTypeSafeUnion myUnion, handle a) generates (HandleTypeSafeUnion myUnion); 118 setHandleB(HandleTypeSafeUnion myUnion, handle[5] b) generates (HandleTypeSafeUnion myUnion); 119 setHandleC(HandleTypeSafeUnion myUnion, vec<handle> c) generates (HandleTypeSafeUnion myUnion); 120}; 121