Introduce KlibMetadataHeaderFlags
This class lists possible flags for KlibMetadataProtoBuf.Header, and helps avoid using magic constants in the source code.
This commit is contained in:
committed by
Space Team
parent
d9ba950d7b
commit
0f63cfecbd
+2
-1
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.backend.common.serialization.isSerializableExpectCla
|
||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataHeaderFlags
|
||||
import org.jetbrains.kotlin.library.metadata.KlibMetadataProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.ProtoBuf
|
||||
import org.jetbrains.kotlin.metadata.deserialization.BinaryVersion
|
||||
@@ -255,7 +256,7 @@ fun serializeKlibHeader(
|
||||
header.moduleName = moduleDescriptor.name.asString()
|
||||
|
||||
if (languageVersionSettings.isPreRelease()) {
|
||||
header.flags = 1
|
||||
header.flags = KlibMetadataHeaderFlags.PRE_RELEASE
|
||||
}
|
||||
|
||||
fragmentNames.forEach {
|
||||
|
||||
@@ -25,7 +25,7 @@ option optimize_for = LITE_RUNTIME;
|
||||
message Header {
|
||||
required string module_name = 1;
|
||||
/*
|
||||
0x1 = preRelease
|
||||
Possible values are listed in KlibMetadataHeaderFlags class.
|
||||
*/
|
||||
optional int32 flags = 2;
|
||||
optional org.jetbrains.kotlin.metadata.StringTable strings = 4;
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ class KlibDeserializedContainerSource private constructor(
|
||||
|
||||
constructor(header: Header, configuration: DeserializationConfiguration, packageFqName: FqName) : this(
|
||||
configuration.reportErrorsOnPreReleaseDependencies &&
|
||||
(header.flags and 1) != 0,
|
||||
(header.flags and KlibMetadataHeaderFlags.PRE_RELEASE) != 0,
|
||||
"Package '$packageFqName'"
|
||||
)
|
||||
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.library.metadata
|
||||
|
||||
/**
|
||||
* Possible values for [KlibMetadataProtoBuf.Header] flags field.
|
||||
*/
|
||||
object KlibMetadataHeaderFlags {
|
||||
const val PRE_RELEASE = 0x1
|
||||
}
|
||||
Reference in New Issue
Block a user