blob: cd602e53359ad4475a3e5fdcec95250e14646d52 [file] [log] [blame]
Muhammad Qureshi9effe482019-10-29 15:36:44 -07001/*
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#pragma once
18
19#include "Collation.h"
20
21#include <map>
22#include <set>
23#include <vector>
24
25#include <stdio.h>
26#include <string.h>
27
28namespace android {
29namespace stats_log_api_gen {
30
31using namespace std;
32
33const string DEFAULT_MODULE_NAME = "DEFAULT";
34const string DEFAULT_CPP_NAMESPACE = "android,util";
35const string DEFAULT_CPP_HEADER_IMPORT = "statslog.h";
Muhammad Qureshic8e22662019-11-20 17:18:03 -080036const string DEFAULT_ATOMS_INFO_CPP_HEADER_IMPORT = "atoms_info.h";
Muhammad Qureshi9effe482019-10-29 15:36:44 -070037const string DEFAULT_JAVA_PACKAGE = "android.util";
38const string DEFAULT_JAVA_CLASS = "StatsLogInternal";
39
40const int JAVA_MODULE_REQUIRES_FLOAT = 0x01;
41const int JAVA_MODULE_REQUIRES_ATTRIBUTION = 0x02;
Muhammad Qureshib6b39952020-01-14 14:42:13 -080042const int JAVA_MODULE_REQUIRES_KEY_VALUE_PAIRS = 0x04;
Muhammad Qureshi9effe482019-10-29 15:36:44 -070043
44string make_constant_name(const string& str);
45
46const char* cpp_type_name(java_type_t type);
47
48const char* java_type_name(java_type_t type);
49
50bool atom_needed_for_module(const AtomDecl& atomDecl, const string& moduleName);
51
52bool signature_needed_for_module(const set<string>& modules, const string& moduleName);
53
Muhammad Qureshic8e22662019-11-20 17:18:03 -080054// Common Native helpers
55void write_namespace(FILE* out, const string& cppNamespaces);
56
57void write_closing_namespace(FILE* out, const string& cppNamespaces);
58
59void write_native_atom_constants(FILE* out, const Atoms& atoms, const AtomDecl& attributionDecl,
Muhammad Qureshi4fdc7fd2019-11-24 22:14:38 -080060 const string& moduleName);
61
62void write_native_method_signature(FILE* out, const string& methodName,
63 const vector<java_type_t>& signature, const AtomDecl& attributionDecl,
64 const string& closer);
65
66void write_native_method_call(FILE* out, const string& methodName,
67 const vector<java_type_t>& signature, const AtomDecl& attributionDecl, int argIndex = 1);
Muhammad Qureshi9effe482019-10-29 15:36:44 -070068
69// Common Java helpers.
70void write_java_atom_codes(FILE* out, const Atoms& atoms, const string& moduleName);
71
72void write_java_enum_values(FILE* out, const Atoms& atoms, const string& moduleName);
73
74void write_java_usage(FILE* out, const string& method_name, const string& atom_code_name,
75 const AtomDecl& atom);
76
77int write_java_non_chained_methods(FILE* out, const map<vector<java_type_t>,
78 set<string>>& signatures_to_modules,
Muhammad Qureshi4fdc7fd2019-11-24 22:14:38 -080079 const string& moduleName);
Muhammad Qureshi9effe482019-10-29 15:36:44 -070080
81int write_java_work_source_methods(
82 FILE* out,
83 const map<vector<java_type_t>, set<string>>& signatures_to_modules,
Muhammad Qureshi4fdc7fd2019-11-24 22:14:38 -080084 const string& moduleName);
Muhammad Qureshi9effe482019-10-29 15:36:44 -070085
86} // namespace stats_log_api_gen
87} // namespace android