|
@@ -74,6 +74,11 @@ public class Extension<M extends ExtendableMessageNano<M>, T> {
|
|
|
public static final int TYPE_SINT32 = InternalNano.TYPE_SINT32;
|
|
|
public static final int TYPE_SINT64 = InternalNano.TYPE_SINT64;
|
|
|
|
|
|
+ // Note: these create...() methods take a long for the tag parameter,
|
|
|
+ // because tags are represented as unsigned longs, and these values exist
|
|
|
+ // in generated code as long values. However, they can fit in 32-bits, so
|
|
|
+ // it's safe to cast them to int without loss of precision.
|
|
|
+
|
|
|
/**
|
|
|
* Creates an {@code Extension} of the given message type and tag number.
|
|
|
* Should be used by the generated code only.
|
|
@@ -81,8 +86,8 @@ public class Extension<M extends ExtendableMessageNano<M>, T> {
|
|
|
* @param type {@link #TYPE_MESSAGE} or {@link #TYPE_GROUP}
|
|
|
*/
|
|
|
public static <M extends ExtendableMessageNano<M>, T extends MessageNano>
|
|
|
- Extension<M, T> createMessageTyped(int type, Class<T> clazz, int tag) {
|
|
|
- return new Extension<M, T>(type, clazz, tag, false);
|
|
|
+ Extension<M, T> createMessageTyped(int type, Class<T> clazz, long tag) {
|
|
|
+ return new Extension<M, T>(type, clazz, (int) tag, false);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -92,8 +97,8 @@ public class Extension<M extends ExtendableMessageNano<M>, T> {
|
|
|
* @param type {@link #TYPE_MESSAGE} or {@link #TYPE_GROUP}
|
|
|
*/
|
|
|
public static <M extends ExtendableMessageNano<M>, T extends MessageNano>
|
|
|
- Extension<M, T[]> createRepeatedMessageTyped(int type, Class<T[]> clazz, int tag) {
|
|
|
- return new Extension<M, T[]>(type, clazz, tag, true);
|
|
|
+ Extension<M, T[]> createRepeatedMessageTyped(int type, Class<T[]> clazz, long tag) {
|
|
|
+ return new Extension<M, T[]>(type, clazz, (int) tag, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -104,8 +109,8 @@ public class Extension<M extends ExtendableMessageNano<M>, T> {
|
|
|
* @param clazz the boxed Java type of this extension
|
|
|
*/
|
|
|
public static <M extends ExtendableMessageNano<M>, T>
|
|
|
- Extension<M, T> createPrimitiveTyped(int type, Class<T> clazz, int tag) {
|
|
|
- return new PrimitiveExtension<M, T>(type, clazz, tag, false, 0, 0);
|
|
|
+ Extension<M, T> createPrimitiveTyped(int type, Class<T> clazz, long tag) {
|
|
|
+ return new PrimitiveExtension<M, T>(type, clazz, (int) tag, false, 0, 0);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -117,8 +122,9 @@ public class Extension<M extends ExtendableMessageNano<M>, T> {
|
|
|
*/
|
|
|
public static <M extends ExtendableMessageNano<M>, T>
|
|
|
Extension<M, T> createRepeatedPrimitiveTyped(
|
|
|
- int type, Class<T> clazz, int tag, int nonPackedTag, int packedTag) {
|
|
|
- return new PrimitiveExtension<M, T>(type, clazz, tag, true, nonPackedTag, packedTag);
|
|
|
+ int type, Class<T> clazz, long tag, long nonPackedTag, long packedTag) {
|
|
|
+ return new PrimitiveExtension<M, T>(type, clazz, (int) tag, true,
|
|
|
+ (int) nonPackedTag, (int) packedTag);
|
|
|
}
|
|
|
|
|
|
/**
|