[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:
committed by
SvyatoslavScherbina
parent
3840d09314
commit
9a430efbe7
@@ -139,13 +139,13 @@ extern "C" OBJ_GETTER(Kotlin_ObjCExport_NSErrorAsException, id error) {
|
||||
}
|
||||
|
||||
@interface NSError (NSErrorKotlinException)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSError (NSErrorKotlinException)
|
||||
-(id)kotlinException {
|
||||
auto userInfo = self.userInfo;
|
||||
return userInfo == nullptr ? nullptr : userInfo[@"KotlinException"];
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
@interface KotlinBase : NSObject <NSCopying>
|
||||
+(instancetype)createRetainedWrapper:(ObjHeader*)obj;
|
||||
@end;
|
||||
@end
|
||||
|
||||
enum class ReleaseMode {
|
||||
kRelease,
|
||||
|
||||
@@ -61,7 +61,7 @@ struct KotlinObjCClassData {
|
||||
@protocol HasKotlinObjCClassData
|
||||
@required
|
||||
-(void*)_kotlinObjCClassData;
|
||||
@end;
|
||||
@end
|
||||
|
||||
static inline struct KotlinObjCClassData* GetKotlinClassData(id objOrClass) {
|
||||
void* ptr = [(id<HasKotlinObjCClassData>)objOrClass _kotlinObjCClassData];
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
@interface NSObject (NSObjectPrivateMethods)
|
||||
// Implemented for NSObject in libobjc/NSObject.mm
|
||||
-(BOOL)_tryRetain;
|
||||
@end;
|
||||
@end
|
||||
|
||||
static void injectToRuntime();
|
||||
|
||||
@@ -167,10 +167,10 @@ static void injectToRuntime();
|
||||
return [self retain];
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface NSObject (NSObjectToKotlin)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSObject (NSObjectToKotlin)
|
||||
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
|
||||
@@ -182,16 +182,16 @@ static void injectToRuntime();
|
||||
return;
|
||||
objc_release(self);
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface NSString (NSStringToKotlin)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSString (NSStringToKotlin)
|
||||
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
|
||||
RETURN_RESULT_OF(Kotlin_Interop_CreateKStringFromNSString, self);
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -209,7 +209,7 @@ OBJ_GETTER(Kotlin_boxDouble, KDouble value);
|
||||
}
|
||||
|
||||
@interface NSNumber (NSNumberToKotlin)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSNumber (NSNumberToKotlin)
|
||||
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
|
||||
@@ -232,17 +232,17 @@ OBJ_GETTER(Kotlin_boxDouble, KDouble value);
|
||||
default: RETURN_RESULT_OF(Kotlin_ObjCExport_convertUnmappedObjCObject, self);
|
||||
}
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface NSDecimalNumber (NSDecimalNumberToKotlin)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSDecimalNumber (NSDecimalNumberToKotlin)
|
||||
// Overrides [NSNumber toKotlin:] implementation.
|
||||
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
|
||||
RETURN_RESULT_OF(Kotlin_ObjCExport_convertUnmappedObjCObject, self);
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
static void injectToRuntimeImpl() {
|
||||
// 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.
|
||||
|
||||
@interface NSArray (NSArrayToKotlin)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSArray (NSArrayToKotlin)
|
||||
-(KRef)toKotlin:(KRef*)OBJ_RESULT {
|
||||
@@ -98,10 +98,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
|
||||
return;
|
||||
objc_release(self);
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface NSMutableArray (NSMutableArrayToKotlin)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSMutableArray (NSArrayToKotlin)
|
||||
-(KRef)toKotlin:(KRef*)OBJ_RESULT {
|
||||
@@ -113,11 +113,11 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
|
||||
return;
|
||||
objc_release(self);
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
|
||||
@interface NSSet (NSSetToKotlin)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSSet (NSSetToKotlin)
|
||||
-(KRef)toKotlin:(KRef*)OBJ_RESULT {
|
||||
@@ -130,10 +130,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
|
||||
objc_release(self);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface NSDictionary (NSDictionaryToKotlin)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSDictionary (NSDictionaryToKotlin)
|
||||
-(KRef)toKotlin:(KRef*)OBJ_RESULT {
|
||||
@@ -146,10 +146,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
|
||||
objc_release(self);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KIteratorAsNSEnumerator : NSEnumerator
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KIteratorAsNSEnumerator {
|
||||
KRefSharedHolder iteratorHolder;
|
||||
@@ -176,10 +176,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KListAsNSArray : NSArray
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KListAsNSArray {
|
||||
KRefSharedHolder listHolder;
|
||||
@@ -212,10 +212,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
|
||||
return Kotlin_Collection_getSize(listHolder.ref<ErrorPolicy::kTerminate>());
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KMutableListAsNSMutableArray : NSMutableArray
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KMutableListAsNSMutableArray {
|
||||
KRefSharedHolder listHolder;
|
||||
@@ -278,10 +278,10 @@ static inline KInt objCIndexToKotlinOrThrow(NSUInteger index) {
|
||||
Kotlin_MutableList_setObject(listHolder.ref<ErrorPolicy::kTerminate>(), objCIndexToKotlinOrThrow(index), kotlinObject);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KSetAsNSSet : NSSet
|
||||
@end;
|
||||
@end
|
||||
|
||||
static inline id KSet_getElement(KRef set, id object) {
|
||||
if (object == NSNull.null) {
|
||||
@@ -338,10 +338,10 @@ static inline id KSet_getElement(KRef set, id object) {
|
||||
ObjHolder holder;
|
||||
return [KIteratorAsNSEnumerator createWithKIterator:Kotlin_Set_iterator(setHolder.ref<ErrorPolicy::kTerminate>(), holder.slot())];
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinMutableSet : NSMutableSet
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinMutableSet {
|
||||
KRefSharedHolder setHolder;
|
||||
@@ -440,10 +440,10 @@ static inline id KSet_getElement(KRef set, id object) {
|
||||
ObjHolder holder;
|
||||
Kotlin_MutableCollection_removeObject(setHolder.ref<ErrorPolicy::kTerminate>(), refFromObjCOrNSNull(object, holder.slot()));
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KMapAsNSDictionary : NSDictionary
|
||||
@end;
|
||||
@end
|
||||
|
||||
static inline id KMap_get(KRef map, id aKey) {
|
||||
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())];
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinMutableDictionary : NSMutableDictionary
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinMutableDictionary {
|
||||
KRefSharedHolder mapHolder;
|
||||
@@ -593,10 +593,10 @@ static inline id KMap_get(KRef map, id aKey) {
|
||||
Kotlin_MutableMap_remove(mapHolder.ref<ErrorPolicy::kTerminate>(), kotlinKey);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface NSEnumerator (NSEnumeratorAsAssociatedObject)
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation NSEnumerator (NSEnumeratorAsAssociatedObject)
|
||||
-(void)releaseAsAssociatedObject:(ReleaseMode)mode {
|
||||
@@ -604,7 +604,7 @@ static inline id KMap_get(KRef map, id aKey) {
|
||||
return;
|
||||
objc_release(self);
|
||||
}
|
||||
@end;
|
||||
@end
|
||||
|
||||
// Referenced from the generated code:
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ OBJ_GETTER(Kotlin_boxDouble, KDouble value);
|
||||
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"
|
||||
|
||||
@interface KotlinNumber : NSNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
[[ noreturn ]] static void incorrectNumberInitialization(KotlinNumber* self, SEL _cmd) {
|
||||
[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 *)numberWithDouble:(double)value { incorrectNumberFactory(self, _cmd); }
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
/*
|
||||
The code below is generated by:
|
||||
@@ -116,7 +116,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
private fun genBoolean(): String = """
|
||||
@interface KotlinBoolean : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinBoolean {
|
||||
BOOL value_;
|
||||
@@ -154,7 +154,7 @@ private fun genBoolean(): String = """
|
||||
RETURN_RESULT_OF(Kotlin_boxBoolean, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
""".trimIndent()
|
||||
|
||||
@@ -165,7 +165,7 @@ private fun genInteger(
|
||||
kind: String = getNSNumberKind(cType)
|
||||
) = """
|
||||
@interface Kotlin$name : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation Kotlin$name {
|
||||
$cType value_;
|
||||
@@ -206,7 +206,7 @@ private fun genInteger(
|
||||
RETURN_RESULT_OF(Kotlin_box$name, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
""".trimIndent()
|
||||
|
||||
@@ -220,7 +220,7 @@ private fun genFloating(
|
||||
kind: String = getNSNumberKind(cType)
|
||||
): String = """
|
||||
@interface Kotlin$name : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation Kotlin$name {
|
||||
$cType value_;
|
||||
@@ -268,7 +268,7 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_box$name, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
""".trimIndent()
|
||||
*/
|
||||
@@ -276,7 +276,7 @@ ${if (cType != "double") """
|
||||
// TODO: consider generating it by compiler.
|
||||
|
||||
@interface KotlinBoolean : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinBoolean {
|
||||
BOOL value_;
|
||||
@@ -314,10 +314,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxBoolean, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinByte : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinByte {
|
||||
char value_;
|
||||
@@ -358,10 +358,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxByte, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinShort : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinShort {
|
||||
short value_;
|
||||
@@ -402,10 +402,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxShort, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinInt : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinInt {
|
||||
int value_;
|
||||
@@ -446,10 +446,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxInt, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinLong : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinLong {
|
||||
long long value_;
|
||||
@@ -490,10 +490,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxLong, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinUByte : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinUByte {
|
||||
unsigned char value_;
|
||||
@@ -534,10 +534,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxUByte, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinUShort : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinUShort {
|
||||
unsigned short value_;
|
||||
@@ -578,10 +578,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxUShort, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinUInt : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinUInt {
|
||||
unsigned int value_;
|
||||
@@ -622,10 +622,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxUInt, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinULong : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinULong {
|
||||
unsigned long long value_;
|
||||
@@ -666,10 +666,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxULong, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinFloat : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinFloat {
|
||||
float value_;
|
||||
@@ -717,10 +717,10 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxFloat, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
@interface KotlinDouble : KotlinNumber
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinDouble {
|
||||
double value_;
|
||||
@@ -761,6 +761,6 @@ ${if (cType != "double") """
|
||||
RETURN_RESULT_OF(Kotlin_boxDouble, value_);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
#endif // KONAN_OBJC_INTEROP
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
@interface KotlinObjectHolder : NSObject
|
||||
-(id)initWithRef:(KRef)ref;
|
||||
-(KRef)ref;
|
||||
@end;
|
||||
@end
|
||||
|
||||
@implementation KotlinObjectHolder {
|
||||
KRefSharedHolder refHolder;
|
||||
@@ -39,7 +39,7 @@
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
static id Kotlin_Interop_createKotlinObjectHolder(KRef any) {
|
||||
if (any == nullptr) {
|
||||
@@ -59,7 +59,7 @@ static KRef Kotlin_Interop_unwrapKotlinObjectHolder(id holder) {
|
||||
|
||||
// Used as an associated object for ObjCWeakReferenceImpl.
|
||||
@interface KotlinObjCWeakReference : NSObject
|
||||
@end;
|
||||
@end
|
||||
|
||||
// libobjc:
|
||||
extern "C" {
|
||||
@@ -81,7 +81,7 @@ void objc_release(id obj);
|
||||
objc_release(self);
|
||||
}
|
||||
|
||||
@end;
|
||||
@end
|
||||
|
||||
extern "C" OBJ_GETTER(Kotlin_Interop_refFromObjC, id obj);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user