Fix bugs in proto3 mode encoding of submessages (#256)
[apps/agl-service-can-low-level.git] / generator / nanopb / options.proto
1 // This is a transitional file, to provide parallel support between the old
2 // nanopb.proto and new options.proto files. Eventually nanopb.proto will
3 // be left only for legacy code, but for now the generator is still also
4 // using it. However, your new code can start using this file already now.
5 // See pull request #241 for details:
6 // https://github.com/nanopb/nanopb/pull/241
7
8 // Custom options for defining:
9 // - Maximum size of string/bytes
10 // - Maximum number of elements in array
11 //
12 // These are used by nanopb to generate statically allocable structures
13 // for memory-limited environments.
14
15 syntax = "proto2";
16 import "google/protobuf/descriptor.proto";
17
18 package nanopb;
19 option java_package = "fi.kapsi.koti.jpa.nanopb";
20
21 enum FieldType {
22     FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible.
23     FT_CALLBACK = 1; // Always generate a callback field.
24     FT_POINTER = 4; // Always generate a dynamically allocated field.
25     FT_STATIC = 2; // Generate a static field or raise an exception if not possible.
26     FT_IGNORE = 3; // Ignore the field completely.
27     FT_INLINE = 5; // Legacy option, use the separate 'fixed_length' option instead
28 }
29
30 enum IntSize {
31     IS_DEFAULT = 0; // Default, 32/64bit based on type in .proto
32     IS_8 = 8;
33     IS_16 = 16;
34     IS_32 = 32;
35     IS_64 = 64;
36 }
37
38 // This is the inner options message, which basically defines options for
39 // a field. When it is used in message or file scope, it applies to all
40 // fields.
41 message Options {
42   // Allocated size for 'bytes' and 'string' fields.
43   // For string fields, this should include the space for null terminator.
44   optional int32 max_size = 1;
45
46   // Maximum length for 'string' fields. Setting this is equivalent
47   // to setting max_size to a value of length+1.
48   optional int32 max_length = 14;
49
50   // Allocated number of entries in arrays ('repeated' fields)
51   optional int32 max_count = 2;
52
53   // Size of integer fields. Can save some memory if you don't need
54   // full 32 bits for the value.
55   optional IntSize int_size = 7 [default = IS_DEFAULT];
56
57   // Force type of field (callback or static allocation)
58   optional FieldType type = 3 [default = FT_DEFAULT];
59
60   // Use long names for enums, i.e. EnumName_EnumValue.
61   optional bool long_names = 4 [default = true];
62
63   // Add 'packed' attribute to generated structs.
64   // Note: this cannot be used on CPUs that break on unaligned
65   // accesses to variables.
66   optional bool packed_struct = 5 [default = false];
67
68   // Add 'packed' attribute to generated enums.
69   optional bool packed_enum = 10 [default = false];
70
71   // Skip this message
72   optional bool skip_message = 6 [default = false];
73
74   // Generate oneof fields as normal optional fields instead of union.
75   optional bool no_unions = 8 [default = false];
76
77   // integer type tag for a message
78   optional uint32 msgid = 9;
79
80   // decode oneof as anonymous union
81   optional bool anonymous_oneof = 11 [default = false];
82
83   // Proto3 singular field does not generate a "has_" flag
84   optional bool proto3 = 12 [default = false];
85
86   // Generate an enum->string mapping function (can take up lots of space).
87   optional bool enum_to_string = 13 [default = false];
88
89   // Generate bytes arrays with fixed length
90   optional bool fixed_length = 15 [default = false];
91 }
92
93 // Extensions to protoc 'Descriptor' type in order to define options
94 // inside a .proto file.
95 //
96 // Protocol Buffers extension number registry
97 // --------------------------------
98 // Project:  Nanopb
99 // Contact:  Petteri Aimonen <jpa@kapsi.fi>
100 // Web site: http://kapsi.fi/~jpa/nanopb
101 // Extensions: 1010 (all types)
102 // --------------------------------
103
104 extend google.protobuf.FileOptions {
105     optional Options fileopt = 1010;
106 }
107
108 extend google.protobuf.MessageOptions {
109     optional Options msgopt = 1010;
110 }
111
112 extend google.protobuf.EnumOptions {
113     optional Options enumopt = 1010;
114 }
115
116 extend google.protobuf.FieldOptions {
117     optional Options fieldopt = 1010;
118 }
119
120