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_AIDL_H_
18 #define AIDL_AIDL_H_
19 
20 #include <limits>
21 #include <memory>
22 #include <string>
23 #include <vector>
24 
25 #include "aidl_language.h"
26 #include "io_delegate.h"
27 #include "options.h"
28 #include "type_namespace.h"
29 
30 namespace android {
31 namespace aidl {
32 
33 enum class AidlError {
34   UNKOWN = std::numeric_limits<int32_t>::min(),
35   BAD_PRE_PROCESSED_FILE,
36   PARSE_ERROR,
37   FOUND_PARCELABLE,
38   BAD_PACKAGE,
39   BAD_IMPORT,
40   BAD_TYPE,
41   BAD_METHOD_ID,
42   GENERATION_ERROR,
43   BAD_CONSTANTS,
44 
45   OK = 0,
46 };
47 
48 int compile_aidl_to_cpp(const CppOptions& options,
49                         const IoDelegate& io_delegate);
50 int compile_aidl_to_java(const JavaOptions& options,
51                          const IoDelegate& io_delegate);
52 bool preprocess_aidl(const JavaOptions& options,
53                      const IoDelegate& io_delegate);
54 
55 namespace internals {
56 
57 AidlError load_and_validate_aidl(
58     const std::vector<std::string>& preprocessed_files,
59     const std::vector<std::string>& import_paths,
60     const std::string& input_file_name,
61     const IoDelegate& io_delegate,
62     TypeNamespace* types,
63     std::unique_ptr<AidlInterface>* returned_interface,
64     std::vector<std::unique_ptr<AidlImport>>* returned_imports);
65 
66 bool parse_preprocessed_file(const IoDelegate& io_delegate,
67                              const std::string& filename, TypeNamespace* types);
68 
69 } // namespace internals
70 
71 }  // namespace android
72 }  // namespace aidl
73 
74 #endif  // AIDL_AIDL_H_
75