aboutsummaryrefslogtreecommitdiffstats
path: root/generator/nanopb.proto
blob: fe564b5ca7ffcb07a5bd50baf97b8c6cbcf026e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Custom options for defining:
// - Maximum size of string/bytes
// - Maximum number of elements in array
//
// These are used by nanopb to generate statically allocable structures
// for memory-limited environments.

import "google/protobuf/descriptor.proto";

option java_package = "fi.kapsi.koti.jpa.nanopb";

enum FieldType {
    FT_DEFAULT = 0; // Automatically decide field type, generate static field if possible.
    FT_CALLBACK = 1; // Always generate a callback field.
    FT_STATIC = 2; // Generate a static field or raise an exception if not possible.
    FT_IGNORE = 3; // Ignore the field completely.
}

// This is the inner options message, which basically defines options for
// a field. When it is used in message or file scope, it applies to all
// fields.
message NanoPBOptions {
  // Allocated size for 'bytes' and 'string' fields.
  optional int32 max_size = 1;
  
  // Allocated number of entries in arrays ('repeated' fields)
  optional int32 max_count = 2;
  
  // Force type of field (callback or static allocation)
  optional FieldType type = 3 [default = FT_DEFAULT];
  
  // Use long names for enums, i.e. EnumName_EnumValue.
  optional bool long_names = 4 [default = true];
  
  // Add 'packed' attribute to generated structs.
  // Note: this cannot be used on CPUs that break on unaligned
  // accesses to variables.
  optional bool packed_struct = 5 [default = false];
}

// Extensions to protoc 'Descriptor' type in order to define options
// inside a .proto file.
//
// Protocol Buffers extension number registry
// --------------------------------
// Project:  Nanopb
// Contact:  Petteri Aimonen <jpa@kapsi.fi>
// Web site: http://kapsi.fi/~jpa/nanopb
// Extensions: 1010 (all types)
// --------------------------------

extend google.protobuf.FileOptions {
    optional NanoPBOptions nanopb_fileopt = 1010;
}

extend google.protobuf.MessageOptions {
    optional NanoPBOptions nanopb_msgopt = 1010;
}

extend google.protobuf.EnumOptions {
    optional NanoPBOptions nanopb_enumopt = 1010;
}

extend google.protobuf.FieldOptions {
    optional NanoPBOptions nanopb = 1010;
}