blob: 61917e992f28de0a8b0d94e787036ffdbc588921 [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
41 if (method.IsUserDefined()) {
42 output << "::android::IBinder::FIRST_CALL_TRANSACTION + ";
43 }
44 output << method.GetId() << " /* " << method.GetName() << " */";
45 return output.str();
46}
Steven Moreland860b1942018-08-16 14:59:28 -070047} // namespace cpp
48} // namespace aidl
49} // namespace android