nanopb 0.4.9.dev1485__tar.gz → 0.4.9.dev1494__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/PKG-INFO +1 -1
  2. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/nanopb_generator.py +38 -10
  3. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/proto/__pycache__/__init__.cpython-38.pyc +0 -0
  4. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/proto/__pycache__/_utils.cpython-38.pyc +0 -0
  5. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/proto/google/protobuf/descriptor.proto +539 -118
  6. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/proto/nanopb.proto +21 -5
  7. nanopb-0.4.9.dev1494/nanopb/generator/proto/nanopb_pb2.py +46 -0
  8. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/pyproject.toml +1 -1
  9. nanopb-0.4.9.dev1485/nanopb/generator/proto/nanopb_pb2.py +0 -46
  10. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/README.md +0 -0
  11. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/__init__.py +0 -0
  12. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/__init__.py +0 -0
  13. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/nanopb_generator +0 -0
  14. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/nanopb_generator.bat +0 -0
  15. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/nanopb_generator.py2 +0 -0
  16. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/platformio_generator.py +0 -0
  17. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/proto/Makefile +0 -0
  18. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/proto/__init__.py +0 -0
  19. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/proto/_utils.py +0 -0
  20. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/protoc +0 -0
  21. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/protoc-gen-nanopb +0 -0
  22. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/protoc-gen-nanopb-py2 +0 -0
  23. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/protoc-gen-nanopb.bat +0 -0
  24. {nanopb-0.4.9.dev1485 → nanopb-0.4.9.dev1494}/nanopb/generator/protoc.bat +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: nanopb
3
- Version: 0.4.9.dev1485
3
+ Version: 0.4.9.dev1494
4
4
  Summary: Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system.
5
5
  Home-page: https://jpa.kapsi.fi/nanopb/
6
6
  License: Zlib
@@ -437,14 +437,11 @@ class Enum(ProtoElement):
437
437
  result += 'typedef enum %s' % Globals.naming_style.enum_name(self.names)
438
438
 
439
439
  # Override the enum size if user wants to use smaller integers
440
- if (FieldD.TYPE_ENUM, self.options.int_size) in datatypes:
441
- self.ctype, self.pbtype, self.enc_size, self.data_item_size = datatypes[(FieldD.TYPE_ENUM, self.options.int_size)]
442
- result += '\n#ifdef __cplusplus\n'
443
- result += ' : ' + self.ctype + '\n'
444
- result += '#endif\n'
445
- result += '{'
446
- else:
447
- result += ' {'
440
+ if (FieldD.TYPE_ENUM, self.options.enum_intsize) in datatypes:
441
+ self.ctype, self.pbtype, self.enc_size, self.data_item_size = datatypes[(FieldD.TYPE_ENUM, self.options.enum_intsize)]
442
+ result += ': ' + self.ctype
443
+
444
+ result += ' {'
448
445
 
449
446
  if trailing_comment:
450
447
  result += " " + trailing_comment
@@ -1345,9 +1342,13 @@ class Message(ProtoElement):
1345
1342
 
1346
1343
  for index, f in enumerate(desc.field):
1347
1344
  field_options = get_nanopb_suboptions(f, message_options, self.name + f.name)
1345
+
1348
1346
  if field_options.type == nanopb_pb2.FT_IGNORE:
1349
1347
  continue
1350
1348
 
1349
+ if field_options.discard_deprecated and f.options.deprecated:
1350
+ continue
1351
+
1351
1352
  if field_options.descriptorsize > self.descriptorsize:
1352
1353
  self.descriptorsize = field_options.descriptorsize
1353
1354
 
@@ -1886,6 +1887,7 @@ class ProtoFile:
1886
1887
  self.dependencies = {}
1887
1888
  self.math_include_required = False
1888
1889
  self.parse()
1890
+ self.discard_unused_automatic_types()
1889
1891
  for message in self.messages:
1890
1892
  if message.math_include_required:
1891
1893
  self.math_include_required = True
@@ -1922,6 +1924,9 @@ class ProtoFile:
1922
1924
  if message_options.skip_message:
1923
1925
  continue
1924
1926
 
1927
+ if message_options.discard_deprecated and message.options.deprecated:
1928
+ continue
1929
+
1925
1930
  # Apply any configured typename mangling options
1926
1931
  message = copy.deepcopy(message)
1927
1932
  for field in message.field:
@@ -1931,8 +1936,9 @@ class ProtoFile:
1931
1936
  # Check for circular dependencies
1932
1937
  msgobject = Message(name, message, message_options, comment_path, self.comment_locations)
1933
1938
  if check_recursive_dependencies(msgobject, self.messages):
1934
- sys.stderr.write('Breaking circular dependency at message %s by converting to callback\n' % msgobject.name)
1935
- message_options.type = nanopb_pb2.FT_CALLBACK
1939
+ message_options.type = message_options.fallback_type
1940
+ sys.stderr.write('Breaking circular dependency at message %s by converting to %s\n'
1941
+ % (msgobject.name, nanopb_pb2.FieldType.Name(message_options.type)))
1936
1942
  msgobject = Message(name, message, message_options, comment_path, self.comment_locations)
1937
1943
  self.messages.append(msgobject)
1938
1944
 
@@ -1954,6 +1960,28 @@ class ProtoFile:
1954
1960
  if field_options.type != nanopb_pb2.FT_IGNORE:
1955
1961
  self.extensions.append(ExtensionField(name, extension, field_options))
1956
1962
 
1963
+ def discard_unused_automatic_types(self):
1964
+ '''Discard unused types that are automatically generated by protoc if they are not actually
1965
+ needed. Currently this applies to map< > types when the field is ignored by options.
1966
+ '''
1967
+
1968
+ if not self.file_options.discard_unused_automatic_types:
1969
+ return
1970
+
1971
+ map_entries = {}
1972
+ types_used = set()
1973
+ for msg in self.messages:
1974
+ if msg.desc.options.map_entry:
1975
+ map_entries[str(msg.name)] = msg
1976
+
1977
+ for field in msg.all_fields():
1978
+ if field.pbtype == 'MESSAGE':
1979
+ types_used.add(str(field.submsgname))
1980
+
1981
+ for name, msg in map_entries.items():
1982
+ if name not in types_used:
1983
+ self.messages.remove(msg)
1984
+
1957
1985
  def add_dependency(self, other):
1958
1986
  for enum in other.enums:
1959
1987
  self.dependencies[str(enum.names)] = enum
@@ -36,11 +36,11 @@
36
36
  // A valid .proto file can be translated directly to a FileDescriptorProto
37
37
  // without any other information (e.g. without reading its imports).
38
38
 
39
-
40
39
  syntax = "proto2";
41
40
 
42
41
  package google.protobuf;
43
- option go_package = "github.com/golang/protobuf/protoc-gen-go/descriptor;descriptor";
42
+
43
+ option go_package = "google.golang.org/protobuf/types/descriptorpb";
44
44
  option java_package = "com.google.protobuf";
45
45
  option java_outer_classname = "DescriptorProtos";
46
46
  option csharp_namespace = "Google.Protobuf.Reflection";
@@ -57,10 +57,46 @@ message FileDescriptorSet {
57
57
  repeated FileDescriptorProto file = 1;
58
58
  }
59
59
 
60
+ // The full set of known editions.
61
+ enum Edition {
62
+ // A placeholder for an unknown edition value.
63
+ EDITION_UNKNOWN = 0;
64
+
65
+ // A placeholder edition for specifying default behaviors *before* a feature
66
+ // was first introduced. This is effectively an "infinite past".
67
+ EDITION_LEGACY = 900;
68
+
69
+ // Legacy syntax "editions". These pre-date editions, but behave much like
70
+ // distinct editions. These can't be used to specify the edition of proto
71
+ // files, but feature definitions must supply proto2/proto3 defaults for
72
+ // backwards compatibility.
73
+ EDITION_PROTO2 = 998;
74
+ EDITION_PROTO3 = 999;
75
+
76
+ // Editions that have been released. The specific values are arbitrary and
77
+ // should not be depended on, but they will always be time-ordered for easy
78
+ // comparison.
79
+ EDITION_2023 = 1000;
80
+ EDITION_2024 = 1001;
81
+
82
+ // Placeholder editions for testing feature resolution. These should not be
83
+ // used or relyed on outside of tests.
84
+ EDITION_1_TEST_ONLY = 1;
85
+ EDITION_2_TEST_ONLY = 2;
86
+ EDITION_99997_TEST_ONLY = 99997;
87
+ EDITION_99998_TEST_ONLY = 99998;
88
+ EDITION_99999_TEST_ONLY = 99999;
89
+
90
+ // Placeholder for specifying unbounded edition support. This should only
91
+ // ever be used by plugins that can expect to never require any changes to
92
+ // support a new edition.
93
+ EDITION_MAX = 0x7FFFFFFF;
94
+ }
95
+
60
96
  // Describes a complete .proto file.
