blob: f335475e0a1fa7e1993f7f95ab52257bf5785a44 [file] [log] [blame]
Steven Moreland860b1942018-08-16 14:59:28 -07001/*
2 * Copyright (C) 2018, The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "aidl_to_cpp.h"
18#include "aidl_language.h"
Jiyong Parkce50e262018-10-29 09:54:20 +090019#include "logging.h"
20
21#include <functional>
22#include <unordered_map>
Steven Moreland860b1942018-08-16 14:59:28 -070023
Jeongik Chab5d962f2018-11-17 09:12:28 +090024using std::ostringstream;
25
Steven Moreland860b1942018-08-16 14:59:28 -070026namespace android {
27namespace aidl {
28namespace cpp {
29
30std::string ConstantValueDecorator(const AidlTypeSpecifier& type, const std::string& raw_value) {
31 if (type.GetName() == "String" && !type.IsArray() && !type.IsUtf8InCpp()) {
32 return "::android::String16(" + raw_value + ")";
33 }
34
35 return raw_value;
36};
37
Jeongik Chab5d962f2018-11-17 09:12:28 +090038std::string GetTransactionIdFor(const AidlMethod& method) {
39 ostringstream output;
40
Jeongik Chaf1470e22019-05-20 18:45:05 +090041 output << "::android::IBinder::FIRST_CALL_TRANSACTION + ";
Jeongik Chab5d962f2018-11-17 09:12:28 +090042 output << method.GetId() << " /* " << method.GetName() << " */";
43 return output.str();
44}
Steven Moreland860b1942018-08-16 14:59:28 -070045} // namespace cpp
46} // namespace aidl
47} // namespace android