protobuf-cucumber 3.10.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +21 -0
  3. data/.rubocop.yml +70 -0
  4. data/.rubocop_todo.yml +145 -0
  5. data/.travis.yml +40 -0
  6. data/.yardopts +5 -0
  7. data/CHANGES.md +344 -0
  8. data/CONTRIBUTING.md +16 -0
  9. data/Gemfile +3 -0
  10. data/LICENSE.txt +22 -0
  11. data/README.md +33 -0
  12. data/Rakefile +64 -0
  13. data/bin/protoc-gen-ruby +22 -0
  14. data/bin/rpc_server +5 -0
  15. data/install-protobuf.sh +28 -0
  16. data/lib/protobuf.rb +129 -0
  17. data/lib/protobuf/cli.rb +257 -0
  18. data/lib/protobuf/code_generator.rb +120 -0
  19. data/lib/protobuf/decoder.rb +28 -0
  20. data/lib/protobuf/deprecation.rb +117 -0
  21. data/lib/protobuf/descriptors.rb +3 -0
  22. data/lib/protobuf/descriptors/google/protobuf/compiler/plugin.pb.rb +62 -0
  23. data/lib/protobuf/descriptors/google/protobuf/descriptor.pb.rb +301 -0
  24. data/lib/protobuf/encoder.rb +11 -0
  25. data/lib/protobuf/enum.rb +365 -0
  26. data/lib/protobuf/exceptions.rb +9 -0
  27. data/lib/protobuf/field.rb +74 -0
  28. data/lib/protobuf/field/base_field.rb +380 -0
  29. data/lib/protobuf/field/base_field_object_definitions.rb +504 -0
  30. data/lib/protobuf/field/bool_field.rb +64 -0
  31. data/lib/protobuf/field/bytes_field.rb +78 -0
  32. data/lib/protobuf/field/double_field.rb +25 -0
  33. data/lib/protobuf/field/enum_field.rb +61 -0
  34. data/lib/protobuf/field/field_array.rb +104 -0
  35. data/lib/protobuf/field/field_hash.rb +122 -0
  36. data/lib/protobuf/field/fixed32_field.rb +25 -0
  37. data/lib/protobuf/field/fixed64_field.rb +28 -0
  38. data/lib/protobuf/field/float_field.rb +43 -0
  39. data/lib/protobuf/field/int32_field.rb +21 -0
  40. data/lib/protobuf/field/int64_field.rb +34 -0
  41. data/lib/protobuf/field/integer_field.rb +23 -0
  42. data/lib/protobuf/field/message_field.rb +51 -0
  43. data/lib/protobuf/field/sfixed32_field.rb +27 -0
  44. data/lib/protobuf/field/sfixed64_field.rb +28 -0
  45. data/lib/protobuf/field/signed_integer_field.rb +29 -0
  46. data/lib/protobuf/field/sint32_field.rb +21 -0
  47. data/lib/protobuf/field/sint64_field.rb +21 -0
  48. data/lib/protobuf/field/string_field.rb +51 -0
  49. data/lib/protobuf/field/uint32_field.rb +21 -0
  50. data/lib/protobuf/field/uint64_field.rb +21 -0
  51. data/lib/protobuf/field/varint_field.rb +77 -0
  52. data/lib/protobuf/generators/base.rb +85 -0
  53. data/lib/protobuf/generators/enum_generator.rb +39 -0
  54. data/lib/protobuf/generators/extension_generator.rb +27 -0
  55. data/lib/protobuf/generators/field_generator.rb +193 -0
  56. data/lib/protobuf/generators/file_generator.rb +262 -0
  57. data/lib/protobuf/generators/group_generator.rb +122 -0
  58. data/lib/protobuf/generators/message_generator.rb +104 -0
  59. data/lib/protobuf/generators/option_generator.rb +17 -0
  60. data/lib/protobuf/generators/printable.rb +160 -0
  61. data/lib/protobuf/generators/service_generator.rb +50 -0
  62. data/lib/protobuf/lifecycle.rb +33 -0
  63. data/lib/protobuf/logging.rb +39 -0
  64. data/lib/protobuf/message.rb +260 -0
  65. data/lib/protobuf/message/fields.rb +233 -0
  66. data/lib/protobuf/message/serialization.rb +85 -0
  67. data/lib/protobuf/optionable.rb +70 -0
  68. data/lib/protobuf/rpc/buffer.rb +78 -0
  69. data/lib/protobuf/rpc/client.rb +140 -0
  70. data/lib/protobuf/rpc/connectors/base.rb +221 -0
  71. data/lib/protobuf/rpc/connectors/ping.rb +89 -0
  72. data/lib/protobuf/rpc/connectors/socket.rb +78 -0
  73. data/lib/protobuf/rpc/connectors/zmq.rb +319 -0
  74. data/lib/protobuf/rpc/dynamic_discovery.pb.rb +50 -0
  75. data/lib/protobuf/rpc/env.rb +60 -0
  76. data/lib/protobuf/rpc/error.rb +28 -0
  77. data/lib/protobuf/rpc/error/client_error.rb +31 -0
  78. data/lib/protobuf/rpc/error/server_error.rb +43 -0
  79. data/lib/protobuf/rpc/middleware.rb +25 -0
  80. data/lib/protobuf/rpc/middleware/exception_handler.rb +40 -0
  81. data/lib/protobuf/rpc/middleware/logger.rb +95 -0
  82. data/lib/protobuf/rpc/middleware/request_decoder.rb +79 -0
  83. data/lib/protobuf/rpc/middleware/response_encoder.rb +83 -0
  84. data/lib/protobuf/rpc/middleware/runner.rb +18 -0
  85. data/lib/protobuf/rpc/rpc.pb.rb +64 -0
  86. data/lib/protobuf/rpc/rpc_method.rb +16 -0
  87. data/lib/protobuf/rpc/server.rb +39 -0
  88. data/lib/protobuf/rpc/servers/socket/server.rb +121 -0
  89. data/lib/protobuf/rpc/servers/socket/worker.rb +56 -0
  90. data/lib/protobuf/rpc/servers/socket_runner.rb +46 -0
  91. data/lib/protobuf/rpc/servers/zmq/broker.rb +194 -0
  92. data/lib/protobuf/rpc/servers/zmq/server.rb +321 -0
  93. data/lib/protobuf/rpc/servers/zmq/util.rb +48 -0
  94. data/lib/protobuf/rpc/servers/zmq/worker.rb +105 -0
  95. data/lib/protobuf/rpc/servers/zmq_runner.rb +70 -0
  96. data/lib/protobuf/rpc/service.rb +172 -0
  97. data/lib/protobuf/rpc/service_directory.rb +261 -0
  98. data/lib/protobuf/rpc/service_dispatcher.rb +45 -0
  99. data/lib/protobuf/rpc/service_filters.rb +250 -0
  100. data/lib/protobuf/rpc/stat.rb +119 -0
  101. data/lib/protobuf/socket.rb +21 -0
  102. data/lib/protobuf/tasks.rb +1 -0
  103. data/lib/protobuf/tasks/compile.rake +80 -0
  104. data/lib/protobuf/varint.rb +20 -0
  105. data/lib/protobuf/varint_pure.rb +31 -0
  106. data/lib/protobuf/version.rb +3 -0
  107. data/lib/protobuf/wire_type.rb +10 -0
  108. data/lib/protobuf/zmq.rb +21 -0
  109. data/profile.html +5103 -0
  110. data/proto/dynamic_discovery.proto +44 -0
  111. data/proto/google/protobuf/compiler/plugin.proto +147 -0
  112. data/proto/google/protobuf/descriptor.proto +779 -0
  113. data/proto/rpc.proto +69 -0
  114. data/protobuf-cucumber.gemspec +57 -0
  115. data/spec/benchmark/tasks.rb +143 -0
  116. data/spec/bin/protoc-gen-ruby_spec.rb +23 -0
  117. data/spec/encoding/all_types_spec.rb +103 -0
  118. data/spec/encoding/extreme_values_spec.rb +0 -0
  119. data/spec/functional/class_inheritance_spec.rb +52 -0
  120. data/spec/functional/code_generator_spec.rb +58 -0
  121. data/spec/functional/socket_server_spec.rb +59 -0
  122. data/spec/functional/zmq_server_spec.rb +105 -0
  123. data/spec/lib/protobuf/cli_spec.rb +317 -0
  124. data/spec/lib/protobuf/code_generator_spec.rb +87 -0
  125. data/spec/lib/protobuf/enum_spec.rb +307 -0
  126. data/spec/lib/protobuf/field/bool_field_spec.rb +91 -0
  127. data/spec/lib/protobuf/field/double_field_spec.rb +9 -0
  128. data/spec/lib/protobuf/field/enum_field_spec.rb +44 -0
  129. data/spec/lib/protobuf/field/field_array_spec.rb +105 -0
  130. data/spec/lib/protobuf/field/field_hash_spec.rb +168 -0
  131. data/spec/lib/protobuf/field/fixed32_field_spec.rb +7 -0
  132. data/spec/lib/protobuf/field/fixed64_field_spec.rb +7 -0
  133. data/spec/lib/protobuf/field/float_field_spec.rb +90 -0
  134. data/spec/lib/protobuf/field/int32_field_spec.rb +120 -0
  135. data/spec/lib/protobuf/field/int64_field_spec.rb +7 -0
  136. data/spec/lib/protobuf/field/message_field_spec.rb +132 -0
  137. data/spec/lib/protobuf/field/sfixed32_field_spec.rb +9 -0
  138. data/spec/lib/protobuf/field/sfixed64_field_spec.rb +9 -0
  139. data/spec/lib/protobuf/field/sint32_field_spec.rb +9 -0
  140. data/spec/lib/protobuf/field/sint64_field_spec.rb +9 -0
  141. data/spec/lib/protobuf/field/string_field_spec.rb +79 -0
  142. data/spec/lib/protobuf/field/uint32_field_spec.rb +7 -0
  143. data/spec/lib/protobuf/field/uint64_field_spec.rb +7 -0
  144. data/spec/lib/protobuf/field_spec.rb +192 -0
  145. data/spec/lib/protobuf/generators/base_spec.rb +154 -0
  146. data/spec/lib/protobuf/generators/enum_generator_spec.rb +82 -0
  147. data/spec/lib/protobuf/generators/extension_generator_spec.rb +42 -0
  148. data/spec/lib/protobuf/generators/field_generator_spec.rb +197 -0
  149. data/spec/lib/protobuf/generators/file_generator_spec.rb +119 -0
  150. data/spec/lib/protobuf/generators/message_generator_spec.rb +0 -0
  151. data/spec/lib/protobuf/generators/service_generator_spec.rb +99 -0
  152. data/spec/lib/protobuf/lifecycle_spec.rb +94 -0
  153. data/spec/lib/protobuf/message_spec.rb +944 -0
  154. data/spec/lib/protobuf/optionable_spec.rb +265 -0
  155. data/spec/lib/protobuf/rpc/client_spec.rb +66 -0
  156. data/spec/lib/protobuf/rpc/connectors/base_spec.rb +226 -0
  157. data/spec/lib/protobuf/rpc/connectors/ping_spec.rb +69 -0
  158. data/spec/lib/protobuf/rpc/connectors/socket_spec.rb +34 -0
  159. data/spec/lib/protobuf/rpc/connectors/zmq_spec.rb +110 -0
  160. data/spec/lib/protobuf/rpc/middleware/exception_handler_spec.rb +62 -0
  161. data/spec/lib/protobuf/rpc/middleware/logger_spec.rb +49 -0
  162. data/spec/lib/protobuf/rpc/middleware/request_decoder_spec.rb +115 -0
  163. data/spec/lib/protobuf/rpc/middleware/response_encoder_spec.rb +91 -0
  164. data/spec/lib/protobuf/rpc/servers/socket_server_spec.rb +38 -0
  165. data/spec/lib/protobuf/rpc/servers/zmq/server_spec.rb +43 -0
  166. data/spec/lib/protobuf/rpc/servers/zmq/util_spec.rb +55 -0
  167. data/spec/lib/protobuf/rpc/servers/zmq/worker_spec.rb +35 -0
  168. data/spec/lib/protobuf/rpc/service_directory_spec.rb +293 -0
  169. data/spec/lib/protobuf/rpc/service_dispatcher_spec.rb +35 -0
  170. data/spec/lib/protobuf/rpc/service_filters_spec.rb +517 -0
  171. data/spec/lib/protobuf/rpc/service_spec.rb +162 -0
  172. data/spec/lib/protobuf/rpc/stat_spec.rb +101 -0
  173. data/spec/lib/protobuf/varint_spec.rb +29 -0
  174. data/spec/lib/protobuf_spec.rb +105 -0
  175. data/spec/spec_helper.rb +42 -0
  176. data/spec/support/all.rb +6 -0
  177. data/spec/support/packed_field.rb +23 -0
  178. data/spec/support/protos/all_types.data.bin +0 -0
  179. data/spec/support/protos/all_types.data.txt +119 -0
  180. data/spec/support/protos/enum.pb.rb +63 -0
  181. data/spec/support/protos/enum.proto +37 -0
  182. data/spec/support/protos/extreme_values.data.bin +0 -0
  183. data/spec/support/protos/google_unittest.bin +0 -0
  184. data/spec/support/protos/google_unittest.pb.rb +798 -0
  185. data/spec/support/protos/google_unittest.proto +884 -0
  186. data/spec/support/protos/google_unittest_custom_options.bin +0 -0
  187. data/spec/support/protos/google_unittest_custom_options.pb.rb +361 -0
  188. data/spec/support/protos/google_unittest_custom_options.proto +424 -0
  189. data/spec/support/protos/google_unittest_import.pb.rb +55 -0
  190. data/spec/support/protos/google_unittest_import.proto +73 -0
  191. data/spec/support/protos/google_unittest_import_public.pb.rb +31 -0
  192. data/spec/support/protos/google_unittest_import_public.proto +41 -0
  193. data/spec/support/protos/map-test.bin +157 -0
  194. data/spec/support/protos/map-test.pb.rb +85 -0
  195. data/spec/support/protos/map-test.proto +68 -0
  196. data/spec/support/protos/multi_field_extensions.pb.rb +59 -0
  197. data/spec/support/protos/multi_field_extensions.proto +35 -0
  198. data/spec/support/protos/resource.pb.rb +172 -0
  199. data/spec/support/protos/resource.proto +137 -0
  200. data/spec/support/resource_service.rb +23 -0
  201. data/spec/support/server.rb +65 -0
  202. data/spec/support/test_app_file.rb +2 -0
  203. data/varint_prof.rb +82 -0
  204. metadata +579 -0
