Nirav Atre | b418616 | 2018-06-08 16:51:29 -0700 | [diff] [blame] | 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 | |
| 17 | package android.hardware.tests.safeunion@1.0; |
| 18 | |
Nirav Atre | 894556c | 2018-07-01 13:48:44 -0700 | [diff] [blame] | 19 | import IOtherInterface; |
| 20 | |
Nirav Atre | b418616 | 2018-06-08 16:51:29 -0700 | [diff] [blame] | 21 | interface ISafeUnion { |
Nirav Atre | 894556c | 2018-07-01 13:48:44 -0700 | [diff] [blame] | 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 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 | |
Nirav Atre | 894556c | 2018-07-01 13:48:44 -0700 | [diff] [blame] | 65 | safe_union InterfaceTypeSafeUnion { |
| 66 | uint32_t a; |
| 67 | int8_t[7] b; |
| 68 | IOtherInterface c; |
| 69 | }; |
| 70 | |
Nirav Atre | b418616 | 2018-06-08 16:51:29 -0700 | [diff] [blame] | 71 | newLargeSafeUnion() generates (LargeSafeUnion myUnion); |
| 72 | setA(LargeSafeUnion myUnion, int8_t a) generates (LargeSafeUnion myUnion); |
| 73 | setB(LargeSafeUnion myUnion, uint16_t b) generates (LargeSafeUnion myUnion); |
| 74 | setC(LargeSafeUnion myUnion, int32_t c) generates (LargeSafeUnion myUnion); |
| 75 | setD(LargeSafeUnion myUnion, uint64_t d) generates (LargeSafeUnion myUnion); |
| 76 | setE(LargeSafeUnion myUnion, int8_t[13] e) generates (LargeSafeUnion myUnion); |
| 77 | setF(LargeSafeUnion myUnion, int64_t[5] f) generates (LargeSafeUnion myUnion); |
| 78 | setG(LargeSafeUnion myUnion, string g) generates (LargeSafeUnion myUnion); |
| 79 | setH(LargeSafeUnion myUnion, vec<bool> h) generates (LargeSafeUnion myUnion); |
| 80 | setI(LargeSafeUnion myUnion, vec<uint64_t> i) generates (LargeSafeUnion myUnion); |
| 81 | setJ(LargeSafeUnion myUnion, J j) generates (LargeSafeUnion myUnion); |
Nirav Atre | 894556c | 2018-07-01 13:48:44 -0700 | [diff] [blame] | 82 | setK(LargeSafeUnion myUnion, LargeSafeUnion.K k) generates (LargeSafeUnion myUnion); |
Nirav Atre | b418616 | 2018-06-08 16:51:29 -0700 | [diff] [blame] | 83 | setL(LargeSafeUnion myUnion, SmallSafeUnion l) generates (LargeSafeUnion myUnion); |
| 84 | |
Nirav Atre | 894556c | 2018-07-01 13:48:44 -0700 | [diff] [blame] | 85 | newInterfaceTypeSafeUnion() generates (InterfaceTypeSafeUnion myUnion); |
| 86 | setInterfaceA(InterfaceTypeSafeUnion myUnion, uint32_t a) generates (InterfaceTypeSafeUnion myUnion); |
| 87 | setInterfaceB(InterfaceTypeSafeUnion myUnion, int8_t[7] b) generates (InterfaceTypeSafeUnion myUnion); |
| 88 | setInterfaceC(InterfaceTypeSafeUnion myUnion, IOtherInterface c) generates (InterfaceTypeSafeUnion myUnion); |
Nirav Atre | b418616 | 2018-06-08 16:51:29 -0700 | [diff] [blame] | 89 | }; |