[K/N] De-duplicate code for mangling objc interop function names
Extract the duplicated functionality to the `ObjCFunctionNameMangleComputer` class.
This commit is contained in:
committed by
teamcity
parent
0fd4f10f6c
commit
e3b5dc509c
+8
-5
@@ -42,12 +42,12 @@ abstract class BaseKotlinMangleComputer<Declaration, Type, TypeParameter, ValueP
|
||||
|
||||
protected val typeParameterContainers = ArrayList<TypeParameterContainer>(4)
|
||||
|
||||
protected open fun FunctionDeclaration.platformSpecificFunctionName(): String? = null
|
||||
protected open fun makePlatformSpecificFunctionNameMangleComputer(
|
||||
function: FunctionDeclaration
|
||||
): PlatformSpecificFunctionNameMangleComputer<ValueParameter> = PlatformSpecificFunctionNameMangleComputer.Default
|
||||
|
||||
protected open fun FunctionDeclaration.platformSpecificSuffix(): String? = null
|
||||
|
||||
protected open fun FunctionDeclaration.specialValueParamPrefix(param: ValueParameter): String = ""
|
||||
|
||||
protected open fun addReturnType(): Boolean = false
|
||||
|
||||
protected open fun addReturnTypeSpecialCase(function: FunctionDeclaration): Boolean = false
|
||||
@@ -145,7 +145,7 @@ abstract class BaseKotlinMangleComputer<Declaration, Type, TypeParameter, ValueP
|
||||
|
||||
builder.appendName(MangleConstant.FUNCTION_NAME_PREFIX)
|
||||
|
||||
platformSpecificFunctionName()?.let {
|
||||
makePlatformSpecificFunctionNameMangleComputer(this).computePlatformSpecificFunctionName()?.let {
|
||||
builder.append(it)
|
||||
return
|
||||
}
|
||||
@@ -180,7 +180,10 @@ abstract class BaseKotlinMangleComputer<Declaration, Type, TypeParameter, ValueP
|
||||
}
|
||||
|
||||
getValueParameters(this).collectForMangler(builder, MangleConstant.VALUE_PARAMETERS) {
|
||||
appendSignature(specialValueParamPrefix(it))
|
||||
appendSignature(
|
||||
makePlatformSpecificFunctionNameMangleComputer(this@mangleSignature)
|
||||
.computePlatformSpecificValueParameterPrefix(it)
|
||||
)
|
||||
mangleValueParameter(this, it, session)
|
||||
}
|
||||
|
||||
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright 2010-2023 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.backend.common.serialization.mangle
|
||||
|
||||
interface PlatformSpecificFunctionNameMangleComputer<in ValueParameter : Any> {
|
||||
|
||||
fun computePlatformSpecificFunctionName(): String?
|
||||
|
||||
fun computePlatformSpecificValueParameterPrefix(valueParameter: ValueParameter): String
|
||||
|
||||
object Default : PlatformSpecificFunctionNameMangleComputer<Any> {
|
||||
|
||||
override fun computePlatformSpecificFunctionName(): String? = null
|
||||
|
||||
override fun computePlatformSpecificValueParameterPrefix(valueParameter: Any): String = ""
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user