• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018, The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <string>
20 
21 #include "aidl_language.h"
22 
23 // This is used to help generate code targetting C++ (the language) whether using the libbinder or
24 // libbinder_ndk backend.
25 
26 namespace android {
27 namespace aidl {
28 namespace cpp {
29 
30 // These roughly correspond to the various class names in the C++ hierarchy:
31 enum class ClassNames {
32   BASE,          // Foo (not a real class, but useful in some circumstances).
33   CLIENT,        // BpFoo
34   SERVER,        // BnFoo
35   INTERFACE,     // IFoo
36   DEFAULT_IMPL,  // IFooDefault
37   RAW,           // (as shown in the file)
38 };
39 
40 string ClassName(const AidlDefinedType& defined_type, ClassNames type);
41 
42 // Generate the relative path to a header file.  If |use_os_sep| we'll use the
43 // operating system specific path separator rather than C++'s expected '/' when
44 // including headers.
45 std::string HeaderFile(const AidlDefinedType& defined_type, ClassNames class_type,
46                        bool use_os_sep = true);
47 
48 void EnterNamespace(CodeWriter& out, const AidlDefinedType& defined_type);
49 void LeaveNamespace(CodeWriter& out, const AidlDefinedType& defined_type);
50 
51 string BuildVarName(const AidlArgument& a);
52 const string GenLogBeforeExecute(const string className, const AidlMethod& method, bool isServer,
53                                  bool isNdk);
54 const string GenLogAfterExecute(const string className, const AidlInterface& interface,
55                                 const AidlMethod& method, const string& statusVarName,
56                                 const string& returnVarName, bool isServer, bool isNdk);
57 }  // namespace cpp
58 }  // namespace aidl
59 }  // namespace android
60