nanopb.proto 2.9 KB

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