blob: 15f622cf9461498ac877051387fd4f50f4ed1ceb [file] [log] [blame]
Joe Onorato1754d742016-11-21 17:51:35 -08001/*
2 * Copyright (C) 2016 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
Joe Onorato76690122016-12-20 08:18:32 -080018#include <frameworks/base/core/proto/android/os/incident.pb.h>
Joe Onorato1754d742016-11-21 17:51:35 -080019
20
21#include <map>
22
23using namespace android::os;
24using namespace google::protobuf;
25using namespace google::protobuf::io;
26using namespace google::protobuf::internal;
27using namespace std;
28
29int
30main(int, const char**)
31{
32 map<string,FieldDescriptor const*> sections;
33 int N;
34
35 printf("// Auto generated file. Do not modify\n");
36 printf("\n");
37 printf("#include \"incident_sections.h\"\n");
38 printf("\n");
39
40 Descriptor const* descriptor = IncidentProto::descriptor();
41 N = descriptor->field_count();
42 for (int i=0; i<N; i++) {
43 const FieldDescriptor* field = descriptor->field(i);
44 if (field->type() == FieldDescriptor::TYPE_MESSAGE) {
45 sections[field->name()] = field;
46 }
47 }
48
49 printf("IncidentSection const INCIDENT_SECTIONS[] = {\n");
50 N = sections.size();
51 int i = 0;
52 for (map<string,FieldDescriptor const*>::const_iterator it = sections.begin();
53 it != sections.end(); it++, i++) {
54 const FieldDescriptor* field = it->second;
55 printf(" { %d, \"%s\" }", field->number(), field->name().c_str());
56 if (i != N-1) {
57 printf(",\n");
58 } else {
59 printf("\n");
60 }
61 }
62 printf("};\n");
63
64 printf("const int INCIDENT_SECTION_COUNT = %d;\n", N);
65
66 return 0;
67}