org.jetbrains.kotlinx.serialization.compiler.resolve.ISerializableProperties.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kotlin-serialization-compiler-plugin-embeddable Show documentation
Show all versions of kotlin-serialization-compiler-plugin-embeddable Show documentation
Kotlinx Serialization Compiler Plugin.embeddable
The newest version!
/*
* 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.kotlinx.serialization.compiler.resolve
interface ISerializableProperties {
val serializableProperties: List
val isExternallySerializable: Boolean
val serializableConstructorProperties: List
val serializableStandaloneProperties: List
}
val ISerializableProperties<*>.goldenMask: Int
get() {
var goldenMask = 0
var requiredBit = 1
for (property in serializableProperties) {
if (!property.optional) {
goldenMask = goldenMask or requiredBit
}
requiredBit = requiredBit shl 1
}
return goldenMask
}
val ISerializableProperties<*>.goldenMaskList: List
get() {
val maskSlotCount = serializableProperties.bitMaskSlotCount()
val goldenMaskList = MutableList(maskSlotCount) { 0 }
for (i in serializableProperties.indices) {
if (!serializableProperties[i].optional) {
val slotNumber = i / 32
val bitInSlot = i % 32
goldenMaskList[slotNumber] = goldenMaskList[slotNumber] or (1 shl bitInSlot)
}
}
return goldenMaskList
}
fun List.bitMaskSlotCount(): Int = size / 32 + 1
fun bitMaskSlotAt(propertyIndex: Int): Int = propertyIndex / 32
© 2015 - 2025 Weber Informatics LLC | Privacy Policy