Minor, serialize/deserialize local visibility
Also support non-subsequent enum values in Flags
This commit is contained in:
@@ -293,4 +293,5 @@ enum Visibility {
|
||||
PROTECTED = 0x02;
|
||||
PUBLIC = 0x03;
|
||||
PRIVATE_TO_THIS = 0x04;
|
||||
LOCAL = 0x05;
|
||||
}
|
||||
|
||||
@@ -154,6 +154,9 @@ public class Flags {
|
||||
else if (visibility == Visibilities.PROTECTED) {
|
||||
return ProtoBuf.Visibility.PROTECTED;
|
||||
}
|
||||
else if (visibility == Visibilities.LOCAL) {
|
||||
return ProtoBuf.Visibility.LOCAL;
|
||||
}
|
||||
throw new IllegalArgumentException("Unknown visibility: " + visibility);
|
||||
}
|
||||
|
||||
@@ -226,7 +229,12 @@ public class Flags {
|
||||
int maskUnshifted = (1 << bitWidth) - 1;
|
||||
int mask = maskUnshifted << offset;
|
||||
int value = (flags & mask) >> offset;
|
||||
return values[value];
|
||||
for (E e : values) {
|
||||
if (getIntValue(e) == value) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Flag not found: " + value);
|
||||
}
|
||||
|
||||
public int toFlags(E value) {
|
||||
|
||||
@@ -110,6 +110,10 @@ public final class ProtoBuf {
|
||||
* <code>PRIVATE_TO_THIS = 4;</code>
|
||||
*/
|
||||
PRIVATE_TO_THIS(4, 4),
|
||||
/**
|
||||
* <code>LOCAL = 5;</code>
|
||||
*/
|
||||
LOCAL(5, 5),
|
||||
;
|
||||
|
||||
/**
|
||||
@@ -136,6 +140,10 @@ public final class ProtoBuf {
|
||||
* <code>PRIVATE_TO_THIS = 4;</code>
|
||||
*/
|
||||
public static final int PRIVATE_TO_THIS_VALUE = 4;
|
||||
/**
|
||||
* <code>LOCAL = 5;</code>
|
||||
*/
|
||||
public static final int LOCAL_VALUE = 5;
|
||||
|
||||
|
||||
public final int getNumber() { return value; }
|
||||
@@ -147,6 +155,7 @@ public final class ProtoBuf {
|
||||
case 2: return PROTECTED;
|
||||
case 3: return PUBLIC;
|
||||
case 4: return PRIVATE_TO_THIS;
|
||||
case 5: return LOCAL;
|
||||
default: return null;
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -43,6 +43,7 @@ fun visibility(visibility: ProtoBuf.Visibility) = when (visibility) {
|
||||
ProtoBuf.Visibility.PRIVATE_TO_THIS -> Visibilities.PRIVATE_TO_THIS
|
||||
ProtoBuf.Visibility.PROTECTED -> Visibilities.PROTECTED
|
||||
ProtoBuf.Visibility.PUBLIC -> Visibilities.PUBLIC
|
||||
ProtoBuf.Visibility.LOCAL -> Visibilities.LOCAL
|
||||
}
|
||||
|
||||
public fun classKind(kind: ProtoBuf.Class.Kind): ClassKind = when (kind) {
|
||||
|
||||
Reference in New Issue
Block a user