blob: 6274d4e1f90d806720f60bbe50b29b40fb916ab2 [file] [log] [blame]
Christopher Wileyeb1acc12015-09-16 11:25:13 -07001/*
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 Wiley3a9911c2016-01-19 12:59:09 -080020#include <memory>
21#include <string>
22
Christopher Wileyeb1acc12015-09-16 11:25:13 -070023#include "aidl_language.h"
Steven Moreland860b1942018-08-16 14:59:28 -070024#include "aidl_to_cpp.h"
Christopher Wileyad339272015-10-05 19:11:58 -070025#include "ast_cpp.h"
Christopher Wileyeb1acc12015-09-16 11:25:13 -070026#include "options.h"
Christopher Wileye3550c62015-09-29 13:26:10 -070027#include "type_cpp.h"
Christopher Wileyeb1acc12015-09-16 11:25:13 -070028
29namespace android {
30namespace aidl {
Christopher Wileyf944e792015-09-29 10:00:46 -070031namespace cpp {
Christopher Wileyeb1acc12015-09-16 11:25:13 -070032
Jiyong Park74595c12018-07-23 15:22:50 +090033bool GenerateCpp(const string& output_file, const Options& options, const cpp::TypeNamespace& types,
Steven Moreland5557f1c2018-07-02 13:50:23 -070034 const AidlDefinedType& parsed_doc, const IoDelegate& io_delegate);
Christopher Wileyeb1acc12015-09-16 11:25:13 -070035
Christopher Wiley3a9911c2016-01-19 12:59:09 -080036// These roughly correspond to the various class names in the C++ hierarchy:
37enum class ClassNames {
Jiyong Park75e1a742018-07-04 12:31:23 +090038 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 Wiley3a9911c2016-01-19 12:59:09 -080043};
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 Moreland5557f1c2018-07-02 13:50:23 -070048std::string HeaderFile(const AidlDefinedType& defined_type, ClassNames class_type,
Christopher Wiley3a9911c2016-01-19 12:59:09 -080049 bool use_os_sep = true);
50
Christopher Wileyad339272015-10-05 19:11:58 -070051namespace internals {
52std::unique_ptr<Document> BuildClientSource(const TypeNamespace& types,
Jiyong Parkfbbfa932018-07-30 21:44:10 +090053 const AidlInterface& parsed_doc,
54 const Options& options);
Christopher Wileyad339272015-10-05 19:11:58 -070055std::unique_ptr<Document> BuildServerSource(const TypeNamespace& types,
Jiyong Parkfbbfa932018-07-30 21:44:10 +090056 const AidlInterface& parsed_doc,
57 const Options& options);
Christopher Wileyad339272015-10-05 19:11:58 -070058std::unique_ptr<Document> BuildInterfaceSource(const TypeNamespace& types,
Jiyong Parkfbbfa932018-07-30 21:44:10 +090059 const AidlInterface& parsed_doc,
60 const Options& options);
Christopher Wileyad339272015-10-05 19:11:58 -070061std::unique_ptr<Document> BuildClientHeader(const TypeNamespace& types,
Jiyong Parkfbbfa932018-07-30 21:44:10 +090062 const AidlInterface& parsed_doc,
63 const Options& options);
Christopher Wileyfd51d602015-10-14 13:04:48 -070064std::unique_ptr<Document> BuildServerHeader(const TypeNamespace& types,
Jiyong Parkfbbfa932018-07-30 21:44:10 +090065 const AidlInterface& parsed_doc,
66 const Options& options);
Christopher Wileyad339272015-10-05 19:11:58 -070067std::unique_ptr<Document> BuildInterfaceHeader(const TypeNamespace& types,
Jiyong Parkfbbfa932018-07-30 21:44:10 +090068 const AidlInterface& parsed_doc,
69 const Options& options);
Steven Moreland5557f1c2018-07-02 13:50:23 -070070
71std::unique_ptr<Document> BuildParcelHeader(const TypeNamespace& types,
Jiyong Parkfbbfa932018-07-30 21:44:10 +090072 const AidlStructuredParcelable& parsed_doc,
73 const Options& options);
Steven Moreland5557f1c2018-07-02 13:50:23 -070074std::unique_ptr<Document> BuildParcelSource(const TypeNamespace& types,
Jiyong Parkfbbfa932018-07-30 21:44:10 +090075 const AidlStructuredParcelable& parsed_doc,
76 const Options& options);
Christopher Wileyad339272015-10-05 19:11:58 -070077}
Christopher Wileyf944e792015-09-29 10:00:46 -070078} // namespace cpp
Christopher Wileyeb1acc12015-09-16 11:25:13 -070079} // namespace aidl
Christopher Wileyf944e792015-09-29 10:00:46 -070080} // namespace android
Christopher Wileyeb1acc12015-09-16 11:25:13 -070081
82#endif // AIDL_GENERATE_CPP_H_