Fix #2371
Mangle parameter names clashing with C keywords when producing framework
This commit is contained in:
committed by
SvyatoslavScherbina
parent
ce5a0c34a5
commit
132e12ba3e
+1
-1
@@ -57,7 +57,7 @@ private operator fun String.times(count: Int): String {
|
|||||||
return builder.toString()
|
return builder.toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
private val cKeywords = setOf(
|
internal val cKeywords = setOf(
|
||||||
// Actual C keywords.
|
// Actual C keywords.
|
||||||
"auto", "break", "case",
|
"auto", "break", "case",
|
||||||
"char", "const", "continue",
|
"char", "const", "continue",
|
||||||
|
|||||||
+1
-1
@@ -652,7 +652,7 @@ abstract class ObjCExportHeaderGenerator(
|
|||||||
fun collectParameters(baseMethodBridge: MethodBridge, method: FunctionDescriptor): List<ObjCParameter> {
|
fun collectParameters(baseMethodBridge: MethodBridge, method: FunctionDescriptor): List<ObjCParameter> {
|
||||||
fun unifyName(initialName: String, usedNames: Set<String>): String {
|
fun unifyName(initialName: String, usedNames: Set<String>): String {
|
||||||
var unique = initialName
|
var unique = initialName
|
||||||
while (unique in usedNames) {
|
while (unique in usedNames || unique in cKeywords) {
|
||||||
unique += "_"
|
unique += "_"
|
||||||
}
|
}
|
||||||
return unique
|
return unique
|
||||||
|
|||||||
@@ -240,3 +240,5 @@ fun IC3?.getValueOrNull3() = this?.value
|
|||||||
|
|
||||||
fun isFrozen(obj: Any): Boolean = obj.isFrozen
|
fun isFrozen(obj: Any): Boolean = obj.isFrozen
|
||||||
fun kotlinLambda(block: (Any) -> Any): Any = block
|
fun kotlinLambda(block: (Any) -> Any): Any = block
|
||||||
|
|
||||||
|
fun multiply(int: Int, long: Long) = int * long
|
||||||
|
|||||||
@@ -271,6 +271,8 @@ func testFunctions() throws {
|
|||||||
|
|
||||||
try assertEquals(actual: ValuesKt.argsFun(i: 10, l: 20, d: 3.5, s: "res") as! String,
|
try assertEquals(actual: ValuesKt.argsFun(i: 10, l: 20, d: 3.5, s: "res") as! String,
|
||||||
expected: "res10203.5")
|
expected: "res10203.5")
|
||||||
|
|
||||||
|
try assertEquals(actual: ValuesKt.multiply(int: 3, long: 2), expected: 6)
|
||||||
}
|
}
|
||||||
|
|
||||||
func testFuncType() throws {
|
func testFuncType() throws {
|
||||||
|
|||||||
Reference in New Issue
Block a user