| Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -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 | #ifndef AIDL_GENERATE_CPP_H_ |
| 18 | #define AIDL_GENERATE_CPP_H_ |
| 19 | |
| Christopher Wiley | 3a9911c | 2016-01-19 12:59:09 -0800 | [diff] [blame] | 20 | #include <memory> |
| 21 | #include <string> |
| 22 | |
| Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 23 | #include "aidl_language.h" |
| Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 24 | #include "ast_cpp.h" |
| Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 25 | #include "options.h" |
| Christopher Wiley | e3550c6 | 2015-09-29 13:26:10 -0700 | [diff] [blame] | 26 | #include "type_cpp.h" |
| Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | namespace aidl { |
| Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 30 | namespace cpp { |
| Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 31 | |
| Christopher Wiley | e3550c6 | 2015-09-29 13:26:10 -0700 | [diff] [blame] | 32 | bool GenerateCpp(const CppOptions& options, |
| 33 | const cpp::TypeNamespace& types, |
| Christopher Wiley | 054afbd | 2015-10-16 17:08:43 -0700 | [diff] [blame] | 34 | const AidlInterface& parsed_doc, |
| 35 | const IoDelegate& io_delegate); |
| Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 36 | |
| Christopher Wiley | 3a9911c | 2016-01-19 12:59:09 -0800 | [diff] [blame] | 37 | // These roughly correspond to the various class names in the C++ hierarchy: |
| 38 | enum class ClassNames { |
| 39 | BASE, // Foo (not a real class, but useful in some circumstances). |
| 40 | CLIENT, // BpFoo |
| 41 | SERVER, // BnFoo |
| 42 | INTERFACE, // IFoo |
| 43 | }; |
| 44 | |
| 45 | // Generate the relative path to a header file. If |use_os_sep| we'll use the |
| 46 | // operating system specific path separator rather than C++'s expected '/' when |
| 47 | // including headers. |
| 48 | std::string HeaderFile(const AidlInterface& interface, ClassNames class_type, |
| 49 | bool use_os_sep = true); |
| 50 | |
| Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 51 | namespace internals { |
| 52 | std::unique_ptr<Document> BuildClientSource(const TypeNamespace& types, |
| 53 | const AidlInterface& parsed_doc); |
| 54 | std::unique_ptr<Document> BuildServerSource(const TypeNamespace& types, |
| 55 | const AidlInterface& parsed_doc); |
| 56 | std::unique_ptr<Document> BuildInterfaceSource(const TypeNamespace& types, |
| 57 | const AidlInterface& parsed_doc); |
| 58 | std::unique_ptr<Document> BuildClientHeader(const TypeNamespace& types, |
| 59 | const AidlInterface& parsed_doc); |
| Christopher Wiley | fd51d60 | 2015-10-14 13:04:48 -0700 | [diff] [blame] | 60 | std::unique_ptr<Document> BuildServerHeader(const TypeNamespace& types, |
| 61 | const AidlInterface& parsed_doc); |
| Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 62 | std::unique_ptr<Document> BuildInterfaceHeader(const TypeNamespace& types, |
| 63 | const AidlInterface& parsed_doc); |
| 64 | } |
| Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 65 | } // namespace cpp |
| Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 66 | } // namespace aidl |
| Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 67 | } // namespace android |
| Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 68 | |
| 69 | #endif // AIDL_GENERATE_CPP_H_ |