9b2f0fbce0005adca8463a29c1076946e357adc5
[apps/agl-service-can-low-level.git] / generator / proto / 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 syntax = "proto2";
9 import "google/protobuf/descriptor.proto";
10
11 option java_package = "fi.kapsi.koti.jpa.nanopb";
12
13 enum FieldType {
14     FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible.
15     FT_CALLBACK = 1; // Always generate a callback field.
16     FT_POINTER = 4; // Always generate a dynamically allocated field.
17     FT_STATIC = 2; // Generate a static field or raise an exception if not possible.
18     FT_IGNORE = 3; // Ignore the field completely.
19 }
20
21 enum IntSize {
22     IS_DEFAULT = 0; // Default, 32/64bit based on type in .proto
23     IS_8 = 8;
24     IS_16 = 16;
25     IS_32 = 32;
26     IS_64 = 64;
27 }
28
29 // This is the inner options message, which basically defines options for
30 // a field. When it is used in message or file scope, it applies to all
31 // fields.
32 message NanoPBOptions {
33   // Allocated size for 'bytes' and 'string' fields.
34   optional int32 max_size = 1;
35   
36   // Allocated number of entries in arrays ('repeated' fields)
37   optional int32 max_count = 2;
38   
39   // Size of integer fields. Can save some memory if you don't need
40   // full 32 bits for the value.
41   optional IntSize int_size = 7 [default = IS_DEFAULT];
42
43   // Force type of field (callback or static allocation)
44   optional FieldType type = 3 [default = FT_DEFAULT];
45   
46   // Use long names for enums, i.e. EnumName_EnumValue.
47   optional bool long_names = 4 [default = true];
48   
49   // Add 'packed' attribute to generated structs.
50   // Note: this cannot be used on CPUs that break on unaligned
51   // accesses to variables.
52   optional bool packed_struct = 5 [default = false];
53   
54   // Add 'packed' attribute to generated enums.
55   optional bool packed_enum = 10 [default = false];
56   
57   // Skip this message
58   optional bool skip_message = 6 [default = false];
59
60   // Generate oneof fields as normal optional fields instead of union.
61   optional bool no_unions = 8 [default = false];
62
63   // integer type tag for a message
64   optional uint32 msgid = 9;
65
66   // decode oneof as anonymous union
67   optional bool anonymous_oneof = 11 [default = false];
68 }
69
70 // Extensions to protoc 'Descriptor' type in order to define options
71 // inside a .proto file.
72 //
73 // Protocol Buffers extension number registry
74 // --------------------------------
75 // Project:  Nanopb
76 // Contact:  Petteri Aimonen <jpa@kapsi.fi>
77 // Web site: http://kapsi.fi/~jpa/nanopb
78 // Extensions: 1010 (all types)
79 // --------------------------------
80
81 extend google.protobuf.FileOptions {
82     optional NanoPBOptions nanopb_fileopt = 1010;
83 }
84
85 extend google.protobuf.MessageOptions {
86     optional NanoPBOptions nanopb_msgopt = 1010;
87 }
88
89 extend google.protobuf.EnumOptions {
90     optional NanoPBOptions nanopb_enumopt = 1010;
91 }
92
93 extend google.protobuf.FieldOptions {
94     optional NanoPBOptions nanopb = 1010;
95 }
96
97