• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2019, 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 ANDROID_STATS_LOG_API_GEN_UTILS_H
18 #define ANDROID_STATS_LOG_API_GEN_UTILS_H
19 
20 #include <stdio.h>
21 #include <string.h>
22 
23 #include <map>
24 #include <set>
25 #include <vector>
26 
27 #include "Collation.h"
28 
29 namespace android {
30 namespace stats_log_api_gen {
31 
32 const char DEFAULT_CPP_NAMESPACE[] = "android,util";
33 const char DEFAULT_CPP_HEADER_IMPORT[] = "statslog.h";
34 
35 const int API_LEVEL_CURRENT = 10000;
36 const int API_Q = 29;
37 const int API_R = 30;
38 
39 const int JAVA_MODULE_REQUIRES_FLOAT = 0x01;
40 const int JAVA_MODULE_REQUIRES_ATTRIBUTION = 0x02;
41 const int JAVA_MODULE_REQUIRES_KEY_VALUE_PAIRS = 0x04;
42 
43 void build_non_chained_decl_map(const Atoms& atoms,
44                                 std::map<int, AtomDeclSet::const_iterator>* decl_map);
45 
46 const map<AnnotationId, string>& get_annotation_id_constants();
47 
48 string make_constant_name(const string& str);
49 
50 const char* cpp_type_name(java_type_t type);
51 
52 const char* java_type_name(java_type_t type);
53 
54 // Common Native helpers
55 void write_namespace(FILE* out, const string& cppNamespaces);
56 
57 void write_closing_namespace(FILE* out, const string& cppNamespaces);
58 
59 void write_native_atom_constants(FILE* out, const Atoms& atoms, const AtomDecl& attributionDecl);
60 
61 void write_native_method_signature(FILE* out, const string& signaturePrefix,
62                                    const vector<java_type_t>& signature,
63                                    const AtomDecl& attributionDecl, const string& closer);
64 
65 void write_native_method_call(FILE* out, const string& methodName,
66                               const vector<java_type_t>& signature, const AtomDecl& attributionDecl,
67                               int argIndex = 1);
68 
69 // Common Java helpers.
70 void write_java_atom_codes(FILE* out, const Atoms& atoms);
71 
72 void write_java_enum_values(FILE* out, const Atoms& atoms);
73 
74 void write_java_usage(FILE* out, const string& method_name, const string& atom_code_name,
75                       const AtomDecl& atom);
76 
77 int write_java_non_chained_methods(FILE* out, const SignatureInfoMap& signatureInfoMap);
78 
79 int write_java_work_source_methods(FILE* out, const SignatureInfoMap& signatureInfoMap);
80 
81 }  // namespace stats_log_api_gen
82 }  // namespace android
83 
84 #endif  // ANDROID_STATS_LOG_API_GEN_UTILS_H
85