[Native] Add HiddenFromObjC and ShouldRefineInSwift annotations

This commit is contained in:
Rick Clephas
2022-08-19 16:44:05 +02:00
committed by SvyatoslavScherbina
parent a65cb947d6
commit 6ae517a2df
14 changed files with 399 additions and 3 deletions
@@ -6,6 +6,7 @@
package kotlin.native
import kotlin.experimental.ExperimentalObjCName
import kotlin.experimental.ExperimentalObjCRefinement
/**
* Makes top level function available from C/C++ code with the given name.
@@ -65,3 +66,62 @@ expect annotation class FreezingIsDeprecated
@OptionalExpectation
@ExperimentalObjCName
public expect annotation class ObjCName(val name: String = "", val swiftName: String = "", val exact: Boolean = false)
/**
* Meta-annotation that instructs the Kotlin compiler to remove the annotated function or property from the public Objective-C API.
*
* Annotation processors that refine the public Objective-C API can annotate their annotations with this meta-annotation
* to have the original declarations automatically removed from the public API.
*
* Note: only annotations with [AnnotationTarget.FUNCTION] and/or [AnnotationTarget.PROPERTY] are supported.
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
@Retention(AnnotationRetention.BINARY)
@MustBeDocumented
@OptionalExpectation
@ExperimentalObjCRefinement
public expect annotation class HidesFromObjC()
/**
* Instructs the Kotlin compiler to remove this function or property from the public Objective-C API.
*/
@HidesFromObjC
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
@MustBeDocumented
@OptionalExpectation
@ExperimentalObjCRefinement
public expect annotation class HiddenFromObjC()
/**
* Meta-annotation that instructs the Kotlin compiler to mark the annotated function or property as
* `swift_private` in the generated Objective-C API.
*
* Annotation processors that refine the public API in Swift can annotate their annotations with this meta-annotation
* to automatically hide the annotated declarations from Swift.
*
* See Apple's documentation of the [`NS_REFINED_FOR_SWIFT`](https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/improving_objective-c_api_declarations_for_swift)
* macro for more information on refining Objective-C declarations in Swift.
*
* Note: only annotations with [AnnotationTarget.FUNCTION] and/or [AnnotationTarget.PROPERTY] are supported.
*/
@Target(AnnotationTarget.ANNOTATION_CLASS)
@Retention(AnnotationRetention.BINARY)
@MustBeDocumented
@OptionalExpectation
@ExperimentalObjCRefinement
public expect annotation class RefinesInSwift()
/**
* Instructs the Kotlin compiler to mark this function or property as `swift_private` in the generated Objective-C API.
*
* See Apple's documentation of the [`NS_REFINED_FOR_SWIFT`](https://developer.apple.com/documentation/swift/objective-c_and_c_code_customization/improving_objective-c_api_declarations_for_swift)
* macro for more information on refining Objective-C declarations in Swift.
*/
@RefinesInSwift
@Target(AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.BINARY)
@MustBeDocumented
@OptionalExpectation
@ExperimentalObjCRefinement
public expect annotation class ShouldRefineInSwift()
@@ -0,0 +1,15 @@
/*
* Copyright 2010-2022 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 kotlin.experimental
/**
* This annotation marks the experimental Objective-C export refinement annotations.
*/
@RequiresOptIn
@Target(AnnotationTarget.ANNOTATION_CLASS)
@Retention(AnnotationRetention.BINARY)
@MustBeDocumented
public annotation class ExperimentalObjCRefinement