@@ -0,0 +1,361 @@
1
+ # encoding: utf-8
2
+
3
+ ##
4
+ # This file is auto-generated. DO NOT EDIT!
5
+ #
6
+ require 'protobuf'
7
+ require 'protobuf/rpc/service'
8
+
9
+
10
+ ##
11
+ # Imports
12
+ #
13
+ require 'google/protobuf/descriptor.pb'
14
+
15
+ module Protobuf_unittest
16
+ ::Protobuf::Optionable.inject(self) { ::Google::Protobuf::FileOptions }
17
+
18
+ ##
19
+ # Enum Classes
20
+ #
21
+ class MethodOpt1 < ::Protobuf::Enum
22
+ define :METHODOPT1_VAL1, 1
23
+ define :METHODOPT1_VAL2, 2
24
+ end
25
+
26
+ class AggregateEnum < ::Protobuf::Enum
27
+ set_option :".protobuf_unittest.enumopt", { :s => "EnumAnnotation" }
28
+
29
+ define :VALUE, 1
30
+ end
31
+
32
+
33
+ ##
34
+ # Message Classes
35
+ #
36
+ class TestMessageWithCustomOptions < ::Protobuf::Message
37
+ class AnEnum < ::Protobuf::Enum
38
+ set_option :".protobuf_unittest.enum_opt1", -789
39
+
40
+ define :ANENUM_VAL1, 1
41
+ define :ANENUM_VAL2, 2
42
+ end
43
+
44
+ end
45
+
46
+ class CustomOptionFooRequest < ::Protobuf::Message; end
47
+ class CustomOptionFooResponse < ::Protobuf::Message; end
48
+ class CustomOptionFooClientMessage < ::Protobuf::Message; end
49
+ class CustomOptionFooServerMessage < ::Protobuf::Message; end
50
+ class DummyMessageContainingEnum < ::Protobuf::Message
51
+ class TestEnumType < ::Protobuf::Enum
52
+ define :TEST_OPTION_ENUM_TYPE1, 22
53
+ define :TEST_OPTION_ENUM_TYPE2, -23
54
+ end
55
+
56
+ end
57
+
58
+ class DummyMessageInvalidAsOptionType < ::Protobuf::Message; end
59
+ class CustomOptionMinIntegerValues < ::Protobuf::Message; end
60
+ class CustomOptionMaxIntegerValues < ::Protobuf::Message; end
61
+ class CustomOptionOtherValues < ::Protobuf::Message; end
62
+ class SettingRealsFromPositiveInts < ::Protobuf::Message; end
63
+ class SettingRealsFromNegativeInts < ::Protobuf::Message; end
64
+ class ComplexOptionType1 < ::Protobuf::Message; end
65
+ class ComplexOptionType2 < ::Protobuf::Message
66
+ class ComplexOptionType4 < ::Protobuf::Message; end
67
+
68
+ end
69
+
70
+ class ComplexOptionType3 < ::Protobuf::Message; end
71
+ class VariousComplexOptions < ::Protobuf::Message; end
72
+ class AggregateMessageSet < ::Protobuf::Message; end
73
+ class AggregateMessageSetElement < ::Protobuf::Message; end
74
+ class Aggregate < ::Protobuf::Message; end
75
+ class AggregateMessage < ::Protobuf::Message; end
76
+ class NestedOptionType < ::Protobuf::Message
77
+ class NestedEnum < ::Protobuf::Enum
78
+ set_option :".protobuf_unittest.enum_opt1", 1003
79
+
80
+ define :NESTED_ENUM_VALUE, 1
81
+ end
82
+
83
+ class NestedMessage < ::Protobuf::Message; end
84
+
85
+ end
86
+
87
+ class OldOptionType < ::Protobuf::Message
88
+ class TestEnum < ::Protobuf::Enum
89
+ define :OLD_VALUE, 0
90
+ end
91
+
92
+ end
93
+
94
+ class NewOptionType < ::Protobuf::Message
95
+ class TestEnum < ::Protobuf::Enum
96
+ define :OLD_VALUE, 0
97
+ define :NEW_VALUE, 1
98
+ end
99
+
100
+ end
101
+
102
+ class TestMessageWithRequiredEnumOption < ::Protobuf::Message; end
103
+
104
+
105
+ ##
106
+ # File Options
107
+ #
108
+ set_option :cc_generic_services, true
109
+ set_option :java_generic_services, true
110
+ set_option :py_generic_services, true
111
+ set_option :".protobuf_unittest.file_opt1", 9876543210
112
+ set_option :".protobuf_unittest.fileopt", { :i => 100, :s => "FileAnnotation", :sub => { :s => "NestedFileAnnotation" }, :file => { :".protobuf_unittest.fileopt" => { :s => "FileExtensionAnnotation" } }, :mset => { :".protobuf_unittest.AggregateMessageSetElement.message_set_extension" => { :s => "EmbeddedMessageSetElement" } } }
113
+
114
+
115
+ ##
116
+ # Message Fields
117
+ #
118
+ class TestMessageWithCustomOptions
119
+ # Message Options
120
+ set_option :message_set_wire_format, false
121
+ set_option :".protobuf_unittest.message_opt1", -56
122
+
123
+ optional :string, :field1, 1, :ctype => ::Google::Protobuf::FieldOptions::CType::CORD, :".protobuf_unittest.field_opt1" => 8765432109
124
+ end
125
+
126
+ class CustomOptionMinIntegerValues
127
+ # Message Options
128
+ set_option :".protobuf_unittest.sfixed64_opt", -9223372036854775808
129
+ set_option :".protobuf_unittest.sfixed32_opt", -2147483648
130
+ set_option :".protobuf_unittest.fixed64_opt", 0
131
+ set_option :".protobuf_unittest.fixed32_opt", 0
132
+ set_option :".protobuf_unittest.sint64_opt", -9223372036854775808
133
+ set_option :".protobuf_unittest.sint32_opt", -2147483648
134
+ set_option :".protobuf_unittest.uint64_opt", 0
135
+ set_option :".protobuf_unittest.uint32_opt", 0
136
+ set_option :".protobuf_unittest.int64_opt", -9223372036854775808
137
+ set_option :".protobuf_unittest.int32_opt", -2147483648
138
+ set_option :".protobuf_unittest.bool_opt", false
139
+
140
+ end
141
+
142
+ class CustomOptionMaxIntegerValues
143
+ # Message Options
144
+ set_option :".protobuf_unittest.sfixed64_opt", 9223372036854775807
145
+ set_option :".protobuf_unittest.sfixed32_opt", 2147483647
146
+ set_option :".protobuf_unittest.fixed64_opt", 18446744073709551615
147
+ set_option :".protobuf_unittest.fixed32_opt", 4294967295
148
+ set_option :".protobuf_unittest.sint64_opt", 9223372036854775807
149
+ set_option :".protobuf_unittest.sint32_opt", 2147483647
150
+ set_option :".protobuf_unittest.uint64_opt", 18446744073709551615
151
+ set_option :".protobuf_unittest.uint32_opt", 4294967295
152
+ set_option :".protobuf_unittest.int64_opt", 9223372036854775807
153
+ set_option :".protobuf_unittest.int32_opt", 2147483647
154
+ set_option :".protobuf_unittest.bool_opt", true
155
+
156
+ end
157
+
158
+ class CustomOptionOtherValues
159
+ # Message Options
160
+ set_option :".protobuf_unittest.enum_opt", ::Protobuf_unittest::DummyMessageContainingEnum::TestEnumType::TEST_OPTION_ENUM_TYPE2
161
+ set_option :".protobuf_unittest.bytes_opt", "Hello\x00World"
162
+ set_option :".protobuf_unittest.string_opt", "Hello, \"World\""
163
+ set_option :".protobuf_unittest.double_opt", 1.2345678901234567
164
+ set_option :".protobuf_unittest.float_opt", 12.34567928314209
165
+ set_option :".protobuf_unittest.int32_opt", -100
166
+
167
+ end
168
+
169
+ class SettingRealsFromPositiveInts
170
+ # Message Options
171
+ set_option :".protobuf_unittest.double_opt", 154.0
172
+ set_option :".protobuf_unittest.float_opt", 12.0
173
+
174
+ end
175
+
176
+ class SettingRealsFromNegativeInts
177
+ # Message Options
178
+ set_option :".protobuf_unittest.double_opt", -154.0
179
+ set_option :".protobuf_unittest.float_opt", -12.0
180
+
181
+ end
182
+
183
+ class ComplexOptionType1
184
+ optional :int32, :foo, 1
185
+ optional :int32, :foo2, 2
186
+ optional :int32, :foo3, 3
187
+ repeated :int32, :foo4, 4
188
+ # Extension Fields
189
+ extensions 100...536870912
190
+ optional :int32, :".protobuf_unittest.quux", 7663707, :extension => true
191
+ optional ::Protobuf_unittest::ComplexOptionType3, :".protobuf_unittest.corge", 7663442, :extension => true
192
+ end
193
+
194
+ class ComplexOptionType2
195
+ class ComplexOptionType4
196
+ optional :int32, :waldo, 1
197
+ end
198
+
199
+ optional ::Protobuf_unittest::ComplexOptionType1, :bar, 1
200
+ optional :int32, :baz, 2
201
+ optional ::Protobuf_unittest::ComplexOptionType2::ComplexOptionType4, :fred, 3
202
+ repeated ::Protobuf_unittest::ComplexOptionType2::ComplexOptionType4, :barney, 4
203
+ # Extension Fields
204
+ extensions 100...536870912
205
+ optional :int32, :".protobuf_unittest.grault", 7650927, :extension => true
206
+ optional ::Protobuf_unittest::ComplexOptionType1, :".protobuf_unittest.garply", 7649992, :extension => true
207
+ end
208
+
209
+ class ComplexOptionType3
210
+ optional :int32, :qux, 1
211
+ end
212
+
213
+ class VariousComplexOptions
214
+ # Message Options
215
+ set_option :".protobuf_unittest.ComplexOptionType2.ComplexOptionType4.complex_opt4", { :waldo => 1971 }
216
+ set_option :".protobuf_unittest.complex_opt3", { :qux => 9 }
217
+ set_option :".protobuf_unittest.repeated_opt1", [1, 2]
218
+ set_option :".protobuf_unittest.repeated_opt2", [{ :qux => 3 }, { :qux => 4 }]
219
+ set_option :".protobuf_unittest.complex_opt2", { :bar => { :foo => 743, :".protobuf_unittest.corge" => { :qux => 2008 }, :".protobuf_unittest.quux" => 1999 }, :baz => 987, :fred => { :waldo => 321 }, :barney => [{ :waldo => 101 }, { :waldo => 212 }], :".protobuf_unittest.garply" => { :foo => 741, :".protobuf_unittest.corge" => { :qux => 2121 }, :".protobuf_unittest.quux" => 1998 }, :".protobuf_unittest.grault" => 654 }
220
+ set_option :".protobuf_unittest.complex_opt1", { :foo => 42, :foo4 => [99, 88], :".protobuf_unittest.corge" => { :qux => 876 }, :".protobuf_unittest.quux" => 324 }
221
+
222
+ end
223
+
224
+ class AggregateMessageSet
225
+ # Message Options
226
+ set_option :message_set_wire_format, false
227
+
228
+ # Extension Fields
229
+ extensions 4...536870912
230
+ optional ::Protobuf_unittest::AggregateMessageSetElement, :".protobuf_unittest.AggregateMessageSetElement.message_set_extension", 15447542, :extension => true
231
+ end
232
+
233
+ class AggregateMessageSetElement
234
+ optional :string, :s, 1
235
+ end
236
+
237
+ class Aggregate
238
+ optional :int32, :i, 1
239
+ optional :string, :s, 2
240
+ optional ::Protobuf_unittest::Aggregate, :sub, 3
241
+ optional ::Google::Protobuf::FileOptions, :file, 4
242
+ optional ::Protobuf_unittest::AggregateMessageSet, :mset, 5
243
+ end
244
+
245
+ class AggregateMessage
246
+ # Message Options
247
+ set_option :".protobuf_unittest.msgopt", { :i => 101, :s => "MessageAnnotation" }
248
+
249
+ optional :int32, :fieldname, 1, :".protobuf_unittest.fieldopt" => { :s => "FieldAnnotation" }
250
+ end
251
+
252
+ class NestedOptionType
253
+ class NestedMessage
254
+ # Message Options
255
+ set_option :".protobuf_unittest.message_opt1", 1001
256
+
257
+ optional :int32, :nested_field, 1, :".protobuf_unittest.field_opt1" => 1002
258
+ end
259
+
260
+ end
261
+
262
+ class OldOptionType
263
+ required ::Protobuf_unittest::OldOptionType::TestEnum, :value, 1
264
+ end
265
+
266
+ class NewOptionType
267
+ required ::Protobuf_unittest::NewOptionType::TestEnum, :value, 1
268
+ end
269
+
270
+ class TestMessageWithRequiredEnumOption
271
+ # Message Options
272
+ set_option :".protobuf_unittest.required_enum_opt", { :value => ::Protobuf_unittest::OldOptionType::TestEnum::OLD_VALUE }
273
+
274
+ end
275
+
276
+
277
+ ##
278
+ # Extended Message Fields
279
+ #
280
+ class ::Google::Protobuf::FileOptions < ::Protobuf::Message
281
+ optional :uint64, :".protobuf_unittest.file_opt1", 7736974, :extension => true
282
+ optional ::Protobuf_unittest::Aggregate, :".protobuf_unittest.fileopt", 15478479, :extension => true
283
+ optional ::Protobuf_unittest::Aggregate, :".protobuf_unittest.Aggregate.nested", 15476903, :extension => true
284
+ optional :int32, :".protobuf_unittest.NestedOptionType.nested_extension", 7912573, :extension => true, :".protobuf_unittest.field_opt2" => 1005
285
+ end
286
+
287
+ class ::Google::Protobuf::MessageOptions < ::Protobuf::Message
288
+ optional :int32, :".protobuf_unittest.message_opt1", 7739036, :extension => true
289
+ optional :bool, :".protobuf_unittest.bool_opt", 7706090, :extension => true
290
+ optional :int32, :".protobuf_unittest.int32_opt", 7705709, :extension => true
291
+ optional :int64, :".protobuf_unittest.int64_opt", 7705542, :extension => true
292
+ optional :uint32, :".protobuf_unittest.uint32_opt", 7704880, :extension => true
293
+ optional :uint64, :".protobuf_unittest.uint64_opt", 7702367, :extension => true
294
+ optional :sint32, :".protobuf_unittest.sint32_opt", 7701568, :extension => true
295
+ optional :sint64, :".protobuf_unittest.sint64_opt", 7700863, :extension => true
296
+ optional :fixed32, :".protobuf_unittest.fixed32_opt", 7700307, :extension => true
297
+ optional :fixed64, :".protobuf_unittest.fixed64_opt", 7700194, :extension => true
298
+ optional :sfixed32, :".protobuf_unittest.sfixed32_opt", 7698645, :extension => true
299
+ optional :sfixed64, :".protobuf_unittest.sfixed64_opt", 7685475, :extension => true
300
+ optional :float, :".protobuf_unittest.float_opt", 7675390, :extension => true
301
+ optional :double, :".protobuf_unittest.double_opt", 7673293, :extension => true
302
+ optional :string, :".protobuf_unittest.string_opt", 7673285, :extension => true
303
+ optional :bytes, :".protobuf_unittest.bytes_opt", 7673238, :extension => true
304
+ optional ::Protobuf_unittest::DummyMessageContainingEnum::TestEnumType, :".protobuf_unittest.enum_opt", 7673233, :extension => true
305
+ optional ::Protobuf_unittest::DummyMessageInvalidAsOptionType, :".protobuf_unittest.message_type_opt", 7665967, :extension => true
306
+ optional ::Protobuf_unittest::ComplexOptionType1, :".protobuf_unittest.complex_opt1", 7646756, :extension => true
307
+ optional ::Protobuf_unittest::ComplexOptionType2, :".protobuf_unittest.complex_opt2", 7636949, :extension => true
308
+ optional ::Protobuf_unittest::ComplexOptionType3, :".protobuf_unittest.complex_opt3", 7636463, :extension => true
309
+ repeated :int32, :".protobuf_unittest.repeated_opt1", 7636464, :extension => true
310
+ repeated ::Protobuf_unittest::ComplexOptionType3, :".protobuf_unittest.repeated_opt2", 7636465, :extension => true
311
+ optional ::Protobuf_unittest::Aggregate, :".protobuf_unittest.msgopt", 15480088, :extension => true
312
+ optional ::Protobuf_unittest::OldOptionType, :".protobuf_unittest.required_enum_opt", 106161807, :extension => true
313
+ optional ::Protobuf_unittest::ComplexOptionType2::ComplexOptionType4, :".protobuf_unittest.ComplexOptionType2.ComplexOptionType4.complex_opt4", 7633546, :extension => true
314
+ end
315
+
316
+ class ::Google::Protobuf::FieldOptions < ::Protobuf::Message
317
+ optional :fixed64, :".protobuf_unittest.field_opt1", 7740936, :extension => true
318
+ optional :int32, :".protobuf_unittest.field_opt2", 7753913, :default => 42, :extension => true
319
+ optional ::Protobuf_unittest::Aggregate, :".protobuf_unittest.fieldopt", 15481374, :extension => true
320
+ end
321
+
322
+ class ::Google::Protobuf::EnumOptions < ::Protobuf::Message
323
+ optional :sfixed32, :".protobuf_unittest.enum_opt1", 7753576, :extension => true
324
+ optional ::Protobuf_unittest::Aggregate, :".protobuf_unittest.enumopt", 15483218, :extension => true
325
+ end
326
+
327
+ class ::Google::Protobuf::EnumValueOptions < ::Protobuf::Message
328
+ optional :int32, :".protobuf_unittest.enum_value_opt1", 1560678, :extension => true
329
+ optional ::Protobuf_unittest::Aggregate, :".protobuf_unittest.enumvalopt", 15486921, :extension => true
330
+ end
331
+
332
+ class ::Google::Protobuf::ServiceOptions < ::Protobuf::Message
333
+ optional :sint64, :".protobuf_unittest.service_opt1", 7887650, :extension => true
334
+ optional ::Protobuf_unittest::Aggregate, :".protobuf_unittest.serviceopt", 15497145, :extension => true
335
+ end
336
+
337
+ class ::Google::Protobuf::MethodOptions < ::Protobuf::Message
338
+ optional ::Protobuf_unittest::MethodOpt1, :".protobuf_unittest.method_opt1", 7890860, :extension => true
339
+ optional ::Protobuf_unittest::Aggregate, :".protobuf_unittest.methodopt", 15512713, :extension => true
340
+ end
341
+
342
+
343
+ ##
344
+ # Service Classes
345
+ #
346
+ class TestServiceWithCustomOptions < ::Protobuf::Rpc::Service
347
+ set_option :".protobuf_unittest.service_opt1", -9876543210
348
+ rpc :foo, ::Protobuf_unittest::CustomOptionFooRequest, ::Protobuf_unittest::CustomOptionFooResponse do
349
+ set_option :".protobuf_unittest.method_opt1", ::Protobuf_unittest::MethodOpt1::METHODOPT1_VAL2
350
+ end
351
+ end
352
+
353
+ class AggregateService < ::Protobuf::Rpc::Service
354
+ set_option :".protobuf_unittest.serviceopt", { :s => "ServiceAnnotation" }
355
+ rpc :method, ::Protobuf_unittest::AggregateMessage, ::Protobuf_unittest::AggregateMessage do
356
+ set_option :".protobuf_unittest.methodopt", { :s => "MethodAnnotation" }
357
+ end
358
+ end
359
+
360
+ end
361
+
@@ -0,0 +1,424 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // https://developers.google.com/protocol-buffers/
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without
6
+ // modification, are permitted provided that the following conditions are
7
+ // met:
8
+ //
9
+ // * Redistributions of source code must retain the above copyright
10
+ // notice, this list of conditions and the following disclaimer.
11
+ // * Redistributions in binary form must reproduce the above
12
+ // copyright notice, this list of conditions and the following disclaimer
13
+ // in the documentation and/or other materials provided with the
14
+ // distribution.
15
+ // * Neither the name of Google Inc. nor the names of its
16
+ // contributors may be used to endorse or promote products derived from
17
+ // this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ // Author: benjy@google.com (Benjy Weinberger)
32
+ // Based on original Protocol Buffers design by
33
+ // Sanjay Ghemawat, Jeff Dean, and others.
34
+ //
35
+ // A proto file used to test the "custom options" feature of google.protobuf.
36
+
37
+ syntax = "proto2";
38
+
39
+ // Some generic_services option(s) added automatically.
40
+ // See: http://go/proto2-generic-services-default
41
+ option cc_generic_services = true; // auto-added
42
+ option java_generic_services = true; // auto-added
43
+ option py_generic_services = true;
44
+
45
+ // A custom file option (defined below).
46
+ option (file_opt1) = 9876543210;
47
+
48
+ import "google/protobuf/descriptor.proto";
49
+
50
+ // We don't put this in a package within proto2 because we need to make sure
51
+ // that the generated code doesn't depend on being in the proto2 namespace.
52
+ package protobuf_unittest;
53
+
54
+
55
+ // Some simple test custom options of various types.
56
+
57
+ extend google.protobuf.FileOptions {
58
+ optional uint64 file_opt1 = 7736974;
59
+ }
60
+
61
+ extend google.protobuf.MessageOptions {
62
+ optional int32 message_opt1 = 7739036;
63
+ }
64
+
65
+ extend google.protobuf.FieldOptions {
66
+ optional fixed64 field_opt1 = 7740936;
67
+ // This is useful for testing that we correctly register default values for
68
+ // extension options.
69
+ optional int32 field_opt2 = 7753913 [default=42];
70
+ }
71
+
72
+ extend google.protobuf.EnumOptions {
73
+ optional sfixed32 enum_opt1 = 7753576;
74
+ }
75
+
76
+ extend google.protobuf.EnumValueOptions {
77
+ optional int32 enum_value_opt1 = 1560678;
78
+ }
79
+
80
+ extend google.protobuf.ServiceOptions {
81
+ optional sint64 service_opt1 = 7887650;
82
+ }
83
+
84
+ enum MethodOpt1 {
85
+ METHODOPT1_VAL1 = 1;
86
+ METHODOPT1_VAL2 = 2;
87
+ }
88
+
89
+ extend google.protobuf.MethodOptions {
90
+ optional MethodOpt1 method_opt1 = 7890860;
91
+ }
92
+
93
+ // A test message with custom options at all possible locations (and also some
94
+ // regular options, to make sure they interact nicely).
95
+ message TestMessageWithCustomOptions {
96
+ option message_set_wire_format = false;
97
+
98
+ option (message_opt1) = -56;
99
+
100
+ optional string field1 = 1 [ctype=CORD,
101
+ (field_opt1)=8765432109];
102
+
103
+ enum AnEnum {
104
+ option (enum_opt1) = -789;
105
+
106
+ ANENUM_VAL1 = 1;
107
+ ANENUM_VAL2 = 2 [(enum_value_opt1) = 123];
108
+ }
109
+ }
110
+
111
+
112
+ // A test RPC service with custom options at all possible locations (and also
113
+ // some regular options, to make sure they interact nicely).
114
+ message CustomOptionFooRequest {
115
+ }
116
+
117
+ message CustomOptionFooResponse {
118
+ }
119
+
120
+ message CustomOptionFooClientMessage {
121
+ }
122
+
123
+ message CustomOptionFooServerMessage {
124
+ }
125
+
126
+ service TestServiceWithCustomOptions {
127
+ option (service_opt1) = -9876543210;
128
+
129
+ rpc Foo(CustomOptionFooRequest) returns (CustomOptionFooResponse) {
130
+ option (method_opt1) = METHODOPT1_VAL2;
131
+ }
132
+ }
133
+
134
+
135
+
136
+ // Options of every possible field type, so we can test them all exhaustively.
137
+
138
+ message DummyMessageContainingEnum {
139
+ enum TestEnumType {
140
+ TEST_OPTION_ENUM_TYPE1 = 22;
141
+ TEST_OPTION_ENUM_TYPE2 = -23;
142
+ }
143
+ }
144
+
145
+ message DummyMessageInvalidAsOptionType {
146
+ }
147
+
148
+ extend google.protobuf.MessageOptions {
149
+ optional bool bool_opt = 7706090;
150
+ optional int32 int32_opt = 7705709;
151
+ optional int64 int64_opt = 7705542;
152
+ optional uint32 uint32_opt = 7704880;
153
+ optional uint64 uint64_opt = 7702367;
154
+ optional sint32 sint32_opt = 7701568;
155
+ optional sint64 sint64_opt = 7700863;
156
+ optional fixed32 fixed32_opt = 7700307;
157
+ optional fixed64 fixed64_opt = 7700194;
158
+ optional sfixed32 sfixed32_opt = 7698645;
159
+ optional sfixed64 sfixed64_opt = 7685475;
160
+ optional float float_opt = 7675390;
161
+ optional double double_opt = 7673293;
162
+ optional string string_opt = 7673285;
163
+ optional bytes bytes_opt = 7673238;
164
+ optional DummyMessageContainingEnum.TestEnumType enum_opt = 7673233;
165
+ optional DummyMessageInvalidAsOptionType message_type_opt = 7665967;
166
+ }
167
+
168
+ message CustomOptionMinIntegerValues {
169
+ option (bool_opt) = false;
170
+ option (int32_opt) = -0x80000000;
171
+ option (int64_opt) = -0x8000000000000000;
172
+ option (uint32_opt) = 0;
173
+ option (uint64_opt) = 0;
174
+ option (sint32_opt) = -0x80000000;
175
+ option (sint64_opt) = -0x8000000000000000;
176
+ option (fixed32_opt) = 0;
177
+ option (fixed64_opt) = 0;
178
+ option (sfixed32_opt) = -0x80000000;
179
+ option (sfixed64_opt) = -0x8000000000000000;
180
+ }
181
+
182
+ message CustomOptionMaxIntegerValues {
183
+ option (bool_opt) = true;
184
+ option (int32_opt) = 0x7FFFFFFF;
185
+ option (int64_opt) = 0x7FFFFFFFFFFFFFFF;
186
+ option (uint32_opt) = 0xFFFFFFFF;
187
+ option (uint64_opt) = 0xFFFFFFFFFFFFFFFF;
188
+ option (sint32_opt) = 0x7FFFFFFF;
189
+ option (sint64_opt) = 0x7FFFFFFFFFFFFFFF;
190
+ option (fixed32_opt) = 0xFFFFFFFF;
191
+ option (fixed64_opt) = 0xFFFFFFFFFFFFFFFF;
192
+ option (sfixed32_opt) = 0x7FFFFFFF;
193
+ option (sfixed64_opt) = 0x7FFFFFFFFFFFFFFF;
194
+ }
195
+
196
+ message CustomOptionOtherValues {
197
+ option (int32_opt) = -100; // To test sign-extension.
198
+ option (float_opt) = 12.3456789;
199
+ option (double_opt) = 1.234567890123456789;
200
+ option (string_opt) = "Hello, \"World\"";
201
+ option (bytes_opt) = "Hello\0World";
202
+ option (enum_opt) = TEST_OPTION_ENUM_TYPE2;
203
+ }
204
+
205
+ message SettingRealsFromPositiveInts {
206
+ option (float_opt) = 12;
207
+ option (double_opt) = 154;
208
+ }
209
+
210
+ message SettingRealsFromNegativeInts {
211
+ option (float_opt) = -12;
212
+ option (double_opt) = -154;
213
+ }
214
+
215
+ // Options of complex message types, themselves combined and extended in
216
+ // various ways.
217
+
218
+ // TODO: do we want to support packed ints?
219
+ // e.g.: repeated int32 foo4 = 4 [packed = true];
220
+ message ComplexOptionType1 {
221
+ optional int32 foo = 1;
222
+ optional int32 foo2 = 2;
223
+ optional int32 foo3 = 3;
224
+ repeated int32 foo4 = 4;
225
+
226
+ extensions 100 to max;
227
+ }
228
+
229
+ message ComplexOptionType2 {
230
+ optional ComplexOptionType1 bar = 1;
231
+ optional int32 baz = 2;
232
+
233
+ message ComplexOptionType4 {
234
+ optional int32 waldo = 1;
235
+
236
+ extend google.protobuf.MessageOptions {
237
+ optional ComplexOptionType4 complex_opt4 = 7633546;
238
+ }
239
+ }
240
+
241
+ optional ComplexOptionType4 fred = 3;
242
+ repeated ComplexOptionType4 barney = 4;
243
+
244
+ extensions 100 to max;
245
+ }
246
+
247
+ message ComplexOptionType3 {
248
+ optional int32 qux = 1;
249
+ }
250
+
251
+ extend ComplexOptionType1 {
252
+ optional int32 quux = 7663707;
253
+ optional ComplexOptionType3 corge = 7663442;
254
+ }
255
+
256
+ extend ComplexOptionType2 {
257
+ optional int32 grault = 7650927;
258
+ optional ComplexOptionType1 garply = 7649992;
259
+ }
260
+
261
+ extend google.protobuf.MessageOptions {
262
+ optional protobuf_unittest.ComplexOptionType1 complex_opt1 = 7646756;
263
+ optional ComplexOptionType2 complex_opt2 = 7636949;
264
+ optional ComplexOptionType3 complex_opt3 = 7636463;
265
+ repeated int32 repeated_opt1 = 7636464;
266
+ repeated protobuf_unittest.ComplexOptionType3 repeated_opt2 = 7636465;
267
+ }
268
+
269
+ // Note that we try various different ways of naming the same extension.
270
+ message VariousComplexOptions {
271
+ option (.protobuf_unittest.complex_opt1).foo = 42;
272
+ option (protobuf_unittest.complex_opt1).(.protobuf_unittest.quux) = 324;
273
+ option (.protobuf_unittest.complex_opt1).(protobuf_unittest.corge).qux = 876;
274
+ option (protobuf_unittest.complex_opt1).foo4 = 99;
275
+ option (protobuf_unittest.complex_opt1).foo4 = 88;
276
+ option (complex_opt2).baz = 987;
277
+ option (complex_opt2).(grault) = 654;
278
+ option (complex_opt2).bar.foo = 743;
279
+ option (complex_opt2).bar.(quux) = 1999;
280
+ option (complex_opt2).bar.(protobuf_unittest.corge).qux = 2008;
281
+ option (complex_opt2).(garply).foo = 741;
282
+ option (complex_opt2).(garply).(.protobuf_unittest.quux) = 1998;
283
+ option (complex_opt2).(protobuf_unittest.garply).(corge).qux = 2121;
284
+ option (ComplexOptionType2.ComplexOptionType4.complex_opt4).waldo = 1971;
285
+ option (complex_opt2).fred.waldo = 321;
286
+ option (complex_opt2).barney = { waldo: 101 };
287
+ option (complex_opt2).barney = { waldo: 212 };
288
+ option (protobuf_unittest.complex_opt3).qux = 9;
289
+ option (repeated_opt1) = 1;
290
+ option (repeated_opt1) = 2;
291
+ option (repeated_opt2) = { qux: 3 };
292
+ option (repeated_opt2) = { qux: 4 };
293
+ /*option (complex_opt3).complexoptiontype5.plugh = 22;*/
294
+ /*option (complexopt6).xyzzy = 24;*/
295
+ }
296
+
297
+ // ------------------------------------------------------
298
+ // Definitions for testing aggregate option parsing.
299
+ // See descriptor_unittest.cc.
300
+
301
+ message AggregateMessageSet {
302
+ option message_set_wire_format = false;
303
+ extensions 4 to max;
304
+ }
305
+
306
+ message AggregateMessageSetElement {
307
+ extend AggregateMessageSet {
308
+ optional AggregateMessageSetElement message_set_extension = 15447542;
309
+ }
310
+ optional string s = 1;
311
+ }
312
+
313
+ // A helper type used to test aggregate option parsing
314
+ message Aggregate {
315
+ optional int32 i = 1;
316
+ optional string s = 2;
317
+
318
+ // A nested object
319
+ optional Aggregate sub = 3;
320
+
321
+ // To test the parsing of extensions inside aggregate values
322
+ optional google.protobuf.FileOptions file = 4;
323
+ extend google.protobuf.FileOptions {
324
+ optional Aggregate nested = 15476903;
325
+ }
326
+
327
+ // An embedded message set
328
+ optional AggregateMessageSet mset = 5;
329
+ }
330
+
331
+ // Allow Aggregate to be used as an option at all possible locations
332
+ // in the .proto grammer.
333
+ extend google.protobuf.FileOptions { optional Aggregate fileopt = 15478479; }
334
+ extend google.protobuf.MessageOptions { optional Aggregate msgopt = 15480088; }
335
+ extend google.protobuf.FieldOptions { optional Aggregate fieldopt = 15481374; }
336
+ extend google.protobuf.EnumOptions { optional Aggregate enumopt = 15483218; }
337
+ extend google.protobuf.EnumValueOptions { optional Aggregate enumvalopt = 15486921; }
338
+ extend google.protobuf.ServiceOptions { optional Aggregate serviceopt = 15497145; }
339
+ extend google.protobuf.MethodOptions { optional Aggregate methodopt = 15512713; }
340
+
341
+ // Try using AggregateOption at different points in the proto grammar
342
+ option (fileopt) = {
343
+ s: 'FileAnnotation'
344
+ // Also test the handling of comments
345
+ /* of both types */ i: 100
346
+
347
+ sub { s: 'NestedFileAnnotation' }
348
+
349
+ // Include a google.protobuf.FileOptions and recursively extend it with
350
+ // another fileopt.
351
+ file {
352
+ [protobuf_unittest.fileopt] {
353
+ s:'FileExtensionAnnotation'
354
+ }
355
+ }
356
+
357
+ // A message set inside an option value
358
+ mset {
359
+ [protobuf_unittest.AggregateMessageSetElement.message_set_extension] {
360
+ s: 'EmbeddedMessageSetElement'
361
+ }
362
+ }
363
+ };
364
+
365
+ message AggregateMessage {
366
+ option (msgopt) = { i:101 s:'MessageAnnotation' };
367
+ optional int32 fieldname = 1 [(fieldopt) = { s:'FieldAnnotation' }];
368
+ }
369
+
370
+ service AggregateService {
371
+ option (serviceopt) = { s:'ServiceAnnotation' };
372
+ rpc Method (AggregateMessage) returns (AggregateMessage) {
373
+ option (methodopt) = { s:'MethodAnnotation' };
374
+ }
375
+ }
376
+
377
+ enum AggregateEnum {
378
+ option (enumopt) = { s:'EnumAnnotation' };
379
+ // TODO: support enum value options
380
+ VALUE = 1 [(enumvalopt) = { s:'EnumValueAnnotation' }];
381
+ }
382
+
383
+ // Test custom options for nested type.
384
+ message NestedOptionType {
385
+ message NestedMessage {
386
+ option (message_opt1) = 1001;
387
+ optional int32 nested_field = 1 [(field_opt1) = 1002];
388
+ }
389
+ enum NestedEnum {
390
+ option (enum_opt1) = 1003;
391
+ // TODO: support enum value options
392
+ NESTED_ENUM_VALUE = 1 [(enum_value_opt1) = 1004];
393
+ }
394
+ extend google.protobuf.FileOptions {
395
+ optional int32 nested_extension = 7912573 [(field_opt2) = 1005];
396
+ }
397
+ }
398
+
399
+ // Custom message option that has a required enum field.
400
+ // WARNING: this is strongly discouraged!
401
+ message OldOptionType {
402
+ enum TestEnum {
403
+ OLD_VALUE = 0;
404
+ }
405
+ required TestEnum value = 1;
406
+ }
407
+
408
+ // Updated version of the custom option above.
409
+ message NewOptionType {
410
+ enum TestEnum {
411
+ OLD_VALUE = 0;
412
+ NEW_VALUE = 1;
413
+ }
414
+ required TestEnum value = 1;
415
+ }
416
+
417
+ extend google.protobuf.MessageOptions {
418
+ optional OldOptionType required_enum_opt = 106161807;
419
+ }
420
+
421
+ // Test message using the "required_enum_opt" option defined above.
422
+ message TestMessageWithRequiredEnumOption {
423
+ option (required_enum_opt) = { value: OLD_VALUE };
424
+ }