blob: d2aa7a4c93d1f2e38cdd7f82ea88411c46d12348 [file] [log] [blame]
Andrei Onea8714b022019-02-01 18:55:54 +00001/*
2 * Copyright (C) 2019, 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 "generate_aidl_mappings.h"
Jeongik Cha2c5e7622019-07-23 14:15:48 +090018#include "aidl_to_java.h"
Andrei Onea8714b022019-02-01 18:55:54 +000019
20#include <sstream>
21
22namespace android {
23namespace aidl {
24namespace mappings {
25
26std::string dump_location(const AidlNode& method) {
27 return method.PrintLocation();
28}
29
30SignatureMap generate_mappings(const AidlDefinedType* defined_type) {
31 const AidlInterface* interface = defined_type->AsInterface();
32 SignatureMap mappings;
33 if (interface == nullptr) {
34 return mappings;
35 }
36 for (const auto& method : interface->GetMethods()) {
37 if (method->IsUserDefined()) {
38 std::stringstream signature;
39 signature << interface->GetCanonicalName() << "|";
40 signature << method->GetName() << "|";
41 for (const auto& arg : method->GetArguments()) {
Steven Moreland3dc29d82019-08-21 17:23:11 -070042 signature << java::JavaSignatureOf(arg->GetType()) << ",";
Andrei Onea8714b022019-02-01 18:55:54 +000043 }
44 signature << "|";
Jeongik Cha2c5e7622019-07-23 14:15:48 +090045 signature << java::JavaSignatureOf(method->GetType());
Andrei Onea8714b022019-02-01 18:55:54 +000046 mappings[signature.str()] = dump_location(*method);
47 }
48 }
49 return mappings;
50}
51
52} // namespace mappings
53} // namespace aidl
54} // namespace android