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 const int API_T = 33; 39 40 const int JAVA_MODULE_REQUIRES_FLOAT = 0x01; 41 const int JAVA_MODULE_REQUIRES_ATTRIBUTION = 0x02; 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 bool is_repeated_field(java_type_t type); 55 56 // Common Native helpers 57 void write_namespace(FILE* out, const string& cppNamespaces); 58 59 void write_closing_namespace(FILE* out, const string& cppNamespaces); 60 61 void write_native_atom_constants(FILE* out, const Atoms& atoms, const AtomDecl& attributionDecl); 62 63 // Common Java helpers. 64 void write_java_atom_codes(FILE* out, const Atoms& atoms); 65 66 void write_java_enum_values(FILE* out, const Atoms& atoms); 67 68 void write_java_usage(FILE* out, const string& method_name, const string& atom_code_name, 69 const AtomDecl& atom); 70 71 int write_java_non_chained_methods(FILE* out, const SignatureInfoMap& signatureInfoMap); 72 73 int write_java_work_source_methods(FILE* out, const SignatureInfoMap& signatureInfoMap); 74 75 } // namespace stats_log_api_gen 76 } // namespace android 77 78 #endif // ANDROID_STATS_LOG_API_GEN_UTILS_H 79