[ObjCExport] Fix property setter
KT-64953: Required part for enum translation
This commit is contained in:
committed by
Space Team
parent
576851e514
commit
8f2fc3d1e2
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#pragma push_macro("_Nullable_result")
|
||||
#if !__has_feature(nullability_nullable_result)
|
||||
#undef _Nullable_result
|
||||
#define _Nullable_result _Nullable
|
||||
#endif
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface FooKt : Base
|
||||
+ (void)funParamParam:(void (^)(void))param __attribute__((swift_name("funParam(param:)")));
|
||||
+ (void)funParamDefaultParam:(void (^)(void))param __attribute__((swift_name("funParamDefault(param:)")));
|
||||
+ (void (^)(void))funReturnsFun __attribute__((swift_name("funReturnsFun()")));
|
||||
+ (void (^ _Nullable)(void))funReturnsNullableFun __attribute__((swift_name("funReturnsNullableFun()")));
|
||||
@property (class, readonly) void (^funProperty)(void) __attribute__((swift_name("funProperty")));
|
||||
@end
|
||||
|
||||
#pragma pop_macro("_Nullable_result")
|
||||
#pragma clang diagnostic pop
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,5 @@
|
||||
val funProperty: () -> Unit = {}
|
||||
fun funParam(param: () -> Unit) {}
|
||||
fun funParamDefault(param: () -> Unit = {}) {}
|
||||
fun funReturnsFun(): () -> Unit = {}
|
||||
fun funReturnsNullableFun(): (() -> Unit)? = null
|
||||
+5
@@ -30,6 +30,11 @@ __attribute__((objc_subclassing_restricted))
|
||||
- (instancetype)initWithA:(int32_t)a b:(int32_t)b c:(int32_t)c __attribute__((swift_name("init(a:b:c:)"))) __attribute__((objc_designated_initializer));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface ConstructorFunction : Base
|
||||
- (instancetype)initWithFoo:(void (^)(void))foo __attribute__((swift_name("init(foo:)"))) __attribute__((objc_designated_initializer));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface ConstructorParam0 : Base
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
|
||||
@@ -7,4 +7,6 @@ class ConstructorDouble(a: Int) {
|
||||
constructor(a: Int): this(a)
|
||||
constructor(a: Int, b: Int): this(b)
|
||||
constructor(a: Int, b: Int, c: Int): this(c)
|
||||
}
|
||||
}
|
||||
|
||||
class ConstructorFunction(foo: () -> Unit)
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#pragma push_macro("_Nullable_result")
|
||||
#if !__has_feature(nullability_nullable_result)
|
||||
#undef _Nullable_result
|
||||
#define _Nullable_result _Nullable
|
||||
#endif
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface FooKt : Base
|
||||
@property (class, readonly) int32_t objcValName __attribute__((swift_name("swiftValName")));
|
||||
@property (class) int32_t objcVaRName __attribute__((swift_name("swiftVaRName")));
|
||||
@end
|
||||
|
||||
#pragma pop_macro("_Nullable_result")
|
||||
#pragma clang diagnostic pop
|
||||
NS_ASSUME_NONNULL_END
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
@file:OptIn(ExperimentalObjCName::class)
|
||||
|
||||
import kotlin.experimental.ExperimentalObjCName
|
||||
|
||||
@kotlin.native.ObjCName("objcValName", "swiftValName")
|
||||
val valProperty = 42
|
||||
|
||||
@kotlin.native.ObjCName("objcVaRName", "swiftVaRName")
|
||||
var varProperty = 42
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#pragma push_macro("_Nullable_result")
|
||||
#if !__has_feature(nullability_nullable_result)
|
||||
#undef _Nullable_result
|
||||
#define _Nullable_result _Nullable
|
||||
#endif
|
||||
|
||||
@protocol Foo
|
||||
@required
|
||||
- (void)invoke __attribute__((swift_name("invoke()")));
|
||||
@end
|
||||
|
||||
#pragma pop_macro("_Nullable_result")
|
||||
#pragma clang diagnostic pop
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,3 @@
|
||||
fun interface Foo {
|
||||
fun invoke()
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
@class SimpleDataClass;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#pragma push_macro("_Nullable_result")
|
||||
#if !__has_feature(nullability_nullable_result)
|
||||
#undef _Nullable_result
|
||||
#define _Nullable_result _Nullable
|
||||
#endif
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface SimpleDataClass : Base
|
||||
- (instancetype)initWithIntValue:(int32_t)intValue intVar:(int32_t)intVar nullableDefaultStringValue:(NSString * _Nullable)nullableDefaultStringValue __attribute__((swift_name("init(intValue:intVar:nullableDefaultStringValue:)"))) __attribute__((objc_designated_initializer));
|
||||
- (SimpleDataClass *)doCopyIntValue:(int32_t)intValue intVar:(int32_t)intVar nullableDefaultStringValue:(NSString * _Nullable)nullableDefaultStringValue __attribute__((swift_name("doCopy(intValue:intVar:nullableDefaultStringValue:)")));
|
||||
- (BOOL)isEqual:(id _Nullable)other __attribute__((swift_name("isEqual(_:)")));
|
||||
- (NSUInteger)hash __attribute__((swift_name("hash()")));
|
||||
- (NSString *)description __attribute__((swift_name("description()")));
|
||||
@property (readonly) int32_t intValue __attribute__((swift_name("intValue")));
|
||||
@property int32_t intVar __attribute__((swift_name("intVar")));
|
||||
@property (readonly) NSString * _Nullable nullableDefaultStringValue __attribute__((swift_name("nullableDefaultStringValue")));
|
||||
@end
|
||||
|
||||
#pragma pop_macro("_Nullable_result")
|
||||
#pragma clang diagnostic pop
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,5 @@
|
||||
data class SimpleDataClass(
|
||||
val intValue: Int,
|
||||
var intVar: Int,
|
||||
val nullableDefaultStringValue: String? = ""
|
||||
)
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
#import <Foundation/NSArray.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSObject.h>
|
||||
#import <Foundation/NSSet.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import <Foundation/NSValue.h>
|
||||
|
||||
@class Foo;
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunknown-warning-option"
|
||||
#pragma clang diagnostic ignored "-Wincompatible-property-type"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
|
||||
#pragma push_macro("_Nullable_result")
|
||||
#if !__has_feature(nullability_nullable_result)
|
||||
#undef _Nullable_result
|
||||
#define _Nullable_result _Nullable
|
||||
#endif
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface Foo : Base
|
||||
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
|
||||
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
|
||||
- (void)doAlloc __attribute__((swift_name("doAlloc()")));
|
||||
- (Foo *)doCopy __attribute__((swift_name("doCopy()")));
|
||||
- (Foo *)doInit __attribute__((swift_name("doInit()")));
|
||||
- (Foo *)doMutableCopy __attribute__((swift_name("doMutableCopy()")));
|
||||
- (Foo *)doNew __attribute__((swift_name("doNew()")));
|
||||
@end
|
||||
|
||||
#pragma pop_macro("_Nullable_result")
|
||||
#pragma clang diagnostic pop
|
||||
NS_ASSUME_NONNULL_END
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
fun alloc() {}
|
||||
fun copy(): Foo = Foo()
|
||||
fun mutableCopy(): Foo = Foo()
|
||||
fun new(): Foo = Foo()
|
||||
fun init(): Foo = Foo()
|
||||
}
|
||||
+2
-1
@@ -20,7 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface FooKt : Base
|
||||
@property (class, readonly) int32_t myTopLevelProperty __attribute__((swift_name("myTopLevelProperty")));
|
||||
@property (class, readonly) int32_t topLevelVal __attribute__((swift_name("topLevelVal")));
|
||||
@property (class) int32_t topLevelVar __attribute__((swift_name("topLevelVar")));
|
||||
@end
|
||||
|
||||
#pragma pop_macro("_Nullable_result")
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
val myTopLevelProperty = 42
|
||||
val topLevelVal = 42
|
||||
var topLevelVar = 42
|
||||
Reference in New Issue
Block a user