[K/N] Replace SymbolName with GCUnsafeCall in interop
This commit is contained in:
+2
-1
@@ -123,7 +123,8 @@ class SimpleBridgeGeneratorImpl(
|
|||||||
val externCPrefix = if (libraryForCStubs.language == Language.CPP) "extern \"C\" " else ""
|
val externCPrefix = if (libraryForCStubs.language == Language.CPP) "extern \"C\" " else ""
|
||||||
val functionName = pkgName.replace(INVALID_CLANG_IDENTIFIER_REGEX, "_") + "_$kotlinFunctionName"
|
val functionName = pkgName.replace(INVALID_CLANG_IDENTIFIER_REGEX, "_") + "_$kotlinFunctionName"
|
||||||
if (independent) kotlinLines.add("@" + topLevelKotlinScope.reference(KotlinTypes.independent))
|
if (independent) kotlinLines.add("@" + topLevelKotlinScope.reference(KotlinTypes.independent))
|
||||||
kotlinLines.add("@SymbolName(${functionName.quoteAsKotlinLiteral()})")
|
// TODO: this should be separate annotation
|
||||||
|
kotlinLines.add("@GCUnsafeCall(${functionName.quoteAsKotlinLiteral()})")
|
||||||
"$externCPrefix$cReturnType $functionName ($joinedCParameters)"
|
"$externCPrefix$cReturnType $functionName ($joinedCParameters)"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -581,7 +581,7 @@ private fun KotlinStubs.createFakeKotlinExternalFunction(
|
|||||||
)
|
)
|
||||||
|
|
||||||
bridge.annotations += buildSimpleAnnotation(irBuiltIns, UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
bridge.annotations += buildSimpleAnnotation(irBuiltIns, UNDEFINED_OFFSET, UNDEFINED_OFFSET,
|
||||||
symbols.symbolName.owner, cFunctionName)
|
symbols.gcUnsafeCall.owner, cFunctionName)
|
||||||
|
|
||||||
if (isObjCMethod) {
|
if (isObjCMethod) {
|
||||||
val methodInfo = signature.getObjCMethodInfo()!!
|
val methodInfo = signature.getObjCMethodInfo()!!
|
||||||
|
|||||||
+2
-1
@@ -130,8 +130,9 @@ private fun createKotlinBridge(
|
|||||||
isInfix = false
|
isInfix = false
|
||||||
)
|
)
|
||||||
if (isExternal) {
|
if (isExternal) {
|
||||||
|
// TODO this should be separate annotation
|
||||||
bridge.annotations += buildSimpleAnnotation(stubs.irBuiltIns, startOffset, endOffset,
|
bridge.annotations += buildSimpleAnnotation(stubs.irBuiltIns, startOffset, endOffset,
|
||||||
stubs.symbols.symbolName.owner, cBridgeName)
|
stubs.symbols.gcUnsafeCall.owner, cBridgeName)
|
||||||
bridge.annotations += buildSimpleAnnotation(stubs.irBuiltIns, startOffset, endOffset,
|
bridge.annotations += buildSimpleAnnotation(stubs.irBuiltIns, startOffset, endOffset,
|
||||||
stubs.symbols.filterExceptions.owner,
|
stubs.symbols.filterExceptions.owner,
|
||||||
foreignExceptionMode.value)
|
foreignExceptionMode.value)
|
||||||
|
|||||||
+1
@@ -110,6 +110,7 @@ internal class KonanSymbols(
|
|||||||
val arrayList = symbolTable.referenceClass(getArrayListClassDescriptor(context))
|
val arrayList = symbolTable.referenceClass(getArrayListClassDescriptor(context))
|
||||||
|
|
||||||
val symbolName = topLevelClass(RuntimeNames.symbolNameAnnotation)
|
val symbolName = topLevelClass(RuntimeNames.symbolNameAnnotation)
|
||||||
|
val gcUnsafeCall = topLevelClass(KonanFqNames.gcUnsafeCall)
|
||||||
val filterExceptions = topLevelClass(RuntimeNames.filterExceptions)
|
val filterExceptions = topLevelClass(RuntimeNames.filterExceptions)
|
||||||
val exportForCppRuntime = topLevelClass(RuntimeNames.exportForCppRuntime)
|
val exportForCppRuntime = topLevelClass(RuntimeNames.exportForCppRuntime)
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -2487,7 +2487,8 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
val result = context.memoryModel == MemoryModel.EXPERIMENTAL && origin == CBridgeOrigin.KOTLIN_TO_C_BRIDGE
|
val result = context.memoryModel == MemoryModel.EXPERIMENTAL && origin == CBridgeOrigin.KOTLIN_TO_C_BRIDGE
|
||||||
if (result) {
|
if (result) {
|
||||||
check(isExternal)
|
check(isExternal)
|
||||||
check(!annotations.hasAnnotation(KonanFqNames.gcUnsafeCall))
|
// TODO: this should be separate annotation
|
||||||
|
// check(!annotations.hasAnnotation(KonanFqNames.gcUnsafeCall))
|
||||||
check(annotations.hasAnnotation(RuntimeNames.filterExceptions))
|
check(annotations.hasAnnotation(RuntimeNames.filterExceptions))
|
||||||
}
|
}
|
||||||
return result
|
return result
|
||||||
|
|||||||
Reference in New Issue
Block a user