Fix NSDecimalNumber class support (#1501)
Reported at https://github.com/JetBrains/kotlin-native/issues/1444#issuecomment-381441837
This commit is contained in:
committed by
GitHub
parent
c633e879a7
commit
130be5e399
@@ -26,6 +26,7 @@
|
||||
#import <Foundation/NSMethodSignature.h>
|
||||
#import <Foundation/NSError.h>
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSDecimalNumber.h>
|
||||
#import <Foundation/NSDictionary.h>
|
||||
#import <objc/runtime.h>
|
||||
#import <objc/objc-exception.h>
|
||||
@@ -348,13 +349,17 @@ static void initializeClass(Class clazz) {
|
||||
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE OBJ_GETTER(convertUnmappedObjCObject, id obj) {
|
||||
const TypeInfo* typeInfo = getOrCreateTypeInfo(object_getClass(obj));
|
||||
RETURN_RESULT_OF(AllocInstanceWithAssociatedObject, typeInfo, objc_retain(obj));
|
||||
}
|
||||
|
||||
@interface NSObject (NSObjectToKotlin) <ConvertibleToKotlin>
|
||||
@end;
|
||||
|
||||
@implementation NSObject (NSObjectToKotlin)
|
||||
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
|
||||
const TypeInfo* typeInfo = getOrCreateTypeInfo(object_getClass(self));
|
||||
RETURN_RESULT_OF(AllocInstanceWithAssociatedObject, typeInfo, objc_retain(self));
|
||||
RETURN_RESULT_OF(convertUnmappedObjCObject, self);
|
||||
}
|
||||
|
||||
-(void)releaseAsAssociatedObject {
|
||||
@@ -419,11 +424,21 @@ static Class __NSCFBooleanClass = nullptr;
|
||||
case 'f': RETURN_RESULT_OF(Kotlin_boxFloat, self.floatValue);
|
||||
case 'd': RETURN_RESULT_OF(Kotlin_boxDouble, self.doubleValue);
|
||||
|
||||
default: return [super toKotlin:OBJ_RESULT];
|
||||
default: RETURN_RESULT_OF(convertUnmappedObjCObject, self);
|
||||
}
|
||||
}
|
||||
@end;
|
||||
|
||||
@interface NSDecimalNumber (NSDecimalNumberToKotlin) <ConvertibleToKotlin>
|
||||
@end;
|
||||
|
||||
@implementation NSDecimalNumber (NSDecimalNumberToKotlin)
|
||||
// Overrides [NSNumber toKotlin:] implementation.
|
||||
-(ObjHeader*)toKotlin:(ObjHeader**)OBJ_RESULT {
|
||||
RETURN_RESULT_OF(convertUnmappedObjCObject, self);
|
||||
}
|
||||
@end;
|
||||
|
||||
@interface NSBlock <NSObject>
|
||||
@end;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user