New code generation implementation is flag guarded by STATS_SCHEMA_LEGACY Support for Q schema can be added by passing --supportQ flag in stats_log_api_gen. (Only needed for statslog_resolv.cpp) Q schema is supported through StatsEventCompat. Generated R schema statslog.h: https://paste.googleplex.com/4986214782337024 Generated R schema statslog.cpp: https://paste.googleplex.com/4856851575341056 Generated R schema statslog_resolv.h: https://paste.googleplex.com/6062978921136128 Generated R schema statslog_resolv.cpp: https://paste.googleplex.com/4752329251225600 Generated Q schema statslog.h: https://paste.googleplex.com/4766729873915904 Generated Q schema statslog.cpp: https://paste.googleplex.com/5018563779756032 Generated Q schema statslog_resolv.h: https://paste.googleplex.com/5338897498243072 Generated Q schema statslog_resolv.cpp: https://paste.googleplex.com/5191011011657728 Test: m -j Test: flashes successfully Test: adb logcat inspection Change-Id: I5675a80c03ca3fbd5cd4a02c04a4b9cb89ec32ab Merged-In: I5675a80c03ca3fbd5cd4a02c04a4b9cb89ec32ab
87 lines
2.8 KiB
C++
87 lines
2.8 KiB
C++
/*
|
|
* Copyright (C) 2019, The Android Open Source Project
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "Collation.h"
|
|
|
|
#include <map>
|
|
#include <set>
|
|
#include <vector>
|
|
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
namespace android {
|
|
namespace stats_log_api_gen {
|
|
|
|
using namespace std;
|
|
|
|
const string DEFAULT_MODULE_NAME = "DEFAULT";
|
|
const string DEFAULT_CPP_NAMESPACE = "android,util";
|
|
const string DEFAULT_CPP_HEADER_IMPORT = "statslog.h";
|
|
const string DEFAULT_ATOMS_INFO_CPP_HEADER_IMPORT = "atoms_info.h";
|
|
const string DEFAULT_JAVA_PACKAGE = "android.util";
|
|
const string DEFAULT_JAVA_CLASS = "StatsLogInternal";
|
|
|
|
const int JAVA_MODULE_REQUIRES_FLOAT = 0x01;
|
|
const int JAVA_MODULE_REQUIRES_ATTRIBUTION = 0x02;
|
|
|
|
string make_constant_name(const string& str);
|
|
|
|
const char* cpp_type_name(java_type_t type);
|
|
|
|
const char* java_type_name(java_type_t type);
|
|
|
|
bool atom_needed_for_module(const AtomDecl& atomDecl, const string& moduleName);
|
|
|
|
bool signature_needed_for_module(const set<string>& modules, const string& moduleName);
|
|
|
|
// Common Native helpers
|
|
void write_namespace(FILE* out, const string& cppNamespaces);
|
|
|
|
void write_closing_namespace(FILE* out, const string& cppNamespaces);
|
|
|
|
void write_native_atom_constants(FILE* out, const Atoms& atoms, const AtomDecl& attributionDecl,
|
|
const string& moduleName);
|
|
|
|
void write_native_method_signature(FILE* out, const string& methodName,
|
|
const vector<java_type_t>& signature, const AtomDecl& attributionDecl,
|
|
const string& closer);
|
|
|
|
void write_native_method_call(FILE* out, const string& methodName,
|
|
const vector<java_type_t>& signature, const AtomDecl& attributionDecl, int argIndex = 1);
|
|
|
|
// Common Java helpers.
|
|
void write_java_atom_codes(FILE* out, const Atoms& atoms, const string& moduleName);
|
|
|
|
void write_java_enum_values(FILE* out, const Atoms& atoms, const string& moduleName);
|
|
|
|
void write_java_usage(FILE* out, const string& method_name, const string& atom_code_name,
|
|
const AtomDecl& atom);
|
|
|
|
int write_java_non_chained_methods(FILE* out, const map<vector<java_type_t>,
|
|
set<string>>& signatures_to_modules,
|
|
const string& moduleName);
|
|
|
|
int write_java_work_source_methods(
|
|
FILE* out,
|
|
const map<vector<java_type_t>, set<string>>& signatures_to_modules,
|
|
const string& moduleName);
|
|
|
|
} // namespace stats_log_api_gen
|
|
} // namespace android
|