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" |
Steven Moreland | 860b194 | 2018-08-16 14:59:28 -0700 | [diff] [blame^] | 24 | #include "aidl_to_cpp.h" |
Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 25 | #include "ast_cpp.h" |
Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 26 | #include "options.h" |
Christopher Wiley | e3550c6 | 2015-09-29 13:26:10 -0700 | [diff] [blame] | 27 | #include "type_cpp.h" |
Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 28 | |
| 29 | namespace android { |
| 30 | namespace aidl { |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 31 | namespace cpp { |
Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 32 | |
Jiyong Park | 74595c1 | 2018-07-23 15:22:50 +0900 | [diff] [blame] | 33 | bool GenerateCpp(const string& output_file, const Options& options, const cpp::TypeNamespace& types, |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 34 | const AidlDefinedType& parsed_doc, const IoDelegate& io_delegate); |
Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 35 | |
Christopher Wiley | 3a9911c | 2016-01-19 12:59:09 -0800 | [diff] [blame] | 36 | // These roughly correspond to the various class names in the C++ hierarchy: |
| 37 | enum class ClassNames { |
Jiyong Park | 75e1a74 | 2018-07-04 12:31:23 +0900 | [diff] [blame] | 38 | BASE, // Foo (not a real class, but useful in some circumstances). |
| 39 | CLIENT, // BpFoo |
| 40 | SERVER, // BnFoo |
| 41 | INTERFACE, // IFoo |
| 42 | DEFAULT_IMPL, // IFooDefault |
Christopher Wiley | 3a9911c | 2016-01-19 12:59:09 -0800 | [diff] [blame] | 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. |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 48 | std::string HeaderFile(const AidlDefinedType& defined_type, ClassNames class_type, |
Christopher Wiley | 3a9911c | 2016-01-19 12:59:09 -0800 | [diff] [blame] | 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, |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 53 | const AidlInterface& parsed_doc, |
| 54 | const Options& options); |
Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 55 | std::unique_ptr<Document> BuildServerSource(const TypeNamespace& types, |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 56 | const AidlInterface& parsed_doc, |
| 57 | const Options& options); |
Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 58 | std::unique_ptr<Document> BuildInterfaceSource(const TypeNamespace& types, |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 59 | const AidlInterface& parsed_doc, |
| 60 | const Options& options); |
Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 61 | std::unique_ptr<Document> BuildClientHeader(const TypeNamespace& types, |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 62 | const AidlInterface& parsed_doc, |
| 63 | const Options& options); |
Christopher Wiley | fd51d60 | 2015-10-14 13:04:48 -0700 | [diff] [blame] | 64 | std::unique_ptr<Document> BuildServerHeader(const TypeNamespace& types, |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 65 | const AidlInterface& parsed_doc, |
| 66 | const Options& options); |
Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 67 | std::unique_ptr<Document> BuildInterfaceHeader(const TypeNamespace& types, |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 68 | const AidlInterface& parsed_doc, |
| 69 | const Options& options); |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 70 | |
| 71 | std::unique_ptr<Document> BuildParcelHeader(const TypeNamespace& types, |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 72 | const AidlStructuredParcelable& parsed_doc, |
| 73 | const Options& options); |
Steven Moreland | 5557f1c | 2018-07-02 13:50:23 -0700 | [diff] [blame] | 74 | std::unique_ptr<Document> BuildParcelSource(const TypeNamespace& types, |
Jiyong Park | fbbfa93 | 2018-07-30 21:44:10 +0900 | [diff] [blame] | 75 | const AidlStructuredParcelable& parsed_doc, |
| 76 | const Options& options); |
Christopher Wiley | ad33927 | 2015-10-05 19:11:58 -0700 | [diff] [blame] | 77 | } |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 78 | } // namespace cpp |
Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 79 | } // namespace aidl |
Christopher Wiley | f944e79 | 2015-09-29 10:00:46 -0700 | [diff] [blame] | 80 | } // namespace android |
Christopher Wiley | eb1acc1 | 2015-09-16 11:25:13 -0700 | [diff] [blame] | 81 | |
| 82 | #endif // AIDL_GENERATE_CPP_H_ |