Add generator option for packed structs.
[apps/agl-service-can-low-level.git] / generator / nanopb.proto
1 // Custom options for defining:
2 // - Maximum size of string/bytes
3 // - Maximum number of elements in array
4 //
5 // These are used by nanopb to generate statically allocable structures
6 // for memory-limited environments.
7
8 import "google/protobuf/descriptor.proto";
9
10 enum FieldType {
11     FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible.
12     FT_CALLBACK = 1; // Always generate a callback field.
13     FT_STATIC = 2; // Generate a static field or raise an exception if not possible.
14 }
15
16 message NanoPBOptions {
17   // Allocated size for 'bytes' and 'string' fields.
18   optional int32 max_size = 1;
19   
20   // Allocated number of entries in arrays ('repeated' fields)
21   optional int32 max_count = 2;
22   
23   // Force type of field (callback or static allocation)
24   optional FieldType type = 3 [default = FT_DEFAULT];
25   
26   // Use long names for enums, i.e. EnumName_EnumValue.
27   optional bool long_names = 4 [default = true];
28   
29   // Add 'packed' attribute to generated structs.
30   optional bool packed_struct = 5 [default = false];
31 }
32
33 // Protocol Buffers extension number registry
34 // --------------------------------
35 // Project:  Nanopb
36 // Contact:  Petteri Aimonen <jpa@kapsi.fi>
37 // Web site: http://kapsi.fi/~jpa/nanopb
38 // Extensions: 1010 (all types)
39 // --------------------------------
40
41 extend google.protobuf.FileOptions {
42     optional NanoPBOptions nanopb_fileopt = 1010;
43 }
44
45 extend google.protobuf.MessageOptions {
46     optional NanoPBOptions nanopb_msgopt = 1010;
47 }
48
49 extend google.protobuf.EnumOptions {
50     optional NanoPBOptions nanopb_enumopt = 1010;
51 }
52
53 extend google.protobuf.FieldOptions {
54     optional NanoPBOptions nanopb = 1010;
55 }
56
57