[KT-52681] Remove unnecessary semicolon after Objective-C @end

Objective-c `@end` doesn't need a semicolon, however KMM exported header
file, for instance:
```
__attribute__((swift_name("KotlinIterator")))
@protocol MyProjectKotlinIterator
@required
- (BOOL)hasNext __attribute__((swift_name("hasNext()")));
- (id _Nullable)next __attribute__((swift_name("next()")));
@end;
```
This creates problems with some code checkers that will not expect it
there, so it seems best to remove it.
This commit is contained in:
Diego Gomez Olvera
2022-06-08 14:13:52 +02:00
committed by SvyatoslavScherbina
parent 3840d09314
commit 9a430efbe7
59 changed files with 938 additions and 938 deletions
@@ -558,7 +558,7 @@ internal class ObjCCategoryStubBuilder(
val description = "${category.clazz.name} (${category.name})" val description = "${category.clazz.name} (${category.name})"
val meta = StubContainerMeta( val meta = StubContainerMeta(
"// @interface $description", "// @interface $description",
"// @end; // $description" "// @end // $description"
) )
val container = SimpleStubContainer( val container = SimpleStubContainer(
meta = meta, meta = meta,
@@ -50,7 +50,7 @@ object StubRenderer {
+renderProtocolHeader() +renderProtocolHeader()
+"@required" +"@required"
renderMembers(this, shouldExportKDoc) renderMembers(this, shouldExportKDoc)
+"@end;" +"@end"
} }
is ObjCInterface -> { is ObjCInterface -> {
attributes.forEach { attributes.forEach {
@@ -58,7 +58,7 @@ object StubRenderer {
} }
+renderInterfaceHeader() +renderInterfaceHeader()
renderMembers(this, shouldExportKDoc) renderMembers(this, shouldExportKDoc)
+"@end;" +"@end"
} }
is ObjCMethod -> { is ObjCMethod -> {
+renderMethod(this) +renderMethod(this)
@@ -3,7 +3,7 @@
#import <Foundation/NSUUID.h> #import <Foundation/NSUUID.h>
@interface MyClass1 : NSObject @interface MyClass1 : NSObject
@end; @end
@interface MyClass2 : NSObject @interface MyClass2 : NSObject
@end; @end
@@ -8,7 +8,7 @@
+ (double)doubleFn; + (double)doubleFn;
+ (simd_float4)simdFn; + (simd_float4)simdFn;
@end; @end
typedef struct { typedef struct {
float f; float f;
@@ -65,4 +65,4 @@ typedef struct {
+ (GeterogeneousSmall)geterogeneousSmallFn; + (GeterogeneousSmall)geterogeneousSmallFn;
@end; @end
@@ -23,7 +23,7 @@
return v; return v;
} }
@end; @end
@implementation AggregateTestSubject @implementation AggregateTestSubject
@@ -78,4 +78,4 @@
return (simd_quatf){ {1, 4, 9, 25} }; return (simd_quatf){ {1, 4, 9, 25} };
} }
@end; @end
@@ -7,7 +7,7 @@
@protocol Printer; @protocol Printer;
@protocol Empty @protocol Empty
@end; @end
@protocol Forward; @protocol Forward;
@class Forward; @class Forward;
@@ -20,16 +20,16 @@ typedef NSString NSStringTypedef;
@interface Foo : NSObject <Empty> @interface Foo : NSObject <Empty>
@property NSStringTypedef* name; @property NSStringTypedef* name;
-(void)helloWithPrinter:(id <Printer>)printer; -(void)helloWithPrinter:(id <Printer>)printer;
@end; @end
@interface Foo (FooExtensions) @interface Foo (FooExtensions)
-(void)hello; -(void)hello;
@end; @end
@protocol Printer @protocol Printer
@required @required
-(void)print:(const char*)string; -(void)print:(const char*)string;
@end; @end
@protocol MutablePair @protocol MutablePair
@required @required
@@ -39,7 +39,7 @@ typedef NSString NSStringTypedef;
-(void)update:(int)index add:(int)delta; -(void)update:(int)index add:(int)delta;
-(void)update:(int)index sub:(int)delta; -(void)update:(int)index sub:(int)delta;
@end; @end
void replacePairElements(id <MutablePair> pair, int first, int second); void replacePairElements(id <MutablePair> pair, int first, int second);
@@ -70,7 +70,7 @@ typedef NS_ENUM(int32_t, ForwardDeclaredEnum) {
@protocol ObjectFactory @protocol ObjectFactory
@required @required
-(id)create; -(id)create;
@end; @end
id createObjectWithFactory(id<ObjectFactory> factory) { id createObjectWithFactory(id<ObjectFactory> factory) {
return [factory create]; return [factory create];
@@ -82,15 +82,15 @@ id createObjectWithFactory(id<ObjectFactory> factory) {
-(void)consume:(id) __attribute__((ns_consumed)) obj; -(void)consume:(id) __attribute__((ns_consumed)) obj;
-(void)consumeSelf __attribute__((ns_consumes_self)); -(void)consumeSelf __attribute__((ns_consumes_self));
-(void (^)(void))returnRetainedBlock:(void (^)(void))block __attribute__((ns_returns_retained)); -(void (^)(void))returnRetainedBlock:(void (^)(void))block __attribute__((ns_returns_retained));
@end; @end
extern BOOL unexpectedDeallocation; extern BOOL unexpectedDeallocation;
@interface MustNotBeDeallocated : NSObject @interface MustNotBeDeallocated : NSObject
@end; @end
@interface CustomRetainMethodsImpl : MustNotBeDeallocated <CustomRetainMethods> @interface CustomRetainMethodsImpl : MustNotBeDeallocated <CustomRetainMethods>
@end; @end
static MustNotBeDeallocated* retainedObj; static MustNotBeDeallocated* retainedObj;
static void (^retainedBlock)(void); static void (^retainedBlock)(void);
@@ -4,14 +4,14 @@
@interface CPrinter : NSObject <Printer> @interface CPrinter : NSObject <Printer>
-(void)print:(const char*)string; -(void)print:(const char*)string;
@end; @end
@implementation CPrinter @implementation CPrinter
-(void)print:(const char*)string { -(void)print:(const char*)string {
printf("%s\n", string); printf("%s\n", string);
fflush(stdout); fflush(stdout);
} }
@end; @end
@implementation Foo @implementation Foo
@@ -33,7 +33,7 @@
printf("Deallocated\n"); printf("Deallocated\n");
} }
@end; @end
@implementation Foo (FooExtensions) @implementation Foo (FooExtensions)
@@ -41,7 +41,7 @@
CPrinter* printer = [[CPrinter alloc] init]; CPrinter* printer = [[CPrinter alloc] init];
[self helloWithPrinter:printer]; [self helloWithPrinter:printer];
} }
@end; @end
void replacePairElements(id <MutablePair> pair, int first, int second) { void replacePairElements(id <MutablePair> pair, int first, int second) {
[pair update:0 add:(first - pair.first)]; [pair update:0 add:(first - pair.first)];
@@ -75,7 +75,7 @@ BOOL unexpectedDeallocation = NO;
-(void)dealloc { -(void)dealloc {
unexpectedDeallocation = YES; unexpectedDeallocation = YES;
} }
@end; @end
static CustomRetainMethodsImpl* retainedCustomRetainMethodsImpl; static CustomRetainMethodsImpl* retainedCustomRetainMethodsImpl;
@@ -94,4 +94,4 @@ static CustomRetainMethodsImpl* retainedCustomRetainMethodsImpl;
-(void (^)(void))returnRetainedBlock:(void (^)(void))block __attribute__((ns_returns_retained)) { -(void (^)(void))returnRetainedBlock:(void (^)(void))block __attribute__((ns_returns_retained)) {
return block; return block;
} }
@end; @end
@@ -8,5 +8,5 @@
@property (nonatomic, readonly) NSObject *copyValue; @property (nonatomic, readonly) NSObject *copyValue;
@property (nonatomic, readonly) NSObject *mutableCopyValue; @property (nonatomic, readonly) NSObject *mutableCopyValue;
@end; @end
@@ -17,4 +17,4 @@
return nil; return nil;
} }
@end; @end
@@ -2,8 +2,8 @@
@protocol KT38234_P1 @protocol KT38234_P1
-(int)foo; -(int)foo;
@end; @end
@interface KT38234_Base : NSObject <KT38234_P1> @interface KT38234_Base : NSObject <KT38234_P1>
-(int)callFoo; -(int)callFoo;
@end; @end
@@ -7,4 +7,4 @@
-(int)callFoo { -(int)callFoo {
return [self foo]; return [self foo];
} }
@end; @end
@@ -2,4 +2,4 @@
@interface TestAllocNoRetain : NSObject @interface TestAllocNoRetain : NSObject
@property BOOL ok; @property BOOL ok;
@end; @end
@@ -11,4 +11,4 @@
} }
return self; return self;
} }
@end; @end
@@ -3,7 +3,7 @@
@protocol BlockProvider @protocol BlockProvider
@required @required
-(int (^)(int)) block; -(int (^)(int)) block;
@end; @end
int callProvidedBlock(id<BlockProvider> blockProvider, int argument) { int callProvidedBlock(id<BlockProvider> blockProvider, int argument) {
return [blockProvider block](argument); return [blockProvider block](argument);
@@ -12,7 +12,7 @@ int callProvidedBlock(id<BlockProvider> blockProvider, int argument) {
@protocol BlockConsumer @protocol BlockConsumer
@required @required
-(int)callBlock:(int (^)(int))block argument:(int)argument; -(int)callBlock:(int (^)(int))block argument:(int)argument;
@end; @end
int callPlusOneBlock(id<BlockConsumer> blockConsumer, int argument) { int callPlusOneBlock(id<BlockConsumer> blockConsumer, int argument) {
return [blockConsumer callBlock:^int(int p) { return p + 1; } argument:argument]; return [blockConsumer callBlock:^int(int p) { return p + 1; } argument:argument];
@@ -24,4 +24,4 @@ int callPlusOneBlock(id<BlockConsumer> blockConsumer, int argument) {
@property (class) void (^nullBlock)(void); @property (class) void (^nullBlock)(void);
@property (class) void (^notNullBlock)(void); @property (class) void (^notNullBlock)(void);
@end; @end
@@ -17,4 +17,4 @@
return ^{}; return ^{};
} }
@end; @end
@@ -4,4 +4,4 @@
@property int value; @property int value;
- (int)instanceMethod; - (int)instanceMethod;
+ (int)classMethod:(int)first :(int)second; + (int)classMethod:(int)first :(int)second;
@end; @end
@@ -8,4 +8,4 @@
+ (int)classMethod:(int)first :(int)second { + (int)classMethod:(int)first :(int)second {
return first + second; return first + second;
} }
@end; @end
@@ -6,17 +6,17 @@
-(NSString*)toString_; -(NSString*)toString_;
-(int)hashCode; -(int)hashCode;
-(BOOL)equals:(id _Nullable)other; -(BOOL)equals:(id _Nullable)other;
@end; @end
@interface TestClashingWithAny2 : NSObject @interface TestClashingWithAny2 : NSObject
-(void)toString; -(void)toString;
-(void)hashCode; -(void)hashCode;
-(void)equals:(int)p; // May clash. -(void)equals:(int)p; // May clash.
@end; @end
@interface TestClashingWithAny3 : NSObject @interface TestClashingWithAny3 : NSObject
// Not clashing actually. // Not clashing actually.
-(NSString*)toString:(int)p; -(NSString*)toString:(int)p;
-(int)hashCode:(int)p; -(int)hashCode:(int)p;
-(BOOL)equals; -(BOOL)equals;
@end; @end
@@ -24,7 +24,7 @@
-(BOOL)equals:(id _Nullable)other { -(BOOL)equals:(id _Nullable)other {
return YES; return YES;
} }
@end; @end
@implementation TestClashingWithAny2 @implementation TestClashingWithAny2
-(NSString*)description { -(NSString*)description {
@@ -43,7 +43,7 @@
-(void)equals:(int)p { -(void)equals:(int)p {
} }
@end; @end
@implementation TestClashingWithAny3 @implementation TestClashingWithAny3
-(NSString*)description { -(NSString*)description {
@@ -65,4 +65,4 @@
-(BOOL)equals { -(BOOL)equals {
return YES; return YES;
} }
@end; @end
@@ -2,4 +2,4 @@
@interface TestConstructorReturnsNull : NSObject @interface TestConstructorReturnsNull : NSObject
- (instancetype)init; - (instancetype)init;
@end; @end
@@ -4,4 +4,4 @@
- (instancetype)init { - (instancetype)init {
return nil; return nil;
} }
@end; @end
@@ -3,7 +3,7 @@
@interface CustomString : NSString @interface CustomString : NSString
- (instancetype)initWithValue:(int)value; - (instancetype)initWithValue:(int)value;
@property int value; @property int value;
@end; @end
CustomString* _Nonnull createCustomString(int value) { CustomString* _Nonnull createCustomString(int value) {
return [[CustomString alloc] initWithValue:value]; return [[CustomString alloc] initWithValue:value];
@@ -29,4 +29,4 @@ BOOL customStringDeallocated = NO;
- (void)dealloc { - (void)dealloc {
customStringDeallocated = YES; customStringDeallocated = YES;
} }
@end; @end
@@ -2,8 +2,8 @@
@protocol ExceptionThrower @protocol ExceptionThrower
-(void)throwException; -(void)throwException;
@end; @end
@interface ExceptionThrowerManager : NSObject @interface ExceptionThrowerManager : NSObject
+(void)throwExceptionWith:(id<ExceptionThrower>)thrower; +(void)throwExceptionWith:(id<ExceptionThrower>)thrower;
@end; @end
@@ -4,4 +4,4 @@
+(void)throwExceptionWith:(id<ExceptionThrower>)thrower { +(void)throwExceptionWith:(id<ExceptionThrower>)thrower {
[thrower throwException]; [thrower throwException];
} }
@end; @end
@@ -5,4 +5,4 @@
@property BOOL custom; @property BOOL custom;
+(instancetype _Nonnull)createCustom; +(instancetype _Nonnull)createCustom;
@end; @end
@@ -20,4 +20,4 @@
return [[self alloc] initCustom]; return [[self alloc] initCustom];
} }
@end; @end
@@ -5,6 +5,6 @@ NS_ASSUME_NONNULL_BEGIN
@interface KT38850Color : NSObject @interface KT38850Color : NSObject
+(instancetype)blackColor; +(instancetype)blackColor;
@property NSString* name; @property NSString* name;
@end; @end
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
@@ -6,4 +6,4 @@
result.name = @"black"; result.name = @"black";
return result; return result;
} }
@end; @end
@@ -3,22 +3,22 @@
extern BOOL deallocRetainReleaseDeallocated; extern BOOL deallocRetainReleaseDeallocated;
@interface DeallocRetainRelease : NSObject @interface DeallocRetainRelease : NSObject
@end; @end
extern DeallocRetainRelease* globalDeallocRetainRelease; extern DeallocRetainRelease* globalDeallocRetainRelease;
@protocol WeakReference @protocol WeakReference
@required @required
@property (weak) id referent; @property (weak) id referent;
@end; @end
@interface ObjCWeakReference : NSObject <WeakReference> @interface ObjCWeakReference : NSObject <WeakReference>
@property (weak) id referent; @property (weak) id referent;
@end; @end
extern id <WeakReference> weakDeallocLoadWeak; extern id <WeakReference> weakDeallocLoadWeak;
extern BOOL deallocLoadWeakDeallocated; extern BOOL deallocLoadWeakDeallocated;
@interface DeallocLoadWeak : NSObject @interface DeallocLoadWeak : NSObject
-(void)checkWeak; -(void)checkWeak;
@end; @end
@@ -13,12 +13,12 @@ BOOL deallocRetainReleaseDeallocated = NO;
assert(!deallocRetainReleaseDeallocated); assert(!deallocRetainReleaseDeallocated);
deallocRetainReleaseDeallocated = YES; deallocRetainReleaseDeallocated = YES;
} }
@end; @end
DeallocRetainRelease* globalDeallocRetainRelease = nil; DeallocRetainRelease* globalDeallocRetainRelease = nil;
@implementation ObjCWeakReference @implementation ObjCWeakReference
@end; @end
id <WeakReference> weakDeallocLoadWeak = nil; id <WeakReference> weakDeallocLoadWeak = nil;
BOOL deallocLoadWeakDeallocated = NO; BOOL deallocLoadWeakDeallocated = NO;
@@ -36,4 +36,4 @@ BOOL deallocLoadWeakDeallocated = NO;
assert(!deallocLoadWeakDeallocated); assert(!deallocLoadWeakDeallocated);
deallocLoadWeakDeallocated = YES; deallocLoadWeakDeallocated = YES;
} }
@end; @end
@@ -5,6 +5,6 @@ extern id kt42482Global;
@interface KT42482 : NSObject @interface KT42482 : NSObject
-(int)fortyTwo; -(int)fortyTwo;
@end; @end
void kt42482Swizzle(id obj); void kt42482Swizzle(id obj);
@@ -13,7 +13,7 @@ id kt42482Global = nil;
-(void)dealloc { -(void)dealloc {
kt42482Deallocated = YES; kt42482Deallocated = YES;
} }
@end; @end
int fortyTwoSwizzledImp(id self, SEL _cmd) { int fortyTwoSwizzledImp(id self, SEL _cmd) {
return 43; return 43;
@@ -3,7 +3,7 @@
// https://youtrack.jetbrains.com/issue/KT-49455 // https://youtrack.jetbrains.com/issue/KT-49455
@interface KT49455 : NSObject @interface KT49455 : NSObject
@end; @end
__attribute__((external_source_symbol(language="Swift", defined_in="sample",generated_declaration))) __attribute__((external_source_symbol(language="Swift", defined_in="sample",generated_declaration)))
@interface KT49455 (KT49455Ext) @interface KT49455 (KT49455Ext)
@@ -1,7 +1,7 @@
#import "kt49455.h" #import "kt49455.h"
@implementation KT49455 @implementation KT49455
@end; @end
@implementation KT49455 (KT49455Ext) @implementation KT49455 (KT49455Ext)
- (int)extensionFunction { - (int)extensionFunction {
@@ -18,8 +18,8 @@ struct MyStruct myStruct = {11, 12, 13, 14};
@protocol Proto @protocol Proto
@property int Companion; // clash on implementing @property int Companion; // clash on implementing
@end; @end
@interface FooMangled : NSObject<Proto> @interface FooMangled : NSObject<Proto>
//- (void) CompanionS; // mangleSimple does not support this: it may clash after mangling //- (void) CompanionS; // mangleSimple does not support this: it may clash after mangling
@end; @end
@@ -3,4 +3,4 @@
// [KT-36067] mangling // [KT-36067] mangling
@implementation FooMangled : NSObject @implementation FooMangled : NSObject
@synthesize Companion; @synthesize Companion;
@end; @end
@@ -2,16 +2,16 @@
@interface MultipleInheritanceClashBase : NSObject @interface MultipleInheritanceClashBase : NSObject
@property (nonnull) MultipleInheritanceClashBase* delegate; @property (nonnull) MultipleInheritanceClashBase* delegate;
@end; @end
@protocol MultipleInheritanceClash @protocol MultipleInheritanceClash
@optional @optional
@property (nullable) id<MultipleInheritanceClash> delegate; @property (nullable) id<MultipleInheritanceClash> delegate;
@end; @end
@interface MultipleInheritanceClash1 : MultipleInheritanceClashBase <MultipleInheritanceClash> @interface MultipleInheritanceClash1 : MultipleInheritanceClashBase <MultipleInheritanceClash>
@end; @end
@interface MultipleInheritanceClash2 : MultipleInheritanceClashBase <MultipleInheritanceClash> @interface MultipleInheritanceClash2 : MultipleInheritanceClashBase <MultipleInheritanceClash>
@property MultipleInheritanceClashBase* delegate; @property MultipleInheritanceClashBase* delegate;
@end; @end
@@ -1,10 +1,10 @@
#import "multipleInheritanceClash.h" #import "multipleInheritanceClash.h"
@implementation MultipleInheritanceClashBase @implementation MultipleInheritanceClashBase
@end; @end
@implementation MultipleInheritanceClash1 @implementation MultipleInheritanceClash1
@end; @end
@implementation MultipleInheritanceClash2 @implementation MultipleInheritanceClash2
@end; @end
@@ -4,10 +4,10 @@
@interface DeallocExecutor : NSObject @interface DeallocExecutor : NSObject
@property DeallocListener* deallocListener; @property DeallocListener* deallocListener;
@end; @end
@interface DeallocListener : NSObject @interface DeallocListener : NSObject
@property (weak) DeallocExecutor* deallocExecutor; @property (weak) DeallocExecutor* deallocExecutor;
@property BOOL deallocated; @property BOOL deallocated;
-(BOOL)deallocExecutorIsNil; -(BOOL)deallocExecutorIsNil;
@end; @end
@@ -4,10 +4,10 @@
-(void)dealloc { -(void)dealloc {
self.deallocListener.deallocated = YES; self.deallocListener.deallocated = YES;
} }
@end; @end
@implementation DeallocListener @implementation DeallocListener
-(BOOL)deallocExecutorIsNil { -(BOOL)deallocExecutorIsNil {
return self.deallocExecutor == nil; return self.deallocExecutor == nil;
} }
@end; @end
@@ -3,4 +3,4 @@
@interface TestOverrideInit : NSObject @interface TestOverrideInit : NSObject
-(instancetype)initWithValue:(int)value NS_DESIGNATED_INITIALIZER; -(instancetype)initWithValue:(int)value NS_DESIGNATED_INITIALIZER;
+(instancetype)createWithValue:(int)value; +(instancetype)createWithValue:(int)value;
@end; @end
@@ -8,4 +8,4 @@
+(instancetype)createWithValue:(int)value { +(instancetype)createWithValue:(int)value {
return [[self alloc] initWithValue:value]; return [[self alloc] initWithValue:value];
} }
@end; @end
@@ -3,4 +3,4 @@
@interface WeakRefHolder : NSObject @interface WeakRefHolder : NSObject
@property (weak) id obj; @property (weak) id obj;
-(void)loadManyTimes; -(void)loadManyTimes;
@end; @end
@@ -8,4 +8,4 @@
[array addObject:self.obj]; [array addObject:self.obj];
} }
} }
@end; @end
@@ -7,14 +7,14 @@
+(NSString* _Nonnull)stringWithFormat:(NSString*)format, ...; +(NSString* _Nonnull)stringWithFormat:(NSString*)format, ...;
+(NSObject* _Nonnull)stringWithFormat:(NSString*)format args:(void*)args; +(NSObject* _Nonnull)stringWithFormat:(NSString*)format args:(void*)args;
@end; @end
@interface TestVarargs (TestVarargsExtension) @interface TestVarargs (TestVarargsExtension)
-(instancetype _Nonnull)initWithFormat:(NSString*)format, ...; -(instancetype _Nonnull)initWithFormat:(NSString*)format, ...;
@end; @end
@interface TestVarargsSubclass : TestVarargs @interface TestVarargsSubclass : TestVarargs
// Test clashes: // Test clashes:
-(instancetype _Nonnull)initWithFormat:(NSString*)format args:(void*)args; -(instancetype _Nonnull)initWithFormat:(NSString*)format args:(void*)args;
+(NSString* _Nonnull)stringWithFormat:(NSString*)format args:(void*)args; +(NSString* _Nonnull)stringWithFormat:(NSString*)format args:(void*)args;
@end; @end
@@ -38,7 +38,7 @@
abort(); abort();
} }
@end; @end
@implementation TestVarargsSubclass @implementation TestVarargsSubclass
-(instancetype _Nonnull)initWithFormat:(NSString*)format args:(void*)args { -(instancetype _Nonnull)initWithFormat:(NSString*)format args:(void*)args {
@@ -48,4 +48,4 @@
+(NSString* _Nonnull)stringWithFormat:(NSString*)format args:(void*)args { +(NSString* _Nonnull)stringWithFormat:(NSString*)format args:(void*)args {
abort(); abort();
} }
@end; @end
@@ -2,8 +2,8 @@
@interface CreateAutoreleaseDeallocated : NSObject @interface CreateAutoreleaseDeallocated : NSObject
@property BOOL value; @property BOOL value;
@end; @end
@interface CreateAutorelease : NSObject @interface CreateAutorelease : NSObject
+(void)createAutorelease:(CreateAutoreleaseDeallocated*)deallocated; +(void)createAutorelease:(CreateAutoreleaseDeallocated*)deallocated;
@end; @end
@@ -1,7 +1,7 @@
#import "workerAutoreleasePool.h" #import "workerAutoreleasePool.h"
@implementation CreateAutoreleaseDeallocated @implementation CreateAutoreleaseDeallocated
@end; @end
@implementation CreateAutorelease { @implementation CreateAutorelease {
CreateAutoreleaseDeallocated* deallocated; CreateAutoreleaseDeallocated* deallocated;
@@ -17,4 +17,4 @@
-(void)dealloc { -(void)dealloc {
deallocated.value = YES; deallocated.value = YES;
} }
@end; @end
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -139,13 +139,13 @@ extern "C" OBJ_GETTER(Kotlin_ObjCExport_NSErrorAsException, id error) {
} }
@interface NSError (NSErrorKotlinException) @interface NSError (NSErrorKotlinException)
@end; @end
@implementation NSError (NSErrorKotlinException) @implementation NSError (NSErrorKotlinException)
-(id)kotlinException { -(id)kotlinException {
auto userInfo = self.userInfo; auto userInfo = self.userInfo;
return userInfo == nullptr ? nullptr : userInfo[@"KotlinException"]; return userInfo == nullptr ? nullptr : userInfo[@"KotlinException"];
} }
@end; @end
#endif #endif
@@ -16,7 +16,7 @@
@interface KotlinBase : NSObject <NSCopying> @interface KotlinBase : NSObject <NSCopying>
+(instancetype)createRetainedWrapper:(ObjHeader*)obj; +(instancetype)createRetainedWrapper:(ObjHeader*)obj;
@end; @end
enum class ReleaseMode { enum class ReleaseMode {
kRelease, kRelease,
@@ -61,7 +61,7 @@ struct KotlinObjCClassData {
@protocol HasKotlinObjCClassData @protocol HasKotlinObjCClassData
@required @required
-(void*)_kotlinObjCClassData; -(void*)_kotlinObjCClassData;
@end; @end
static inline struct KotlinObjCClassData* GetKotlinClassData(id objOrClass) { static inline struct KotlinObjCClassData* GetKotlinClassData(id objOrClass) {
void* ptr = [(id<HasKotlinObjCClassData>)objOrClass _kotlinObjCClassData]; void* ptr = [(id<HasKotlinObjCClassData>)objOrClass _kotlinObjCClassData];
@@ -28,7 +28,7 @@
@interface NSObject (NSObjectPrivateMethods) @interface NSObject (NSObjectPrivateMethods)
// Implemented for NSObject in libobjc/NSObject.mm // Implemented for NSObject in libobjc/NSObject.mm
-(BOOL)_tryRetain; -(BOOL)_tryRetain;
@end; @end
static void injectToRuntime(); static void injectToRuntime();
@@ -167,10 +167,10 @@ static void injectToRuntime();
return [self retain]; return [self retain];
} }
@end; @end
@interface NSObject (NSObjectToKotlin) @interface NSObject (NSObjectToKotlin)
@end; @end
@implementation NSObject (NSObjectToKotlin) @implementation NSObject (NSObjectToKotlin)
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT { -(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
@@ -182,16 +182,16 @@ static void injectToRuntime();
return; return;
objc_release(self); objc_release(self);
} }
@end; @end
@interface NSString (NSStringToKotlin) @interface NSString (NSStringToKotlin)
@end; @end
@implementation NSString (NSStringToKotlin) @implementation NSString (NSStringToKotlin)
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT { -(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
RETURN_RESULT_OF(Kotlin_Interop_CreateKStringFromNSString, self); RETURN_RESULT_OF(Kotlin_Interop_CreateKStringFromNSString, self);
} }
@end; @end
extern "C" { extern "C" {
@@ -209,7 +209,7 @@ OBJ_GETTER(Kotlin_boxDouble, KDouble value);
} }
@interface NSNumber (NSNumberToKotlin) @interface NSNumber (NSNumberToKotlin)
@end; @end
@implementation NSNumber (NSNumberToKotlin) @implementation NSNumber (NSNumberToKotlin)
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT { -(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
@@ -232,17 +232,17 @@ OBJ_GETTER(Kotlin_boxDouble, KDouble value);
default: RETURN_RESULT_OF(Kotlin_ObjCExport_convertUnmappedObjCObject, self); default: RETURN_RESULT_OF(Kotlin_ObjCExport_convertUnmappedObjCObject, self);
} }
} }
@end; @end
@interface NSDecimalNumber (NSDecimalNumberToKotlin) @interface NSDecimalNumber (NSDecimalNumberToKotlin)
@end; @end
@implementation NSDecimalNumber (NSDecimalNumberToKotlin) @implementation NSDecimalNumber (NSDecimalNumberToKotlin)
// Overrides [NSNumber toKotlin:] implementation. // Overrides [NSNumber toKotlin:] implementation.
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT { -(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
RETURN_RESULT_OF(Kotlin_ObjCExport_convertUnmappedObjCObject, self); RETURN_RESULT_OF(Kotlin_ObjCExport_convertUnmappedObjCObject, self);
} }
@end; @end
static void injectToRuntimeImpl() { static void injectToRuntimeImpl() {
// If the code below fails, then it is most likely caused by KT-42254. // If the code below fails, then it is most likely caused by KT-42254.
@@ -86,7 +86,7 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
// when they are either frozen or if they are called on the worker that created them. // when they are either frozen or if they are called on the worker that created them.
@interface NSArray (NSArrayToKotlin) @interface NSArray (NSArrayToKotlin)
@end; @end
@implementation NSArray (NSArrayToKotlin) @implementation NSArray (NSArrayToKotlin)
-(KRef)toKotlin:(KRef*)OBJ_RESULT { -(KRef)toKotlin:(KRef*)OBJ_RESULT {
@@ -98,10 +98,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
return; return;
objc_release(self); objc_release(self);
} }
@end; @end
@interface NSMutableArray (NSMutableArrayToKotlin) @interface NSMutableArray (NSMutableArrayToKotlin)
@end; @end
@implementation NSMutableArray (NSArrayToKotlin) @implementation NSMutableArray (NSArrayToKotlin)
-(KRef)toKotlin:(KRef*)OBJ_RESULT { -(KRef)toKotlin:(KRef*)OBJ_RESULT {
@@ -113,11 +113,11 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
return; return;
objc_release(self); objc_release(self);
} }
@end; @end
@interface NSSet (NSSetToKotlin) @interface NSSet (NSSetToKotlin)
@end; @end
@implementation NSSet (NSSetToKotlin) @implementation NSSet (NSSetToKotlin)
-(KRef)toKotlin:(KRef*)OBJ_RESULT { -(KRef)toKotlin:(KRef*)OBJ_RESULT {
@@ -130,10 +130,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
objc_release(self); objc_release(self);
} }
@end; @end
@interface NSDictionary (NSDictionaryToKotlin) @interface NSDictionary (NSDictionaryToKotlin)
@end; @end
@implementation NSDictionary (NSDictionaryToKotlin) @implementation NSDictionary (NSDictionaryToKotlin)
-(KRef)toKotlin:(KRef*)OBJ_RESULT { -(KRef)toKotlin:(KRef*)OBJ_RESULT {
@@ -146,10 +146,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
objc_release(self); objc_release(self);
} }
@end; @end
@interface KIteratorAsNSEnumerator : NSEnumerator @interface KIteratorAsNSEnumerator : NSEnumerator
@end; @end
@implementation KIteratorAsNSEnumerator { @implementation KIteratorAsNSEnumerator {
KRefSharedHolder iteratorHolder; KRefSharedHolder iteratorHolder;
@@ -176,10 +176,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
return nullptr; return nullptr;
} }
} }
@end; @end
@interface KListAsNSArray : NSArray @interface KListAsNSArray : NSArray
@end; @end
@implementation KListAsNSArray { @implementation KListAsNSArray {
KRefSharedHolder listHolder; KRefSharedHolder listHolder;
@@ -212,10 +212,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
return Kotlin_Collection_getSize(listHolder.ref<ErrorPolicy::kTerminate>()); return Kotlin_Collection_getSize(listHolder.ref<ErrorPolicy::kTerminate>());
} }
@end; @end
@interface KMutableListAsNSMutableArray : NSMutableArray @interface KMutableListAsNSMutableArray : NSMutableArray
@end; @end
@implementation KMutableListAsNSMutableArray { @implementation KMutableListAsNSMutableArray {
KRefSharedHolder listHolder; KRefSharedHolder listHolder;
@@ -278,10 +278,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
Kotlin_MutableList_setObject(listHolder.ref<ErrorPolicy::kTerminate>(), objCIndexToKotlinOrThrow(index), kotlinObject); Kotlin_MutableList_setObject(listHolder.ref<ErrorPolicy::kTerminate>(), objCIndexToKotlinOrThrow(index), kotlinObject);
} }
@end; @end
@interface KSetAsNSSet : NSSet @interface KSetAsNSSet : NSSet
@end; @end
static inline id KSet_getElement(KRef set, id object) { static inline id KSet_getElement(KRef set, id object) {
if (object == NSNull.null) { if (object == NSNull.null) {
@@ -338,10 +338,10 @@ static inline id KSet_getElement(KRef set, id object) {
ObjHolder holder; ObjHolder holder;
return [KIteratorAsNSEnumerator createWithKIterator:Kotlin_Set_iterator(setHolder.ref<ErrorPolicy::kTerminate>(), holder.slot())]; return [KIteratorAsNSEnumerator createWithKIterator:Kotlin_Set_iterator(setHolder.ref<ErrorPolicy::kTerminate>(), holder.slot())];
} }
@end; @end
@interface KotlinMutableSet : NSMutableSet @interface KotlinMutableSet : NSMutableSet
@end; @end
@implementation KotlinMutableSet { @implementation KotlinMutableSet {
KRefSharedHolder setHolder; KRefSharedHolder setHolder;
@@ -440,10 +440,10 @@ static inline id KSet_getElement(KRef set, id object) {
ObjHolder holder; ObjHolder holder;
Kotlin_MutableCollection_removeObject(setHolder.ref<ErrorPolicy::kTerminate>(), refFromObjCOrNSNull(object, holder.slot())); Kotlin_MutableCollection_removeObject(setHolder.ref<ErrorPolicy::kTerminate>(), refFromObjCOrNSNull(object, holder.slot()));
} }
@end; @end
@interface KMapAsNSDictionary : NSDictionary @interface KMapAsNSDictionary : NSDictionary
@end; @end
static inline id KMap_get(KRef map, id aKey) { static inline id KMap_get(KRef map, id aKey) {
ObjHolder keyHolder, valueHolder; ObjHolder keyHolder, valueHolder;
@@ -497,10 +497,10 @@ static inline id KMap_get(KRef map, id aKey) {
return [KIteratorAsNSEnumerator createWithKIterator:Kotlin_Map_keyIterator(mapHolder.ref<ErrorPolicy::kTerminate>(), holder.slot())]; return [KIteratorAsNSEnumerator createWithKIterator:Kotlin_Map_keyIterator(mapHolder.ref<ErrorPolicy::kTerminate>(), holder.slot())];
} }
@end; @end
@interface KotlinMutableDictionary : NSMutableDictionary @interface KotlinMutableDictionary : NSMutableDictionary
@end; @end
@implementation KotlinMutableDictionary { @implementation KotlinMutableDictionary {
KRefSharedHolder mapHolder; KRefSharedHolder mapHolder;
@@ -593,10 +593,10 @@ static inline id KMap_get(KRef map, id aKey) {
Kotlin_MutableMap_remove(mapHolder.ref<ErrorPolicy::kTerminate>(), kotlinKey); Kotlin_MutableMap_remove(mapHolder.ref<ErrorPolicy::kTerminate>(), kotlinKey);
} }
@end; @end
@interface NSEnumerator (NSEnumeratorAsAssociatedObject) @interface NSEnumerator (NSEnumeratorAsAssociatedObject)
@end; @end
@implementation NSEnumerator (NSEnumeratorAsAssociatedObject) @implementation NSEnumerator (NSEnumeratorAsAssociatedObject)
-(void)releaseAsAssociatedObject:(ReleaseMode)mode { -(void)releaseAsAssociatedObject:(ReleaseMode)mode {
@@ -604,7 +604,7 @@ static inline id KMap_get(KRef map, id aKey) {
return; return;
objc_release(self); objc_release(self);
} }
@end; @end
// Referenced from the generated code: // Referenced from the generated code:
@@ -44,7 +44,7 @@ OBJ_GETTER(Kotlin_boxDouble, KDouble value);
#pragma clang diagnostic ignored "-Wobjc-designated-initializers" #pragma clang diagnostic ignored "-Wobjc-designated-initializers"
@interface KotlinNumber : NSNumber @interface KotlinNumber : NSNumber
@end; @end
[[ noreturn ]] static void incorrectNumberInitialization(KotlinNumber* self, SEL _cmd) { [[ noreturn ]] static void incorrectNumberInitialization(KotlinNumber* self, SEL _cmd) {
[NSException raise:NSGenericException format:@"%@ can't be initialized with %s, use properly typed initialized", [NSException raise:NSGenericException format:@"%@ can't be initialized with %s, use properly typed initialized",
@@ -94,7 +94,7 @@ OBJ_GETTER(Kotlin_boxDouble, KDouble value);
+ (NSNumber *)numberWithFloat:(float)value { incorrectNumberFactory(self, _cmd); } + (NSNumber *)numberWithFloat:(float)value { incorrectNumberFactory(self, _cmd); }
+ (NSNumber *)numberWithDouble:(double)value { incorrectNumberFactory(self, _cmd); } + (NSNumber *)numberWithDouble:(double)value { incorrectNumberFactory(self, _cmd); }
@end; @end
/* /*
The code below is generated by: The code below is generated by:
@@ -116,7 +116,7 @@ fun main(args: Array<String>) {
private fun genBoolean(): String = """ private fun genBoolean(): String = """
@interface KotlinBoolean : KotlinNumber @interface KotlinBoolean : KotlinNumber
@end; @end
@implementation KotlinBoolean { @implementation KotlinBoolean {
BOOL value_; BOOL value_;
@@ -154,7 +154,7 @@ private fun genBoolean(): String = """
RETURN_RESULT_OF(Kotlin_boxBoolean, value_); RETURN_RESULT_OF(Kotlin_boxBoolean, value_);
} }
@end; @end
""".trimIndent() """.trimIndent()
@@ -165,7 +165,7 @@ private fun genInteger(
kind: String = getNSNumberKind(cType) kind: String = getNSNumberKind(cType)
) = """ ) = """
@interface Kotlin$name : KotlinNumber @interface Kotlin$name : KotlinNumber
@end; @end
@implementation Kotlin$name { @implementation Kotlin$name {
$cType value_; $cType value_;
@@ -206,7 +206,7 @@ private fun genInteger(
RETURN_RESULT_OF(Kotlin_box$name, value_); RETURN_RESULT_OF(Kotlin_box$name, value_);
} }
@end; @end
""".trimIndent() """.trimIndent()
@@ -220,7 +220,7 @@ private fun genFloating(
kind: String = getNSNumberKind(cType) kind: String = getNSNumberKind(cType)
): String = """ ): String = """
@interface Kotlin$name : KotlinNumber @interface Kotlin$name : KotlinNumber
@end; @end
@implementation Kotlin$name { @implementation Kotlin$name {
$cType value_; $cType value_;
@@ -268,7 +268,7 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_box$name, value_); RETURN_RESULT_OF(Kotlin_box$name, value_);
} }
@end; @end
""".trimIndent() """.trimIndent()
*/ */
@@ -276,7 +276,7 @@ ${if (cType != "double") """
// TODO: consider generating it by compiler. // TODO: consider generating it by compiler.
@interface KotlinBoolean : KotlinNumber @interface KotlinBoolean : KotlinNumber
@end; @end
@implementation KotlinBoolean { @implementation KotlinBoolean {
BOOL value_; BOOL value_;
@@ -314,10 +314,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxBoolean, value_); RETURN_RESULT_OF(Kotlin_boxBoolean, value_);
} }
@end; @end
@interface KotlinByte : KotlinNumber @interface KotlinByte : KotlinNumber
@end; @end
@implementation KotlinByte { @implementation KotlinByte {
char value_; char value_;
@@ -358,10 +358,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxByte, value_); RETURN_RESULT_OF(Kotlin_boxByte, value_);
} }
@end; @end
@interface KotlinShort : KotlinNumber @interface KotlinShort : KotlinNumber
@end; @end
@implementation KotlinShort { @implementation KotlinShort {
short value_; short value_;
@@ -402,10 +402,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxShort, value_); RETURN_RESULT_OF(Kotlin_boxShort, value_);
} }
@end; @end
@interface KotlinInt : KotlinNumber @interface KotlinInt : KotlinNumber
@end; @end
@implementation KotlinInt { @implementation KotlinInt {
int value_; int value_;
@@ -446,10 +446,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxInt, value_); RETURN_RESULT_OF(Kotlin_boxInt, value_);
} }
@end; @end
@interface KotlinLong : KotlinNumber @interface KotlinLong : KotlinNumber
@end; @end
@implementation KotlinLong { @implementation KotlinLong {
long long value_; long long value_;
@@ -490,10 +490,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxLong, value_); RETURN_RESULT_OF(Kotlin_boxLong, value_);
} }
@end; @end
@interface KotlinUByte : KotlinNumber @interface KotlinUByte : KotlinNumber
@end; @end
@implementation KotlinUByte { @implementation KotlinUByte {
unsigned char value_; unsigned char value_;
@@ -534,10 +534,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxUByte, value_); RETURN_RESULT_OF(Kotlin_boxUByte, value_);
} }
@end; @end
@interface KotlinUShort : KotlinNumber @interface KotlinUShort : KotlinNumber
@end; @end
@implementation KotlinUShort { @implementation KotlinUShort {
unsigned short value_; unsigned short value_;
@@ -578,10 +578,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxUShort, value_); RETURN_RESULT_OF(Kotlin_boxUShort, value_);
} }
@end; @end
@interface KotlinUInt : KotlinNumber @interface KotlinUInt : KotlinNumber
@end; @end
@implementation KotlinUInt { @implementation KotlinUInt {
unsigned int value_; unsigned int value_;
@@ -622,10 +622,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxUInt, value_); RETURN_RESULT_OF(Kotlin_boxUInt, value_);
} }
@end; @end
@interface KotlinULong : KotlinNumber @interface KotlinULong : KotlinNumber
@end; @end
@implementation KotlinULong { @implementation KotlinULong {
unsigned long long value_; unsigned long long value_;
@@ -666,10 +666,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxULong, value_); RETURN_RESULT_OF(Kotlin_boxULong, value_);
} }
@end; @end
@interface KotlinFloat : KotlinNumber @interface KotlinFloat : KotlinNumber
@end; @end
@implementation KotlinFloat { @implementation KotlinFloat {
float value_; float value_;
@@ -717,10 +717,10 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxFloat, value_); RETURN_RESULT_OF(Kotlin_boxFloat, value_);
} }
@end; @end
@interface KotlinDouble : KotlinNumber @interface KotlinDouble : KotlinNumber
@end; @end
@implementation KotlinDouble { @implementation KotlinDouble {
double value_; double value_;
@@ -761,6 +761,6 @@ ${if (cType != "double") """
RETURN_RESULT_OF(Kotlin_boxDouble, value_); RETURN_RESULT_OF(Kotlin_boxDouble, value_);
} }
@end; @end
#endif // KONAN_OBJC_INTEROP #endif // KONAN_OBJC_INTEROP
@@ -17,7 +17,7 @@
@interface KotlinObjectHolder : NSObject @interface KotlinObjectHolder : NSObject
-(id)initWithRef:(KRef)ref; -(id)initWithRef:(KRef)ref;
-(KRef)ref; -(KRef)ref;
@end; @end
@implementation KotlinObjectHolder { @implementation KotlinObjectHolder {
KRefSharedHolder refHolder; KRefSharedHolder refHolder;
@@ -39,7 +39,7 @@
[super dealloc]; [super dealloc];
} }
@end; @end
static id Kotlin_Interop_createKotlinObjectHolder(KRef any) { static id Kotlin_Interop_createKotlinObjectHolder(KRef any) {
if (any == nullptr) { if (any == nullptr) {
@@ -59,7 +59,7 @@ static KRef Kotlin_Interop_unwrapKotlinObjectHolder(id holder) {
// Used as an associated object for ObjCWeakReferenceImpl. // Used as an associated object for ObjCWeakReferenceImpl.
@interface KotlinObjCWeakReference : NSObject @interface KotlinObjCWeakReference : NSObject
@end; @end
// libobjc: // libobjc:
extern "C" { extern "C" {
@@ -81,7 +81,7 @@ void objc_release(id obj);
objc_release(self); objc_release(self);
} }
@end; @end
extern "C" OBJ_GETTER(Kotlin_Interop_refFromObjC, id obj); extern "C" OBJ_GETTER(Kotlin_Interop_refFromObjC, id obj);