blob: 50737a68bf89af15a8dbec0d599486cdaa56a10d [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;
42
43string make_constant_name(const string& str);
44
45const char* cpp_type_name(java_type_t type);
46
47const char* java_type_name(java_type_t type);
48
49bool atom_needed_for_module(const AtomDecl& atomDecl, const string& moduleName);
50
51bool signature_needed_for_module(const set<string>& modules, const string& moduleName);
52
Muhammad Qureshic8e22662019-11-20 17:18:03 -080053// Common Native helpers
54void write_namespace(FILE* out, const string& cppNamespaces);
55
56void write_closing_namespace(FILE* out, const string& cppNamespaces);
57
58void write_native_atom_constants(FILE* out, const Atoms& atoms, const AtomDecl& attributionDecl,
Muhammad Qureshi4fdc7fd2019-11-24 22:14:38 -080059 const string& moduleName);
60
61void write_native_method_signature(FILE* out, const string& methodName,
62 const vector<java_type_t>& signature, const AtomDecl& attributionDecl,
63 const string& closer);
64
65void write_native_method_call(FILE* out, const string& methodName,
66 const vector<java_type_t>& signature, const AtomDecl& attributionDecl, int argIndex = 1);
Muhammad Qureshi9effe482019-10-29 15:36:44 -070067
68// Common Java helpers.
69void write_java_atom_codes(FILE* out, const Atoms& atoms, const string& moduleName);
70
71void write_java_enum_values(FILE* out, const Atoms& atoms, const string& moduleName);
72
73void write_java_usage(FILE* out, const string& method_name, const string& atom_code_name,
74 const AtomDecl& atom);
75
76int write_java_non_chained_methods(FILE* out, const map<vector<java_type_t>,
77 set<string>>& signatures_to_modules,
Muhammad Qureshi4fdc7fd2019-11-24 22:14:38 -080078 const string& moduleName);
Muhammad Qureshi9effe482019-10-29 15:36:44 -070079
80int write_java_work_source_methods(
81 FILE* out,
82 const map<vector<java_type_t>, set<string>>& signatures_to_modules,
Muhammad Qureshi4fdc7fd2019-11-24 22:14:38 -080083 const string& moduleName);
Muhammad Qureshi9effe482019-10-29 15:36:44 -070084
85} // namespace stats_log_api_gen
86} // namespace android