1// Copyright 2019 The Pigweed Authors
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may not
4// use this file except in compliance with the License. You may obtain a copy of
5// the License at
6//
7//     https://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12// License for the specific language governing permissions and limitations under
13// the License.
14syntax = "proto3";
15
16// This is a test .proto file for pw_protobuf's codegen implementation.
17
18package pw.protobuf.test;
19
20// Top-level enum definition.
21enum Bool {
22  TRUE = 0;
23  FALSE = 1;
24  FILE_NOT_FOUND = 2;
25}
26
27// A message!
28message Pigweed {
29  // Nested messages and enums.
30  message Pigweed {
31    enum Binary {
32      ZERO = 0;
33      ONE = 1;
34    }
35
36    Bool status = 1;
37  }
38
39  message Protobuf {
40    enum Binary {
41      ONE = 0;
42      ZERO = 1;
43    }
44
45    // We must go deeper.
46    message Compiler {
47      enum Status {
48        OK = 0;
49        ERROR = 1;
50        FUBAR = 2;
51      }
52
53      string file_name = 1;
54      Status status = 2;
55      Binary protobuf_bin = 3;
56      Pigweed.Binary pigweed_bin = 4;
57    }
58
59    Binary binary_value = 1;
60  }
61
62  // Regular types.
63  uint32 magic_number = 1;
64  sint32 ziggy = 2;
65  fixed64 cycles = 3;
66  float ratio = 4;
67  string error_message = 5;
68
69  DeviceInfo device_info = 6;
70
71  // Nested messages and enums as fields.
72  Pigweed pigweed = 7;
73  Protobuf.Binary bin = 8;
74
75  Proto proto = 9;
76  repeated Proto.ID id = 10;
77}
78
79// Another message.
80message Proto {
81  enum Binary {
82    OFF = 0;
83    ON = 1;
84  }
85
86  message ID {
87    uint32 id = 1;
88  }
89
90  // Circular dependency with Pigweed.
91  Pigweed pigweed = 1;
92
93  // Same name, different namespace.
94  Binary bin = 2;
95  Pigweed.Pigweed.Binary pigweed_pigweed_bin = 3;
96  Pigweed.Protobuf.Binary pigweed_protobuf_bin = 4;
97
98  Pigweed.Protobuf.Compiler meta = 5;
99}
100
101// Yet another message.
102message DeviceInfo {
103  enum DeviceStatus {
104    OK = 0;
105    ASSERT = 1;
106    FAULT = 2;
107    PANIC = 3;
108  }
109
110  string device_name = 1;
111  fixed32 device_id = 2;
112  DeviceStatus status = 3;
113
114  repeated KeyValuePair attributes = 4;
115}
116
117// This might be useful.
118message KeyValuePair {
119  string key = 1;
120  string value = 2;
121}
122