DCCL v4
test.proto
1 // Copyright 2023:
2 // GobySoft, LLC (2013-)
3 // Community contributors (see AUTHORS file)
4 // File authors:
5 // Toby Schneider <toby@gobysoft.org>
6 //
7 //
8 // This file is part of the Dynamic Compact Control Language Library
9 // ("DCCL").
10 //
11 // DCCL is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU Lesser General Public License as published by
13 // the Free Software Foundation, either version 2.1 of the License, or
14 // (at your option) any later version.
15 //
16 // DCCL is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU Lesser General Public License for more details.
20 //
21 // You should have received a copy of the GNU Lesser General Public License
22 // along with DCCL. If not, see <http://www.gnu.org/licenses/>.
23 syntax = "proto2";
24 
25 import "dccl/option_extensions.proto";
26 
27 package dccl.test;
28 
29 message EmbeddedMsg1
30 {
31  optional double val = 1 [
32  (dccl.field).min = 0,
33  (dccl.field).max = 126,
34  (dccl.field).precision = 3
35  ];
36 }
37 
38 message TestMsg
39 {
40  option (dccl.msg).id = 2;
41  option (dccl.msg).max_bytes = 32;
42  option (dccl.msg).codec_version = 4;
43 
44  enum E
45  {
46  VALUE1 = 1;
47  VALUE2 = 2;
48  }
49 
50  required E e = 5;
51  optional double d = 6
52  [default = 1.5, (dccl.field) = { min: 0, max: 10, precision: 1 }];
53 
54  oneof test_oneof1
55  {
56  double double_oneof1 = 118 [
57  (dccl.field).min = -100,
58  (dccl.field).max = 126,
59  (dccl.field).precision = 2
60  ];
61 
62  EmbeddedMsg1 msg_oneof1 = 119;
63  }
64 
65  oneof test_oneof2
66  {
67  int32 int32_oneof2 = 120
68  [(dccl.field).min = -20, (dccl.field).max = 3000];
69  EmbeddedMsg1 msg_oneof2 = 121;
70  }
71 
72  optional uint32 hash_opt = 200 [
73  (dccl.field).codec = "dccl.hash",
74  (dccl.field).max = 0xFFFF // 16 bits
75  ];
76  required uint32 hash_req = 201 [
77  (dccl.field).codec = "dccl.hash",
78  (dccl.field).max = 0xFFFFFFFF // 32 bits
79  ];
80 }
81 
82 message TestMsgNoHashableChanges
83 {
84  option (dccl.msg).id = 2;
85  option (dccl.msg).max_bytes = 64;
86  option (dccl.msg).codec_version = 4;
87 
88  enum E
89  {
90  VALUE1 = 1;
91  VALUE2 = 2;
92  }
93 
94  required E e = 5;
95  optional double d = 6
96  [default = 2.5, (dccl.field) = { min: 0, max: 10, precision: 1 }];
97 
98  oneof test_oneof1
99  {
100  double double_oneof1 = 118 [
101  (dccl.field).min = -100,
102  (dccl.field).max = 126,
103  (dccl.field).precision = 2
104  ];
105 
106  EmbeddedMsg1 msg_oneof1 = 119;
107  }
108 
109  oneof test_oneof2
110  {
111  int32 int32_oneof2 = 120
112  [(dccl.field).min = -20, (dccl.field).max = 3000];
113  EmbeddedMsg1 msg_oneof2 = 121;
114  }
115  optional uint32 hash_opt = 200 [
116  (dccl.field).codec = "dccl.hash",
117  (dccl.field).max = 0xFFFF // 16 bits
118  ];
119  required uint32 hash_req = 201 [
120  (dccl.field).codec = "dccl.hash",
121  (dccl.field).max = 0xFFFFFFFF // 32 bits
122  ];
123 }
124 
125 message TestMsgNewID
126 {
127  option (dccl.msg).id = 3;
128  option (dccl.msg).max_bytes = 32;
129  option (dccl.msg).codec_version = 4;
130 
131  enum E
132  {
133  VALUE1 = 1;
134  VALUE2 = 2;
135  }
136 
137  required E e = 5;
138  optional double d = 6
139  [default = 1.5, (dccl.field) = { min: 0, max: 10, precision: 1 }];
140 
141  oneof test_oneof1
142  {
143  double double_oneof1 = 118 [
144  (dccl.field).min = -100,
145  (dccl.field).max = 126,
146  (dccl.field).precision = 2
147  ];
148 
149  EmbeddedMsg1 msg_oneof1 = 119;
150  }
151 
152  oneof test_oneof2
153  {
154  int32 int32_oneof2 = 120
155  [(dccl.field).min = -20, (dccl.field).max = 3000];
156  EmbeddedMsg1 msg_oneof2 = 121;
157  }
158  optional uint32 hash_opt = 200 [
159  (dccl.field).codec = "dccl.hash",
160  (dccl.field).max = 0xFFFF // 16 bits
161  ];
162  required uint32 hash_req = 201 [
163  (dccl.field).codec = "dccl.hash",
164  (dccl.field).max = 0xFFFFFFFF // 32 bits
165  ];
166 }
167 
168 message TestMsgNewEnum
169 {
170  option (dccl.msg).id = 2;
171  option (dccl.msg).max_bytes = 32;
172  option (dccl.msg).codec_version = 4;
173 
174  enum E
175  {
176  VALUE1 = 1;
177  VALUE2 = 2;
178  VALUE3 = 3;
179  }
180 
181  required E e = 5;
182  optional double d = 6
183  [default = 1.5, (dccl.field) = { min: 0, max: 10, precision: 1 }];
184 
185  oneof test_oneof1
186  {
187  double double_oneof1 = 118 [
188  (dccl.field).min = -100,
189  (dccl.field).max = 126,
190  (dccl.field).precision = 2
191  ];
192 
193  EmbeddedMsg1 msg_oneof1 = 119;
194  }
195 
196  oneof test_oneof2
197  {
198  int32 int32_oneof2 = 120
199  [(dccl.field).min = -20, (dccl.field).max = 3000];
200  EmbeddedMsg1 msg_oneof2 = 121;
201  }
202  optional uint32 hash_opt = 200 [
203  (dccl.field).codec = "dccl.hash",
204  (dccl.field).max = 0xFFFF // 16 bits
205  ];
206  required uint32 hash_req = 201 [
207  (dccl.field).codec = "dccl.hash",
208  (dccl.field).max = 0xFFFFFFFF // 32 bits
209  ];
210 }
211 
212 message TestMsgNewBounds
213 {
214  option (dccl.msg).id = 2;
215  option (dccl.msg).max_bytes = 32;
216  option (dccl.msg).codec_version = 4;
217 
218  enum E
219  {
220  VALUE1 = 1;
221  VALUE2 = 2;
222  }
223 
224  required E e = 5;
225  optional double d = 6
226  [default = 1.5, (dccl.field) = { min: -1, max: 10, precision: 1 }];
227 
228  oneof test_oneof1
229  {
230  double double_oneof1 = 118 [
231  (dccl.field).min = -100,
232  (dccl.field).max = 126,
233  (dccl.field).precision = 2
234  ];
235 
236  EmbeddedMsg1 msg_oneof1 = 119;
237  }
238 
239  oneof test_oneof2
240  {
241  int32 int32_oneof2 = 120
242  [(dccl.field).min = -20, (dccl.field).max = 3000];
243  EmbeddedMsg1 msg_oneof2 = 121;
244  }
245 
246  optional uint32 hash_opt = 200 [
247  (dccl.field).codec = "dccl.hash",
248  (dccl.field).max = 0xFFFF // 16 bits
249  ];
250  required uint32 hash_req = 201 [
251  (dccl.field).codec = "dccl.hash",
252  (dccl.field).max = 0xFFFFFFFF // 32 bits
253  ];
254 }
255 
256 message TestMsgV2
257 {
258  option (dccl.msg).id = 2;
259  option (dccl.msg).max_bytes = 32;
260  option (dccl.msg).codec_version = 2;
261 
262  enum E
263  {
264  VALUE1 = 1;
265  VALUE2 = 2;
266  }
267 
268  required E e = 5;
269  optional double d = 6
270  [default = 1.5, (dccl.field) = { min: 0, max: 10, precision: 1 }];
271 }
272 
273 message TestMsgV3
274 {
275  option (dccl.msg).id = 2;
276  option (dccl.msg).max_bytes = 32;
277  option (dccl.msg).codec_version = 3;
278 
279  enum E
280  {
281  VALUE1 = 1;
282  VALUE2 = 2;
283  }
284 
285  required E e = 5;
286  optional double d = 6
287  [default = 1.5, (dccl.field) = { min: 0, max: 10, precision: 1 }];
288 }
289 
290 message TestMsgV4
291 {
292  option (dccl.msg).id = 2;
293  option (dccl.msg).max_bytes = 32;
294  option (dccl.msg).codec_version = 4;
295 
296  enum E
297  {
298  VALUE1 = 1;
299  VALUE2 = 2;
300  }
301 
302  required E e = 5;
303  optional double d = 6
304  [default = 1.5, (dccl.field) = { min: 0, max: 10, precision: 1 }];
305 }
306 
307 message TestMsgMultiHash
308 {
309  option (dccl.msg).id = 3;
310  option (dccl.msg).max_bytes = 32;
311  option (dccl.msg).codec_version = 4;
312 
313  // selection of odd sized hashes
314 
315  optional uint32 hash4 = 1
316  [(dccl.field).codec = "dccl.hash", (dccl.field).max = 0xF];
317 
318  optional uint32 hash6 = 2
319  [(dccl.field).codec = "dccl.hash", (dccl.field).max = 0x3F];
320 
321  optional uint32 hash8 = 3
322  [(dccl.field).codec = "dccl.hash", (dccl.field).max = 0xFF];
323 
324  optional uint32 hash13 = 4
325  [(dccl.field).codec = "dccl.hash", (dccl.field).max = 0x1FFF];
326 
327  optional uint32 hash26 = 5
328  [(dccl.field).codec = "dccl.hash", (dccl.field).max = 0X3ffffff];
329 }
330 
331 message TestMsgHashMaxTooLarge
332 {
333  option (dccl.msg).id = 3;
334  option (dccl.msg).max_bytes = 32;
335  option (dccl.msg).codec_version = 4;
336 
337  // too large
338  optional uint32 hash34 = 1
339  [(dccl.field).codec = "dccl.hash", (dccl.field).max = 17179869183];
340 }