[ObjCExport] Add translation of functions and properties extensions
KT-65630
This commit is contained in:
committed by
Space Team
parent
a34b87c63a
commit
30b63e4843
Vendored
+9
-2
@@ -24,11 +24,18 @@ __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)funA __attribute__((swift_name("funA()")));
|
||||
- (void)memberFun __attribute__((swift_name("memberFun()")));
|
||||
@end
|
||||
|
||||
@interface Foo (Extensions)
|
||||
- (void)funB __attribute__((swift_name("funB()")));
|
||||
- (void)extensionFunA __attribute__((swift_name("extensionFunA()")));
|
||||
- (void)extensionFunB __attribute__((swift_name("extensionFunB()")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface FooKt : Base
|
||||
+ (void)topLevelFunA __attribute__((swift_name("topLevelFunA()")));
|
||||
+ (void)topLevelFunB __attribute__((swift_name("topLevelFunB()")));
|
||||
@end
|
||||
|
||||
#pragma pop_macro("_Nullable_result")
|
||||
|
||||
+8
-4
@@ -1,5 +1,9 @@
|
||||
class Foo {
|
||||
fun funA() {}
|
||||
}
|
||||
fun topLevelFunA() {}
|
||||
fun topLevelFunB() {}
|
||||
|
||||
fun Foo.funB() {}
|
||||
fun Foo.extensionFunA() {}
|
||||
fun Foo.extensionFunB() {}
|
||||
|
||||
class Foo {
|
||||
fun memberFun() {}
|
||||
}
|
||||
|
||||
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
#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)memberFun __attribute__((swift_name("memberFun()")));
|
||||
@end
|
||||
|
||||
@interface Foo (Extensions)
|
||||
@property (readonly) int32_t extensionValA __attribute__((swift_name("extensionValA")));
|
||||
@property (readonly) int32_t extensionValB __attribute__((swift_name("extensionValB")));
|
||||
@property int32_t extensionVarA __attribute__((swift_name("extensionVarA")));
|
||||
@property int32_t extensionVarB __attribute__((swift_name("extensionVarB")));
|
||||
@end
|
||||
|
||||
__attribute__((objc_subclassing_restricted))
|
||||
@interface FooKt : Base
|
||||
@property (class, readonly) int32_t topLevelPropA __attribute__((swift_name("topLevelPropA")));
|
||||
@property (class, readonly) int32_t topLevelPropB __attribute__((swift_name("topLevelPropB")));
|
||||
@end
|
||||
|
||||
#pragma pop_macro("_Nullable_result")
|
||||
#pragma clang diagnostic pop
|
||||
NS_ASSUME_NONNULL_END
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
val topLevelPropA = 0
|
||||
val topLevelPropB = 1
|
||||
|
||||
val Foo.extensionValA
|
||||
get() = 0
|
||||
val Foo.extensionValB
|
||||
get() = 1
|
||||
|
||||
var Foo.extensionVarA
|
||||
get() = 0
|
||||
set(value) {}
|
||||
var Foo.extensionVarB
|
||||
get() = 1
|
||||
set(value) {}
|
||||
|
||||
class Foo {
|
||||
fun memberFun() {}
|
||||
}
|
||||
Reference in New Issue
Block a user