|
|
|
|
@@ -58,19 +58,25 @@ static void write_atoms_info_header_body(FILE* out, const Atoms& atoms) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|
|
|
|
std::set<string> kTruncatingAtomNames = {"mobile_radio_power_state_changed",
|
|
|
|
|
"audio_state_changed",
|
|
|
|
|
"call_state_changed",
|
|
|
|
|
"phone_signal_strength_changed",
|
|
|
|
|
"mobile_bytes_transfer_by_fg_bg",
|
|
|
|
|
"mobile_bytes_transfer"};
|
|
|
|
|
std::set<string> kTruncatingAtomNames = {
|
|
|
|
|
"mobile_radio_power_state_changed",
|
|
|
|
|
"audio_state_changed",
|
|
|
|
|
"call_state_changed",
|
|
|
|
|
"phone_signal_strength_changed",
|
|
|
|
|
"mobile_bytes_transfer_by_fg_bg",
|
|
|
|
|
"mobile_bytes_transfer"
|
|
|
|
|
};
|
|
|
|
|
fprintf(out,
|
|
|
|
|
"const std::set<int> "
|
|
|
|
|
"AtomsInfo::kTruncatingTimestampAtomBlackList = {\n");
|
|
|
|
|
for (set<string>::const_iterator blacklistedAtom = kTruncatingAtomNames.begin();
|
|
|
|
|
blacklistedAtom != kTruncatingAtomNames.end(); blacklistedAtom++) {
|
|
|
|
|
fprintf(out, " %s,\n", make_constant_name(*blacklistedAtom).c_str());
|
|
|
|
|
for (set<AtomDecl>::const_iterator atom = atoms.decls.begin();
|
|
|
|
|
atom != atoms.decls.end(); atom++) {
|
|
|
|
|
if (kTruncatingAtomNames.find(atom->name) != kTruncatingAtomNames.end()) {
|
|
|
|
|
const string constant = make_constant_name(atom->name);
|
|
|
|
|
fprintf(out, " %d, // %s\n", atom->code, constant.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(out, "};\n");
|
|
|
|
|
fprintf(out, "\n");
|
|
|
|
|
|
|
|
|
|
@@ -81,8 +87,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|
|
|
|
for (vector<AtomField>::const_iterator field = atom->fields.begin();
|
|
|
|
|
field != atom->fields.end(); field++) {
|
|
|
|
|
if (field->javaType == JAVA_TYPE_ATTRIBUTION_CHAIN) {
|
|
|
|
|
string constant = make_constant_name(atom->name);
|
|
|
|
|
fprintf(out, " %s,\n", constant.c_str());
|
|
|
|
|
const string constant = make_constant_name(atom->name);
|
|
|
|
|
fprintf(out, " %d, // %s\n", atom->code, constant.c_str());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -96,8 +102,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|
|
|
|
for (set<AtomDecl>::const_iterator atom = atoms.decls.begin();
|
|
|
|
|
atom != atoms.decls.end(); atom++) {
|
|
|
|
|
if (atom->whitelisted) {
|
|
|
|
|
string constant = make_constant_name(atom->name);
|
|
|
|
|
fprintf(out, " %s,\n", constant.c_str());
|
|
|
|
|
const string constant = make_constant_name(atom->name);
|
|
|
|
|
fprintf(out, " %d, // %s\n", atom->code, constant.c_str());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -105,7 +111,7 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|
|
|
|
fprintf(out, "\n");
|
|
|
|
|
|
|
|
|
|
fprintf(out, "static std::map<int, int> getAtomUidField() {\n");
|
|
|
|
|
fprintf(out, " std::map<int, int> uidField;\n");
|
|
|
|
|
fprintf(out, " std::map<int, int> uidField;\n");
|
|
|
|
|
for (set<AtomDecl>::const_iterator atom = atoms.decls.begin();
|
|
|
|
|
atom != atoms.decls.end(); atom++) {
|
|
|
|
|
if (atom->uidField == 0) {
|
|
|
|
|
@@ -115,8 +121,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|
|
|
|
"\n // Adding uid field for atom "
|
|
|
|
|
"(%d)%s\n",
|
|
|
|
|
atom->code, atom->name.c_str());
|
|
|
|
|
fprintf(out, " uidField[static_cast<int>(%s)] = %d;\n",
|
|
|
|
|
make_constant_name(atom->name).c_str(), atom->uidField);
|
|
|
|
|
fprintf(out, " uidField[%d /* %s */] = %d;\n",
|
|
|
|
|
atom->code, make_constant_name(atom->name).c_str(), atom->uidField);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(out, " return uidField;\n");
|
|
|
|
|
@@ -140,8 +146,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|
|
|
|
"\n // Adding primary and exclusive fields for atom "
|
|
|
|
|
"(%d)%s\n",
|
|
|
|
|
atom->code, atom->name.c_str());
|
|
|
|
|
fprintf(out, " opt = &(options[static_cast<int>(%s)]);\n",
|
|
|
|
|
make_constant_name(atom->name).c_str());
|
|
|
|
|
fprintf(out, " opt = &(options[%d /* %s */]);\n",
|
|
|
|
|
atom->code, make_constant_name(atom->name).c_str());
|
|
|
|
|
fprintf(out, " opt->primaryFields.reserve(%lu);\n", atom->primaryFields.size());
|
|
|
|
|
for (const auto& field : atom->primaryFields) {
|
|
|
|
|
fprintf(out, " opt->primaryFields.push_back(%d);\n", field);
|
|
|
|
|
@@ -185,8 +191,8 @@ static void write_atoms_info_cpp_body(FILE* out, const Atoms& atoms) {
|
|
|
|
|
atom->code, atom->name.c_str());
|
|
|
|
|
|
|
|
|
|
for (const auto& field : atom->binaryFields) {
|
|
|
|
|
fprintf(out, " options[static_cast<int>(%s)].push_back(%d);\n",
|
|
|
|
|
make_constant_name(atom->name).c_str(), field);
|
|
|
|
|
fprintf(out, " options[%d /* %s */].push_back(%d);\n",
|
|
|
|
|
atom->code, make_constant_name(atom->name).c_str(), field);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -222,12 +228,11 @@ int write_atoms_info_header(FILE* out, const Atoms &atoms, const string& namespa
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int write_atoms_info_cpp(FILE *out, const Atoms &atoms, const string& namespaceStr,
|
|
|
|
|
const string& importHeader, const string& statslogHeader) {
|
|
|
|
|
const string& importHeader) {
|
|
|
|
|
// Print prelude
|
|
|
|
|
fprintf(out, "// This file is autogenerated\n");
|
|
|
|
|
fprintf(out, "\n");
|
|
|
|
|
fprintf(out, "#include <%s>\n", importHeader.c_str());
|
|
|
|
|
fprintf(out, "#include <%s>\n", statslogHeader.c_str());
|
|
|
|
|
fprintf(out, "\n");
|
|
|
|
|
|
|
|
|
|
write_namespace(out, namespaceStr);
|
|
|
|
|
|