From 28e9add9b93f0a643004761d99adb6a61c37d83c Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Wed, 5 Feb 2020 20:12:56 +0700 Subject: [PATCH] [StubIr][Metadata] Support global arrays --- .../native/interop/gen/StubIrElementBuilders.kt | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/StubIrElementBuilders.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/StubIrElementBuilders.kt index 2167068d0f3..55a6687f51f 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/StubIrElementBuilders.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/StubIrElementBuilders.kt @@ -605,9 +605,20 @@ internal class GlobalStubBuilder( val kind: PropertyStub.Kind if (unwrappedType is ArrayType) { kotlinType = (mirror as TypeMirror.ByValue).valueType - val getter = PropertyAccessor.Getter.SimpleGetter() - val extra = BridgeGenerationInfo(global.name, mirror.info) - context.bridgeComponentsBuilder.arrayGetterBridgeInfo[getter] = extra + val getter = when (context.platform) { + KotlinPlatform.JVM -> { + PropertyAccessor.Getter.SimpleGetter().also { + val extra = BridgeGenerationInfo(global.name, mirror.info) + context.bridgeComponentsBuilder.arrayGetterBridgeInfo[it] = extra + } + } + KotlinPlatform.NATIVE -> { + val cCallAnnotation = AnnotationStub.CCall.Symbol("${context.generateNextUniqueId("knifunptr_")}_${global.name}_getter") + PropertyAccessor.Getter.ExternalGetter(listOf(cCallAnnotation)).also { + context.wrapperComponentsBuilder.getterToWrapperInfo[it] = WrapperGenerationInfo(global) + } + } + } kind = PropertyStub.Kind.Val(getter) } else { when (mirror) {