diff options
author | Muhammad Qureshi <muhammadq@google.com> | 2019-11-24 22:14:38 -0800 |
---|---|---|
committer | Muhammad Qureshi <muhammadq@google.com> | 2020-01-02 14:54:16 -0800 |
commit | 4fdc7fd375f69a3219d8680ef4da90fe8cf80020 (patch) | |
tree | 44f9ad562f54f9f28ebdcdae44f7064391591a99 /tools/stats_log_api_gen/utils.cpp | |
parent | 610a12603c78a6f680d0bbec98b0e1bd1f1b2021 (diff) |
Support new socket schema in native codegen
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
Diffstat (limited to 'tools/stats_log_api_gen/utils.cpp')
-rw-r--r-- | tools/stats_log_api_gen/utils.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/tools/stats_log_api_gen/utils.cpp b/tools/stats_log_api_gen/utils.cpp index d6cfe95a34f5..c65d1901ea7e 100644 --- a/tools/stats_log_api_gen/utils.cpp +++ b/tools/stats_log_api_gen/utils.cpp @@ -204,6 +204,65 @@ void write_native_atom_constants(FILE* out, const Atoms& atoms, const AtomDecl& fprintf(out, "\n"); } +void write_native_method_signature(FILE* out, const string& methodName, + const vector<java_type_t>& signature, const AtomDecl& attributionDecl, + const string& closer) { + fprintf(out, "%s(int32_t code", methodName.c_str()); + int argIndex = 1; + for (vector<java_type_t>::const_iterator arg = signature.begin(); + arg != signature.end(); arg++) { + if (*arg == JAVA_TYPE_ATTRIBUTION_CHAIN) { + for (auto chainField : attributionDecl.fields) { + if (chainField.javaType == JAVA_TYPE_STRING) { + fprintf(out, ", const std::vector<%s>& %s", + cpp_type_name(chainField.javaType), + chainField.name.c_str()); + } else { + fprintf(out, ", const %s* %s, size_t %s_length", + cpp_type_name(chainField.javaType), + chainField.name.c_str(), chainField.name.c_str()); + } + } + } else if (*arg == JAVA_TYPE_KEY_VALUE_PAIR) { + fprintf(out, ", const std::map<int, int32_t>& arg%d_1, " + "const std::map<int, int64_t>& arg%d_2, " + "const std::map<int, char const*>& arg%d_3, " + "const std::map<int, float>& arg%d_4", + argIndex, argIndex, argIndex, argIndex); + } else { + fprintf(out, ", %s arg%d", cpp_type_name(*arg), argIndex); + } + argIndex++; + } + fprintf(out, ")%s\n", closer.c_str()); +} + +void write_native_method_call(FILE* out, const string& methodName, + const vector<java_type_t>& signature, const AtomDecl& attributionDecl, int argIndex) { + fprintf(out, "%s(code", methodName.c_str()); + for (vector<java_type_t>::const_iterator arg = signature.begin(); + arg != signature.end(); arg++) { + if (*arg == JAVA_TYPE_ATTRIBUTION_CHAIN) { + for (auto chainField : attributionDecl.fields) { + if (chainField.javaType == JAVA_TYPE_STRING) { + fprintf(out, ", %s", + chainField.name.c_str()); + } else { + fprintf(out, ", %s, %s_length", + chainField.name.c_str(), chainField.name.c_str()); + } + } + } else if (*arg == JAVA_TYPE_KEY_VALUE_PAIR) { + fprintf(out, ", arg%d_1, arg%d_2, arg%d_3, arg%d_4", argIndex, + argIndex, argIndex, argIndex); + } else { + fprintf(out, ", arg%d", argIndex); + } + argIndex++; + } + fprintf(out, ");\n"); +} + // Java void write_java_atom_codes(FILE* out, const Atoms& atoms, const string& moduleName) { fprintf(out, " // Constants for atom codes.\n"); |