NSCoder: implement NSSecureCoding stub

Implement stubs for NSSecureCoding which do not break projects that rely
on it.
This commit is contained in:
Daniel Ferreira 2017-06-25 06:35:23 +10:00 committed by Ivan Vučica
parent be874e5d8f
commit 314f437f43
4 changed files with 60 additions and 0 deletions

View file

@ -28,6 +28,7 @@
#import <Foundation/NSObject.h> #import <Foundation/NSObject.h>
#import <Foundation/NSGeometry.h> #import <Foundation/NSGeometry.h>
#import <Foundation/NSSet.h>
#import <Foundation/NSZone.h> #import <Foundation/NSZone.h>
#if defined(__cplusplus) #if defined(__cplusplus)
@ -303,6 +304,8 @@ extern "C" {
*/ */
- (id) decodeObjectForKey: (NSString*)aKey; - (id) decodeObjectForKey: (NSString*)aKey;
/** <override-subclass /> /** <override-subclass />
* Encodes aBool and associates the encoded value with aKey. * Encodes aBool and associates the encoded value with aKey.
*/ */
@ -363,6 +366,20 @@ extern "C" {
* Decodes an NSInteger associated with the key. * Decodes an NSInteger associated with the key.
*/ */
- (NSInteger) decodeIntegerForKey: (NSString *)key; - (NSInteger) decodeIntegerForKey: (NSString *)key;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_8, GS_API_LATEST)
#if GS_HAS_DECLARED_PROPERTIES
@property (nonatomic, assign) BOOL requiresSecureCoding;
#else
- (BOOL) requiresSecureCoding;
- (void) setRequiresSecureCoding: (BOOL)requires;
#endif
- (id) decodeObjectOfClass: (Class)cls forKey: (NSString *)key;
- (id) decodeObjectOfClasses: (NSSet *)classes forKey: (NSString *)key;
#endif #endif
@end @end

View file

@ -283,6 +283,10 @@ extern "C" {
- (id) initWithCoder: (NSCoder*)aDecoder; - (id) initWithCoder: (NSCoder*)aDecoder;
@end @end
@protocol NSSecureCoding <NSCoding>
+ (BOOL)supportsSecureCoding;
@end
GS_ROOT_CLASS @interface NSObject <NSObject> GS_ROOT_CLASS @interface NSObject <NSObject>
{ {

View file

@ -35,6 +35,7 @@
#define EXPOSE_NSCoder_IVARS 1 #define EXPOSE_NSCoder_IVARS 1
#import "Foundation/NSData.h" #import "Foundation/NSData.h"
#import "Foundation/NSCoder.h" #import "Foundation/NSCoder.h"
#import "Foundation/NSSet.h"
#import "Foundation/NSSerialization.h" #import "Foundation/NSSerialization.h"
#import "Foundation/NSUserDefaults.h" #import "Foundation/NSUserDefaults.h"
@ -331,6 +332,17 @@ static unsigned systemVersion = MAX_SUPPORTED_SYSTEM_VERSION;
// Keyed archiving extensions // Keyed archiving extensions
- (BOOL) requiresSecureCoding
{
[self subclassResponsibility: _cmd];
return NO;
}
- (void) setRequiresSecureCoding: (BOOL)secure
{
[self subclassResponsibility: _cmd];
}
- (BOOL) allowsKeyedCoding - (BOOL) allowsKeyedCoding
{ {
return NO; return NO;
@ -397,6 +409,18 @@ static unsigned systemVersion = MAX_SUPPORTED_SYSTEM_VERSION;
return nil; return nil;
} }
- (id) decodeObjectOfClass: (Class)cls forKey: (NSString *)aKey
{
return [self decodeObjectOfClasses: [NSSet setWithObject:(id)cls]
forKey: aKey];
}
- (id) decodeObjectOfClasses: (NSSet *)classes forKey: (NSString *)aKey
{
[self subclassResponsibility: _cmd];
return nil;
}
- (void) encodeBool: (BOOL) aBool forKey: (NSString*)aKey - (void) encodeBool: (BOOL) aBool forKey: (NSString*)aKey
{ {
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];

View file

@ -365,6 +365,16 @@ static NSMapTable *globalClassMap = 0;
return YES; return YES;
} }
- (BOOL)requiresSecureCoding
{
return NO;
}
- (void)setRequiresSecureCoding: (BOOL)secure
{
return;
}
- (Class) classForClassName: (NSString*)aString - (Class) classForClassName: (NSString*)aString
{ {
return _clsMap == 0 ? Nil : (Class)NSMapGet(_clsMap, (void*)aString); return _clsMap == 0 ? Nil : (Class)NSMapGet(_clsMap, (void*)aString);
@ -636,6 +646,11 @@ static NSMapTable *globalClassMap = 0;
return nil; return nil;
} }
- (id) decodeObjectOfClasses: (NSSet *)classes forKey: (NSString *)key
{
return [self decodeObjectForKey: key];
}
- (NSPoint) decodePoint - (NSPoint) decodePoint
{ {
NSPoint p; NSPoint p;