Skip to content

Commit e74892a

Browse files
committed
fix int32 type. keep the POJO in the order of descriptor.proto
1 parent af13b45 commit e74892a

File tree

1 file changed

+52
-45
lines changed

1 file changed

+52
-45
lines changed

protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/schema/FileDescriptorSet.java

Lines changed: 52 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ static class FileDescriptorProto
9898
@JsonProperty("package")
9999
public String packageName;
100100
public String[] dependency;
101-
public long[] public_dependency;
102-
public long[] weak_dependency;
101+
public int[] public_dependency;
102+
public int[] weak_dependency;
103103
public DescriptorProto[] message_type;
104104
public EnumDescriptorProto[] enum_type;
105105
public ServiceDescriptorProto[] service;
@@ -127,8 +127,8 @@ static class DescriptorProto
127127

128128
class ExtensionRange
129129
{
130-
public long start;
131-
public long end;
130+
public int start;
131+
public int end;
132132
}
133133

134134
public ExtensionRange[] extension_range;
@@ -137,6 +137,8 @@ class ExtensionRange
137137

138138
class ReservedRange
139139
{
140+
public int start; // Inclusive.
141+
public int end; // Exclusive.
140142
}
141143

142144
public ReservedRange[] reserved_range;
@@ -219,42 +221,6 @@ public MessageElement buildMessageElement()
219221

