aboutsummaryrefslogtreecommitdiff
path: root/generator/proto/nanopb.proto
diff options
context:
space:
mode:
Diffstat (limited to 'generator/proto/nanopb.proto')
-rw-r--r--generator/proto/nanopb.proto46
1 files changed, 46 insertions, 0 deletions
diff --git a/generator/proto/nanopb.proto b/generator/proto/nanopb.proto
index 2be2f80..0c05a2b 100644
--- a/generator/proto/nanopb.proto
+++ b/generator/proto/nanopb.proto
@@ -5,6 +5,7 @@
// These are used by nanopb to generate statically allocable structures
// for memory-limited environments.
+syntax = "proto2";
import "google/protobuf/descriptor.proto";
option java_package = "fi.kapsi.koti.jpa.nanopb";
@@ -15,6 +16,15 @@ enum FieldType {
FT_POINTER = 4; // Always generate a dynamically allocated field.
FT_STATIC = 2; // Generate a static field or raise an exception if not possible.
FT_IGNORE = 3; // Ignore the field completely.
+ FT_INLINE = 5; // Legacy option, use the separate 'fixed_length' option instead
+}
+
+enum IntSize {
+ IS_DEFAULT = 0; // Default, 32/64bit based on type in .proto
+ IS_8 = 8;
+ IS_16 = 16;
+ IS_32 = 32;
+ IS_64 = 64;
}
// This is the inner options message, which basically defines options for
@@ -22,11 +32,20 @@ enum FieldType {
// fields.
message NanoPBOptions {
// Allocated size for 'bytes' and 'string' fields.
+ // For string fields, this should include the space for null terminator.
optional int32 max_size = 1;
+ // Maximum length for 'string' fields. Setting this is equivalent
+ // to setting max_size to a value of length+1.
+ optional int32 max_length = 14;
+
// Allocated number of entries in arrays ('repeated' fields)
optional int32 max_count = 2;
+ // Size of integer fields. Can save some memory if you don't need
+ // full 32 bits for the value.
+ optional IntSize int_size = 7 [default = IS_DEFAULT];
+
// Force type of field (callback or static allocation)
optional FieldType type = 3 [default = FT_DEFAULT];
@@ -37,6 +56,33 @@ message NanoPBOptions {
// Note: this cannot be used on CPUs that break on unaligned
// accesses to variables.
optional bool packed_struct = 5 [default = false];
+
+ // Add 'packed' attribute to generated enums.
+ optional bool packed_enum = 10 [default = false];
+
+ // Skip this message
+ optional bool skip_message = 6 [default = false];
+
+ // Generate oneof fields as normal optional fields instead of union.
+ optional bool no_unions = 8 [default = false];
+
+ // integer type tag for a message
+ optional uint32 msgid = 9;
+
+ // decode oneof as anonymous union
+ optional bool anonymous_oneof = 11 [default = false];
+
+ // Proto3 singular field does not generate a "has_" flag
+ optional bool proto3 = 12 [default = false];
+
+ // Generate an enum->string mapping function (can take up lots of space).
+ optional bool enum_to_string = 13 [default = false];
+
+ // Generate bytes arrays with fixed length
+ optional bool fixed_length = 15 [default = false];
+
+ // Generate repeated field with fixed count
+ optional bool fixed_count = 16 [default = false];
}
// Extensions to protoc 'Descriptor' type in order to define options