Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015, 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 | #include <string> |
| 18 | |
Elliott Hughes | 0a62067 | 2015-12-04 13:53:18 -0800 | [diff] [blame] | 19 | #include <android-base/stringprintf.h> |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 20 | #include <gtest/gtest.h> |
| 21 | |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 22 | #include "aidl.h" |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 23 | #include "aidl_language.h" |
| 24 | #include "ast_cpp.h" |
| 25 | #include "code_writer.h" |
Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 26 | #include "generate_cpp.h" |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 27 | #include "os.h" |
Christopher Wiley | 4a2884b | 2015-10-07 11:27:45 -0700 | [diff] [blame] | 28 | #include "tests/fake_io_delegate.h" |
Casey Dahlin | 80ada3d | 2015-10-20 20:33:56 -0700 | [diff] [blame] | 29 | #include "tests/test_util.h" |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 30 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 31 | using ::android::aidl::test::FakeIoDelegate; |
| 32 | using ::android::base::StringPrintf; |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 33 | using std::string; |
| 34 | using std::unique_ptr; |
| 35 | |
| 36 | namespace android { |
| 37 | namespace aidl { |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 38 | namespace cpp { |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 39 | namespace { |
| 40 | |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 41 | // clang-format off |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 42 | const string kComplexTypeInterfaceAIDL = |
| 43 | R"(package android.os; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 44 | import foo.IFooType; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 45 | interface IComplexTypeInterface { |
Casey Dahlin | d40e2fe | 2015-11-24 14:06:52 -0800 | [diff] [blame] | 46 | const int MY_CONSTANT = 3; |
Casey Dahlin | cb5317d | 2015-12-03 15:43:33 -0800 | [diff] [blame] | 47 | int[] Send(in @nullable int[] goes_in, inout double[] goes_in_and_out, out boolean[] goes_out); |
Casey Dahlin | 0dd08af | 2015-10-20 18:45:50 -0700 | [diff] [blame] | 48 | oneway void Piff(int times); |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 49 | IFooType TakesABinder(IFooType f); |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 50 | @nullable IFooType NullableBinder(); |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 51 | List<String> StringListMethod(in java.util.List<String> input, out List<String> output); |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 52 | List<IBinder> BinderListMethod(in java.util.List<IBinder> input, out List<IBinder> output); |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 53 | FileDescriptor TakesAFileDescriptor(in FileDescriptor f); |
| 54 | FileDescriptor[] TakesAFileDescriptorArray(in FileDescriptor[] f); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 55 | })"; |
| 56 | |
| 57 | const char kExpectedComplexTypeClientHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 58 | R"(#pragma once |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 59 | |
| 60 | #include <binder/IBinder.h> |
| 61 | #include <binder/IInterface.h> |
| 62 | #include <utils/Errors.h> |
| 63 | #include <android/os/IComplexTypeInterface.h> |
| 64 | |
| 65 | namespace android { |
| 66 | |
| 67 | namespace os { |
| 68 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 69 | class BpComplexTypeInterface : public ::android::BpInterface<IComplexTypeInterface> { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 70 | public: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 71 | explicit BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl); |
| 72 | virtual ~BpComplexTypeInterface() = default; |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 73 | ::android::binder::Status Send(const ::std::optional<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) override; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 74 | ::android::binder::Status Piff(int32_t times) override; |
| 75 | ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) override; |
| 76 | ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) override; |
| 77 | ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) override; |
| 78 | ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) override; |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 79 | ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) override; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 80 | ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) override; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 81 | }; // class BpComplexTypeInterface |
| 82 | |
| 83 | } // namespace os |
| 84 | |
| 85 | } // namespace android |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 86 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 87 | |
| 88 | const char kExpectedComplexTypeClientSourceOutput[] = |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 89 | R"(#include <android/os/BpComplexTypeInterface.h> |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 90 | #include <android/os/BnComplexTypeInterface.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 91 | #include <binder/Parcel.h> |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 92 | #include <android-base/macros.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 93 | |
| 94 | namespace android { |
| 95 | |
| 96 | namespace os { |
| 97 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 98 | BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl) |
| 99 | : BpInterface<IComplexTypeInterface>(_aidl_impl){ |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 100 | } |
| 101 | |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 102 | ::android::binder::Status BpComplexTypeInterface::Send(const ::std::optional<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 103 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 104 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 105 | ::android::Parcel _aidl_reply; |
| 106 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 107 | ::android::binder::Status _aidl_status; |
| 108 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 109 | if (((_aidl_ret_status) != (::android::OK))) { |
| 110 | goto _aidl_error; |
| 111 | } |
| 112 | _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in); |
| 113 | if (((_aidl_ret_status) != (::android::OK))) { |
| 114 | goto _aidl_error; |
| 115 | } |
| 116 | _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out); |
| 117 | if (((_aidl_ret_status) != (::android::OK))) { |
| 118 | goto _aidl_error; |
| 119 | } |
| 120 | _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out); |
| 121 | if (((_aidl_ret_status) != (::android::OK))) { |
| 122 | goto _aidl_error; |
| 123 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 124 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Send, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 125 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 126 | return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _aidl_return); |
| 127 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 128 | if (((_aidl_ret_status) != (::android::OK))) { |
| 129 | goto _aidl_error; |
| 130 | } |
| 131 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 132 | if (((_aidl_ret_status) != (::android::OK))) { |
| 133 | goto _aidl_error; |
| 134 | } |
| 135 | if (!_aidl_status.isOk()) { |
| 136 | return _aidl_status; |
| 137 | } |
| 138 | _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return); |
| 139 | if (((_aidl_ret_status) != (::android::OK))) { |
| 140 | goto _aidl_error; |
| 141 | } |
| 142 | _aidl_ret_status = _aidl_reply.readDoubleVector(goes_in_and_out); |
| 143 | if (((_aidl_ret_status) != (::android::OK))) { |
| 144 | goto _aidl_error; |
| 145 | } |
| 146 | _aidl_ret_status = _aidl_reply.readBoolVector(goes_out); |
| 147 | if (((_aidl_ret_status) != (::android::OK))) { |
| 148 | goto _aidl_error; |
| 149 | } |
| 150 | _aidl_error: |
| 151 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 152 | return _aidl_status; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 153 | } |
| 154 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 155 | ::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 156 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 157 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 158 | ::android::Parcel _aidl_reply; |
| 159 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 160 | ::android::binder::Status _aidl_status; |
| 161 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 162 | if (((_aidl_ret_status) != (::android::OK))) { |
| 163 | goto _aidl_error; |
| 164 | } |
| 165 | _aidl_ret_status = _aidl_data.writeInt32(times); |
| 166 | if (((_aidl_ret_status) != (::android::OK))) { |
| 167 | goto _aidl_error; |
| 168 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 169 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Piff, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 170 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 171 | return IComplexTypeInterface::getDefaultImpl()->Piff(times); |
| 172 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 173 | if (((_aidl_ret_status) != (::android::OK))) { |
| 174 | goto _aidl_error; |
| 175 | } |
| 176 | _aidl_error: |
| 177 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 178 | return _aidl_status; |
Casey Dahlin | 0dd08af | 2015-10-20 18:45:50 -0700 | [diff] [blame] | 179 | } |
| 180 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 181 | ::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 182 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 183 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 184 | ::android::Parcel _aidl_reply; |
| 185 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 186 | ::android::binder::Status _aidl_status; |
| 187 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 188 | if (((_aidl_ret_status) != (::android::OK))) { |
| 189 | goto _aidl_error; |
| 190 | } |
| 191 | _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f)); |
| 192 | if (((_aidl_ret_status) != (::android::OK))) { |
| 193 | goto _aidl_error; |
| 194 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 195 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesABinder, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 196 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 197 | return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _aidl_return); |
| 198 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 199 | if (((_aidl_ret_status) != (::android::OK))) { |
| 200 | goto _aidl_error; |
| 201 | } |
| 202 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 203 | if (((_aidl_ret_status) != (::android::OK))) { |
| 204 | goto _aidl_error; |
| 205 | } |
| 206 | if (!_aidl_status.isOk()) { |
| 207 | return _aidl_status; |
| 208 | } |
| 209 | _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return); |
| 210 | if (((_aidl_ret_status) != (::android::OK))) { |
| 211 | goto _aidl_error; |
| 212 | } |
| 213 | _aidl_error: |
| 214 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 215 | return _aidl_status; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 218 | ::android::binder::Status BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 219 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 220 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 221 | ::android::Parcel _aidl_reply; |
| 222 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 223 | ::android::binder::Status _aidl_status; |
| 224 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 225 | if (((_aidl_ret_status) != (::android::OK))) { |
| 226 | goto _aidl_error; |
| 227 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 228 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_NullableBinder, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 229 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 230 | return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_aidl_return); |
| 231 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 232 | if (((_aidl_ret_status) != (::android::OK))) { |
| 233 | goto _aidl_error; |
| 234 | } |
| 235 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 236 | if (((_aidl_ret_status) != (::android::OK))) { |
| 237 | goto _aidl_error; |
| 238 | } |
| 239 | if (!_aidl_status.isOk()) { |
| 240 | return _aidl_status; |
| 241 | } |
| 242 | _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return); |
| 243 | if (((_aidl_ret_status) != (::android::OK))) { |
| 244 | goto _aidl_error; |
| 245 | } |
| 246 | _aidl_error: |
| 247 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 248 | return _aidl_status; |
Casey Dahlin | ef88bce | 2016-04-15 11:55:30 -0700 | [diff] [blame] | 249 | } |
| 250 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 251 | ::android::binder::Status BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 252 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 253 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 254 | ::android::Parcel _aidl_reply; |
| 255 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 256 | ::android::binder::Status _aidl_status; |
| 257 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 258 | if (((_aidl_ret_status) != (::android::OK))) { |
| 259 | goto _aidl_error; |
| 260 | } |
| 261 | _aidl_ret_status = _aidl_data.writeString16Vector(input); |
| 262 | if (((_aidl_ret_status) != (::android::OK))) { |
| 263 | goto _aidl_error; |
| 264 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 265 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_StringListMethod, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 266 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 267 | return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _aidl_return); |
| 268 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 269 | if (((_aidl_ret_status) != (::android::OK))) { |
| 270 | goto _aidl_error; |
| 271 | } |
| 272 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 273 | if (((_aidl_ret_status) != (::android::OK))) { |
| 274 | goto _aidl_error; |
| 275 | } |
| 276 | if (!_aidl_status.isOk()) { |
| 277 | return _aidl_status; |
| 278 | } |
| 279 | _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return); |
| 280 | if (((_aidl_ret_status) != (::android::OK))) { |
| 281 | goto _aidl_error; |
| 282 | } |
| 283 | _aidl_ret_status = _aidl_reply.readString16Vector(output); |
| 284 | if (((_aidl_ret_status) != (::android::OK))) { |
| 285 | goto _aidl_error; |
| 286 | } |
| 287 | _aidl_error: |
| 288 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 289 | return _aidl_status; |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 290 | } |
| 291 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 292 | ::android::binder::Status BpComplexTypeInterface::BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 293 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 294 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 295 | ::android::Parcel _aidl_reply; |
| 296 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 297 | ::android::binder::Status _aidl_status; |
| 298 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 299 | if (((_aidl_ret_status) != (::android::OK))) { |
| 300 | goto _aidl_error; |
| 301 | } |
| 302 | _aidl_ret_status = _aidl_data.writeStrongBinderVector(input); |
| 303 | if (((_aidl_ret_status) != (::android::OK))) { |
| 304 | goto _aidl_error; |
| 305 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 306 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_BinderListMethod, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 307 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 308 | return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _aidl_return); |
| 309 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 310 | if (((_aidl_ret_status) != (::android::OK))) { |
| 311 | goto _aidl_error; |
| 312 | } |
| 313 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 314 | if (((_aidl_ret_status) != (::android::OK))) { |
| 315 | goto _aidl_error; |
| 316 | } |
| 317 | if (!_aidl_status.isOk()) { |
| 318 | return _aidl_status; |
| 319 | } |
| 320 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return); |
| 321 | if (((_aidl_ret_status) != (::android::OK))) { |
| 322 | goto _aidl_error; |
| 323 | } |
| 324 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(output); |
| 325 | if (((_aidl_ret_status) != (::android::OK))) { |
| 326 | goto _aidl_error; |
| 327 | } |
| 328 | _aidl_error: |
| 329 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 330 | return _aidl_status; |
Casey Dahlin | 7ecd69f | 2015-11-03 13:52:38 -0800 | [diff] [blame] | 331 | } |
| 332 | |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 333 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 334 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 335 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 336 | ::android::Parcel _aidl_reply; |
| 337 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 338 | ::android::binder::Status _aidl_status; |
| 339 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 340 | if (((_aidl_ret_status) != (::android::OK))) { |
| 341 | goto _aidl_error; |
| 342 | } |
| 343 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f); |
| 344 | if (((_aidl_ret_status) != (::android::OK))) { |
| 345 | goto _aidl_error; |
| 346 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 347 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 348 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 349 | return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(std::move(f), _aidl_return); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 350 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 351 | if (((_aidl_ret_status) != (::android::OK))) { |
| 352 | goto _aidl_error; |
| 353 | } |
| 354 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 355 | if (((_aidl_ret_status) != (::android::OK))) { |
| 356 | goto _aidl_error; |
| 357 | } |
| 358 | if (!_aidl_status.isOk()) { |
| 359 | return _aidl_status; |
| 360 | } |
| 361 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptor(_aidl_return); |
| 362 | if (((_aidl_ret_status) != (::android::OK))) { |
| 363 | goto _aidl_error; |
| 364 | } |
| 365 | _aidl_error: |
| 366 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 367 | return _aidl_status; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 368 | } |
| 369 | |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 370 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 371 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 372 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 373 | ::android::Parcel _aidl_reply; |
| 374 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 375 | ::android::binder::Status _aidl_status; |
| 376 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 377 | if (((_aidl_ret_status) != (::android::OK))) { |
| 378 | goto _aidl_error; |
| 379 | } |
| 380 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f); |
| 381 | if (((_aidl_ret_status) != (::android::OK))) { |
| 382 | goto _aidl_error; |
| 383 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 384 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 385 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 386 | return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _aidl_return); |
| 387 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 388 | if (((_aidl_ret_status) != (::android::OK))) { |
| 389 | goto _aidl_error; |
| 390 | } |
| 391 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 392 | if (((_aidl_ret_status) != (::android::OK))) { |
| 393 | goto _aidl_error; |
| 394 | } |
| 395 | if (!_aidl_status.isOk()) { |
| 396 | return _aidl_status; |
| 397 | } |
| 398 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptorVector(_aidl_return); |
| 399 | if (((_aidl_ret_status) != (::android::OK))) { |
| 400 | goto _aidl_error; |
| 401 | } |
| 402 | _aidl_error: |
| 403 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 404 | return _aidl_status; |
Casey Dahlin | a4ba4b6 | 2015-11-02 15:43:30 -0800 | [diff] [blame] | 405 | } |
| 406 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 407 | } // namespace os |
| 408 | |
| 409 | } // namespace android |
| 410 | )"; |
| 411 | |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 412 | const char kExpectedComplexTypeClientWithTraceSourceOutput[] = |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 413 | R"(#include <android/os/BpComplexTypeInterface.h> |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 414 | #include <android/os/BnComplexTypeInterface.h> |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 415 | #include <binder/Parcel.h> |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 416 | #include <android-base/macros.h> |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 417 | |
| 418 | namespace android { |
| 419 | |
| 420 | namespace os { |
| 421 | |
| 422 | BpComplexTypeInterface::BpComplexTypeInterface(const ::android::sp<::android::IBinder>& _aidl_impl) |
| 423 | : BpInterface<IComplexTypeInterface>(_aidl_impl){ |
| 424 | } |
| 425 | |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 426 | ::android::binder::Status BpComplexTypeInterface::Send(const ::std::optional<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 427 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 428 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 429 | ::android::Parcel _aidl_reply; |
| 430 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 431 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 432 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::Send::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 433 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 434 | if (((_aidl_ret_status) != (::android::OK))) { |
| 435 | goto _aidl_error; |
| 436 | } |
| 437 | _aidl_ret_status = _aidl_data.writeInt32Vector(goes_in); |
| 438 | if (((_aidl_ret_status) != (::android::OK))) { |
| 439 | goto _aidl_error; |
| 440 | } |
| 441 | _aidl_ret_status = _aidl_data.writeDoubleVector(*goes_in_and_out); |
| 442 | if (((_aidl_ret_status) != (::android::OK))) { |
| 443 | goto _aidl_error; |
| 444 | } |
| 445 | _aidl_ret_status = _aidl_data.writeVectorSize(*goes_out); |
| 446 | if (((_aidl_ret_status) != (::android::OK))) { |
| 447 | goto _aidl_error; |
| 448 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 449 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Send, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 450 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 451 | return IComplexTypeInterface::getDefaultImpl()->Send(goes_in, goes_in_and_out, goes_out, _aidl_return); |
| 452 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 453 | if (((_aidl_ret_status) != (::android::OK))) { |
| 454 | goto _aidl_error; |
| 455 | } |
| 456 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 457 | if (((_aidl_ret_status) != (::android::OK))) { |
| 458 | goto _aidl_error; |
| 459 | } |
| 460 | if (!_aidl_status.isOk()) { |
| 461 | return _aidl_status; |
| 462 | } |
| 463 | _aidl_ret_status = _aidl_reply.readInt32Vector(_aidl_return); |
| 464 | if (((_aidl_ret_status) != (::android::OK))) { |
| 465 | goto _aidl_error; |
| 466 | } |
| 467 | _aidl_ret_status = _aidl_reply.readDoubleVector(goes_in_and_out); |
| 468 | if (((_aidl_ret_status) != (::android::OK))) { |
| 469 | goto _aidl_error; |
| 470 | } |
| 471 | _aidl_ret_status = _aidl_reply.readBoolVector(goes_out); |
| 472 | if (((_aidl_ret_status) != (::android::OK))) { |
| 473 | goto _aidl_error; |
| 474 | } |
| 475 | _aidl_error: |
| 476 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 477 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 478 | } |
| 479 | |
| 480 | ::android::binder::Status BpComplexTypeInterface::Piff(int32_t times) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 481 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 482 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 483 | ::android::Parcel _aidl_reply; |
| 484 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 485 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 486 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::Piff::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 487 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 488 | if (((_aidl_ret_status) != (::android::OK))) { |
| 489 | goto _aidl_error; |
| 490 | } |
| 491 | _aidl_ret_status = _aidl_data.writeInt32(times); |
| 492 | if (((_aidl_ret_status) != (::android::OK))) { |
| 493 | goto _aidl_error; |
| 494 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 495 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_Piff, _aidl_data, &_aidl_reply, ::android::IBinder::FLAG_ONEWAY); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 496 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 497 | return IComplexTypeInterface::getDefaultImpl()->Piff(times); |
| 498 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 499 | if (((_aidl_ret_status) != (::android::OK))) { |
| 500 | goto _aidl_error; |
| 501 | } |
| 502 | _aidl_error: |
| 503 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 504 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 505 | } |
| 506 | |
| 507 | ::android::binder::Status BpComplexTypeInterface::TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 508 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 509 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 510 | ::android::Parcel _aidl_reply; |
| 511 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 512 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 513 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesABinder::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 514 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 515 | if (((_aidl_ret_status) != (::android::OK))) { |
| 516 | goto _aidl_error; |
| 517 | } |
| 518 | _aidl_ret_status = _aidl_data.writeStrongBinder(::foo::IFooType::asBinder(f)); |
| 519 | if (((_aidl_ret_status) != (::android::OK))) { |
| 520 | goto _aidl_error; |
| 521 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 522 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesABinder, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 523 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 524 | return IComplexTypeInterface::getDefaultImpl()->TakesABinder(f, _aidl_return); |
| 525 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 526 | if (((_aidl_ret_status) != (::android::OK))) { |
| 527 | goto _aidl_error; |
| 528 | } |
| 529 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 530 | if (((_aidl_ret_status) != (::android::OK))) { |
| 531 | goto _aidl_error; |
| 532 | } |
| 533 | if (!_aidl_status.isOk()) { |
| 534 | return _aidl_status; |
| 535 | } |
| 536 | _aidl_ret_status = _aidl_reply.readStrongBinder(_aidl_return); |
| 537 | if (((_aidl_ret_status) != (::android::OK))) { |
| 538 | goto _aidl_error; |
| 539 | } |
| 540 | _aidl_error: |
| 541 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 542 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 543 | } |
| 544 | |
| 545 | ::android::binder::Status BpComplexTypeInterface::NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 546 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 547 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 548 | ::android::Parcel _aidl_reply; |
| 549 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 550 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 551 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::NullableBinder::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 552 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 553 | if (((_aidl_ret_status) != (::android::OK))) { |
| 554 | goto _aidl_error; |
| 555 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 556 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_NullableBinder, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 557 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 558 | return IComplexTypeInterface::getDefaultImpl()->NullableBinder(_aidl_return); |
| 559 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 560 | if (((_aidl_ret_status) != (::android::OK))) { |
| 561 | goto _aidl_error; |
| 562 | } |
| 563 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 564 | if (((_aidl_ret_status) != (::android::OK))) { |
| 565 | goto _aidl_error; |
| 566 | } |
| 567 | if (!_aidl_status.isOk()) { |
| 568 | return _aidl_status; |
| 569 | } |
| 570 | _aidl_ret_status = _aidl_reply.readNullableStrongBinder(_aidl_return); |
| 571 | if (((_aidl_ret_status) != (::android::OK))) { |
| 572 | goto _aidl_error; |
| 573 | } |
| 574 | _aidl_error: |
| 575 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 576 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 577 | } |
| 578 | |
| 579 | ::android::binder::Status BpComplexTypeInterface::StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 580 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 581 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 582 | ::android::Parcel _aidl_reply; |
| 583 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 584 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 585 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::StringListMethod::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 586 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 587 | if (((_aidl_ret_status) != (::android::OK))) { |
| 588 | goto _aidl_error; |
| 589 | } |
| 590 | _aidl_ret_status = _aidl_data.writeString16Vector(input); |
| 591 | if (((_aidl_ret_status) != (::android::OK))) { |
| 592 | goto _aidl_error; |
| 593 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 594 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_StringListMethod, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 595 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 596 | return IComplexTypeInterface::getDefaultImpl()->StringListMethod(input, output, _aidl_return); |
| 597 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 598 | if (((_aidl_ret_status) != (::android::OK))) { |
| 599 | goto _aidl_error; |
| 600 | } |
| 601 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 602 | if (((_aidl_ret_status) != (::android::OK))) { |
| 603 | goto _aidl_error; |
| 604 | } |
| 605 | if (!_aidl_status.isOk()) { |
| 606 | return _aidl_status; |
| 607 | } |
| 608 | _aidl_ret_status = _aidl_reply.readString16Vector(_aidl_return); |
| 609 | if (((_aidl_ret_status) != (::android::OK))) { |
| 610 | goto _aidl_error; |
| 611 | } |
| 612 | _aidl_ret_status = _aidl_reply.readString16Vector(output); |
| 613 | if (((_aidl_ret_status) != (::android::OK))) { |
| 614 | goto _aidl_error; |
| 615 | } |
| 616 | _aidl_error: |
| 617 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 618 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 619 | } |
| 620 | |
| 621 | ::android::binder::Status BpComplexTypeInterface::BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 622 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 623 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 624 | ::android::Parcel _aidl_reply; |
| 625 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 626 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 627 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::BinderListMethod::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 628 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 629 | if (((_aidl_ret_status) != (::android::OK))) { |
| 630 | goto _aidl_error; |
| 631 | } |
| 632 | _aidl_ret_status = _aidl_data.writeStrongBinderVector(input); |
| 633 | if (((_aidl_ret_status) != (::android::OK))) { |
| 634 | goto _aidl_error; |
| 635 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 636 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_BinderListMethod, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 637 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 638 | return IComplexTypeInterface::getDefaultImpl()->BinderListMethod(input, output, _aidl_return); |
| 639 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 640 | if (((_aidl_ret_status) != (::android::OK))) { |
| 641 | goto _aidl_error; |
| 642 | } |
| 643 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 644 | if (((_aidl_ret_status) != (::android::OK))) { |
| 645 | goto _aidl_error; |
| 646 | } |
| 647 | if (!_aidl_status.isOk()) { |
| 648 | return _aidl_status; |
| 649 | } |
| 650 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(_aidl_return); |
| 651 | if (((_aidl_ret_status) != (::android::OK))) { |
| 652 | goto _aidl_error; |
| 653 | } |
| 654 | _aidl_ret_status = _aidl_reply.readStrongBinderVector(output); |
| 655 | if (((_aidl_ret_status) != (::android::OK))) { |
| 656 | goto _aidl_error; |
| 657 | } |
| 658 | _aidl_error: |
| 659 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 660 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 661 | } |
| 662 | |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 663 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 664 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 665 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 666 | ::android::Parcel _aidl_reply; |
| 667 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 668 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 669 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesAFileDescriptor::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 670 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 671 | if (((_aidl_ret_status) != (::android::OK))) { |
| 672 | goto _aidl_error; |
| 673 | } |
| 674 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptor(f); |
| 675 | if (((_aidl_ret_status) != (::android::OK))) { |
| 676 | goto _aidl_error; |
| 677 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 678 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 679 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 680 | return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptor(std::move(f), _aidl_return); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 681 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 682 | if (((_aidl_ret_status) != (::android::OK))) { |
| 683 | goto _aidl_error; |
| 684 | } |
| 685 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 686 | if (((_aidl_ret_status) != (::android::OK))) { |
| 687 | goto _aidl_error; |
| 688 | } |
| 689 | if (!_aidl_status.isOk()) { |
| 690 | return _aidl_status; |
| 691 | } |
| 692 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptor(_aidl_return); |
| 693 | if (((_aidl_ret_status) != (::android::OK))) { |
| 694 | goto _aidl_error; |
| 695 | } |
| 696 | _aidl_error: |
| 697 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 698 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | ::android::binder::Status BpComplexTypeInterface::TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 702 | ::android::Parcel _aidl_data; |
Steven Moreland | 7a935a8 | 2020-11-21 00:44:35 +0000 | [diff] [blame] | 703 | _aidl_data.markForBinder(remote()); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 704 | ::android::Parcel _aidl_reply; |
| 705 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 706 | ::android::binder::Status _aidl_status; |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 707 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesAFileDescriptorArray::cppClient"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 708 | _aidl_ret_status = _aidl_data.writeInterfaceToken(getInterfaceDescriptor()); |
| 709 | if (((_aidl_ret_status) != (::android::OK))) { |
| 710 | goto _aidl_error; |
| 711 | } |
| 712 | _aidl_ret_status = _aidl_data.writeUniqueFileDescriptorVector(f); |
| 713 | if (((_aidl_ret_status) != (::android::OK))) { |
| 714 | goto _aidl_error; |
| 715 | } |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 716 | _aidl_ret_status = remote()->transact(BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray, _aidl_data, &_aidl_reply, 0); |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 717 | if (UNLIKELY(_aidl_ret_status == ::android::UNKNOWN_TRANSACTION && IComplexTypeInterface::getDefaultImpl())) { |
| 718 | return IComplexTypeInterface::getDefaultImpl()->TakesAFileDescriptorArray(f, _aidl_return); |
| 719 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 720 | if (((_aidl_ret_status) != (::android::OK))) { |
| 721 | goto _aidl_error; |
| 722 | } |
| 723 | _aidl_ret_status = _aidl_status.readFromParcel(_aidl_reply); |
| 724 | if (((_aidl_ret_status) != (::android::OK))) { |
| 725 | goto _aidl_error; |
| 726 | } |
| 727 | if (!_aidl_status.isOk()) { |
| 728 | return _aidl_status; |
| 729 | } |
| 730 | _aidl_ret_status = _aidl_reply.readUniqueFileDescriptorVector(_aidl_return); |
| 731 | if (((_aidl_ret_status) != (::android::OK))) { |
| 732 | goto _aidl_error; |
| 733 | } |
| 734 | _aidl_error: |
| 735 | _aidl_status.setFromStatusT(_aidl_ret_status); |
| 736 | return _aidl_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 737 | } |
| 738 | |
| 739 | } // namespace os |
| 740 | |
| 741 | } // namespace android |
| 742 | )"; |
| 743 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 744 | const char kExpectedComplexTypeServerHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 745 | R"(#pragma once |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 746 | |
| 747 | #include <binder/IInterface.h> |
| 748 | #include <android/os/IComplexTypeInterface.h> |
| 749 | |
| 750 | namespace android { |
| 751 | |
| 752 | namespace os { |
| 753 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 754 | class BnComplexTypeInterface : public ::android::BnInterface<IComplexTypeInterface> { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 755 | public: |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 756 | static constexpr uint32_t TRANSACTION_Send = ::android::IBinder::FIRST_CALL_TRANSACTION + 0; |
| 757 | static constexpr uint32_t TRANSACTION_Piff = ::android::IBinder::FIRST_CALL_TRANSACTION + 1; |
| 758 | static constexpr uint32_t TRANSACTION_TakesABinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 2; |
| 759 | static constexpr uint32_t TRANSACTION_NullableBinder = ::android::IBinder::FIRST_CALL_TRANSACTION + 3; |
| 760 | static constexpr uint32_t TRANSACTION_StringListMethod = ::android::IBinder::FIRST_CALL_TRANSACTION + 4; |
| 761 | static constexpr uint32_t TRANSACTION_BinderListMethod = ::android::IBinder::FIRST_CALL_TRANSACTION + 5; |
| 762 | static constexpr uint32_t TRANSACTION_TakesAFileDescriptor = ::android::IBinder::FIRST_CALL_TRANSACTION + 6; |
| 763 | static constexpr uint32_t TRANSACTION_TakesAFileDescriptorArray = ::android::IBinder::FIRST_CALL_TRANSACTION + 7; |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 764 | explicit BnComplexTypeInterface(); |
Jiyong Park | 8533bd0 | 2018-10-29 21:31:18 +0900 | [diff] [blame] | 765 | ::android::status_t onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) override; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 766 | }; // class BnComplexTypeInterface |
| 767 | |
| 768 | } // namespace os |
| 769 | |
| 770 | } // namespace android |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 771 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 772 | |
| 773 | const char kExpectedComplexTypeServerSourceOutput[] = |
Jeongik Cha | b5d962f | 2018-11-17 09:12:28 +0900 | [diff] [blame] | 774 | R"(#include <android/os/BnComplexTypeInterface.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 775 | #include <binder/Parcel.h> |
Steven Moreland | a57d0a6 | 2019-07-30 09:41:14 -0700 | [diff] [blame] | 776 | #include <binder/Stability.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 777 | |
| 778 | namespace android { |
| 779 | |
| 780 | namespace os { |
| 781 | |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 782 | BnComplexTypeInterface::BnComplexTypeInterface() |
| 783 | { |
Steven Moreland | a57d0a6 | 2019-07-30 09:41:14 -0700 | [diff] [blame] | 784 | ::android::internal::Stability::markCompilationUnit(this); |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 785 | } |
| 786 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 787 | ::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 788 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 789 | switch (_aidl_code) { |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 790 | case BnComplexTypeInterface::TRANSACTION_Send: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 791 | { |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 792 | ::std::optional<::std::vector<int32_t>> in_goes_in; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 793 | ::std::vector<double> in_goes_in_and_out; |
| 794 | ::std::vector<bool> out_goes_out; |
| 795 | ::std::vector<int32_t> _aidl_return; |
| 796 | if (!(_aidl_data.checkInterface(this))) { |
| 797 | _aidl_ret_status = ::android::BAD_TYPE; |
| 798 | break; |
| 799 | } |
| 800 | _aidl_ret_status = _aidl_data.readInt32Vector(&in_goes_in); |
| 801 | if (((_aidl_ret_status) != (::android::OK))) { |
| 802 | break; |
| 803 | } |
| 804 | _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out); |
| 805 | if (((_aidl_ret_status) != (::android::OK))) { |
| 806 | break; |
| 807 | } |
| 808 | _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out); |
| 809 | if (((_aidl_ret_status) != (::android::OK))) { |
| 810 | break; |
| 811 | } |
| 812 | ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return)); |
| 813 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 814 | if (((_aidl_ret_status) != (::android::OK))) { |
| 815 | break; |
| 816 | } |
| 817 | if (!_aidl_status.isOk()) { |
| 818 | break; |
| 819 | } |
| 820 | _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return); |
| 821 | if (((_aidl_ret_status) != (::android::OK))) { |
| 822 | break; |
| 823 | } |
| 824 | _aidl_ret_status = _aidl_reply->writeDoubleVector(in_goes_in_and_out); |
| 825 | if (((_aidl_ret_status) != (::android::OK))) { |
| 826 | break; |
| 827 | } |
| 828 | _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out); |
| 829 | if (((_aidl_ret_status) != (::android::OK))) { |
| 830 | break; |
| 831 | } |
| 832 | } |
| 833 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 834 | case BnComplexTypeInterface::TRANSACTION_Piff: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 835 | { |
| 836 | int32_t in_times; |
| 837 | if (!(_aidl_data.checkInterface(this))) { |
| 838 | _aidl_ret_status = ::android::BAD_TYPE; |
| 839 | break; |
| 840 | } |
| 841 | _aidl_ret_status = _aidl_data.readInt32(&in_times); |
| 842 | if (((_aidl_ret_status) != (::android::OK))) { |
| 843 | break; |
| 844 | } |
| 845 | ::android::binder::Status _aidl_status(Piff(in_times)); |
| 846 | } |
| 847 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 848 | case BnComplexTypeInterface::TRANSACTION_TakesABinder: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 849 | { |
| 850 | ::android::sp<::foo::IFooType> in_f; |
| 851 | ::android::sp<::foo::IFooType> _aidl_return; |
| 852 | if (!(_aidl_data.checkInterface(this))) { |
| 853 | _aidl_ret_status = ::android::BAD_TYPE; |
| 854 | break; |
| 855 | } |
| 856 | _aidl_ret_status = _aidl_data.readStrongBinder(&in_f); |
| 857 | if (((_aidl_ret_status) != (::android::OK))) { |
| 858 | break; |
| 859 | } |
| 860 | ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return)); |
| 861 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 862 | if (((_aidl_ret_status) != (::android::OK))) { |
| 863 | break; |
| 864 | } |
| 865 | if (!_aidl_status.isOk()) { |
| 866 | break; |
| 867 | } |
| 868 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 869 | if (((_aidl_ret_status) != (::android::OK))) { |
| 870 | break; |
| 871 | } |
| 872 | } |
| 873 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 874 | case BnComplexTypeInterface::TRANSACTION_NullableBinder: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 875 | { |
| 876 | ::android::sp<::foo::IFooType> _aidl_return; |
| 877 | if (!(_aidl_data.checkInterface(this))) { |
| 878 | _aidl_ret_status = ::android::BAD_TYPE; |
| 879 | break; |
| 880 | } |
| 881 | ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return)); |
| 882 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 883 | if (((_aidl_ret_status) != (::android::OK))) { |
| 884 | break; |
| 885 | } |
| 886 | if (!_aidl_status.isOk()) { |
| 887 | break; |
| 888 | } |
| 889 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 890 | if (((_aidl_ret_status) != (::android::OK))) { |
| 891 | break; |
| 892 | } |
| 893 | } |
| 894 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 895 | case BnComplexTypeInterface::TRANSACTION_StringListMethod: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 896 | { |
| 897 | ::std::vector<::android::String16> in_input; |
| 898 | ::std::vector<::android::String16> out_output; |
| 899 | ::std::vector<::android::String16> _aidl_return; |
| 900 | if (!(_aidl_data.checkInterface(this))) { |
| 901 | _aidl_ret_status = ::android::BAD_TYPE; |
| 902 | break; |
| 903 | } |
| 904 | _aidl_ret_status = _aidl_data.readString16Vector(&in_input); |
| 905 | if (((_aidl_ret_status) != (::android::OK))) { |
| 906 | break; |
| 907 | } |
| 908 | ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return)); |
| 909 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 910 | if (((_aidl_ret_status) != (::android::OK))) { |
| 911 | break; |
| 912 | } |
| 913 | if (!_aidl_status.isOk()) { |
| 914 | break; |
| 915 | } |
| 916 | _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return); |
| 917 | if (((_aidl_ret_status) != (::android::OK))) { |
| 918 | break; |
| 919 | } |
| 920 | _aidl_ret_status = _aidl_reply->writeString16Vector(out_output); |
| 921 | if (((_aidl_ret_status) != (::android::OK))) { |
| 922 | break; |
| 923 | } |
| 924 | } |
| 925 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 926 | case BnComplexTypeInterface::TRANSACTION_BinderListMethod: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 927 | { |
| 928 | ::std::vector<::android::sp<::android::IBinder>> in_input; |
| 929 | ::std::vector<::android::sp<::android::IBinder>> out_output; |
| 930 | ::std::vector<::android::sp<::android::IBinder>> _aidl_return; |
| 931 | if (!(_aidl_data.checkInterface(this))) { |
| 932 | _aidl_ret_status = ::android::BAD_TYPE; |
| 933 | break; |
| 934 | } |
| 935 | _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input); |
| 936 | if (((_aidl_ret_status) != (::android::OK))) { |
| 937 | break; |
| 938 | } |
| 939 | ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_aidl_return)); |
| 940 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 941 | if (((_aidl_ret_status) != (::android::OK))) { |
| 942 | break; |
| 943 | } |
| 944 | if (!_aidl_status.isOk()) { |
| 945 | break; |
| 946 | } |
| 947 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return); |
| 948 | if (((_aidl_ret_status) != (::android::OK))) { |
| 949 | break; |
| 950 | } |
| 951 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output); |
| 952 | if (((_aidl_ret_status) != (::android::OK))) { |
| 953 | break; |
| 954 | } |
| 955 | } |
| 956 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 957 | case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 958 | { |
| 959 | ::android::base::unique_fd in_f; |
| 960 | ::android::base::unique_fd _aidl_return; |
| 961 | if (!(_aidl_data.checkInterface(this))) { |
| 962 | _aidl_ret_status = ::android::BAD_TYPE; |
| 963 | break; |
| 964 | } |
| 965 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f); |
| 966 | if (((_aidl_ret_status) != (::android::OK))) { |
| 967 | break; |
| 968 | } |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 969 | ::android::binder::Status _aidl_status(TakesAFileDescriptor(std::move(in_f), &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 970 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 971 | if (((_aidl_ret_status) != (::android::OK))) { |
| 972 | break; |
| 973 | } |
| 974 | if (!_aidl_status.isOk()) { |
| 975 | break; |
| 976 | } |
| 977 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptor(_aidl_return); |
| 978 | if (((_aidl_ret_status) != (::android::OK))) { |
| 979 | break; |
| 980 | } |
| 981 | } |
| 982 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 983 | case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 984 | { |
| 985 | ::std::vector<::android::base::unique_fd> in_f; |
| 986 | ::std::vector<::android::base::unique_fd> _aidl_return; |
| 987 | if (!(_aidl_data.checkInterface(this))) { |
| 988 | _aidl_ret_status = ::android::BAD_TYPE; |
| 989 | break; |
| 990 | } |
| 991 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f); |
| 992 | if (((_aidl_ret_status) != (::android::OK))) { |
| 993 | break; |
| 994 | } |
| 995 | ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return)); |
| 996 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 997 | if (((_aidl_ret_status) != (::android::OK))) { |
| 998 | break; |
| 999 | } |
| 1000 | if (!_aidl_status.isOk()) { |
| 1001 | break; |
| 1002 | } |
| 1003 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptorVector(_aidl_return); |
| 1004 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1005 | break; |
| 1006 | } |
| 1007 | } |
| 1008 | break; |
| 1009 | default: |
| 1010 | { |
| 1011 | _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags); |
| 1012 | } |
| 1013 | break; |
| 1014 | } |
| 1015 | if (_aidl_ret_status == ::android::UNEXPECTED_NULL) { |
| 1016 | _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply); |
| 1017 | } |
| 1018 | return _aidl_ret_status; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1019 | } |
| 1020 | |
| 1021 | } // namespace os |
| 1022 | |
| 1023 | } // namespace android |
| 1024 | )"; |
| 1025 | |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1026 | const char kExpectedComplexTypeServerWithTraceSourceOutput[] = |
Jeongik Cha | b5d962f | 2018-11-17 09:12:28 +0900 | [diff] [blame] | 1027 | R"(#include <android/os/BnComplexTypeInterface.h> |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1028 | #include <binder/Parcel.h> |
Steven Moreland | a57d0a6 | 2019-07-30 09:41:14 -0700 | [diff] [blame] | 1029 | #include <binder/Stability.h> |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1030 | |
| 1031 | namespace android { |
| 1032 | |
| 1033 | namespace os { |
| 1034 | |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 1035 | BnComplexTypeInterface::BnComplexTypeInterface() |
| 1036 | { |
Steven Moreland | a57d0a6 | 2019-07-30 09:41:14 -0700 | [diff] [blame] | 1037 | ::android::internal::Stability::markCompilationUnit(this); |
Steven Moreland | 800508d | 2019-07-30 10:45:31 -0700 | [diff] [blame] | 1038 | } |
| 1039 | |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1040 | ::android::status_t BnComplexTypeInterface::onTransact(uint32_t _aidl_code, const ::android::Parcel& _aidl_data, ::android::Parcel* _aidl_reply, uint32_t _aidl_flags) { |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1041 | ::android::status_t _aidl_ret_status = ::android::OK; |
| 1042 | switch (_aidl_code) { |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1043 | case BnComplexTypeInterface::TRANSACTION_Send: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1044 | { |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 1045 | ::std::optional<::std::vector<int32_t>> in_goes_in; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1046 | ::std::vector<double> in_goes_in_and_out; |
| 1047 | ::std::vector<bool> out_goes_out; |
| 1048 | ::std::vector<int32_t> _aidl_return; |
| 1049 | if (!(_aidl_data.checkInterface(this))) { |
| 1050 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1051 | break; |
| 1052 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1053 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::Send::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1054 | _aidl_ret_status = _aidl_data.readInt32Vector(&in_goes_in); |
| 1055 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1056 | break; |
| 1057 | } |
| 1058 | _aidl_ret_status = _aidl_data.readDoubleVector(&in_goes_in_and_out); |
| 1059 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1060 | break; |
| 1061 | } |
| 1062 | _aidl_ret_status = _aidl_data.resizeOutVector(&out_goes_out); |
| 1063 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1064 | break; |
| 1065 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1066 | ::android::binder::Status _aidl_status(Send(in_goes_in, &in_goes_in_and_out, &out_goes_out, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1067 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1068 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1069 | break; |
| 1070 | } |
| 1071 | if (!_aidl_status.isOk()) { |
| 1072 | break; |
| 1073 | } |
| 1074 | _aidl_ret_status = _aidl_reply->writeInt32Vector(_aidl_return); |
| 1075 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1076 | break; |
| 1077 | } |
| 1078 | _aidl_ret_status = _aidl_reply->writeDoubleVector(in_goes_in_and_out); |
| 1079 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1080 | break; |
| 1081 | } |
| 1082 | _aidl_ret_status = _aidl_reply->writeBoolVector(out_goes_out); |
| 1083 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1084 | break; |
| 1085 | } |
| 1086 | } |
| 1087 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1088 | case BnComplexTypeInterface::TRANSACTION_Piff: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1089 | { |
| 1090 | int32_t in_times; |
| 1091 | if (!(_aidl_data.checkInterface(this))) { |
| 1092 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1093 | break; |
| 1094 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1095 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::Piff::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1096 | _aidl_ret_status = _aidl_data.readInt32(&in_times); |
| 1097 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1098 | break; |
| 1099 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1100 | ::android::binder::Status _aidl_status(Piff(in_times)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1101 | } |
| 1102 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1103 | case BnComplexTypeInterface::TRANSACTION_TakesABinder: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1104 | { |
| 1105 | ::android::sp<::foo::IFooType> in_f; |
| 1106 | ::android::sp<::foo::IFooType> _aidl_return; |
| 1107 | if (!(_aidl_data.checkInterface(this))) { |
| 1108 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1109 | break; |
| 1110 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1111 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesABinder::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1112 | _aidl_ret_status = _aidl_data.readStrongBinder(&in_f); |
| 1113 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1114 | break; |
| 1115 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1116 | ::android::binder::Status _aidl_status(TakesABinder(in_f, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1117 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1118 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1119 | break; |
| 1120 | } |
| 1121 | if (!_aidl_status.isOk()) { |
| 1122 | break; |
| 1123 | } |
| 1124 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 1125 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1126 | break; |
| 1127 | } |
| 1128 | } |
| 1129 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1130 | case BnComplexTypeInterface::TRANSACTION_NullableBinder: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1131 | { |
| 1132 | ::android::sp<::foo::IFooType> _aidl_return; |
| 1133 | if (!(_aidl_data.checkInterface(this))) { |
| 1134 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1135 | break; |
| 1136 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1137 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::NullableBinder::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1138 | ::android::binder::Status _aidl_status(NullableBinder(&_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1139 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1140 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1141 | break; |
| 1142 | } |
| 1143 | if (!_aidl_status.isOk()) { |
| 1144 | break; |
| 1145 | } |
| 1146 | _aidl_ret_status = _aidl_reply->writeStrongBinder(::foo::IFooType::asBinder(_aidl_return)); |
| 1147 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1148 | break; |
| 1149 | } |
| 1150 | } |
| 1151 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1152 | case BnComplexTypeInterface::TRANSACTION_StringListMethod: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1153 | { |
| 1154 | ::std::vector<::android::String16> in_input; |
| 1155 | ::std::vector<::android::String16> out_output; |
| 1156 | ::std::vector<::android::String16> _aidl_return; |
| 1157 | if (!(_aidl_data.checkInterface(this))) { |
| 1158 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1159 | break; |
| 1160 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1161 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::StringListMethod::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1162 | _aidl_ret_status = _aidl_data.readString16Vector(&in_input); |
| 1163 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1164 | break; |
| 1165 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1166 | ::android::binder::Status _aidl_status(StringListMethod(in_input, &out_output, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1167 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1168 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1169 | break; |
| 1170 | } |
| 1171 | if (!_aidl_status.isOk()) { |
| 1172 | break; |
| 1173 | } |
| 1174 | _aidl_ret_status = _aidl_reply->writeString16Vector(_aidl_return); |
| 1175 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1176 | break; |
| 1177 | } |
| 1178 | _aidl_ret_status = _aidl_reply->writeString16Vector(out_output); |
| 1179 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1180 | break; |
| 1181 | } |
| 1182 | } |
| 1183 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1184 | case BnComplexTypeInterface::TRANSACTION_BinderListMethod: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1185 | { |
| 1186 | ::std::vector<::android::sp<::android::IBinder>> in_input; |
| 1187 | ::std::vector<::android::sp<::android::IBinder>> out_output; |
| 1188 | ::std::vector<::android::sp<::android::IBinder>> _aidl_return; |
| 1189 | if (!(_aidl_data.checkInterface(this))) { |
| 1190 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1191 | break; |
| 1192 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1193 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::BinderListMethod::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1194 | _aidl_ret_status = _aidl_data.readStrongBinderVector(&in_input); |
| 1195 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1196 | break; |
| 1197 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1198 | ::android::binder::Status _aidl_status(BinderListMethod(in_input, &out_output, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1199 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1200 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1201 | break; |
| 1202 | } |
| 1203 | if (!_aidl_status.isOk()) { |
| 1204 | break; |
| 1205 | } |
| 1206 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(_aidl_return); |
| 1207 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1208 | break; |
| 1209 | } |
| 1210 | _aidl_ret_status = _aidl_reply->writeStrongBinderVector(out_output); |
| 1211 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1212 | break; |
| 1213 | } |
| 1214 | } |
| 1215 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1216 | case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptor: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1217 | { |
| 1218 | ::android::base::unique_fd in_f; |
| 1219 | ::android::base::unique_fd _aidl_return; |
| 1220 | if (!(_aidl_data.checkInterface(this))) { |
| 1221 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1222 | break; |
| 1223 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1224 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesAFileDescriptor::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1225 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptor(&in_f); |
| 1226 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1227 | break; |
| 1228 | } |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 1229 | ::android::binder::Status _aidl_status(TakesAFileDescriptor(std::move(in_f), &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1230 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1231 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1232 | break; |
| 1233 | } |
| 1234 | if (!_aidl_status.isOk()) { |
| 1235 | break; |
| 1236 | } |
| 1237 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptor(_aidl_return); |
| 1238 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1239 | break; |
| 1240 | } |
| 1241 | } |
| 1242 | break; |
Jiyong Park | 717fc69 | 2020-11-25 16:31:32 +0900 | [diff] [blame] | 1243 | case BnComplexTypeInterface::TRANSACTION_TakesAFileDescriptorArray: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1244 | { |
| 1245 | ::std::vector<::android::base::unique_fd> in_f; |
| 1246 | ::std::vector<::android::base::unique_fd> _aidl_return; |
| 1247 | if (!(_aidl_data.checkInterface(this))) { |
| 1248 | _aidl_ret_status = ::android::BAD_TYPE; |
| 1249 | break; |
| 1250 | } |
Devin Moore | f760087 | 2020-05-13 15:47:50 -0700 | [diff] [blame] | 1251 | ::android::ScopedTrace _aidl_trace(ATRACE_TAG_AIDL, "AIDL::cpp::IComplexTypeInterface::TakesAFileDescriptorArray::cppServer"); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1252 | _aidl_ret_status = _aidl_data.readUniqueFileDescriptorVector(&in_f); |
| 1253 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1254 | break; |
| 1255 | } |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1256 | ::android::binder::Status _aidl_status(TakesAFileDescriptorArray(in_f, &_aidl_return)); |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1257 | _aidl_ret_status = _aidl_status.writeToParcel(_aidl_reply); |
| 1258 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1259 | break; |
| 1260 | } |
| 1261 | if (!_aidl_status.isOk()) { |
| 1262 | break; |
| 1263 | } |
| 1264 | _aidl_ret_status = _aidl_reply->writeUniqueFileDescriptorVector(_aidl_return); |
| 1265 | if (((_aidl_ret_status) != (::android::OK))) { |
| 1266 | break; |
| 1267 | } |
| 1268 | } |
| 1269 | break; |
| 1270 | default: |
| 1271 | { |
| 1272 | _aidl_ret_status = ::android::BBinder::onTransact(_aidl_code, _aidl_data, _aidl_reply, _aidl_flags); |
| 1273 | } |
| 1274 | break; |
| 1275 | } |
| 1276 | if (_aidl_ret_status == ::android::UNEXPECTED_NULL) { |
| 1277 | _aidl_ret_status = ::android::binder::Status::fromExceptionCode(::android::binder::Status::EX_NULL_POINTER).writeToParcel(_aidl_reply); |
| 1278 | } |
| 1279 | return _aidl_ret_status; |
Martijn Coenen | f1b5078 | 2018-02-21 21:06:23 +0100 | [diff] [blame] | 1280 | } |
| 1281 | |
| 1282 | } // namespace os |
| 1283 | |
| 1284 | } // namespace android |
| 1285 | )"; |
| 1286 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1287 | const char kExpectedComplexTypeInterfaceHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 1288 | R"(#pragma once |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1289 | |
Christopher Wiley | 7cb9c25 | 2016-04-11 11:07:33 -0700 | [diff] [blame] | 1290 | #include <android-base/unique_fd.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1291 | #include <binder/IBinder.h> |
| 1292 | #include <binder/IInterface.h> |
Christopher Wiley | 433c8bb | 2015-11-12 14:20:46 -0800 | [diff] [blame] | 1293 | #include <binder/Status.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1294 | #include <cstdint> |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1295 | #include <foo/IFooType.h> |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 1296 | #include <optional> |
Christopher Wiley | 56c9bf3 | 2015-10-30 10:41:12 -0700 | [diff] [blame] | 1297 | #include <utils/String16.h> |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1298 | #include <utils/StrongPointer.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1299 | #include <vector> |
| 1300 | |
| 1301 | namespace android { |
| 1302 | |
| 1303 | namespace os { |
| 1304 | |
Casey Dahlin | b8d9e88 | 2015-11-24 10:57:23 -0800 | [diff] [blame] | 1305 | class IComplexTypeInterface : public ::android::IInterface { |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1306 | public: |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1307 | DECLARE_META_INTERFACE(ComplexTypeInterface) |
| 1308 | enum : int32_t { |
| 1309 | MY_CONSTANT = 3, |
| 1310 | }; |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 1311 | virtual ::android::binder::Status Send(const ::std::optional<::std::vector<int32_t>>& goes_in, ::std::vector<double>* goes_in_and_out, ::std::vector<bool>* goes_out, ::std::vector<int32_t>* _aidl_return) = 0; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1312 | virtual ::android::binder::Status Piff(int32_t times) = 0; |
| 1313 | virtual ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>& f, ::android::sp<::foo::IFooType>* _aidl_return) = 0; |
| 1314 | virtual ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>* _aidl_return) = 0; |
| 1315 | virtual ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>& input, ::std::vector<::android::String16>* output, ::std::vector<::android::String16>* _aidl_return) = 0; |
| 1316 | virtual ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>& input, ::std::vector<::android::sp<::android::IBinder>>* output, ::std::vector<::android::sp<::android::IBinder>>* _aidl_return) = 0; |
Jiyong Park | 4f3e8c0 | 2019-11-22 14:28:47 +0900 | [diff] [blame] | 1317 | virtual ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd f, ::android::base::unique_fd* _aidl_return) = 0; |
Jiyong Park | a755dc7 | 2018-06-29 13:52:24 +0900 | [diff] [blame] | 1318 | virtual ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>& f, ::std::vector<::android::base::unique_fd>* _aidl_return) = 0; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1319 | }; // class IComplexTypeInterface |
| 1320 | |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 1321 | class IComplexTypeInterfaceDefault : public IComplexTypeInterface { |
| 1322 | public: |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1323 | ::android::IBinder* onAsBinder() override { |
| 1324 | return nullptr; |
| 1325 | } |
Jooyung Han | 4312246 | 2020-01-23 13:03:10 +0900 | [diff] [blame] | 1326 | ::android::binder::Status Send(const ::std::optional<::std::vector<int32_t>>&, ::std::vector<double>*, ::std::vector<bool>*, ::std::vector<int32_t>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1327 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1328 | } |
| 1329 | ::android::binder::Status Piff(int32_t) override { |
| 1330 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1331 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1332 | ::android::binder::Status TakesABinder(const ::android::sp<::foo::IFooType>&, ::android::sp<::foo::IFooType>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1333 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1334 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1335 | ::android::binder::Status NullableBinder(::android::sp<::foo::IFooType>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1336 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1337 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1338 | ::android::binder::Status StringListMethod(const ::std::vector<::android::String16>&, ::std::vector<::android::String16>*, ::std::vector<::android::String16>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1339 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1340 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1341 | ::android::binder::Status BinderListMethod(const ::std::vector<::android::sp<::android::IBinder>>&, ::std::vector<::android::sp<::android::IBinder>>*, ::std::vector<::android::sp<::android::IBinder>>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1342 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1343 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1344 | ::android::binder::Status TakesAFileDescriptor(::android::base::unique_fd, ::android::base::unique_fd*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1345 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1346 | } |
Jooyung Han | 6991d92 | 2020-01-30 18:13:55 +0900 | [diff] [blame] | 1347 | ::android::binder::Status TakesAFileDescriptorArray(const ::std::vector<::android::base::unique_fd>&, ::std::vector<::android::base::unique_fd>*) override { |
Jooyung Han | 7bee8e3 | 2020-01-30 17:25:21 +0900 | [diff] [blame] | 1348 | return ::android::binder::Status::fromStatusT(::android::UNKNOWN_TRANSACTION); |
| 1349 | } |
| 1350 | }; // class IComplexTypeInterfaceDefault |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 1351 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1352 | } // namespace os |
| 1353 | |
| 1354 | } // namespace android |
Christopher Wiley | 11a9d79 | 2016-02-24 17:20:33 -0800 | [diff] [blame] | 1355 | )"; |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1356 | |
| 1357 | const char kExpectedComplexTypeInterfaceSourceOutput[] = |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 1358 | R"(#include <android/os/IComplexTypeInterface.h> |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1359 | #include <android/os/BpComplexTypeInterface.h> |
| 1360 | |
| 1361 | namespace android { |
| 1362 | |
| 1363 | namespace os { |
| 1364 | |
Ivan Lozano | b3f4d62 | 2019-11-25 09:30:02 -0800 | [diff] [blame] | 1365 | DO_NOT_DIRECTLY_USE_ME_IMPLEMENT_META_INTERFACE(ComplexTypeInterface, "android.os.IComplexTypeInterface") |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1366 | |
| 1367 | } // namespace os |
| 1368 | |
| 1369 | } // namespace android |
| 1370 | )"; |
| 1371 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1372 | const string kEnumAIDL = R"(package android.os; |
| 1373 | enum TestEnum { |
Daniel Norman | b28684e | 2019-10-17 15:31:39 -0700 | [diff] [blame] | 1374 | ZERO, |
| 1375 | ONE, |
| 1376 | THREE = 3, |
Daniel Norman | f0ca44f | 2019-10-25 09:59:44 -0700 | [diff] [blame] | 1377 | FOUR = 3 + 1, |
Daniel Norman | b28684e | 2019-10-17 15:31:39 -0700 | [diff] [blame] | 1378 | FIVE, |
Daniel Norman | f0ca44f | 2019-10-25 09:59:44 -0700 | [diff] [blame] | 1379 | SIX, |
| 1380 | SEVEN, |
| 1381 | EIGHT = 16 / 2, |
| 1382 | NINE, |
| 1383 | TEN, |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1384 | })"; |
| 1385 | |
| 1386 | const char kExpectedEnumHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 1387 | R"(#pragma once |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1388 | |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1389 | #include <array> |
| 1390 | #include <binder/Enums.h> |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1391 | #include <cstdint> |
Daniel Norman | 0c1bd36 | 2019-11-12 23:05:31 -0800 | [diff] [blame] | 1392 | #include <string> |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1393 | |
| 1394 | namespace android { |
| 1395 | |
| 1396 | namespace os { |
| 1397 | |
| 1398 | enum class TestEnum : int8_t { |
Daniel Norman | b28684e | 2019-10-17 15:31:39 -0700 | [diff] [blame] | 1399 | ZERO = 0, |
| 1400 | ONE = 1, |
| 1401 | THREE = 3, |
| 1402 | FOUR = 4, |
| 1403 | FIVE = 5, |
Daniel Norman | f0ca44f | 2019-10-25 09:59:44 -0700 | [diff] [blame] | 1404 | SIX = 6, |
| 1405 | SEVEN = 7, |
| 1406 | EIGHT = 8, |
| 1407 | NINE = 9, |
| 1408 | TEN = 10, |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1409 | }; |
| 1410 | |
Daniel Norman | 0c1bd36 | 2019-11-12 23:05:31 -0800 | [diff] [blame] | 1411 | static inline std::string toString(TestEnum val) { |
| 1412 | switch(val) { |
| 1413 | case TestEnum::ZERO: |
| 1414 | return "ZERO"; |
| 1415 | case TestEnum::ONE: |
| 1416 | return "ONE"; |
| 1417 | case TestEnum::THREE: |
| 1418 | return "THREE"; |
| 1419 | case TestEnum::FOUR: |
| 1420 | return "FOUR"; |
| 1421 | case TestEnum::FIVE: |
| 1422 | return "FIVE"; |
| 1423 | case TestEnum::SIX: |
| 1424 | return "SIX"; |
| 1425 | case TestEnum::SEVEN: |
| 1426 | return "SEVEN"; |
| 1427 | case TestEnum::EIGHT: |
| 1428 | return "EIGHT"; |
| 1429 | case TestEnum::NINE: |
| 1430 | return "NINE"; |
| 1431 | case TestEnum::TEN: |
| 1432 | return "TEN"; |
| 1433 | default: |
| 1434 | return std::to_string(static_cast<int8_t>(val)); |
| 1435 | } |
| 1436 | } |
| 1437 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1438 | } // namespace os |
| 1439 | |
| 1440 | } // namespace android |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1441 | namespace android { |
| 1442 | |
| 1443 | namespace internal { |
| 1444 | |
Jooyung Han | 0e2a03c | 2019-12-17 23:25:39 +0900 | [diff] [blame] | 1445 | #pragma clang diagnostic push |
| 1446 | #pragma clang diagnostic ignored "-Wc++17-extensions" |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1447 | template <> |
| 1448 | constexpr inline std::array<::android::os::TestEnum, 10> enum_values<::android::os::TestEnum> = { |
| 1449 | ::android::os::TestEnum::ZERO, |
| 1450 | ::android::os::TestEnum::ONE, |
| 1451 | ::android::os::TestEnum::THREE, |
| 1452 | ::android::os::TestEnum::FOUR, |
| 1453 | ::android::os::TestEnum::FIVE, |
| 1454 | ::android::os::TestEnum::SIX, |
| 1455 | ::android::os::TestEnum::SEVEN, |
| 1456 | ::android::os::TestEnum::EIGHT, |
| 1457 | ::android::os::TestEnum::NINE, |
| 1458 | ::android::os::TestEnum::TEN, |
| 1459 | }; |
Jooyung Han | 0e2a03c | 2019-12-17 23:25:39 +0900 | [diff] [blame] | 1460 | #pragma clang diagnostic pop |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1461 | |
| 1462 | } // namespace internal |
| 1463 | |
| 1464 | } // namespace android |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1465 | )"; |
| 1466 | |
| 1467 | const string kEnumWithBackingTypeAIDL = R"(package android.os; |
| 1468 | @Backing(type="long") |
| 1469 | enum TestEnum { |
| 1470 | FOO = 1, |
| 1471 | BAR = 2, |
| 1472 | })"; |
| 1473 | |
| 1474 | const char kExpectedEnumWithBackingTypeHeaderOutput[] = |
Devin Moore | 7aaa9cb | 2020-08-13 14:53:01 -0700 | [diff] [blame] | 1475 | R"(#pragma once |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1476 | |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1477 | #include <array> |
| 1478 | #include <binder/Enums.h> |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1479 | #include <cstdint> |
Daniel Norman | 0c1bd36 | 2019-11-12 23:05:31 -0800 | [diff] [blame] | 1480 | #include <string> |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1481 | |
| 1482 | namespace android { |
| 1483 | |
| 1484 | namespace os { |
| 1485 | |
| 1486 | enum class TestEnum : int64_t { |
Daniel Norman | 716d311 | 2019-09-10 13:11:56 -0700 | [diff] [blame] | 1487 | FOO = 1L, |
| 1488 | BAR = 2L, |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1489 | }; |
| 1490 | |
Daniel Norman | 0c1bd36 | 2019-11-12 23:05:31 -0800 | [diff] [blame] | 1491 | static inline std::string toString(TestEnum val) { |
| 1492 | switch(val) { |
| 1493 | case TestEnum::FOO: |
| 1494 | return "FOO"; |
| 1495 | case TestEnum::BAR: |
| 1496 | return "BAR"; |
| 1497 | default: |
| 1498 | return std::to_string(static_cast<int64_t>(val)); |
| 1499 | } |
| 1500 | } |
| 1501 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1502 | } // namespace os |
| 1503 | |
| 1504 | } // namespace android |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1505 | namespace android { |
| 1506 | |
| 1507 | namespace internal { |
| 1508 | |
Jooyung Han | 0e2a03c | 2019-12-17 23:25:39 +0900 | [diff] [blame] | 1509 | #pragma clang diagnostic push |
| 1510 | #pragma clang diagnostic ignored "-Wc++17-extensions" |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1511 | template <> |
| 1512 | constexpr inline std::array<::android::os::TestEnum, 2> enum_values<::android::os::TestEnum> = { |
| 1513 | ::android::os::TestEnum::FOO, |
| 1514 | ::android::os::TestEnum::BAR, |
| 1515 | }; |
Jooyung Han | 0e2a03c | 2019-12-17 23:25:39 +0900 | [diff] [blame] | 1516 | #pragma clang diagnostic pop |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1517 | |
| 1518 | } // namespace internal |
| 1519 | |
| 1520 | } // namespace android |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1521 | )"; |
Jooyung Han | 7a9aceb | 2019-12-17 14:18:15 +0000 | [diff] [blame] | 1522 | // clang-format on |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1523 | |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1524 | } // namespace |
| 1525 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1526 | class ASTTest : public ::testing::Test { |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1527 | protected: |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1528 | ASTTest(const string& cmdline, const string& file_contents) |
| 1529 | : options_(Options::From(cmdline)), file_contents_(file_contents) { |
Christopher Wiley | 5679952 | 2015-10-31 10:17:04 -0700 | [diff] [blame] | 1530 | } |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1531 | |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1532 | AidlInterface* ParseSingleInterface() { |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1533 | io_delegate_.SetFileContents(options_.InputFiles().at(0), file_contents_); |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1534 | |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1535 | vector<string> imported_files; |
Jiyong Park | 8c38053 | 2018-08-30 14:55:26 +0900 | [diff] [blame] | 1536 | ImportResolver import_resolver{io_delegate_, options_.InputFiles().at(0), {"."}, {}}; |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1537 | AidlError err = ::android::aidl::internals::load_and_validate_aidl( |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1538 | options_.InputFiles().front(), options_, io_delegate_, &typenames_, &imported_files); |
Christopher Wiley | 4a2884b | 2015-10-07 11:27:45 -0700 | [diff] [blame] | 1539 | |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 1540 | if (err != AidlError::OK) { |
Casey Dahlin | 2cc9316 | 2015-10-02 16:14:17 -0700 | [diff] [blame] | 1541 | return nullptr; |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 1542 | } |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1543 | |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1544 | const auto& defined_types = typenames_.MainDocument().DefinedTypes(); |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1545 | EXPECT_EQ(1ul, defined_types.size()); |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1546 | EXPECT_NE(nullptr, defined_types.front().get()->AsInterface()); |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 1547 | |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1548 | return defined_types.front().get()->AsInterface(); |
Christopher Wiley | 90be4e3 | 2015-10-20 14:55:25 -0700 | [diff] [blame] | 1549 | } |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1550 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1551 | AidlEnumDeclaration* ParseSingleEnumDeclaration() { |
| 1552 | io_delegate_.SetFileContents(options_.InputFiles().at(0), file_contents_); |
| 1553 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1554 | vector<string> imported_files; |
| 1555 | AidlError err = ::android::aidl::internals::load_and_validate_aidl( |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1556 | options_.InputFiles().front(), options_, io_delegate_, &typenames_, &imported_files); |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1557 | |
| 1558 | if (err != AidlError::OK) { |
| 1559 | return nullptr; |
| 1560 | } |
| 1561 | |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1562 | const auto& defined_types = typenames_.MainDocument().DefinedTypes(); |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1563 | EXPECT_EQ(1ul, defined_types.size()); |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1564 | EXPECT_NE(nullptr, defined_types.front().get()->AsEnumDeclaration()); |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1565 | |
Jiyong Park | 8e79b7f | 2020-07-20 20:52:38 +0900 | [diff] [blame] | 1566 | return defined_types.front().get()->AsEnumDeclaration(); |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1567 | } |
| 1568 | |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1569 | void Compare(Document* doc, const char* expected) { |
| 1570 | string output; |
Jiyong Park | b78e15b | 2018-07-04 20:31:03 +0900 | [diff] [blame] | 1571 | doc->Write(CodeWriter::ForString(&output).get()); |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1572 | |
Casey Dahlin | 80ada3d | 2015-10-20 20:33:56 -0700 | [diff] [blame] | 1573 | if (expected == output) { |
| 1574 | return; // Success |
| 1575 | } |
| 1576 | |
| 1577 | test::PrintDiff(expected, output); |
| 1578 | FAIL() << "Document contents did not match expected contents"; |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1579 | } |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1580 | |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1581 | const Options options_; |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1582 | const string file_contents_; |
| 1583 | FakeIoDelegate io_delegate_; |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1584 | AidlTypenames typenames_; |
Christopher Wiley | 0c732db | 2015-09-29 14:36:44 -0700 | [diff] [blame] | 1585 | }; |
| 1586 | |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1587 | class ComplexTypeInterfaceASTTest : public ASTTest { |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1588 | public: |
| 1589 | ComplexTypeInterfaceASTTest() |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1590 | : ASTTest("aidl --lang=cpp -I . -o out android/os/IComplexTypeInterface.aidl", |
Casey Dahlin | 389781f | 2015-10-22 13:13:21 -0700 | [diff] [blame] | 1591 | kComplexTypeInterfaceAIDL) { |
| 1592 | io_delegate_.SetFileContents("foo/IFooType.aidl", |
| 1593 | "package foo; interface IFooType {}"); |
| 1594 | } |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1595 | }; |
| 1596 | |
| 1597 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientHeader) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1598 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1599 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1600 | unique_ptr<Document> doc = internals::BuildClientHeader(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1601 | Compare(doc.get(), kExpectedComplexTypeClientHeaderOutput); |
| 1602 | } |
| 1603 | |
| 1604 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesClientSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1605 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1606 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1607 | unique_ptr<Document> doc = internals::BuildClientSource(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1608 | Compare(doc.get(), kExpectedComplexTypeClientSourceOutput); |
| 1609 | } |
| 1610 | |
| 1611 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerHeader) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1612 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1613 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1614 | unique_ptr<Document> doc = internals::BuildServerHeader(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1615 | Compare(doc.get(), kExpectedComplexTypeServerHeaderOutput); |
| 1616 | } |
| 1617 | |
| 1618 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesServerSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1619 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1620 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1621 | unique_ptr<Document> doc = internals::BuildServerSource(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1622 | Compare(doc.get(), kExpectedComplexTypeServerSourceOutput); |
| 1623 | } |
| 1624 | |
| 1625 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceHeader) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1626 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1627 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1628 | unique_ptr<Document> doc = internals::BuildInterfaceHeader(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1629 | Compare(doc.get(), kExpectedComplexTypeInterfaceHeaderOutput); |
| 1630 | } |
| 1631 | |
| 1632 | TEST_F(ComplexTypeInterfaceASTTest, GeneratesInterfaceSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1633 | AidlInterface* interface = ParseSingleInterface(); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1634 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1635 | unique_ptr<Document> doc = internals::BuildInterfaceSource(typenames_, *interface, options_); |
Casey Dahlin | b096661 | 2015-10-19 16:35:26 -0700 | [diff] [blame] | 1636 | Compare(doc.get(), kExpectedComplexTypeInterfaceSourceOutput); |
Christopher Wiley | 1dd458d | 2015-09-30 11:05:52 -0700 | [diff] [blame] | 1637 | } |
| 1638 | |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1639 | class ComplexTypeInterfaceASTTestWithTrace : public ASTTest { |
| 1640 | public: |
| 1641 | ComplexTypeInterfaceASTTestWithTrace() |
| 1642 | : ASTTest("aidl --lang=cpp -t -I . -o out android/os/IComplexTypeInterface.aidl", |
| 1643 | kComplexTypeInterfaceAIDL) { |
| 1644 | io_delegate_.SetFileContents("foo/IFooType.aidl", "package foo; interface IFooType {}"); |
| 1645 | } |
| 1646 | }; |
| 1647 | |
| 1648 | TEST_F(ComplexTypeInterfaceASTTestWithTrace, GeneratesClientSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1649 | AidlInterface* interface = ParseSingleInterface(); |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1650 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1651 | unique_ptr<Document> doc = internals::BuildClientSource(typenames_, *interface, options_); |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1652 | Compare(doc.get(), kExpectedComplexTypeClientWithTraceSourceOutput); |
| 1653 | } |
| 1654 | |
| 1655 | TEST_F(ComplexTypeInterfaceASTTestWithTrace, GeneratesServerSource) { |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1656 | AidlInterface* interface = ParseSingleInterface(); |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1657 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1658 | unique_ptr<Document> doc = internals::BuildServerSource(typenames_, *interface, options_); |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 1659 | Compare(doc.get(), kExpectedComplexTypeServerWithTraceSourceOutput); |
| 1660 | } |
| 1661 | |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1662 | namespace test_io_handling { |
| 1663 | |
| 1664 | const char kInputPath[] = "a/IFoo.aidl"; |
| 1665 | const char kOutputPath[] = "output.cpp"; |
| 1666 | const char kHeaderDir[] = "headers"; |
| 1667 | const char kInterfaceHeaderRelPath[] = "a/IFoo.h"; |
| 1668 | |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1669 | const string kCmdline = string("aidl-cpp ") + kInputPath + " " + kHeaderDir + " " + kOutputPath; |
| 1670 | |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1671 | } // namespace test_io_handling |
| 1672 | |
| 1673 | class IoErrorHandlingTest : public ASTTest { |
| 1674 | public: |
Jiyong Park | 6f77e0c | 2018-07-28 16:55:44 +0900 | [diff] [blame] | 1675 | IoErrorHandlingTest() : ASTTest(test_io_handling::kCmdline, "package a; interface IFoo {}") {} |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1676 | }; |
| 1677 | |
| 1678 | TEST_F(IoErrorHandlingTest, GenerateCorrectlyAbsentErrors) { |
| 1679 | // Confirm that this is working correctly without I/O problems. |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1680 | AidlInterface* interface = ParseSingleInterface(); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1681 | ASSERT_NE(interface, nullptr); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1682 | ASSERT_TRUE(GenerateCpp(options_.OutputFile(), options_, typenames_, *interface, io_delegate_)); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1683 | } |
| 1684 | |
| 1685 | TEST_F(IoErrorHandlingTest, HandlesBadHeaderWrite) { |
| 1686 | using namespace test_io_handling; |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1687 | AidlInterface* interface = ParseSingleInterface(); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1688 | ASSERT_NE(interface, nullptr); |
| 1689 | |
| 1690 | // Simulate issues closing the interface header. |
| 1691 | const string header_path = |
| 1692 | StringPrintf("%s%c%s", kHeaderDir, OS_PATH_SEPARATOR, |
| 1693 | kInterfaceHeaderRelPath); |
| 1694 | io_delegate_.AddBrokenFilePath(header_path); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1695 | ASSERT_FALSE(GenerateCpp(options_.OutputFile(), options_, typenames_, *interface, io_delegate_)); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1696 | // We should never attempt to write the C++ file if we fail writing headers. |
| 1697 | ASSERT_FALSE(io_delegate_.GetWrittenContents(kOutputPath, nullptr)); |
| 1698 | // We should remove partial results. |
| 1699 | ASSERT_TRUE(io_delegate_.PathWasRemoved(header_path)); |
| 1700 | } |
| 1701 | |
| 1702 | TEST_F(IoErrorHandlingTest, HandlesBadCppWrite) { |
| 1703 | using test_io_handling::kOutputPath; |
Jiyong Park | b034bf0 | 2018-07-30 17:44:33 +0900 | [diff] [blame] | 1704 | AidlInterface* interface = ParseSingleInterface(); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1705 | ASSERT_NE(interface, nullptr); |
| 1706 | |
| 1707 | // Simulate issues closing the cpp file. |
| 1708 | io_delegate_.AddBrokenFilePath(kOutputPath); |
Jeongik Cha | 047c5ee | 2019-08-07 23:16:49 +0900 | [diff] [blame] | 1709 | ASSERT_FALSE(GenerateCpp(options_.OutputFile(), options_, typenames_, *interface, io_delegate_)); |
Christopher Wiley | 9d6e0b2 | 2015-11-13 12:18:16 -0800 | [diff] [blame] | 1710 | // We should remove partial results. |
| 1711 | ASSERT_TRUE(io_delegate_.PathWasRemoved(kOutputPath)); |
| 1712 | } |
| 1713 | |
Daniel Norman | 85aed54 | 2019-08-21 12:01:14 -0700 | [diff] [blame] | 1714 | class EnumASTTest : public ASTTest { |
| 1715 | public: |
| 1716 | EnumASTTest() : ASTTest("aidl --lang=cpp -I . -o out android/os/TestEnum.aidl", kEnumAIDL) {} |
| 1717 | }; |
| 1718 | |
| 1719 | TEST_F(EnumASTTest, GeneratesEnumHeader) { |
| 1720 | AidlEnumDeclaration* enum_decl = ParseSingleEnumDeclaration(); |
| 1721 | ASSERT_NE(enum_decl, nullptr); |
| 1722 | unique_ptr<Document> doc = internals::BuildEnumHeader(typenames_, *enum_decl); |
| 1723 | Compare(doc.get(), kExpectedEnumHeaderOutput); |
| 1724 | } |
| 1725 | |
| 1726 | class EnumWithBackingTypeASTTest : public ASTTest { |
| 1727 | public: |
| 1728 | EnumWithBackingTypeASTTest() |
| 1729 | : ASTTest("aidl --lang=cpp -I . -o out android/os/TestEnum.aidl", kEnumWithBackingTypeAIDL) {} |
| 1730 | }; |
| 1731 | |
| 1732 | TEST_F(EnumWithBackingTypeASTTest, GeneratesEnumHeader) { |
| 1733 | AidlEnumDeclaration* enum_decl = ParseSingleEnumDeclaration(); |
| 1734 | ASSERT_NE(enum_decl, nullptr); |
| 1735 | unique_ptr<Document> doc = internals::BuildEnumHeader(typenames_, *enum_decl); |
| 1736 | Compare(doc.get(), kExpectedEnumWithBackingTypeHeaderOutput); |
| 1737 | } |
| 1738 | |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 1739 | } // namespace cpp |
Casey Dahlin | a834dd4 | 2015-09-23 11:52:15 -0700 | [diff] [blame] | 1740 | } // namespace aidl |
| 1741 | } // namespace android |