diff options
Diffstat (limited to 'tools/stats_log_api_gen/native_writer.cpp')
-rw-r--r-- | tools/stats_log_api_gen/native_writer.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/tools/stats_log_api_gen/native_writer.cpp b/tools/stats_log_api_gen/native_writer.cpp index deb7e0fd446c..c0d73fa6261f 100644 --- a/tools/stats_log_api_gen/native_writer.cpp +++ b/tools/stats_log_api_gen/native_writer.cpp @@ -33,6 +33,8 @@ static void write_annotations(FILE* out, int argIndex, for (const shared_ptr<AtomDecl>& atomDecl : atomDeclSet) { fprintf(out, " if (code == %d) {\n", atomDecl->code); const AnnotationSet& annotations = atomDecl->fieldNumberToAnnotations.at(argIndex); + int resetState = -1; + int defaultState = -1; for (const shared_ptr<Annotation>& annotation : annotations) { // TODO(b/151786433): Write atom constant name instead of atom id literal. switch (annotation->type) { @@ -41,9 +43,15 @@ static void write_annotations(FILE* out, int argIndex, case ANNOTATION_TYPE_INT: // TODO(b/151786433): Write annotation constant name instead of // annotation id literal. - fprintf(out, " %saddInt32Annotation(%s%d, %d);\n", methodPrefix.c_str(), - methodSuffix.c_str(), annotation->annotationId, - annotation->value.intValue); + if (ANNOTATION_ID_RESET_STATE == annotation->annotationId) { + resetState = annotation->value.intValue; + } else if (ANNOTATION_ID_DEFAULT_STATE == annotation->annotationId) { + defaultState = annotation->value.intValue; + } else { + fprintf(out, " %saddInt32Annotation(%s%d, %d);\n", + methodPrefix.c_str(), methodSuffix.c_str(), + annotation->annotationId, annotation->value.intValue); + } break; case ANNOTATION_TYPE_BOOL: // TODO(b/151786433): Write annotation constant name instead of @@ -56,6 +64,12 @@ static void write_annotations(FILE* out, int argIndex, break; } } + if (defaultState != -1 && resetState != -1) { + fprintf(out, " if (arg%d == %d) {\n", argIndex, resetState); + fprintf(out, " %saddInt32Annotation(%s%d, %d);\n", methodPrefix.c_str(), + methodSuffix.c_str(), ANNOTATION_ID_RESET_STATE, defaultState); + fprintf(out, " }\n"); + } fprintf(out, " }\n"); } } |