Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ class ObjCExportTranslatorImpl(
mapReferenceType(descriptor.companionObjectDescriptor!!.defaultType, genericExportScope),
listOf("class", "readonly"),
getterName = namer.getCompanionObjectPropertySelector(descriptor),
declarationAttributes = listOf(swiftNameAttribute(ObjCExportNamer.companionObjectPropertyName))
declarationAttributes = emptyList()
)
}
}
Expand All @@ -277,7 +277,7 @@ class ObjCExportTranslatorImpl(
ObjCExportNamer.objectPropertyName, null,
mapReferenceType(descriptor.defaultType, genericExportScope), listOf("class", "readonly"),
getterName = namer.getObjectPropertySelector(descriptor),
declarationAttributes = listOf(swiftNameAttribute(ObjCExportNamer.objectPropertyName))
declarationAttributes = emptyList()
)
}
}
Expand All @@ -287,10 +287,15 @@ class ObjCExportTranslatorImpl(
descriptor.enumEntries.forEach {
val entryName = namer.getEnumEntrySelector(it)
val swiftName = namer.getEnumEntrySwiftName(it)
val declarationAttrs = if (entryName != swiftName) {
listOf(swiftNameAttribute(swiftName))
} else {
emptyList()
}
add {
ObjCProperty(
entryName, it, type, listOf("class", "readonly"),
declarationAttributes = listOf(swiftNameAttribute(swiftName))
declarationAttributes = declarationAttrs
)
}
if (namer.needsExplicitMethodFamily(entryName)) {
Expand Down Expand Up @@ -388,7 +393,7 @@ class ObjCExportTranslatorImpl(
returnType = mapReferenceType(enumValues.returnType!!, genericExportScope),
selectors = splitSelector(selector),
parameters = emptyList(),
attributes = listOf(swiftNameAttribute("$selector()"))
attributes = emptyList()
)
}

Expand All @@ -402,7 +407,7 @@ class ObjCExportTranslatorImpl(
enumEntries,
type = mapReferenceType(enumEntries.type, genericExportScope),
propertyAttributes = listOf("class", "readonly"),
declarationAttributes = listOf(swiftNameAttribute(selector))
declarationAttributes = emptyList()
)
}

Expand Down Expand Up @@ -570,7 +575,13 @@ class ObjCExportTranslatorImpl(
val getterSelector = getSelector(baseProperty.getter!!)
val getterName: String? = if (getterSelector != name) getterSelector else null

val declarationAttributes = mutableListOf(property.getSwiftPrivateAttribute() ?: swiftNameAttribute(propertyName.swiftName))
val declarationAttributes = mutableListOf<String>()
val privateAttribute: String? = property.getSwiftPrivateAttribute()
if (privateAttribute != null) {
declarationAttributes.add(privateAttribute)
} else if (propertyName.objCName != propertyName.swiftName) {
declarationAttributes.add(swiftNameAttribute(propertyName.swiftName))
}
declarationAttributes.addIfNotNull(mapper.getDeprecation(property)?.toDeprecationAttribute())

val visibilityComments = visibilityComments(property.visibility, "property")
Expand Down Expand Up @@ -658,9 +669,14 @@ class ObjCExportTranslatorImpl(
val selector = getSelector(baseMethod)
val selectorParts: List<String> = splitSelector(selector)
val swiftName = namer.getSwiftName(baseMethod)
val defaultSwiftName = namer.getSelector(baseMethod) + "()"
val attributes = mutableListOf<String>()

attributes += method.getSwiftPrivateAttribute() ?: swiftNameAttribute(swiftName)
val privateAttribute: String? = method.getSwiftPrivateAttribute()
if (privateAttribute != null) {
attributes.add(privateAttribute)
} else if (defaultSwiftName != swiftName) {
attributes.add(swiftNameAttribute(swiftName))
}
val returnBridge = baseMethodBridge.returnBridge
if (returnBridge is MethodBridge.ReturnValue.WithError.ZeroForError && returnBridge.successMayBeZero) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ NS_ASSUME_NONNULL_BEGIN

__attribute__((objc_subclassing_restricted))
@interface FooKt : Base
@property (class, readonly) NSMutableArray<Int *> *a __attribute__((swift_name("a")));
@property (class, readonly) NSMutableArray<Int *> *a;
@end

#pragma pop_macro("_Nullable_result")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ NS_ASSUME_NONNULL_BEGIN

__attribute__((objc_subclassing_restricted))
@interface FooKt : Base
@property (class, readonly) Kotlinx_coroutines_coreCompletionHandlerException * _Nullable handler __attribute__((swift_name("handler")));
@property (class, readonly) Kotlinx_coroutines_coreCompletionHandlerException * _Nullable handler;
@end

@interface KotlinThrowable : Base
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
- (instancetype)init __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (instancetype)initWithMessage:(NSString * _Nullable)message __attribute__((swift_name("init(message:)"))) __attribute__((objc_designated_initializer));
- (instancetype)initWithCause:(KotlinThrowable * _Nullable)cause __attribute__((swift_name("init(cause:)"))) __attribute__((objc_designated_initializer));
Expand All @@ -38,24 +38,24 @@ __attribute__((objc_subclassing_restricted))
* @note annotations
* kotlin.experimental.ExperimentalNativeApi
*/
- (KotlinArray<NSString *> *)getStackTrace __attribute__((swift_name("getStackTrace()")));
- (void)printStackTrace __attribute__((swift_name("printStackTrace()")));
- (NSString *)description __attribute__((swift_name("description()")));
@property (readonly) KotlinThrowable * _Nullable cause __attribute__((swift_name("cause")));
@property (readonly) NSString * _Nullable message __attribute__((swift_name("message")));
- (KotlinArray<NSString *> *)getStackTrace;
- (void)printStackTrace;
- (NSString *)description;
@property (readonly) KotlinThrowable * _Nullable cause;
@property (readonly) NSString * _Nullable message;
- (NSError *)asError __attribute__((swift_name("asError()")));
@end

@interface KotlinException : KotlinThrowable
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
- (instancetype)init __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (instancetype)initWithMessage:(NSString * _Nullable)message __attribute__((swift_name("init(message:)"))) __attribute__((objc_designated_initializer));
- (instancetype)initWithCause:(KotlinThrowable * _Nullable)cause __attribute__((swift_name("init(cause:)"))) __attribute__((objc_designated_initializer));
- (instancetype)initWithMessage:(NSString * _Nullable)message cause:(KotlinThrowable * _Nullable)cause __attribute__((swift_name("init(message:cause:)"))) __attribute__((objc_designated_initializer));
@end

@interface KotlinRuntimeException : KotlinException
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
- (instancetype)init __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (instancetype)initWithMessage:(NSString * _Nullable)message __attribute__((swift_name("init(message:)"))) __attribute__((objc_designated_initializer));
- (instancetype)initWithCause:(KotlinThrowable * _Nullable)cause __attribute__((swift_name("init(cause:)"))) __attribute__((objc_designated_initializer));
Expand All @@ -65,7 +65,7 @@ __attribute__((objc_subclassing_restricted))
__attribute__((objc_subclassing_restricted))
@interface Kotlinx_coroutines_coreCompletionHandlerException : KotlinRuntimeException
- (instancetype)initWithMessage:(NSString *)message cause:(KotlinThrowable *)cause __attribute__((swift_name("init(message:cause:)"))) __attribute__((objc_designated_initializer));
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
- (instancetype)init __attribute__((objc_designated_initializer)) __attribute__((unavailable));
+ (instancetype)new __attribute__((unavailable));
- (instancetype)initWithMessage:(NSString * _Nullable)message __attribute__((swift_name("init(message:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
- (instancetype)initWithCause:(KotlinThrowable * _Nullable)cause __attribute__((swift_name("init(cause:)"))) __attribute__((objc_designated_initializer)) __attribute__((unavailable));
Expand All @@ -77,15 +77,15 @@ __attribute__((objc_subclassing_restricted))
+ (instancetype)alloc __attribute__((unavailable));
+ (instancetype)allocWithZone:(struct _NSZone *)zone __attribute__((unavailable));
- (T _Nullable)getIndex:(int32_t)index __attribute__((swift_name("get(index:)")));
- (id<KotlinIterator>)iterator __attribute__((swift_name("iterator()")));
- (id<KotlinIterator>)iterator;
- (void)setIndex:(int32_t)index value:(T _Nullable)value __attribute__((swift_name("set(index:value:)")));
@property (readonly) int32_t size __attribute__((swift_name("size")));
@property (readonly) int32_t size;
@end

@protocol KotlinIterator
@required
- (BOOL)hasNext __attribute__((swift_name("hasNext()")));
- (id _Nullable)next __attribute__((swift_name("next()")));
- (BOOL)hasNext;
- (id _Nullable)next;
@end

#pragma pop_macro("_Nullable_result")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ NS_ASSUME_NONNULL_BEGIN

@protocol KotlinIterator
@required
- (BOOL)hasNext __attribute__((swift_name("hasNext()")));
- (id _Nullable)next __attribute__((swift_name("next()")));
- (BOOL)hasNext;
- (id _Nullable)next;
@end

__attribute__((objc_subclassing_restricted))
@interface Foo : Base <KotlinIterator>
- (instancetype)init __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer));
- (instancetype)init __attribute__((objc_designated_initializer));
+ (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead")));
- (BOOL)hasNext __attribute__((swift_name("hasNext()")));
- (Int *)next __attribute__((swift_name("next()")));
- (BOOL)hasNext;
- (Int *)next;
@end

#pragma pop_macro("_Nullable_result")
Expand Down