Rename "desc" parameters in kotlinx-metadata-jvm to "signature"

This commit is contained in:
Alexander Udalov
2019-05-06 17:58:14 +02:00
parent 4e15b95d17
commit fe52f5fc7c
6 changed files with 97 additions and 91 deletions
@@ -3,6 +3,7 @@
## 0.0.6
- [`KT-31308`](https://youtrack.jetbrains.com/issue/KT-31308) Add module name extensions to kotlinx-metadata-jvm
- Rename `desc` parameters to `signature` in JvmFunctionExtensionVisitor, JvmPropertyExtensionVisitor, JvmConstructorExtensionVisitor
## 0.0.5
@@ -148,9 +148,9 @@ internal class JvmMetadataExtensions : MetadataExtensions {
): KmFunctionExtensionVisitor? {
if (type != JvmFunctionExtensionVisitor.TYPE) return null
return object : JvmFunctionExtensionVisitor() {
override fun visit(desc: JvmMethodSignature?) {
if (desc != null) {
proto.setExtension(JvmProtoBuf.methodSignature, desc.toJvmMethodSignature(c))
override fun visit(signature: JvmMethodSignature?) {
if (signature != null) {
proto.setExtension(JvmProtoBuf.methodSignature, signature.toJvmMethodSignature(c))
}
}
@@ -167,36 +167,38 @@ internal class JvmMetadataExtensions : MetadataExtensions {
return object : JvmPropertyExtensionVisitor() {
var signature: JvmProtoBuf.JvmPropertySignature.Builder? = null
override fun visit(fieldDesc: JvmFieldSignature?, getterDesc: JvmMethodSignature?, setterDesc: JvmMethodSignature?) {
if (fieldDesc == null && getterDesc == null && setterDesc == null) return
override fun visit(
fieldSignature: JvmFieldSignature?, getterSignature: JvmMethodSignature?, setterSignature: JvmMethodSignature?
) {
if (fieldSignature == null && getterSignature == null && setterSignature == null) return
if (signature == null) {
signature = JvmProtoBuf.JvmPropertySignature.newBuilder()
}
signature!!.apply {
if (fieldDesc != null) {
if (fieldSignature != null) {
field = JvmProtoBuf.JvmFieldSignature.newBuilder().also { field ->
field.name = c[fieldDesc.name]
field.desc = c[fieldDesc.desc]
field.name = c[fieldSignature.name]
field.desc = c[fieldSignature.desc]
}.build()
}
if (getterDesc != null) {
getter = getterDesc.toJvmMethodSignature(c)
if (getterSignature != null) {
getter = getterSignature.toJvmMethodSignature(c)
}
if (setterDesc != null) {
setter = setterDesc.toJvmMethodSignature(c)
if (setterSignature != null) {
setter = setterSignature.toJvmMethodSignature(c)
}
}
}
override fun visitSyntheticMethodForAnnotations(desc: JvmMethodSignature?) {
if (desc == null) return
override fun visitSyntheticMethodForAnnotations(signature: JvmMethodSignature?) {
if (signature == null) return
if (signature == null) {
signature = JvmProtoBuf.JvmPropertySignature.newBuilder()
if (this.signature == null) {
this.signature = JvmProtoBuf.JvmPropertySignature.newBuilder()
}
signature!!.syntheticMethod = desc.toJvmMethodSignature(c)
this.signature!!.syntheticMethod = signature.toJvmMethodSignature(c)
}
override fun visitEnd() {
@@ -212,9 +214,9 @@ internal class JvmMetadataExtensions : MetadataExtensions {
): KmConstructorExtensionVisitor? {
if (type != JvmConstructorExtensionVisitor.TYPE) return null
return object : JvmConstructorExtensionVisitor() {
override fun visit(desc: JvmMethodSignature?) {
if (desc != null) {
proto.setExtension(JvmProtoBuf.constructorSignature, desc.toJvmMethodSignature(c))
override fun visit(signature: JvmMethodSignature?) {
if (signature != null) {
proto.setExtension(JvmProtoBuf.constructorSignature, signature.toJvmMethodSignature(c))
}
}
}
@@ -115,10 +115,10 @@ open class JvmFunctionExtensionVisitor @JvmOverloads constructor(
*
* Example: `JvmMethodSignature("equals", "(Ljava/lang/Object;)Z")`
*
* @param desc the signature of the function
* @param signature the signature of the function
*/
open fun visit(desc: JvmMethodSignature?) {
delegate?.visit(desc)
open fun visit(signature: JvmMethodSignature?) {
delegate?.visit(signature)
}
/**
@@ -156,19 +156,17 @@ open class JvmPropertyExtensionVisitor @JvmOverloads constructor(
/**
* Visits JVM signatures of field and accessors generated for the property.
*
* @param fieldDesc the name and the type of the field in the JVM-based format, or `null` if this property has no field.
* Example: `JvmFieldSignature("X", "Ljava/lang/Object;")`
* @param fieldSignature the signature of the field, or `null` if this property has no field.
* Example: `JvmFieldSignature("X", "Ljava/lang/Object;")`
*
* @param getterDesc the signature of the property getter in the JVM-based format,
* or `null` if this property has no getter or its signature is unknown.
* Example: `JvmMethodSignature("getX()", "Ljava/lang/Object;")`
* @param getterSignature the signature of the property getter, or `null` if this property has no getter or its signature is unknown.
* Example: `JvmMethodSignature("getX()", "Ljava/lang/Object;")`
*
* @param setterDesc the signature of the property setter in the JVM-based format,
* or `null` if this property has no setter or its signature is unknown
* Example: `JvmMethodSignature("setX", "(Ljava/lang/Object;)V")`,
* @param setterSignature the signature of the property setter, or `null` if this property has no setter or its signature is unknown.
* Example: `JvmMethodSignature("setX", "(Ljava/lang/Object;)V")`
*/
open fun visit(fieldDesc: JvmFieldSignature?, getterDesc: JvmMethodSignature?, setterDesc: JvmMethodSignature?) {
delegate?.visit(fieldDesc, getterDesc, setterDesc)
open fun visit(fieldSignature: JvmFieldSignature?, getterSignature: JvmMethodSignature?, setterSignature: JvmMethodSignature?) {
delegate?.visit(fieldSignature, getterSignature, setterSignature)
}
/**
@@ -176,10 +174,10 @@ open class JvmPropertyExtensionVisitor @JvmOverloads constructor(
*
* Example: `JvmMethodSignature("getX$annotations", "()V")`
*
* @param desc the signature of the synthetic method
* @param signature the signature of the synthetic method
*/
open fun visitSyntheticMethodForAnnotations(desc: JvmMethodSignature?) {
delegate?.visitSyntheticMethodForAnnotations(desc)
open fun visitSyntheticMethodForAnnotations(signature: JvmMethodSignature?) {
delegate?.visitSyntheticMethodForAnnotations(signature)
}
/**
@@ -207,15 +205,14 @@ open class JvmConstructorExtensionVisitor @JvmOverloads constructor(
private val delegate: JvmConstructorExtensionVisitor? = null
) : KmConstructorExtensionVisitor {
/**
* Visits the JVM signature of the constructor in the JVM-based format,
* or null if the JVM signature of this constructor is unknown.
* Visits the JVM signature of the constructor, or null if the JVM signature of this constructor is unknown.
*
* Example: `JvmMethodSignature("<init>", "(Ljava/lang/Object;)V")`
*
* @param desc the signature of the constructor
* @param signature the signature of the constructor
*/
open fun visit(desc: JvmMethodSignature?) {
delegate?.visit(desc)
open fun visit(signature: JvmMethodSignature?) {
delegate?.visit(signature)
}
companion object {
@@ -41,9 +41,9 @@ class MetadataSmokeTest {
if (type != JvmFunctionExtensionVisitor.TYPE) return null
return object : JvmFunctionExtensionVisitor() {
override fun visit(desc: JvmMethodSignature?) {
if (Flag.Function.IS_INLINE(flags) && desc != null) {
inlineFunctions += desc.asString()
override fun visit(signature: JvmMethodSignature?) {
if (Flag.Function.IS_INLINE(flags) && signature != null) {
inlineFunctions += signature.asString()
}
}
}