Cleanup descriptors.proto, regenerate

- move enums and messages nested in Callable to top level, since they're likely
  to be reused in other messages soon
- delete obsolete comments: some did not any value, some became obsolete with
  custom options ("id in StringTable" -> name_id_in_table)
This commit is contained in:
Alexander Udalov
2015-09-29 18:37:00 +03:00
parent b09e727462
commit e4090d3f30
30 changed files with 2490 additions and 3365 deletions
+1 -1
View File
@@ -35,6 +35,6 @@ extend Callable {
optional Annotation.Argument.Value compile_time_value = 151;
}
extend Callable.ValueParameter {
extend ValueParameter {
repeated Annotation parameter_annotation = 150;
}
+63 -75
View File
@@ -27,10 +27,9 @@ message StringTable {
}
message QualifiedNameTable {
message QualifiedName {
optional int32 parent_qualified_name = 1 [default = -1];
// Id in the StringTable
// id in the StringTable
required int32 short_name = 2;
optional Kind kind = 3 [default = PACKAGE];
@@ -69,19 +68,17 @@ message Annotation {
// However, to save space, this field is optional: in case of homogeneous arrays, only the type of the first element is required
optional Type type = 1;
// Only one of the following values should be present. Consider using `oneof` instead when we upgrade to protobuf 2.6.0+
// Only one of the following values should be present
optional sint64 int_value = 2;
optional float float_value = 3;
optional double double_value = 4;
// id in StringTable
optional int32 string_value = 5 [(string_id_in_table) = true];
// If type = CLASS, FQ name id of the referenced class; if type = ENUM, FQ name id of the enum class
// If type = CLASS, FQ name of the referenced class; if type = ENUM, FQ name of the enum class
optional int32 class_id = 6 [(fq_name_id_in_table) = true];
// id in StringTable
optional int32 enum_value_id = 7 [(name_id_in_table) = true];
optional Annotation annotation = 8;
@@ -89,12 +86,10 @@ message Annotation {
repeated Value array_element = 9;
}
// id in StringTable
required int32 name_id = 1 [(name_id_in_table) = true];
required Value value = 2;
}
// Class FQ name id
required int32 id = 1 [(fq_name_id_in_table) = true];
repeated Argument argument = 2;
@@ -117,27 +112,23 @@ message Type {
optional bool nullable = 3 [default = false];
// Id in the StringTable
// If this field is set, the type is flexible.
// All the other fields and extensions represent its lower bound, and flexible_upper_bound must be set and represents its upper bound.
optional int32 flexible_type_capabilities_id = 4 [(string_id_in_table) = true];
// While such an "indirect" encoding helps backwards compatibility with pre-flexible-types versions of this format,
// we use it mainly to save space: having a special mandatory tag on each an every type just to have an option
// to represent flexible types is too many wasted bytes.
optional Type flexible_upper_bound = 5;
// Only one of the following values should be present. Consider using `oneof` instead when we upgrade to protobuf 2.6.0+
// Only one of the following values should be present
optional int32 class_name = 6 [(fq_name_id_in_table) = true]; // fqName id
optional int32 type_parameter = 7; // type parameter id
optional int32 class_name = 6 [(fq_name_id_in_table) = true];
optional int32 type_parameter = 7; // id of the type parameter
extensions 100 to 199;
}
message TypeParameter {
required int32 id = 1;
// Id in the StringTable
required int32 name = 2 [(name_id_in_table) = true];
optional bool reified = 3 [default = false];
@@ -165,24 +156,21 @@ message Class {
}
/*
Visibility
Modality
has_annotation
ClassKind
is_inner
*/
Visibility
Modality
hasAnnotations
ClassKind
isInner
*/
optional int32 flags = 1 [default = 0 /*internal final class, no annotations*/];
required int32 fq_name = 3 [(fq_name_id_in_table) = true];
// If this field is present, it contains the name of companion object.
optional int32 companion_object_name = 4 [(name_id_in_table) = true];
repeated TypeParameter type_parameter = 5;
repeated Type supertype = 6;
// we store only names, because the actual information must reside in the corresponding .class files,
// to be obtainable through reflection at runtime
repeated int32 nested_class_name = 7 [packed = true, (name_id_in_table) = true];
repeated Callable member = 11;
@@ -210,44 +198,28 @@ message Package {
}
message Callable {
enum MemberKind {
// 2 bits
DECLARATION = 0;
FAKE_OVERRIDE = 1;
DELEGATION = 2;
SYNTHESIZED = 3;
}
enum CallableKind {
// 2 bits
FUN = 0;
VAL = 1;
VAR = 2;
CONSTRUCTOR = 3;
}
/*
Visibility
Modality
has_annotations
CallableKind
MemberKind
hasGetter
hasSetter
hasConstant
isConst
lateinit
isOperator
isInfix
*/
Visibility
Modality
hasAnnotations
CallableKind
MemberKind
hasGetter
hasSetter
hasConstant
isConst
lateinit
isOperator
isInfix
*/
optional int32 flags = 1;
/*
isNotDefault
Visibility
Modality
has_annotations
*/
isNotDefault
Visibility
Modality
hasAnnotations
*/
optional int32 getter_flags = 9 /* absent => same as property */;
optional int32 setter_flags = 10 /* absent => same as property */;
@@ -255,24 +227,8 @@ message Callable {
optional Type receiver_type = 5;
// Id in the StringTable
required int32 name = 6 [(name_id_in_table) = true];
message ValueParameter {
/*
declaresDefault
has_annotations
*/
optional int32 flags = 1;
// Id in the StringTable
required int32 name = 2 [(name_id_in_table) = true];
required Type type = 3;
optional Type vararg_element_type = 4;
extensions 100 to 199;
}
// Value parameters for functions and constructors, or setter value parameter for properties
repeated ValueParameter value_parameter = 7;
@@ -281,6 +237,22 @@ message Callable {
extensions 100 to 199;
}
message ValueParameter {
/*
declaresDefault
hasAnnotations
*/
optional int32 flags = 1;
required int32 name = 2 [(name_id_in_table) = true];
required Type type = 3;
optional Type vararg_element_type = 4;
extensions 100 to 199;
}
enum Modality {
// 2 bits
FINAL = 0x00;
@@ -298,3 +270,19 @@ enum Visibility {
PRIVATE_TO_THIS = 0x04;
LOCAL = 0x05;
}
enum CallableKind {
// 2 bits
FUN = 0;
VAL = 1;
VAR = 2;
CONSTRUCTOR = 3;
}
enum MemberKind {
// 2 bits
DECLARATION = 0;
FAKE_OVERRIDE = 1;
DELEGATION = 2;
SYNTHESIZED = 3;
}
@@ -39,11 +39,9 @@ public class Flags {
// Callables
public static final FlagField<ProtoBuf.Callable.CallableKind> CALLABLE_KIND = FlagField.after(MODALITY,
ProtoBuf.Callable.CallableKind.values());
public static final FlagField<ProtoBuf.CallableKind> CALLABLE_KIND = FlagField.after(MODALITY, ProtoBuf.CallableKind.values());
public static final FlagField<ProtoBuf.Callable.MemberKind> MEMBER_KIND = FlagField.after(CALLABLE_KIND,
ProtoBuf.Callable.MemberKind.values());
public static final FlagField<ProtoBuf.MemberKind> MEMBER_KIND = FlagField.after(CALLABLE_KIND, ProtoBuf.MemberKind.values());
public static final FlagField<Boolean> HAS_GETTER = FlagField.booleanAfter(MEMBER_KIND);
public static final FlagField<Boolean> HAS_SETTER = FlagField.booleanAfter(HAS_GETTER);
public static final FlagField<Boolean> HAS_CONSTANT = FlagField.booleanAfter(HAS_SETTER);
@@ -117,7 +115,7 @@ public class Flags {
@NotNull Visibility visibility,
@NotNull Modality modality,
@NotNull CallableMemberDescriptor.Kind memberKind,
@NotNull ProtoBuf.Callable.CallableKind callableKind,
@NotNull ProtoBuf.CallableKind callableKind,
boolean hasGetter,
boolean hasSetter,
boolean hasConstant,
@@ -193,16 +191,16 @@ public class Flags {
}
@NotNull
private static ProtoBuf.Callable.MemberKind memberKind(@NotNull CallableMemberDescriptor.Kind kind) {
private static ProtoBuf.MemberKind memberKind(@NotNull CallableMemberDescriptor.Kind kind) {
switch (kind) {
case DECLARATION:
return ProtoBuf.Callable.MemberKind.DECLARATION;
return ProtoBuf.MemberKind.DECLARATION;
case FAKE_OVERRIDE:
return ProtoBuf.Callable.MemberKind.FAKE_OVERRIDE;
return ProtoBuf.MemberKind.FAKE_OVERRIDE;
case DELEGATION:
return ProtoBuf.Callable.MemberKind.DELEGATION;
return ProtoBuf.MemberKind.DELEGATION;
case SYNTHESIZED:
return ProtoBuf.Callable.MemberKind.SYNTHESIZED;
return ProtoBuf.MemberKind.SYNTHESIZED;
}
throw new IllegalArgumentException("Unknown member kind: " + kind);
}
File diff suppressed because it is too large Load Diff
@@ -75,14 +75,14 @@ public final class BuiltInsProtoBuf {
com.google.protobuf.WireFormat.FieldType.MESSAGE);
public static final int PARAMETER_ANNOTATION_FIELD_NUMBER = 150;
/**
* <code>extend .org.jetbrains.kotlin.serialization.Callable.ValueParameter { ... }</code>
* <code>extend .org.jetbrains.kotlin.serialization.ValueParameter { ... }</code>
*/
public static final
com.google.protobuf.GeneratedMessageLite.GeneratedExtension<
org.jetbrains.kotlin.serialization.ProtoBuf.Callable.ValueParameter,
org.jetbrains.kotlin.serialization.ProtoBuf.ValueParameter,
java.util.List<org.jetbrains.kotlin.serialization.ProtoBuf.Annotation>> parameterAnnotation = com.google.protobuf.GeneratedMessageLite
.newRepeatedGeneratedExtension(
org.jetbrains.kotlin.serialization.ProtoBuf.Callable.ValueParameter.getDefaultInstance(),
org.jetbrains.kotlin.serialization.ProtoBuf.ValueParameter.getDefaultInstance(),
org.jetbrains.kotlin.serialization.ProtoBuf.Annotation.getDefaultInstance(),
null,
150,
@@ -45,7 +45,7 @@ public interface AnnotationAndConstantLoader<A, C, T> {
@NotNull NameResolver nameResolver,
@NotNull AnnotatedCallableKind kind,
int parameterIndex,
@NotNull ProtoBuf.Callable.ValueParameter proto
@NotNull ProtoBuf.ValueParameter proto
);
@NotNull
@@ -25,10 +25,11 @@ import org.jetbrains.kotlin.descriptors.impl.PropertySetterDescriptorImpl
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
import org.jetbrains.kotlin.resolve.DescriptorFactory
import org.jetbrains.kotlin.serialization.Flags
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind.FUN
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind.VAL
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind.VAR
import org.jetbrains.kotlin.serialization.ProtoBuf.CallableKind.FUN
import org.jetbrains.kotlin.serialization.ProtoBuf.CallableKind.VAL
import org.jetbrains.kotlin.serialization.ProtoBuf.CallableKind.VAR
import org.jetbrains.kotlin.serialization.deserialization.descriptors.*
import org.jetbrains.kotlin.utils.toReadOnlyList
@@ -50,7 +51,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
getAnnotations(proto, flags, AnnotatedCallableKind.PROPERTY),
Deserialization.modality(Flags.MODALITY.get(flags)),
Deserialization.visibility(Flags.VISIBILITY.get(flags)),
Flags.CALLABLE_KIND.get(flags) == Callable.CallableKind.VAR,
Flags.CALLABLE_KIND.get(flags) == ProtoBuf.CallableKind.VAR,
c.nameResolver.getName(proto.getName()),
Deserialization.memberKind(Flags.MEMBER_KIND.get(flags)),
proto,
@@ -230,7 +231,7 @@ public class MemberDeserializer(private val c: DeserializationContext) {
callable: Callable,
kind: AnnotatedCallableKind,
index: Int,
valueParameter: Callable.ValueParameter
valueParameter: ProtoBuf.ValueParameter
): Annotations {
return DeserializedAnnotations(c.storageManager) {
c.components.annotationAndConstantLoader.loadValueParameterAnnotations(
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter
import org.jetbrains.kotlin.resolve.scopes.JetScopeImpl
import org.jetbrains.kotlin.serialization.Flags
import org.jetbrains.kotlin.serialization.ProtoBuf
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind
import org.jetbrains.kotlin.serialization.ProtoBuf.CallableKind
import org.jetbrains.kotlin.serialization.deserialization.DeserializationContext
import org.jetbrains.kotlin.utils.Printer
import org.jetbrains.kotlin.utils.toReadOnlyList
@@ -26,11 +26,11 @@ import org.jetbrains.kotlin.types.Variance
object Deserialization {
@JvmStatic
fun memberKind(memberKind: ProtoBuf.Callable.MemberKind) = when (memberKind) {
ProtoBuf.Callable.MemberKind.DECLARATION -> CallableMemberDescriptor.Kind.DECLARATION
ProtoBuf.Callable.MemberKind.FAKE_OVERRIDE -> CallableMemberDescriptor.Kind.FAKE_OVERRIDE
ProtoBuf.Callable.MemberKind.DELEGATION -> CallableMemberDescriptor.Kind.DELEGATION
ProtoBuf.Callable.MemberKind.SYNTHESIZED -> CallableMemberDescriptor.Kind.SYNTHESIZED
fun memberKind(memberKind: ProtoBuf.MemberKind) = when (memberKind) {
ProtoBuf.MemberKind.DECLARATION -> CallableMemberDescriptor.Kind.DECLARATION
ProtoBuf.MemberKind.FAKE_OVERRIDE -> CallableMemberDescriptor.Kind.FAKE_OVERRIDE
ProtoBuf.MemberKind.DELEGATION -> CallableMemberDescriptor.Kind.DELEGATION
ProtoBuf.MemberKind.SYNTHESIZED -> CallableMemberDescriptor.Kind.SYNTHESIZED
}
@JvmStatic