OSDN Git Service

Generate constants for enum values.
authorStefan Lafon <stlafon@google.com>
Tue, 31 Oct 2017 04:20:20 +0000 (21:20 -0700)
committerStefan Lafon <stlafon@google.com>
Tue, 31 Oct 2017 18:23:09 +0000 (11:23 -0700)
commit9478f3515b2e0ccc8320b1911e6f911e3a3ffde0
treed6f3b618e3854b1037852e8a6d56970b495a6822
parent941dcba6e310e0bafcc1459422e7db01c5b70bb0
Generate constants for enum values.

Test: Builds successfully, tests pass and statsd works (it seems).

This will allow us to use those constants instead of literals.
The generated code only augmentes the java constant file.
If needed, the same can be done for the C++ file.
Some of the constant names are very long, but this is due to enum value names that are unnecessarily redundant with the enum names, i.e.
enum ENUM_NAME {
  ENUM_NAME_UNKNOWN = 0;
  ENUM_NAME_VALUE1 = 1;
  ENUM_NAME_VALUE2 = 2;
  ...
}
which can be fixed by avoiding the 'ENUM_NAME_' part in the value names above.
So, when possible, we should use shorter value names in stats_events.proto.

Change-Id: I1ad19b86e28d0df0f8c15d4c995d101423cff4c2
tools/stats_log_api_gen/Collation.cpp
tools/stats_log_api_gen/Collation.h
tools/stats_log_api_gen/main.cpp
tools/stats_log_api_gen/test_collation.cpp