Migrating to 1.3 preview API

This commit is contained in:
Leonid Startsev
2018-08-16 17:45:58 +03:00
parent 359a37c9c3
commit 087f60389a
5 changed files with 14 additions and 10 deletions
@@ -19,7 +19,7 @@
<groupId>org.jetbrains.kotlinx</groupId>
<artifactId>kotlinx-maven-serialization-plugin</artifactId>
<packaging>jar</packaging>
<version>0.5.2-SNAPSHOT</version>
<version>0.7.0-eap-1</version>
<description>Serialization plugin for Maven</description>
<repositories>
@@ -8,9 +8,9 @@ configureJvmProject(project)
configurePublishing(project)
group = 'org.jetbrains.kotlinx'
version = '0.7.1'
version = '0.7.0'
if (!project.hasProperty("deploy")) {
version = "$version-SNAPSHOT"
version = "$version-eap-1"
}
compileJava {
@@ -48,7 +48,7 @@ class SerializationKotlinGradleSubplugin : KotlinGradleSubplugin<AbstractCompile
}
private val log = Logging.getLogger(this.javaClass)
private val pluginVersion = "0.7.1-SNAPSHOT"
private val pluginVersion = "0.7.0-eap-1"
private var useUnshaded = false
override fun isApplicable(project: Project, task: AbstractCompile): Boolean {
@@ -33,6 +33,8 @@ import org.jetbrains.kotlinx.serialization.compiler.backend.jvm.contextSerialize
import org.jetbrains.kotlinx.serialization.compiler.backend.jvm.enumSerializerId
import org.jetbrains.kotlinx.serialization.compiler.backend.jvm.referenceArraySerializerId
import org.jetbrains.kotlinx.serialization.compiler.resolve.*
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.DECODER_CLASS
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.ENCODER_CLASS
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.SERIAL_DESCRIPTOR_CLASS_IMPL
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.STRUCTURE_DECODER_CLASS
import org.jetbrains.kotlinx.serialization.compiler.resolve.SerialEntityNames.STRUCTURE_ENCODER_CLASS
@@ -168,13 +170,14 @@ class SerializerIrGenerator(val irClass: IrClass, override val compilerContext:
IrGetValueImpl(startOffset, endOffset, saveFunc.dispatchReceiverParameter!!.symbol)
val kOutputClass = serializerDescriptor.getClassFromSerializationPackage(STRUCTURE_ENCODER_CLASS)
val kOutputSmallClass = serializerDescriptor.getClassFromSerializationPackage(ENCODER_CLASS)
val descriptorGetterSymbol = compilerContext.localSymbolTable.referenceFunction(anySerialDescProperty?.getter!!) //???
val localSerialDesc = irTemporary(irGet(descriptorGetterSymbol.owner.returnType, irThis(), descriptorGetterSymbol), "desc")
// fun beginStructure(desc: SerialDescriptor, vararg typeParams: KSerializer<*>): StructureEncoder
val beginFunc = kOutputClass.referenceMethod(CallingConventions.begin) // todo: retrieve from actual encoder instead
val beginFunc = kOutputSmallClass.referenceMethod(CallingConventions.begin) // todo: retrieve from actual encoder instead
val call = irCall(beginFunc).mapValueParametersIndexed { i, parameterDescriptor ->
if (i == 0) irGet(localSerialDesc) else IrVarargImpl(
@@ -257,6 +260,7 @@ class SerializerIrGenerator(val irClass: IrClass, override val compilerContext:
fun IrVariable.get() = irGet(this)
val inputClass = serializerDescriptor.getClassFromSerializationPackage(STRUCTURE_DECODER_CLASS)
val inputSmallClass = serializerDescriptor.getClassFromSerializationPackage(DECODER_CLASS)
val descriptorGetterSymbol = compilerContext.localSymbolTable.referenceFunction(anySerialDescProperty?.getter!!) //???
val localSerialDesc = irTemporary(irGet(descriptorGetterSymbol.owner.returnType, irThis(), descriptorGetterSymbol), "desc")
@@ -283,7 +287,7 @@ class SerializerIrGenerator(val irClass: IrClass, override val compilerContext:
}
//input = input.beginStructure(...)
val beginFunc = inputClass.referenceMethod(CallingConventions.begin)
val beginFunc = inputSmallClass.referenceMethod(CallingConventions.begin)
val call = irInvoke(
irGet(loadFunc.valueParameters[0]),
beginFunc,
@@ -33,9 +33,9 @@ object SerialEntityNames {
val IMPL_NAME = Name.identifier("Impl")
const val ENCODER_CLASS = "Encoder"
const val STRUCTURE_ENCODER_CLASS = "StructureEncoder"
const val STRUCTURE_ENCODER_CLASS = "CompositeEncoder"
const val DECODER_CLASS = "Decoder"
const val STRUCTURE_DECODER_CLASS = "StructureDecoder"
const val STRUCTURE_DECODER_CLASS = "CompositeDecoder"
const val SERIAL_SAVER_CLASS = "SerializationStrategy"
const val SERIAL_LOADER_CLASS = "DeserializationStrategy"
@@ -75,8 +75,8 @@ object CallingConventions {
const val decode = "decode"
const val update = "update"
const val encode = "encode"
const val decodeElementIndex = "decodeElement"
const val elementPostfix = "ElementValue"
const val decodeElementIndex = "decodeElementIndex"
const val elementPostfix = "Element"
const val addElement = "addElement"
const val addAnnotation = "pushAnnotation"