3import "dccl/option_extensions.proto";
9 option(dccl.msg) = { id : 2, max_bytes : 512, codec_version : 4 };
13 STATE_1 = 1; STATE_2 = 2; STATE_3 = 3;
16 required State state = 1;
18 optional int32 a = 2 [(dccl.field) = {
19 min : 0 max : 200 dynamic_conditions{
21 required_if : "return this.state == 'STATE_1'"
22 omit_if : "return this.state ~= 'STATE_1'"
26 optional int32 b = 3 [(dccl.field) = {
27 min : 0 max : 300 dynamic_conditions{
28 // if no return in script, assume it is implicit - DCCL will prefix
30 required_if : "this.state == 'STATE_2'" omit_if : "this.state ~= 'STATE_2'"
34 optional int32 c_center = 4 [default = 199, (dccl.field) = {
35 min : 0 max : 300 dynamic_conditions{
36 // same as required_if: "this.state == 'STATE_3'" and omit_if ~=
38 only_if : "this.state == 'STATE_1'"
44 optional int32 c = 6 [(dccl.field) = {
45 min : 0 max : 400 dynamic_conditions{
46 only_if : "this.state == 'STATE_1'" min : "this.c_center-100" max : "this.c_center+100"
50 repeated int32 d = 7 [(dccl.field) = {
51 min : 0 max : 300 max_repeat : 6 dynamic_conditions{
53 only_if : "this_index ~= 4" min : "this_index*50" max : "this_index*50+100"
57 repeated Child child = 10 [(dccl.field) = {max_repeat : 10}];
63 UNUSED = 0; YES = 1; NO = 2;
66 required IncludeI include_i = 1;
67 optional int32 i = 2 [(dccl.field) = {
69 // within the embedded message, 'this' refers to the embedded
70 // message (innermost scope) ...
71 dynamic_conditions{only_if : "this.include_i == 'YES'"}
74 optional int32 i2 = 3 [(dccl.field) = {
76 // ... but the entire message is still accessible with 'root', and
77 // 'this_index' refers to the current repeated message index
79 only_if : "print(this_index); return root.child[this_index].include_i == 'YES'"
88 UNUSED = 0; YES = 1; NO = 2;
91 required IncludeI include_i = 1;
92 optional int32 i = 2 [(dccl.field) = {
93 min : 0 max : 255 dynamic_conditions{only_if : "this.include_i == 'YES'"}
98 required Child2 child2 = 11;
104 UNUSED = 0; YES = 1; NO = 2;
107 required IncludeI include_i = 1;
108 optional int32 i = 2 [(dccl.field) = {
110 // check that root works correctly here
111 dynamic_conditions{only_if : "root.child3.include_i == 'YES'"}
115 // since this message uses local scoping only, we can include it again
116 optional Child2 subchild = 3;
118 optional Child3 child3 = 12;
124 {min : 0 max : 255 dynamic_conditions{only_if : "this.state == 'STATE_1'"}}];
127 {min : 0 max : 255 dynamic_conditions{only_if : "this.state == 'STATE_2'"}}];