220222
static class FieldDescriptorProto
221223
{
222-
static private Map<Type, DataType> scalarTypeMap = new HashMap();
223-
static private Map<Label, FieldElement.Label> labelMap = new HashMap();
224-
225-
static {
226-
scalarTypeMap.put(Type.TYPE_DOUBLE, DataType.ScalarType.DOUBLE);
227-
scalarTypeMap.put(Type.TYPE_FLOAT, DataType.ScalarType.FLOAT);
228-
scalarTypeMap.put(Type.TYPE_INT64, DataType.ScalarType.INT64);
229-
scalarTypeMap.put(Type.TYPE_UINT64, DataType.ScalarType.UINT64);
230-
scalarTypeMap.put(Type.TYPE_INT32, DataType.ScalarType.INT32);
231-
scalarTypeMap.put(Type.TYPE_FIXED64, DataType.ScalarType.FIXED64);
232-
scalarTypeMap.put(Type.TYPE_FIXED32, DataType.ScalarType.FIXED32);
233-
scalarTypeMap.put(Type.TYPE_BOOL, DataType.ScalarType.BOOL);
234-
scalarTypeMap.put(Type.TYPE_STRING, DataType.ScalarType.STRING);
235-
scalarTypeMap.put(Type.TYPE_BYTES, DataType.ScalarType.BYTES);
236-
scalarTypeMap.put(Type.TYPE_UINT32, DataType.ScalarType.UINT32);
237-
scalarTypeMap.put(Type.TYPE_SFIXED32, DataType.ScalarType.SFIXED32);
238-
scalarTypeMap.put(Type.TYPE_SFIXED64, DataType.ScalarType.SFIXED64);
239-
scalarTypeMap.put(Type.TYPE_SINT32, DataType.ScalarType.SINT32);
240-
scalarTypeMap.put(Type.TYPE_SINT64, DataType.ScalarType.SINT64);
241-
242-
labelMap.put(Label.LABEL_OPTIONAL, FieldElement.Label.OPTIONAL);
243-
labelMap.put(Label.LABEL_REQUIRED, FieldElement.Label.REQUIRED);
244-
labelMap.put(Label.LABEL_REPEATED, FieldElement.Label.REPEATED);
245-
}
246-
247-
public String name;
248-
public int number;
249-
public Label label;
250-
public Type type;
251-
public String type_name;
252-
public String extendee;
253-
public String default_value;
254-
public long oneof_index;
255-
public String json_name;
256-
public FieldOptions options;
257-
258224
enum Type
259225
{
260226
TYPE_DOUBLE,
@@ -284,6 +250,42 @@ enum Label
284250
LABEL_REPEATED
285251
}
286252

253+
public String name;
254+
public int number;
255+
public Label label;
256+
public Type type;
257+
public String type_name;
258+
public String extendee;
259+
public String default_value;
260+
public int oneof_index;
261+
public String json_name;
262+
public FieldOptions options;
263+
264+
static private Map<Type, DataType> scalarTypeMap = new HashMap();
265+
static private Map<Label, FieldElement.Label> labelMap = new HashMap();
266+
267+
static {
268+
scalarTypeMap.put(Type.TYPE_DOUBLE, DataType.ScalarType.DOUBLE);
269+
scalarTypeMap.put(Type.TYPE_FLOAT, DataType.ScalarType.FLOAT);
270+
scalarTypeMap.put(Type.TYPE_INT64, DataType.ScalarType.INT64);
271+
scalarTypeMap.put(Type.TYPE_UINT64, DataType.ScalarType.UINT64);
272+
scalarTypeMap.put(Type.TYPE_INT32, DataType.ScalarType.INT32);
273+
scalarTypeMap.put(Type.TYPE_FIXED64, DataType.ScalarType.FIXED64);
274+
scalarTypeMap.put(Type.TYPE_FIXED32, DataType.ScalarType.FIXED32);
275+
scalarTypeMap.put(Type.TYPE_BOOL, DataType.ScalarType.BOOL);
276+
scalarTypeMap.put(Type.TYPE_STRING, DataType.ScalarType.STRING);
277+
scalarTypeMap.put(Type.TYPE_BYTES, DataType.ScalarType.BYTES);
278+
scalarTypeMap.put(Type.TYPE_UINT32, DataType.ScalarType.UINT32);
279+
scalarTypeMap.put(Type.TYPE_SFIXED32, DataType.ScalarType.SFIXED32);
280+
scalarTypeMap.put(Type.TYPE_SFIXED64, DataType.ScalarType.SFIXED64);
281+
scalarTypeMap.put(Type.TYPE_SINT32, DataType.ScalarType.SINT32);
282+
scalarTypeMap.put(Type.TYPE_SINT64, DataType.ScalarType.SINT64);
283+
284+
labelMap.put(Label.LABEL_OPTIONAL, FieldElement.Label.OPTIONAL);
285+
labelMap.put(Label.LABEL_REQUIRED, FieldElement.Label.REQUIRED);
286+
labelMap.put(Label.LABEL_REPEATED, FieldElement.Label.REPEATED);
287+
}
288+
287289
public DataType getDataType()
288290
{
289291
return scalarTypeMap.get(type);
@@ -342,6 +344,9 @@ static class FileOptions
342344

343345
enum OptimizeMode
344346
{
347+
SPEED,
348+
CODE_SIZE,
349+
LITE_RUNTIME
345350
}
346351

347352
public OptimizeMode optimize_for; // [default=SPEED];
@@ -431,7 +436,9 @@ static class MethodOptions
431436

432437
enum IdempotencyLevel
433438
{
434-
IDEMPOTENCY_UNKNOWN;
439+
IDEMPOTENCY_UNKNOWN,
440+
NO_SIDE_EFFECTS,
441+
IDEMPOTENT
435442
}
436443

437444
public IdempotencyLevel idempotency_level; // [default=IDEMPOTENCY_UNKNOWN];
@@ -462,8 +469,8 @@ static class SourceCodeInfo
462469

463470
class Location
464471
{
465-
public long[] path; // [packed=true];
466-
public long[] span; // [packed=true];
472+
public int[] path; // [packed=true];
473+
public int[] span; // [packed=true];
467474
public String leading_comments;
468475
public String trailing_comments;
469476
public String[] leading_detached_comments;
@@ -478,8 +485,8 @@ class Annotation
478485
{
479486
public long[] path; // [packed=true];
480487
public String source_file;
481-
public long begin;
482-
public long end;
488+
public int begin;
489+
public int end;
483490
}
484491
}
485492

0 commit comments

Comments
 (0)