Home | History | Annotate | Download | only in 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 option java_package = "fi.kapsi.koti.jpa.nanopb";
     11 
     12 enum FieldType {
     13     FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible.
     14     FT_CALLBACK = 1; // Always generate a callback field.
     15     FT_POINTER = 4; // Always generate a dynamically allocated field.
     16     FT_STATIC = 2; // Generate a static field or raise an exception if not possible.
     17     FT_IGNORE = 3; // Ignore the field completely.
     18 }
     19 
     20 // This is the inner options message, which basically defines options for
     21 // a field. When it is used in message or file scope, it applies to all
     22 // fields.
     23 message NanoPBOptions {
     24   // Allocated size for 'bytes' and 'string' fields.
     25   optional int32 max_size = 1;
     26   
     27   // Allocated number of entries in arrays ('repeated' fields)
     28   optional int32 max_count = 2;
     29   
     30   // Force type of field (callback or static allocation)
     31   optional FieldType type = 3 [default = FT_DEFAULT];
     32   
     33   // Use long names for enums, i.e. EnumName_EnumValue.
     34   optional bool long_names = 4 [default = true];
     35   
     36   // Add 'packed' attribute to generated structs.
     37   // Note: this cannot be used on CPUs that break on unaligned
     38   // accesses to variables.
     39   optional bool packed_struct = 5 [default = false];
     40 }
     41 
     42 // Extensions to protoc 'Descriptor' type in order to define options
     43 // inside a .proto file.
     44 //
     45 // Protocol Buffers extension number registry
     46 // --------------------------------
     47 // Project:  Nanopb
     48 // Contact:  Petteri Aimonen <jpa (a] kapsi.fi>
     49 // Web site: http://kapsi.fi/~jpa/nanopb
     50 // Extensions: 1010 (all types)
     51 // --------------------------------
     52 
     53 extend google.protobuf.FileOptions {
     54     optional NanoPBOptions nanopb_fileopt = 1010;
     55 }
     56 
     57 extend google.protobuf.MessageOptions {
     58     optional NanoPBOptions nanopb_msgopt = 1010;
     59 }
     60 
     61 extend google.protobuf.EnumOptions {
     62     optional NanoPBOptions nanopb_enumopt = 1010;
     63 }
     64 
     65 extend google.protobuf.FieldOptions {
     66     optional NanoPBOptions nanopb = 1010;
     67 }
     68 
     69 
     70