61
97
  message FileDescriptorProto {
62
- optional string name = 1; // file name, relative to root of source tree
63
- optional string package = 2; // e.g. "foo", "foo.bar", etc.
98
+ optional string name = 1; // file name, relative to root of source tree
99
+ optional string package = 2; // e.g. "foo", "foo.bar", etc.
64
100
 
65
101
  // Names of files imported by this file.
66
102
  repeated string dependency = 3;
@@ -85,8 +121,13 @@ message FileDescriptorProto {
85
121
  optional SourceCodeInfo source_code_info = 9;
86
122
 
87
123
  // The syntax of the proto file.
88
- // The supported values are "proto2" and "proto3".
124
+ // The supported values are "proto2", "proto3", and "editions".
125
+ //
126
+ // If `edition` is present, this value must be "editions".
89
127
  optional string syntax = 12;
128
+
129
+ // The edition of the proto file.
130
+ optional Edition edition = 14;
90
131
  }
91
132
 
92
133
  // Describes a message type.
@@ -100,8 +141,8 @@ message DescriptorProto {
100
141
  repeated EnumDescriptorProto enum_type = 4;
101
142
 
102
143
  message ExtensionRange {
103
- optional int32 start = 1;
104
- optional int32 end = 2;
144
+ optional int32 start = 1; // Inclusive.
145
+ optional int32 end = 2; // Exclusive.
105
146
 
106
147
  optional ExtensionRangeOptions options = 3;
107
148
  }
@@ -115,8 +156,8 @@ message DescriptorProto {
115
156
  // fields or extension ranges in the same message. Reserved ranges may
116
157
  // not overlap.
117
158
  message ReservedRange {
118
- optional int32 start = 1; // Inclusive.
119
- optional int32 end = 2; // Exclusive.
159
+ optional int32 start = 1; // Inclusive.
160
+ optional int32 end = 2; // Exclusive.
120
161
  }
121
162
  repeated ReservedRange reserved_range = 9;
122
163
  // Reserved field names, which may not be used by fields in the same message.
@@ -128,6 +169,52 @@ message ExtensionRangeOptions {
128
169
  // The parser stores options it doesn't recognize here. See above.
129
170
  repeated UninterpretedOption uninterpreted_option = 999;
130
171
 
172
+ message Declaration {
173
+ // The extension number declared within the extension range.
174
+ optional int32 number = 1;
175
+
176
+ // The fully-qualified name of the extension field. There must be a leading
177
+ // dot in front of the full name.
178
+ optional string full_name = 2;
179
+
180
+ // The fully-qualified type name of the extension field. Unlike
181
+ // Metadata.type, Declaration.type must have a leading dot for messages
182
+ // and enums.
183
+ optional string type = 3;
184
+
185
+ // If true, indicates that the number is reserved in the extension range,
186
+ // and any extension field with the number will fail to compile. Set this
187
+ // when a declared extension field is deleted.
188
+ optional bool reserved = 5;
189
+
190
+ // If true, indicates that the extension must be defined as repeated.
191
+ // Otherwise the extension must be defined as optional.
192
+ optional bool repeated = 6;
193
+
194
+ reserved 4; // removed is_repeated
195
+ }
196
+
197
+ // For external users: DO NOT USE. We are in the process of open sourcing
198
+ // extension declaration and executing internal cleanups before it can be
199
+ // used externally.
200
+ repeated Declaration declaration = 2 [retention = RETENTION_SOURCE];
201
+
202
+ // Any features defined in the specific edition.
203
+ optional FeatureSet features = 50;
204
+
205
+ // The verification state of the extension range.
206
+ enum VerificationState {
207
+ // All the extensions of the range must be declared.
208
+ DECLARATION = 0;
209
+ UNVERIFIED = 1;
210
+ }
211
+
212
+ // The verification state of the range.
213
+ // TODO: flip the default to DECLARATION once all empty ranges
214
+ // are marked as UNVERIFIED.
215
+ optional VerificationState verification = 3
216
+ [default = UNVERIFIED, retention = RETENTION_SOURCE];
217
+
131
218
  // Clients can define custom options in extensions of this message. See above.
132
219
  extensions 1000 to max;
133
220
  }
@@ -137,42 +224,46 @@ message FieldDescriptorProto {
137
224
  enum Type {
138
225
  // 0 is reserved for errors.
139
226
  // Order is weird for historical reasons.
140
- TYPE_DOUBLE = 1;
141
- TYPE_FLOAT = 2;
227
+ TYPE_DOUBLE = 1;
228
+ TYPE_FLOAT = 2;
142
229
  // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if
143
230
  // negative values are likely.
144
- TYPE_INT64 = 3;
145
- TYPE_UINT64 = 4;
231
+ TYPE_INT64 = 3;
232
+ TYPE_UINT64 = 4;
146
233
  // Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if
147
234
  // negative values are likely.
148
- TYPE_INT32 = 5;
149
- TYPE_FIXED64 = 6;
150
- TYPE_FIXED32 = 7;
151
- TYPE_BOOL = 8;
152
- TYPE_STRING = 9;
235
+ TYPE_INT32 = 5;
236
+ TYPE_FIXED64 = 6;
237
+ TYPE_FIXED32 = 7;
238
+ TYPE_BOOL = 8;
239
+ TYPE_STRING = 9;
153
240
  // Tag-delimited aggregate.
154
- // Group type is deprecated and not supported in proto3. However, Proto3
241
+ // Group type is deprecated and not supported after google.protobuf. However, Proto3
155
242
  // implementations should still be able to parse the group wire format and
156
- // treat group fields as unknown fields.
157
- TYPE_GROUP = 10;
158
- TYPE_MESSAGE = 11; // Length-delimited aggregate.
243
+ // treat group fields as unknown fields. In Editions, the group wire format
244
+ // can be enabled via the `message_encoding` feature.
245
+ TYPE_GROUP = 10;
246
+ TYPE_MESSAGE = 11; // Length-delimited aggregate.
159
247
 
160
248
  // New in version 2.
161
- TYPE_BYTES = 12;
162
- TYPE_UINT32 = 13;
163
- TYPE_ENUM = 14;
164
- TYPE_SFIXED32 = 15;
165
- TYPE_SFIXED64 = 16;
166
- TYPE_SINT32 = 17; // Uses ZigZag encoding.
167
- TYPE_SINT64 = 18; // Uses ZigZag encoding.
168
- };
249
+ TYPE_BYTES = 12;
250
+ TYPE_UINT32 = 13;
251
+ TYPE_ENUM = 14;
252
+ TYPE_SFIXED32 = 15;
253
+ TYPE_SFIXED64 = 16;
254
+ TYPE_SINT32 = 17; // Uses ZigZag encoding.
255
+ TYPE_SINT64 = 18; // Uses ZigZag encoding.
256
+ }
169
257
 
170
258
  enum Label {
171
259
  // 0 is reserved for errors
172
- LABEL_OPTIONAL = 1;
173
- LABEL_REQUIRED = 2;
174
- LABEL_REPEATED = 3;
175
- };
260
+ LABEL_OPTIONAL = 1;
261
+ LABEL_REPEATED = 3;
262
+ // The required label is only allowed in google.protobuf. In proto3 and Editions
263
+ // it's explicitly prohibited. In Editions, the `field_presence` feature
264
+ // can be used to get this behavior.
265
+ LABEL_REQUIRED = 2;
266
+ }
176
267
 
177
268
  optional string name = 1;
178
269
  optional int32 number = 3;
@@ -197,7 +288,6 @@ message FieldDescriptorProto {
197
288
  // For booleans, "true" or "false".
198
289
  // For strings, contains the default text contents (not escaped in any way).
199
290
  // For bytes, contains the C escaped value. All bytes >= 128 are escaped.
200
- // TODO(kenton): Base-64 encode?
201
291
  optional string default_value = 7;
202
292
 
203
293
  // If set, gives the index of a oneof in the containing type's oneof_decl
@@ -211,6 +301,29 @@ message FieldDescriptorProto {
211
301
  optional string json_name = 10;
212
302
 
213
303
  optional FieldOptions options = 8;
304
+
305
+ // If true, this is a proto3 "optional". When a proto3 field is optional, it
306
+ // tracks presence regardless of field type.
307
+ //
308
+ // When proto3_optional is true, this field must belong to a oneof to signal
309
+ // to old proto3 clients that presence is tracked for this field. This oneof
310
+ // is known as a "synthetic" oneof, and this field must be its sole member
311
+ // (each proto3 optional field gets its own synthetic oneof). Synthetic oneofs
312
+ // exist in the descriptor only, and do not generate any API. Synthetic oneofs
313
+ // must be ordered after all "real" oneofs.
314
+ //
315
+ // For message fields, proto3_optional doesn't create any semantic change,
316
+ // since non-repeated message fields always track presence. However it still
317
+ // indicates the semantic detail of whether the user wrote "optional" or not.
318
+ // This can be useful for round-tripping the .proto file. For consistency we
319
+ // give message fields a synthetic oneof also, even though it is not required
320
+ // to track presence. This is especially important because the parser can't
321
+ // tell if a field is a message or an enum, so it must always create a
322
+ // synthetic oneof.
323
+ //
324
+ // Proto2 optional fields do not set this flag, because they already indicate
325
+ // optional with `LABEL_OPTIONAL`.
326
+ optional bool proto3_optional = 17;
214
327
  }
215
328
 
216
329
  // Describes a oneof.
@@ -234,8 +347,8 @@ message EnumDescriptorProto {
234
347
  // is inclusive such that it can appropriately represent the entire int32
235
348
  // domain.
236
349
  message EnumReservedRange {
237
- optional int32 start = 1; // Inclusive.
238
- optional int32 end = 2; // Inclusive.
350
+ optional int32 start = 1; // Inclusive.
351
+ optional int32 end = 2; // Inclusive.
239
352
  }
240
353
 
241
354
  // Range of reserved numeric values. Reserved numeric values may not be used
@@ -276,12 +389,11 @@ message MethodDescriptorProto {
276
389
  optional MethodOptions options = 4;
277
390
 
278
391
  // Identifies if client streams multiple client messages
279
- optional bool client_streaming = 5 [default=false];
392
+ optional bool client_streaming = 5 [default = false];
280
393
  // Identifies if server streams multiple server messages
281
- optional bool server_streaming = 6 [default=false];
394
+ optional bool server_streaming = 6 [default = false];
282
395
  }
283
396
 
284
-
285
397
  // ===================================================================
286
398
  // Options
287
399
 
@@ -314,7 +426,6 @@ message MethodDescriptorProto {
314
426
  // If this turns out to be popular, a web service will be set up
315
427
  // to automatically assign option numbers.
316
428
 
317
-
318
429
  message FileOptions {
319
430
 
320
431
  // Sets the Java package where classes generated from this .proto will be
@@ -323,42 +434,44 @@ message FileOptions {
323
434
  // domain names.
324
435
  optional string java_package = 1;
325
436
 
326
-
327
- // If set, all the classes from the .proto file are wrapped in a single
328
- // outer class with the given name. This applies to both Proto1
329
- // (equivalent to the old "--one_java_file" option) and Proto2 (where
330
- // a .proto always translates to a single class, but you may want to
331
- // explicitly choose the class name).
437
+ // Controls the name of the wrapper Java class generated for the .proto file.
438
+ // That class will always contain the .proto file's getDescriptor() method as
439
+ // well as any top-level extensions defined in the .proto file.
440
+ // If java_multiple_files is disabled, then all the other classes from the
441
+ // .proto file will be nested inside the single wrapper outer class.
332
442
  optional string java_outer_classname = 8;
333
443
 
334
- // If set true, then the Java code generator will generate a separate .java
444
+ // If enabled, then the Java code generator will generate a separate .java
335
445
  // file for each top-level message, enum, and service defined in the .proto
336
- // file. Thus, these types will *not* be nested inside the outer class
337
- // named by java_outer_classname. However, the outer class will still be
446
+ // file. Thus, these types will *not* be nested inside the wrapper class
447
+ // named by java_outer_classname. However, the wrapper class will still be
338
448
  // generated to contain the file's getDescriptor() method as well as any
339
449
  // top-level extensions defined in the file.
340
- optional bool java_multiple_files = 10 [default=false];
450
+ optional bool java_multiple_files = 10 [default = false];
341
451
 
342
452
  // This option does nothing.
343
453
  optional bool java_generate_equals_and_hash = 20 [deprecated=true];
344
454
 
345
- // If set true, then the Java2 code generator will generate code that
346
- // throws an exception whenever an attempt is made to assign a non-UTF-8
347
- // byte sequence to a string field.
348
- // Message reflection will do the same.
349
- // However, an extension field still accepts non-UTF-8 byte sequences.
350
- // This option has no effect on when used with the lite runtime.
351
- optional bool java_string_check_utf8 = 27 [default=false];
352
-
455
+ // A proto2 file can set this to true to opt in to UTF-8 checking for Java,
456
+ // which will throw an exception if invalid UTF-8 is parsed from the wire or
457
+ // assigned to a string field.
458
+ //
459
+ // TODO: clarify exactly what kinds of field types this option
460
+ // applies to, and update these docs accordingly.
461
+ //
462
+ // Proto3 files already perform these checks. Setting the option explicitly to
463
+ // false has no effect: it cannot be used to opt proto3 files out of UTF-8
464
+ // checks.
465
+ optional bool java_string_check_utf8 = 27 [default = false];
353
466
 
354
467
  // Generated classes can be optimized for speed or code size.
355
468
  enum OptimizeMode {
356
- SPEED = 1; // Generate complete code for parsing, serialization,
357
- // etc.
358
- CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
359
- LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
469
+ SPEED = 1; // Generate complete code for parsing, serialization,
470
+ // etc.
471
+ CODE_SIZE = 2; // Use ReflectionOps to implement these methods.
472
+ LITE_RUNTIME = 3; // Generate code using MessageLite and the lite runtime.
360
473
  }
361
- optional OptimizeMode optimize_for = 9 [default=SPEED];
474
+ optional OptimizeMode optimize_for = 9 [default = SPEED];
362
475
 
363
476
  // Sets the Go package where structs generated from this .proto will be
364
477
  // placed. If omitted, the Go package will be derived from the following:
@@ -367,8 +480,6 @@ message FileOptions {
367
480
  // - Otherwise, the basename of the .proto file, without extension.
368
481
  optional string go_package = 11;
369
482
 
370
-
371
-
372
483
  // Should generic services be generated in each language? "Generic" services
373
484
  // are not specific to any particular RPC system. They are generated by the
374
485
  // main code generators in each language (without additional plugins).
@@ -379,21 +490,21 @@ message FileOptions {
379
490
  // that generate code specific to your particular RPC system. Therefore,
380
491
  // these default to false. Old code which depends on generic services should
381
492
  // explicitly set them to true.
382
- optional bool cc_generic_services = 16 [default=false];
383
- optional bool java_generic_services = 17 [default=false];
384
- optional bool py_generic_services = 18 [default=false];
385
- optional bool php_generic_services = 42 [default=false];
493
+ optional bool cc_generic_services = 16 [default = false];
494
+ optional bool java_generic_services = 17 [default = false];
495
+ optional bool py_generic_services = 18 [default = false];
496
+ reserved 42; // removed php_generic_services
497
+ reserved "php_generic_services";
386
498
 
387
499
  // Is this file deprecated?
388
500
  // Depending on the target platform, this can emit Deprecated annotations
389
501
  // for everything in the file, or it will be completely ignored; in the very
390
502
  // least, this is a formalization for deprecating files.
391
- optional bool deprecated = 23 [default=false];
503
+ optional bool deprecated = 23 [default = false];
392
504
 
393
505
  // Enables the use of arenas for the proto messages in this file. This applies
394
506
  // only to generated classes for C++.
395
- optional bool cc_enable_arenas = 31 [default=false];
396
-
507
+ optional bool cc_enable_arenas = 31 [default = true];
397
508
 
398
509
  // Sets the objective c class prefix which is prepended to all objective c
399
510
  // generated classes from this .proto. There is no default.
@@ -417,6 +528,19 @@ message FileOptions {
417
528
  // determining the namespace.
418
529
  optional string php_namespace = 41;
419
530
 
531
+ // Use this option to change the namespace of php generated metadata classes.
532
+ // Default is empty. When this option is empty, the proto file name will be
533
+ // used for determining the namespace.
534
+ optional string php_metadata_namespace = 44;
535
+
536
+ // Use this option to change the package of ruby generated classes. Default
537
+ // is empty. When this option is not set, the package name will be used for
538
+ // determining the ruby package.
539
+ optional string ruby_package = 45;
540
+
541
+ // Any features defined in the specific edition.
542
+ optional FeatureSet features = 50;
543
+
420
544
  // The parser stores options it doesn't recognize here.
421
545
  // See the documentation for the "Options" section above.
422
546
  repeated UninterpretedOption uninterpreted_option = 999;
@@ -447,18 +571,20 @@ message MessageOptions {
447
571
  //
448
572
  // Because this is an option, the above two restrictions are not enforced by
449
573
  // the protocol compiler.
450
- optional bool message_set_wire_format = 1 [default=false];
574
+ optional bool message_set_wire_format = 1 [default = false];
451
575
 
452
576
  // Disables the generation of the standard "descriptor()" accessor, which can
453
577
  // conflict with a field of the same name. This is meant to make migration
454
578
  // from proto1 easier; new code should avoid fields named "descriptor".
455
- optional bool no_standard_descriptor_accessor = 2 [default=false];
579
+ optional bool no_standard_descriptor_accessor = 2 [default = false];
456
580
 
457
581
  // Is this message deprecated?
458
582
  // Depending on the target platform, this can emit Deprecated annotations
459
583
  // for the message, or it will be completely ignored; in the very least,
460
584
  // this is a formalization for deprecating messages.
461
- optional bool deprecated = 3 [default=false];
585
+ optional bool deprecated = 3 [default = false];
586
+
587
+ reserved 4, 5, 6;
462
588
 
463
589
  // Whether the message is an automatically generated map entry type for the
464
590
  // maps field.
@@ -475,7 +601,7 @@ message MessageOptions {
475
601
  //
476
602
  // Implementations may choose not to generate the map_entry=true message, but
477
603
  // use a native map in the target language to hold the keys and values.
478
- // The reflection APIs in such implementions still need to work as
604
+ // The reflection APIs in such implementations still need to work as
479
605
  // if the field is a repeated message field.
480
606
  //
481
607
  // NOTE: Do not set the option in .proto files. Always use the maps syntax
@@ -486,6 +612,21 @@ message MessageOptions {
486
612
  reserved 8; // javalite_serializable
487
613
  reserved 9; // javanano_as_lite
488
614
 
615
+ // Enable the legacy handling of JSON field name conflicts. This lowercases
616
+ // and strips underscored from the fields before comparison in proto3 only.
617
+ // The new behavior takes `json_name` into account and applies to proto2 as
618
+ // well.
619
+ //
620
+ // This should only be used as a temporary measure against broken builds due
621
+ // to the change in behavior for JSON field name conflicts.
622
+ //
623
+ // TODO This is legacy behavior we plan to remove once downstream
624
+ // teams have had time to migrate.
625
+ optional bool deprecated_legacy_json_field_conflicts = 11 [deprecated = true];
626
+
627
+ // Any features defined in the specific edition.
628
+ optional FeatureSet features = 12;
629
+
489
630
  // The parser stores options it doesn't recognize here. See above.
490
631
  repeated UninterpretedOption uninterpreted_option = 999;
491
632
 
@@ -494,15 +635,24 @@ message MessageOptions {
494
635
  }
495
636
 
496
637
  message FieldOptions {
638
+ // NOTE: ctype is deprecated. Use `features.(pb.cpp).string_type` instead.
497
639
  // The ctype option instructs the C++ code generator to use a different
498
640
  // representation of the field than it normally would. See the specific
499
- // options below. This option is not yet implemented in the open source
500
- // release -- sorry, we'll try to include it in a future version!
501
- optional CType ctype = 1 [default = STRING];
641
+ // options below. This option is only implemented to support use of
642
+ // [ctype=CORD] and [ctype=STRING] (the default) on non-repeated fields of
643
+ // type "bytes" in the open source release.
644
+ // TODO: make ctype actually deprecated.
645
+ optional CType ctype = 1 [/*deprecated = true,*/ default = STRING];
502
646
  enum CType {
503
647
  // Default mode.
504
648
  STRING = 0;
505
649
 
650
+ // The option [ctype=CORD] may be applied to a non-repeated field of type
651
+ // "bytes". It indicates that in C++, the data should be stored in a Cord
652
+ // instead of a string. For very large strings, this may reduce memory
653
+ // fragmentation. It may also allow better performance when parsing from a
654
+ // Cord, or when parsing with aliasing enabled, as the parsed Cord may then
655
+ // alias the original buffer.
506
656
  CORD = 1;
507
657
 
508
658
  STRING_PIECE = 2;
@@ -511,7 +661,9 @@ message FieldOptions {
511
661
  // a more efficient representation on the wire. Rather than repeatedly
512
662
  // writing the tag and type for each element, the entire array is encoded as
513
663
  // a single length-delimited blob. In proto3, only explicit setting it to
514
- // false will avoid using packed encoding.
664
+ // false will avoid using packed encoding. This option is prohibited in
665
+ // Editions, but the `repeated_field_encoding` feature can be used to control
666
+ // the behavior.
515
667
  optional bool packed = 2;
516
668
 
517
669
  // The jstype option determines the JavaScript type used for values of the
@@ -554,28 +706,88 @@ message FieldOptions {
554
706
  // call from multiple threads concurrently, while non-const methods continue
555
707
  // to require exclusive access.
556
708
  //
557
- //
558
- // Note that implementations may choose not to check required fields within
559
- // a lazy sub-message. That is, calling IsInitialized() on the outer message
560
- // may return true even if the inner message has missing required fields.
561
- // This is necessary because otherwise the inner message would have to be
562
- // parsed in order to perform the check, defeating the purpose of lazy
563
- // parsing. An implementation which chooses not to check required fields
564
- // must be consistent about it. That is, for any particular sub-message, the
565
- // implementation must either *always* check its required fields, or *never*
566
- // check its required fields, regardless of whether or not the message has
567
- // been parsed.
568
- optional bool lazy = 5 [default=false];
709
+ // Note that lazy message fields are still eagerly verified to check
710
+ // ill-formed wireformat or missing required fields. Calling IsInitialized()
711
+ // on the outer message would fail if the inner message has missing required
712
+ // fields. Failed verification would result in parsing failure (except when
713
+ // uninitialized messages are acceptable).
714
+ optional bool lazy = 5 [default = false];
715
+
716
+ // unverified_lazy does no correctness checks on the byte stream. This should
717
+ // only be used where lazy with verification is prohibitive for performance
718
+ // reasons.
719
+ optional bool unverified_lazy = 15 [default = false];
569
720
 
570
721
  // Is this field deprecated?
571
722
  // Depending on the target platform, this can emit Deprecated annotations
572
723
  // for accessors, or it will be completely ignored; in the very least, this
573
724
  // is a formalization for deprecating fields.
574
- optional bool deprecated = 3 [default=false];
725
+ optional bool deprecated = 3 [default = false];
575
726
 
576
727
  // For Google-internal migration only. Do not use.
577
- optional bool weak = 10 [default=false];
728
+ optional bool weak = 10 [default = false];
729
+
730
+ // Indicate that the field value should not be printed out when using debug
731
+ // formats, e.g. when the field contains sensitive credentials.
732
+ optional bool debug_redact = 16 [default = false];
733
+
734
+ // If set to RETENTION_SOURCE, the option will be omitted from the binary.
735
+ enum OptionRetention {
736
+ RETENTION_UNKNOWN = 0;
737
+ RETENTION_RUNTIME = 1;
738
+ RETENTION_SOURCE = 2;
739
+ }
740
+
741
+ optional OptionRetention retention = 17;
742
+
743
+ // This indicates the types of entities that the field may apply to when used
744
+ // as an option. If it is unset, then the field may be freely used as an
745
+ // option on any kind of entity.
746
+ enum OptionTargetType {
747
+ TARGET_TYPE_UNKNOWN = 0;
748
+ TARGET_TYPE_FILE = 1;
749
+ TARGET_TYPE_EXTENSION_RANGE = 2;
750
+ TARGET_TYPE_MESSAGE = 3;
751
+ TARGET_TYPE_FIELD = 4;
752
+ TARGET_TYPE_ONEOF = 5;
753
+ TARGET_TYPE_ENUM = 6;
754
+ TARGET_TYPE_ENUM_ENTRY = 7;
755
+ TARGET_TYPE_SERVICE = 8;
756
+ TARGET_TYPE_METHOD = 9;
757
+ }
578
758
 
759
+ repeated OptionTargetType targets = 19;
760
+
761
+ message EditionDefault {
762
+ optional Edition edition = 3;
763
+ optional string value = 2; // Textproto value.
764
+ }
765
+ repeated EditionDefault edition_defaults = 20;
766
+
767
+ // Any features defined in the specific edition.
768
+ optional FeatureSet features = 21;
769
+
770
+ // Information about the support window of a feature.
771
+ message FeatureSupport {
772
+ // The edition that this feature was first available in. In editions
773
+ // earlier than this one, the default assigned to EDITION_LEGACY will be
774
+ // used, and proto files will not be able to override it.
775
+ optional Edition edition_introduced = 1;
776
+
777
+ // The edition this feature becomes deprecated in. Using this after this
778
+ // edition may trigger warnings.
779
+ optional Edition edition_deprecated = 2;
780
+
781
+ // The deprecation warning text if this feature is used after the edition it
782
+ // was marked deprecated in.
783
+ optional string deprecation_warning = 3;
784
+
785
+ // The edition this feature is no longer available in. In editions after
786
+ // this one, the last default assigned will be used, and proto files will
787
+ // not be able to override it.
788
+ optional Edition edition_removed = 4;
789
+ }
790
+ optional FeatureSupport feature_support = 22;
579
791
 
580
792
  // The parser stores options it doesn't recognize here. See above.
581
793
  repeated UninterpretedOption uninterpreted_option = 999;
@@ -583,10 +795,14 @@ message FieldOptions {
583
795
  // Clients can define custom options in extensions of this message. See above.
584
796
  extensions 1000 to max;
585
797
 
586
- reserved 4; // removed jtype
798
+ reserved 4; // removed jtype
799
+ reserved 18; // reserve target, target_obsolete_do_not_use
587
800
  }
588
801
 
589
802
  message OneofOptions {
803
+ // Any features defined in the specific edition.
804
+ optional FeatureSet features = 1;
805
+
590
806
  // The parser stores options it doesn't recognize here. See above.
591
807
  repeated UninterpretedOption uninterpreted_option = 999;
592
808
 
@@ -604,10 +820,21 @@ message EnumOptions {
604
820
  // Depending on the target platform, this can emit Deprecated annotations
605
821
  // for the enum, or it will be completely ignored; in the very least, this
606
822
  // is a formalization for deprecating enums.
607
- optional bool deprecated = 3 [default=false];
823
+ optional bool deprecated = 3 [default = false];
608
824
 
609
825
  reserved 5; // javanano_as_lite
610
826
 
827
+ // Enable the legacy handling of JSON field name conflicts. This lowercases
828
+ // and strips underscored from the fields before comparison in proto3 only.
829
+ // The new behavior takes `json_name` into account and applies to proto2 as
830
+ // well.
831
+ // TODO Remove this legacy behavior once downstream teams have
832
+ // had time to migrate.
833
+ optional bool deprecated_legacy_json_field_conflicts = 6 [deprecated = true];
834
+
835
+ // Any features defined in the specific edition.
836
+ optional FeatureSet features = 7;
837
+
611
838
  // The parser stores options it doesn't recognize here. See above.
612
839
  repeated UninterpretedOption uninterpreted_option = 999;
613
840
 
@@ -620,7 +847,18 @@ message EnumValueOptions {
620
847
  // Depending on the target platform, this can emit Deprecated annotations
621
848
  // for the enum value, or it will be completely ignored; in the very least,
622
849
  // this is a formalization for deprecating enum values.
623
- optional bool deprecated = 1 [default=false];
850
+ optional bool deprecated = 1 [default = false];
851
+
852
+ // Any features defined in the specific edition.
853
+ optional FeatureSet features = 2;
854
+
855
+ // Indicate that fields annotated with this enum value should not be printed
856
+ // out when using debug formats, e.g. when the field contains sensitive
857
+ // credentials.
858
+ optional bool debug_redact = 3 [default = false];
859
+
860
+ // Information about the support window of a feature value.
861
+ optional FieldOptions.FeatureSupport feature_support = 4;
624
862
 
625
863
  // The parser stores options it doesn't recognize here. See above.
626
864
  repeated UninterpretedOption uninterpreted_option = 999;
@@ -631,6 +869,9 @@ message EnumValueOptions {
631
869
 
632
870
  message ServiceOptions {
633
871
 
872
+ // Any features defined in the specific edition.
873
+ optional FeatureSet features = 34;
874
+
634
875
  // Note: Field numbers 1 through 32 are reserved for Google's internal RPC
635
876
  // framework. We apologize for hoarding these numbers to ourselves, but
636
877
  // we were already using them long before we decided to release Protocol
@@ -640,7 +881,7 @@ message ServiceOptions {
640
881
  // Depending on the target platform, this can emit Deprecated annotations
641
882
  // for the service, or it will be completely ignored; in the very least,
642
883
  // this is a formalization for deprecating services.
643
- optional bool deprecated = 33 [default=false];
884
+ optional bool deprecated = 33 [default = false];
644
885
 
645
886
  // The parser stores options it doesn't recognize here. See above.
646
887
  repeated UninterpretedOption uninterpreted_option = 999;
@@ -660,18 +901,21 @@ message MethodOptions {
660
901
  // Depending on the target platform, this can emit Deprecated annotations
661
902
  // for the method, or it will be completely ignored; in the very least,
662
903
  // this is a formalization for deprecating methods.
663
- optional bool deprecated = 33 [default=false];
904
+ optional bool deprecated = 33 [default = false];
664
905
 
665
906
  // Is this method side-effect-free (or safe in HTTP parlance), or idempotent,
666
907
  // or neither? HTTP based RPC implementation may choose GET verb for safe
667
908
  // methods, and PUT verb for idempotent methods instead of the default POST.
668
909
  enum IdempotencyLevel {
669
910
  IDEMPOTENCY_UNKNOWN = 0;
670
- NO_SIDE_EFFECTS = 1; // implies idempotent
671
- IDEMPOTENT = 2; // idempotent, but may have side effects
911
+ NO_SIDE_EFFECTS = 1; // implies idempotent
912
+ IDEMPOTENT = 2; // idempotent, but may have side effects
672
913
  }
673
- optional IdempotencyLevel idempotency_level =
674
- 34 [default=IDEMPOTENCY_UNKNOWN];
914
+ optional IdempotencyLevel idempotency_level = 34
915
+ [default = IDEMPOTENCY_UNKNOWN];
916
+
917
+ // Any features defined in the specific edition.
918
+ optional FeatureSet features = 35;
675
919
 
676
920
  // The parser stores options it doesn't recognize here. See above.
677
921
  repeated UninterpretedOption uninterpreted_option = 999;
@@ -680,7 +924,6 @@ message MethodOptions {
680
924
  extensions 1000 to max;
681
925
  }
682
926
 
683
-
684
927
  // A message representing a option the parser does not recognize. This only
685
928
  // appears in options protos created by the compiler::Parser class.
686
929
  // DescriptorPool resolves these when building Descriptor objects. Therefore,
@@ -691,8 +934,8 @@ message UninterpretedOption {
691
934
  // The name of the uninterpreted option. Each string represents a segment in
692
935
  // a dot-separated name. is_extension is true iff a segment represents an
693
936
  // extension (denoted with parentheses in options specs in .proto files).
694
- // E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents
695
- // "foo.(bar.baz).qux".
937
+ // E.g.,{ ["foo", false], ["bar.baz", true], ["moo", false] } represents
938
+ // "foo.(bar.baz).moo".
696
939
  message NamePart {
697
940
  required string name_part = 1;
698
941
  required bool is_extension = 2;
@@ -709,6 +952,172 @@ message UninterpretedOption {
709
952
  optional string aggregate_value = 8;
710
953
  }
711
954
 
955
+ // ===================================================================
956
+ // Features
957
+
958
+ // TODO Enums in C++ gencode (and potentially other languages) are
959
+ // not well scoped. This means that each of the feature enums below can clash
960
+ // with each other. The short names we've chosen maximize call-site
961
+ // readability, but leave us very open to this scenario. A future feature will
962
+ // be designed and implemented to handle this, hopefully before we ever hit a
963
+ // conflict here.
964
+ message FeatureSet {
965
+ enum FieldPresence {
966
+ FIELD_PRESENCE_UNKNOWN = 0;
967
+ EXPLICIT = 1;
968
+ IMPLICIT = 2;
969
+ LEGACY_REQUIRED = 3;
970
+ }
971
+ optional FieldPresence field_presence = 1 [
972
+ retention = RETENTION_RUNTIME,
973
+ targets = TARGET_TYPE_FIELD,
974
+ targets = TARGET_TYPE_FILE,
975
+ feature_support = {
976
+ edition_introduced: EDITION_2023,
977
+ },
978
+ edition_defaults = { edition: EDITION_LEGACY, value: "EXPLICIT" },
979
+ edition_defaults = { edition: EDITION_PROTO3, value: "IMPLICIT" },
980
+ edition_defaults = { edition: EDITION_2023, value: "EXPLICIT" }
981
+ ];
982
+
983
+ enum EnumType {
984
+ ENUM_TYPE_UNKNOWN = 0;
985
+ OPEN = 1;
986
+ CLOSED = 2;
987
+ }
988
+ optional EnumType enum_type = 2 [
989
+ retention = RETENTION_RUNTIME,
990
+ targets = TARGET_TYPE_ENUM,
991
+ targets = TARGET_TYPE_FILE,
992
+ feature_support = {
993
+ edition_introduced: EDITION_2023,
994
+ },
995
+ edition_defaults = { edition: EDITION_LEGACY, value: "CLOSED" },
996
+ edition_defaults = { edition: EDITION_PROTO3, value: "OPEN" }
997
+ ];
998
+
999
+ enum RepeatedFieldEncoding {
1000
+ REPEATED_FIELD_ENCODING_UNKNOWN = 0;
1001
+ PACKED = 1;
1002
+ EXPANDED = 2;
1003
+ }
1004
+ optional RepeatedFieldEncoding repeated_field_encoding = 3 [
1005
+ retention = RETENTION_RUNTIME,
1006
+ targets = TARGET_TYPE_FIELD,
1007
+ targets = TARGET_TYPE_FILE,
1008
+ feature_support = {
1009
+ edition_introduced: EDITION_2023,
1010
+ },
1011
+ edition_defaults = { edition: EDITION_LEGACY, value: "EXPANDED" },
1012
+ edition_defaults = { edition: EDITION_PROTO3, value: "PACKED" }
1013
+ ];
1014
+
1015
+ enum Utf8Validation {
1016
+ UTF8_VALIDATION_UNKNOWN = 0;
1017
+ VERIFY = 2;
1018
+ NONE = 3;
1019
+ reserved 1;
1020
+ }
1021
+ optional Utf8Validation utf8_validation = 4 [
1022
+ retention = RETENTION_RUNTIME,
1023
+ targets = TARGET_TYPE_FIELD,
1024
+ targets = TARGET_TYPE_FILE,
1025
+ feature_support = {
1026
+ edition_introduced: EDITION_2023,
1027
+ },
1028
+ edition_defaults = { edition: EDITION_LEGACY, value: "NONE" },
1029
+ edition_defaults = { edition: EDITION_PROTO3, value: "VERIFY" }
1030
+ ];
1031
+
1032
+ enum MessageEncoding {
1033
+ MESSAGE_ENCODING_UNKNOWN = 0;
1034
+ LENGTH_PREFIXED = 1;
1035
+ DELIMITED = 2;
1036
+ }
1037
+ optional MessageEncoding message_encoding = 5 [
1038
+ retention = RETENTION_RUNTIME,
1039
+ targets = TARGET_TYPE_FIELD,
1040
+ targets = TARGET_TYPE_FILE,
1041
+ feature_support = {
1042
+ edition_introduced: EDITION_2023,
1043
+ },
1044
+ edition_defaults = { edition: EDITION_LEGACY, value: "LENGTH_PREFIXED" }
1045
+ ];
1046
+
1047
+ enum JsonFormat {
1048
+ JSON_FORMAT_UNKNOWN = 0;
1049
+ ALLOW = 1;
1050
+ LEGACY_BEST_EFFORT = 2;
1051
+ }
1052
+ optional JsonFormat json_format = 6 [
1053
+ retention = RETENTION_RUNTIME,
1054
+ targets = TARGET_TYPE_MESSAGE,
1055
+ targets = TARGET_TYPE_ENUM,
1056
+ targets = TARGET_TYPE_FILE,
1057
+ feature_support = {
1058
+ edition_introduced: EDITION_2023,
1059
+ },
1060
+ edition_defaults = { edition: EDITION_LEGACY, value: "LEGACY_BEST_EFFORT" },
1061
+ edition_defaults = { edition: EDITION_PROTO3, value: "ALLOW" }
1062
+ ];
1063
+
1064
+ reserved 999;
1065
+
1066
+ extensions 1000 to 9994 [
1067
+ declaration = {
1068
+ number: 1000,
1069
+ full_name: ".pb.cpp",
1070
+ type: ".pb.CppFeatures"
1071
+ },
1072
+ declaration = {
1073
+ number: 1001,
1074
+ full_name: ".pb.java",
1075
+ type: ".pb.JavaFeatures"
1076
+ },
1077
+ declaration = { number: 1002, full_name: ".pb.go", type: ".pb.GoFeatures" },
1078
+ declaration = {
1079
+ number: 9990,
1080
+ full_name: ".pb.proto1",
1081
+ type: ".pb.Proto1Features"
1082
+ }
1083
+ ];
1084
+
1085
+ extensions 9995 to 9999; // For internal testing
1086
+ extensions 10000; // for https://github.com/bufbuild/protobuf-es
1087
+ }
1088
+
1089
+ // A compiled specification for the defaults of a set of features. These
1090
+ // messages are generated from FeatureSet extensions and can be used to seed
1091
+ // feature resolution. The resolution with this object becomes a simple search
1092
+ // for the closest matching edition, followed by proto merges.
1093
+ message FeatureSetDefaults {
1094
+ // A map from every known edition with a unique set of defaults to its
1095
+ // defaults. Not all editions may be contained here. For a given edition,
1096
+ // the defaults at the closest matching edition ordered at or before it should
1097
+ // be used. This field must be in strict ascending order by edition.
1098
+ message FeatureSetEditionDefault {
1099
+ optional Edition edition = 3;
1100
+
1101
+ // Defaults of features that can be overridden in this edition.
1102
+ optional FeatureSet overridable_features = 4;
1103
+
1104
+ // Defaults of features that can't be overridden in this edition.
1105
+ optional FeatureSet fixed_features = 5;
1106
+
1107
+ reserved 1, 2;
1108
+ reserved "features";
1109
+ }
1110
+ repeated FeatureSetEditionDefault defaults = 1;
1111
+
1112
+ // The minimum supported edition (inclusive) when this was constructed.
1113
+ // Editions before this will not have defaults.
1114
+ optional Edition minimum_edition = 4;
1115
+
1116
+ // The maximum known edition (inclusive) when this was constructed. Editions
1117
+ // after this will not have reliable defaults.
1118
+ optional Edition maximum_edition = 5;
1119
+ }
1120
+
712
1121
  // ===================================================================
713
1122
  // Optional source code info
714
1123
 
@@ -752,7 +1161,7 @@ message SourceCodeInfo {
752
1161
  // beginning of the "extend" block and is shared by all extensions within
753
1162
  // the block.
754
1163
  // - Just because a location's span is a subset of some other location's span
755
- // does not mean that it is a descendent. For example, a "group" defines
1164
+ // does not mean that it is a descendant. For example, a "group" defines
756
1165
  // both a type and a field in a single declaration. Thus, the locations
757
1166
  // corresponding to the type and field and their components will overlap.
758
1167
  // - Code which tries to interpret locations should probably be designed to
@@ -764,8 +1173,8 @@ message SourceCodeInfo {
764
1173
  // location.
765
1174
  //
766
1175
  // Each element is a field number or an index. They form a path from
767
- // the root FileDescriptorProto to the place where the definition. For
768
- // example, this path:
1176
+ // the root FileDescriptorProto to the place where the definition appears.
1177
+ // For example, this path:
769
1178
  // [ 4, 3, 2, 7, 1 ]
770
1179
  // refers to:
771
1180
  // file.message_type(3) // 4, 3
@@ -783,14 +1192,14 @@ message SourceCodeInfo {
783
1192
  // [ 4, 3, 2, 7 ]
784
1193
  // this path refers to the whole field declaration (from the beginning
785
1194
  // of the label to the terminating semicolon).
786
- repeated int32 path = 1 [packed=true];
1195
+ repeated int32 path = 1 [packed = true];
787
1196
 
788
1197
  // Always has exactly three or four elements: start line, start column,
789
1198
  // end line (optional, otherwise assumed same as start line), end column.
790
1199
  // These are packed into a single field for efficiency. Note that line
791
1200
  // and column numbers are zero-based -- typically you will want to add
792
1201
  // 1 to each before displaying to a user.
793
- repeated int32 span = 2 [packed=true];
1202
+ repeated int32 span = 2 [packed = true];
794
1203
 
795
1204
  // If this SourceCodeInfo represents a complete declaration, these are any
796
1205
  // comments appearing before and after the declaration which appear to be
@@ -819,13 +1228,13 @@ message SourceCodeInfo {
819
1228
  // // Comment attached to baz.
820
1229
  // // Another line attached to baz.
821
1230
  //
822
- // // Comment attached to qux.
1231
+ // // Comment attached to moo.
823
1232
  // //
824
- // // Another line attached to qux.
825
- // optional double qux = 4;
1233
+ // // Another line attached to moo.
1234
+ // optional double moo = 4;
826
1235
  //
827
1236
  // // Detached comment for corge. This is not leading or trailing comments
828
- // // to qux or corge because there are blank lines separating it from
1237
+ // // to moo or corge because there are blank lines separating it from
829
1238
  // // both.
830
1239
  //
831
1240
  // // Detached comment for corge paragraph 2.
@@ -855,7 +1264,7 @@ message GeneratedCodeInfo {
855
1264
  message Annotation {
856
1265
  // Identifies the element in the original source .proto file. This field
857
1266
  // is formatted the same as SourceCodeInfo.Location.path.
858
- repeated int32 path = 1 [packed=true];
1267
+ repeated int32 path = 1 [packed = true];
859
1268
 
860
1269
  // Identifies the filesystem path to the original source .proto.
861
1270
  optional string source_file = 2;
@@ -865,8 +1274,20 @@ message GeneratedCodeInfo {
865
1274
  optional int32 begin = 3;
866
1275
 
867
1276
  // Identifies the ending offset in bytes in the generated code that
868
- // relates to the identified offset. The end offset should be one past
1277
+ // relates to the identified object. The end offset should be one past
869
1278
  // the last relevant byte (so the length of the text = end - begin).
870
1279
  optional int32 end = 4;
1280
+
1281
+ // Represents the identified object's effect on the element in the original
1282
+ // .proto file.
1283
+ enum Semantic {
1284
+ // There is no effect or the effect is indescribable.
1285
+ NONE = 0;
1286
+ // The element is set or otherwise mutated.
1287
+ SET = 1;
1288
+ // An alias to the element is returned.
1289
+ ALIAS = 2;
1290
+ }
1291
+ optional Semantic semantic = 5;
871
1292
  }
872
1293
  }
@@ -1,9 +1,15 @@
1
- // Custom options for defining:
2
- // - Maximum size of string/bytes
3
- // - Maximum number of elements in array
1
+ // This file contains definitions of custom options used to control the
2
+ // code generator in nanopb protocol buffers library.
4
3
  //
5
- // These are used by nanopb to generate statically allocable structures
6
- // for memory-limited environments.
4
+ // Most commonly used options are max_count and max_size, which allow
5
+ // the generator to allocate static arrays for repeated and string fields.
6
+ //
7
+ // There are three ways to use these options:
8
+ // 1. Use a separate <protofile>.options file
9
+ // 2. Use command line switches to nanopb_generator.py
10
+ // 3. Use [(nanopb).option = value] in your <protofile>.proto file
11
+ //
12
+ // For detailed documentation, refer to "Generator options" in docs/reference.md
7
13
 
8
14
  syntax = "proto2";
9
15
  import "google/protobuf/descriptor.proto";
@@ -61,6 +67,9 @@ message NanoPBOptions {
61
67
  // full 32 bits for the value.
62
68
  optional IntSize int_size = 7 [default = IS_DEFAULT];
63
69
 
70
+ // Size for enum fields. Supported by C++11 and C23 standards.
71
+ optional IntSize enum_intsize = 34 [default = IS_DEFAULT];
72
+
64
73
  // Force type of field (callback or static allocation)
65
74
  optional FieldType type = 3 [default = FT_DEFAULT];
66
75
 
@@ -165,6 +174,13 @@ message NanoPBOptions {
165
174
  // Override initializer used in generated MyMessage_init_zero and MyMessage_init_default macros
166
175
  // By default decided automatically based on field default value and datatype.
167
176
  optional string initializer = 30;
177
+
178
+ // Discard unused types that are automatically generated by protoc if they are not actually
179
+ // needed. Currently this applies to map< > types when the field is ignored by options.
180
+ optional bool discard_unused_automatic_types = 33 [default = true];
181
+
182
+ // Discard messages and fields marked with [deprecated = true] in the proto file.
183
+ optional bool discard_deprecated = 35 [default = false];
168
184
  }
169
185
 
170
186
  // Extensions to protoc 'Descriptor' type in order to define options
@@ -0,0 +1,46 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
3
+ # NO CHECKED-IN PROTOBUF GENCODE
4
+ # source: nanopb.proto
5
+ # Protobuf Python Version: 5.27.2
6
+ """Generated protocol buffer code."""
7
+ from google.protobuf import descriptor as _descriptor
8
+ from google.protobuf import descriptor_pool as _descriptor_pool
9
+ from google.protobuf import runtime_version as _runtime_version
10
+ from google.protobuf import symbol_database as _symbol_database
11
+ from google.protobuf.internal import builder as _builder
12
+ _runtime_version.ValidateProtobufRuntimeVersion(
13
+ _runtime_version.Domain.PUBLIC,
14
+ 5,
15
+ 27,
16
+ 2,
17
+ '',
18
+ 'nanopb.proto'
19
+ )
20
+ # @@protoc_insertion_point(imports)
21
+
22
+ _sym_db = _symbol_database.Default()
23
+
24
+
25
+ from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2
26
+
27
+
28
+ DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cnanopb.proto\x1a google/protobuf/descriptor.proto\"\x99\t\n\rNanoPBOptions\x12\x10\n\x08max_size\x18\x01 \x01(\x05\x12\x12\n\nmax_length\x18\x0e \x01(\x05\x12\x11\n\tmax_count\x18\x02 \x01(\x05\x12&\n\x08int_size\x18\x07 \x01(\x0e\x32\x08.IntSize:\nIS_DEFAULT\x12*\n\x0c\x65num_intsize\x18\" \x01(\x0e\x32\x08.IntSize:\nIS_DEFAULT\x12$\n\x04type\x18\x03 \x01(\x0e\x32\n.FieldType:\nFT_DEFAULT\x12\x18\n\nlong_names\x18\x04 \x01(\x08:\x04true\x12\x1c\n\rpacked_struct\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1a\n\x0bpacked_enum\x18\n \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0cskip_message\x18\x06 \x01(\x08:\x05\x66\x61lse\x12\x18\n\tno_unions\x18\x08 \x01(\x08:\x05\x66\x61lse\x12\r\n\x05msgid\x18\t \x01(\r\x12\x1e\n\x0f\x61nonymous_oneof\x18\x0b \x01(\x08:\x05\x66\x61lse\x12\x15\n\x06proto3\x18\x0c \x01(\x08:\x05\x66\x61lse\x12#\n\x14proto3_singular_msgs\x18\x15 \x01(\x08:\x05\x66\x61lse\x12\x1d\n\x0e\x65num_to_string\x18\r \x01(\x08:\x05\x66\x61lse\x12\x1c\n\renum_validate\x18 \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0c\x66ixed_length\x18\x0f \x01(\x08:\x05\x66\x61lse\x12\x1a\n\x0b\x66ixed_count\x18\x10 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x0fsubmsg_callback\x18\x16 \x01(\x08:\x05\x66\x61lse\x12/\n\x0cmangle_names\x18\x11 \x01(\x0e\x32\x11.TypenameMangling:\x06M_NONE\x12(\n\x11\x63\x61llback_datatype\x18\x12 \x01(\t:\rpb_callback_t\x12\x34\n\x11\x63\x61llback_function\x18\x13 \x01(\t:\x19pb_default_field_callback\x12\x30\n\x0e\x64\x65scriptorsize\x18\x14 \x01(\x0e\x32\x0f.DescriptorSize:\x07\x44S_AUTO\x12\x1a\n\x0b\x64\x65\x66\x61ult_has\x18\x17 \x01(\x08:\x05\x66\x61lse\x12\x0f\n\x07include\x18\x18 \x03(\t\x12\x0f\n\x07\x65xclude\x18\x1a \x03(\t\x12\x0f\n\x07package\x18\x19 \x01(\t\x12\x41\n\rtype_override\x18\x1b \x01(\x0e\x32*.google.protobuf.FieldDescriptorProto.Type\x12\x43\n\x0elabel_override\x18\x1f \x01(\x0e\x32+.google.protobuf.FieldDescriptorProto.Label\x12\x19\n\x0bsort_by_tag\x18\x1c \x01(\x08:\x04true\x12.\n\rfallback_type\x18\x1d \x01(\x0e\x32\n.FieldType:\x0b\x46T_CALLBACK\x12\x13\n\x0binitializer\x18\x1e \x01(\t\x12,\n\x1e\x64iscard_unused_automatic_types\x18! \x01(\x08:\x04true\x12!\n\x12\x64iscard_deprecated\x18# \x01(\x08:\x05\x66\x61lse*i\n\tFieldType\x12\x0e\n\nFT_DEFAULT\x10\x00\x12\x0f\n\x0b\x46T_CALLBACK\x10\x01\x12\x0e\n\nFT_POINTER\x10\x04\x12\r\n\tFT_STATIC\x10\x02\x12\r\n\tFT_IGNORE\x10\x03\x12\r\n\tFT_INLINE\x10\x05*D\n\x07IntSize\x12\x0e\n\nIS_DEFAULT\x10\x00\x12\x08\n\x04IS_8\x10\x08\x12\t\n\x05IS_16\x10\x10\x12\t\n\x05IS_32\x10 \x12\t\n\x05IS_64\x10@*Z\n\x10TypenameMangling\x12\n\n\x06M_NONE\x10\x00\x12\x13\n\x0fM_STRIP_PACKAGE\x10\x01\x12\r\n\tM_FLATTEN\x10\x02\x12\x16\n\x12M_PACKAGE_INITIALS\x10\x03*E\n\x0e\x44\x65scriptorSize\x12\x0b\n\x07\x44S_AUTO\x10\x00\x12\x08\n\x04\x44S_1\x10\x01\x12\x08\n\x04\x44S_2\x10\x02\x12\x08\n\x04\x44S_4\x10\x04\x12\x08\n\x04\x44S_8\x10\x08:E\n\x0enanopb_fileopt\x12\x1c.google.protobuf.FileOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:G\n\rnanopb_msgopt\x12\x1f.google.protobuf.MessageOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:E\n\x0enanopb_enumopt\x12\x1c.google.protobuf.EnumOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:>\n\x06nanopb\x12\x1d.google.protobuf.FieldOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptionsB\x1a\n\x18\x66i.kapsi.koti.jpa.nanopb')
29
+
30
+ _globals = globals()
31
+ _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
32
+ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'nanopb_pb2', _globals)
33
+ if not _descriptor._USE_C_DESCRIPTORS:
34
+ _globals['DESCRIPTOR']._loaded_options = None
35
+ _globals['DESCRIPTOR']._serialized_options = b'\n\030fi.kapsi.koti.jpa.nanopb'
36
+ _globals['_FIELDTYPE']._serialized_start=1230
37
+ _globals['_FIELDTYPE']._serialized_end=1335
38
+ _globals['_INTSIZE']._serialized_start=1337
39
+ _globals['_INTSIZE']._serialized_end=1405
40
+ _globals['_TYPENAMEMANGLING']._serialized_start=1407
41
+ _globals['_TYPENAMEMANGLING']._serialized_end=1497
42
+ _globals['_DESCRIPTORSIZE']._serialized_start=1499
43
+ _globals['_DESCRIPTORSIZE']._serialized_end=1568
44
+ _globals['_NANOPBOPTIONS']._serialized_start=51
45
+ _globals['_NANOPBOPTIONS']._serialized_end=1228
46
+ # @@protoc_insertion_point(module_scope)
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "nanopb"
3
- version = "0.4.9-dev1485"
3
+ version = "0.4.9-dev1494"
4
4
  description = "Nanopb is a small code-size Protocol Buffers implementation in ansi C. It is especially suitable for use in microcontrollers, but fits any memory restricted system."
5
5
  authors = ["Petteri Aimonen <jpa@npb.mail.kapsi.fi>"]
6
6
  license = "Zlib"
@@ -1,46 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # Generated by the protocol buffer compiler. DO NOT EDIT!
3
- # NO CHECKED-IN PROTOBUF GENCODE
4
- # source: nanopb.proto
5
- # Protobuf Python Version: 5.27.2
6
- """Generated protocol buffer code."""
7
- from google.protobuf import descriptor as _descriptor
8
- from google.protobuf import descriptor_pool as _descriptor_pool
9
- from google.protobuf import runtime_version as _runtime_version
10
- from google.protobuf import symbol_database as _symbol_database
11
- from google.protobuf.internal import builder as _builder
12
- _runtime_version.ValidateProtobufRuntimeVersion(
13
- _runtime_version.Domain.PUBLIC,
14
- 5,
15
- 27,
16
- 2,
17
- '',
18
- 'nanopb.proto'
19
- )
20
- # @@protoc_insertion_point(imports)
21
-
22
- _sym_db = _symbol_database.Default()
23
-
24
-
25
- from google.protobuf import descriptor_pb2 as google_dot_protobuf_dot_descriptor__pb2
26
-
27
-
28
- DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0cnanopb.proto\x1a google/protobuf/descriptor.proto\"\x9c\x08\n\rNanoPBOptions\x12\x10\n\x08max_size\x18\x01 \x01(\x05\x12\x12\n\nmax_length\x18\x0e \x01(\x05\x12\x11\n\tmax_count\x18\x02 \x01(\x05\x12&\n\x08int_size\x18\x07 \x01(\x0e\x32\x08.IntSize:\nIS_DEFAULT\x12$\n\x04type\x18\x03 \x01(\x0e\x32\n.FieldType:\nFT_DEFAULT\x12\x18\n\nlong_names\x18\x04 \x01(\x08:\x04true\x12\x1c\n\rpacked_struct\x18\x05 \x01(\x08:\x05\x66\x61lse\x12\x1a\n\x0bpacked_enum\x18\n \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0cskip_message\x18\x06 \x01(\x08:\x05\x66\x61lse\x12\x18\n\tno_unions\x18\x08 \x01(\x08:\x05\x66\x61lse\x12\r\n\x05msgid\x18\t \x01(\r\x12\x1e\n\x0f\x61nonymous_oneof\x18\x0b \x01(\x08:\x05\x66\x61lse\x12\x15\n\x06proto3\x18\x0c \x01(\x08:\x05\x66\x61lse\x12#\n\x14proto3_singular_msgs\x18\x15 \x01(\x08:\x05\x66\x61lse\x12\x1d\n\x0e\x65num_to_string\x18\r \x01(\x08:\x05\x66\x61lse\x12\x1c\n\renum_validate\x18 \x01(\x08:\x05\x66\x61lse\x12\x1b\n\x0c\x66ixed_length\x18\x0f \x01(\x08:\x05\x66\x61lse\x12\x1a\n\x0b\x66ixed_count\x18\x10 \x01(\x08:\x05\x66\x61lse\x12\x1e\n\x0fsubmsg_callback\x18\x16 \x01(\x08:\x05\x66\x61lse\x12/\n\x0cmangle_names\x18\x11 \x01(\x0e\x32\x11.TypenameMangling:\x06M_NONE\x12(\n\x11\x63\x61llback_datatype\x18\x12 \x01(\t:\rpb_callback_t\x12\x34\n\x11\x63\x61llback_function\x18\x13 \x01(\t:\x19pb_default_field_callback\x12\x30\n\x0e\x64\x65scriptorsize\x18\x14 \x01(\x0e\x32\x0f.DescriptorSize:\x07\x44S_AUTO\x12\x1a\n\x0b\x64\x65\x66\x61ult_has\x18\x17 \x01(\x08:\x05\x66\x61lse\x12\x0f\n\x07include\x18\x18 \x03(\t\x12\x0f\n\x07\x65xclude\x18\x1a \x03(\t\x12\x0f\n\x07package\x18\x19 \x01(\t\x12\x41\n\rtype_override\x18\x1b \x01(\x0e\x32*.google.protobuf.FieldDescriptorProto.Type\x12\x43\n\x0elabel_override\x18\x1f \x01(\x0e\x32+.google.protobuf.FieldDescriptorProto.Label\x12\x19\n\x0bsort_by_tag\x18\x1c \x01(\x08:\x04true\x12.\n\rfallback_type\x18\x1d \x01(\x0e\x32\n.FieldType:\x0b\x46T_CALLBACK\x12\x13\n\x0binitializer\x18\x1e \x01(\t*i\n\tFieldType\x12\x0e\n\nFT_DEFAULT\x10\x00\x12\x0f\n\x0b\x46T_CALLBACK\x10\x01\x12\x0e\n\nFT_POINTER\x10\x04\x12\r\n\tFT_STATIC\x10\x02\x12\r\n\tFT_IGNORE\x10\x03\x12\r\n\tFT_INLINE\x10\x05*D\n\x07IntSize\x12\x0e\n\nIS_DEFAULT\x10\x00\x12\x08\n\x04IS_8\x10\x08\x12\t\n\x05IS_16\x10\x10\x12\t\n\x05IS_32\x10 \x12\t\n\x05IS_64\x10@*Z\n\x10TypenameMangling\x12\n\n\x06M_NONE\x10\x00\x12\x13\n\x0fM_STRIP_PACKAGE\x10\x01\x12\r\n\tM_FLATTEN\x10\x02\x12\x16\n\x12M_PACKAGE_INITIALS\x10\x03*E\n\x0e\x44\x65scriptorSize\x12\x0b\n\x07\x44S_AUTO\x10\x00\x12\x08\n\x04\x44S_1\x10\x01\x12\x08\n\x04\x44S_2\x10\x02\x12\x08\n\x04\x44S_4\x10\x04\x12\x08\n\x04\x44S_8\x10\x08:E\n\x0enanopb_fileopt\x12\x1c.google.protobuf.FileOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:G\n\rnanopb_msgopt\x12\x1f.google.protobuf.MessageOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:E\n\x0enanopb_enumopt\x12\x1c.google.protobuf.EnumOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptions:>\n\x06nanopb\x12\x1d.google.protobuf.FieldOptions\x18\xf2\x07 \x01(\x0b\x32\x0e.NanoPBOptionsB\x1a\n\x18\x66i.kapsi.koti.jpa.nanopb')
29
-
30
- _globals = globals()
31
- _builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
32
- _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'nanopb_pb2', _globals)
33
- if not _descriptor._USE_C_DESCRIPTORS:
34
- _globals['DESCRIPTOR']._loaded_options = None
35
- _globals['DESCRIPTOR']._serialized_options = b'\n\030fi.kapsi.koti.jpa.nanopb'
36
- _globals['_FIELDTYPE']._serialized_start=1105
37
- _globals['_FIELDTYPE']._serialized_end=1210
38
- _globals['_INTSIZE']._serialized_start=1212
39
- _globals['_INTSIZE']._serialized_end=1280
40
- _globals['_TYPENAMEMANGLING']._serialized_start=1282
41
- _globals['_TYPENAMEMANGLING']._serialized_end=1372
42
- _globals['_DESCRIPTORSIZE']._serialized_start=1374
43
- _globals['_DESCRIPTORSIZE']._serialized_end=1443
44
- _globals['_NANOPBOPTIONS']._serialized_start=51
45
- _globals['_NANOPBOPTIONS']._serialized_end=1103
46
- # @@protoc_insertion_point(module_scope)
File without changes