blob: 1ffc681ceac064cd1a84b5386a42e37e8cfca7f0 [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"
Christopher Wileyad339272015-10-05 19:11:58 -070024#include "ast_cpp.h"
Christopher Wileyeb1acc12015-09-16 11:25:13 -070025#include "options.h"
Christopher Wileye3550c62015-09-29 13:26:10 -070026#include "type_cpp.h"
Christopher Wileyeb1acc12015-09-16 11:25:13 -070027
28namespace android {
29namespace aidl {
Christopher Wileyf944e792015-09-29 10:00:46 -070030namespace cpp {
Christopher Wileyeb1acc12015-09-16 11:25:13 -070031
Christopher Wileye3550c62015-09-29 13:26:10 -070032bool GenerateCpp(const CppOptions& options,
33 const cpp::TypeNamespace& types,
Christopher Wiley054afbd2015-10-16 17:08:43 -070034 const AidlInterface& parsed_doc,
35 const IoDelegate& io_delegate);
Christopher Wileyeb1acc12015-09-16 11:25:13 -070036
Christopher Wiley3a9911c2016-01-19 12:59:09 -080037// These roughly correspond to the various class names in the C++ hierarchy:
38enum 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.
48std::string HeaderFile(const AidlInterface& interface, ClassNames class_type,
49 bool use_os_sep = true);
50
Christopher Wileyad339272015-10-05 19:11:58 -070051namespace internals {
52std::unique_ptr<Document> BuildClientSource(const TypeNamespace& types,
53 const AidlInterface& parsed_doc);
54std::unique_ptr<Document> BuildServerSource(const TypeNamespace& types,
55 const AidlInterface& parsed_doc);
56std::unique_ptr<Document> BuildInterfaceSource(const TypeNamespace& types,
57 const AidlInterface& parsed_doc);
58std::unique_ptr<Document> BuildClientHeader(const TypeNamespace& types,
59 const AidlInterface& parsed_doc);
Christopher Wileyfd51d602015-10-14 13:04:48 -070060std::unique_ptr<Document> BuildServerHeader(const TypeNamespace& types,
61 const AidlInterface& parsed_doc);
Christopher Wileyad339272015-10-05 19:11:58 -070062std::unique_ptr<Document> BuildInterfaceHeader(const TypeNamespace& types,
63 const AidlInterface& parsed_doc);
64}
Christopher Wileyf944e792015-09-29 10:00:46 -070065} // namespace cpp
Christopher Wileyeb1acc12015-09-16 11:25:13 -070066} // namespace aidl
Christopher Wileyf944e792015-09-29 10:00:46 -070067} // namespace android
Christopher Wileyeb1acc12015-09-16 11:25:13 -070068
69#endif // AIDL_GENERATE_CPP_H_