Skip to content

Commit

Permalink
Remove retain (#522)
Browse files Browse the repository at this point in the history
  • Loading branch information
bamx23 authored Jul 1, 2024
1 parent 8cc2170 commit 18ddf26
Show file tree
Hide file tree
Showing 26 changed files with 123 additions and 270 deletions.
31 changes: 11 additions & 20 deletions Sources/KSCrashFilters/KSCrashReportFilterAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ - (void)startWithTitle:(NSString *)title

@implementation KSCrashAlertViewProcess

@synthesize reports = _reports;
@synthesize onCompletion = _onCompletion;
@synthesize expectedButtonIndex = _expectedButtonIndex;

+ (KSCrashAlertViewProcess *)process
{
return [[self alloc] init];
Expand All @@ -78,9 +74,9 @@ - (void)startWithTitle:(NSString *)title
onCompletion:(KSCrashReportFilterCompletion)onCompletion
{
KSLOG_TRACE(@"Starting alert view process");
self.reports = [reports copy];
self.onCompletion = onCompletion;
self.expectedButtonIndex = noAnswer == nil ? 0 : 1;
_reports = [reports copy];
_onCompletion = [onCompletion copy];
_expectedButtonIndex = noAnswer == nil ? 0 : 1;

#if KSCRASH_HAS_UIALERTCONTROLLER
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title
Expand Down Expand Up @@ -130,20 +126,15 @@ - (void)alertView:(__unused id)alertView clickedButtonAtIndex:(NSInteger)buttonI

@interface KSCrashReportFilterAlert ()

@property(nonatomic, readwrite, retain) NSString *title;
@property(nonatomic, readwrite, retain) NSString *message;
@property(nonatomic, readwrite, retain) NSString *yesAnswer;
@property(nonatomic, readwrite, retain) NSString *noAnswer;
@property(nonatomic, readwrite, copy) NSString *title;
@property(nonatomic, readwrite, copy) NSString *message;
@property(nonatomic, readwrite, copy) NSString *yesAnswer;
@property(nonatomic, readwrite, copy) NSString *noAnswer;

@end

@implementation KSCrashReportFilterAlert

@synthesize title = _title;
@synthesize message = _message;
@synthesize yesAnswer = _yesAnswer;
@synthesize noAnswer = _noAnswer;

+ (instancetype)filterWithTitle:(NSString *)title
message:(nullable NSString *)message
yesAnswer:(NSString *)yesAnswer
Expand All @@ -158,10 +149,10 @@ - (instancetype)initWithTitle:(NSString *)title
noAnswer:(nullable NSString *)noAnswer;
{
if ((self = [super init])) {
self.title = title;
self.message = message;
self.yesAnswer = yesAnswer;
self.noAnswer = noAnswer;
_title = [title copy];
_message = [message copy];
_yesAnswer = [yesAnswer copy];
_noAnswer = [noAnswer copy];
}
return self;
}
Expand Down
4 changes: 1 addition & 3 deletions Sources/KSCrashFilters/KSCrashReportFilterAppleFmt.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ - (NSComparisonResult)kscrash_compareRegisterName:(NSString *)other

@implementation KSCrashReportFilterAppleFmt

@synthesize reportStyle = _reportStyle;

/** Date formatter for Apple date format in crash reports. */
static NSDateFormatter *g_dateFormatter;

Expand Down Expand Up @@ -176,7 +174,7 @@ + (instancetype)filterWithReportStyle:(KSAppleReportStyle)reportStyle
- (instancetype)initWithReportStyle:(KSAppleReportStyle)reportStyle
{
if ((self = [super init])) {
self.reportStyle = reportStyle;
_reportStyle = reportStyle;
}
return self;
}
Expand Down
30 changes: 10 additions & 20 deletions Sources/KSCrashFilters/KSCrashReportFilterBasic.m
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,18 @@ - (void)filterReports:(NSArray<KSCrashReport *> *)reports onCompletion:(KSCrashR

@interface KSCrashReportFilterCombine ()

@property(nonatomic, readwrite, retain) NSArray *filters;
@property(nonatomic, readwrite, retain) NSArray *keys;
@property(nonatomic, readwrite, copy) NSArray *filters;
@property(nonatomic, readwrite, copy) NSArray *keys;

@end

@implementation KSCrashReportFilterCombine

@synthesize filters = _filters;
@synthesize keys = _keys;

- (instancetype)initWithFilters:(NSArray *)filters keys:(NSArray<NSString *> *)keys
{
if ((self = [super init])) {
self.filters = filters;
self.keys = keys;
_filters = [filters copy];
_keys = [keys copy];
}
return self;
}
Expand Down Expand Up @@ -207,8 +204,6 @@ @interface KSCrashReportFilterPipeline ()

@implementation KSCrashReportFilterPipeline

@synthesize filters = _filters;

+ (instancetype)filterWithFilters:(id)firstFilter, ...
{
ksva_list_to_nsarray(firstFilter, filters);
Expand Down Expand Up @@ -303,16 +298,13 @@ - (void)filterReports:(NSArray<KSCrashReport *> *)reports onCompletion:(KSCrashR

@interface KSCrashReportFilterConcatenate ()

@property(nonatomic, readwrite, retain) NSString *separatorFmt;
@property(nonatomic, readwrite, retain) NSArray<NSString *> *keys;
@property(nonatomic, readwrite, copy) NSString *separatorFmt;
@property(nonatomic, readwrite, copy) NSArray<NSString *> *keys;

@end

@implementation KSCrashReportFilterConcatenate

@synthesize separatorFmt = _separatorFmt;
@synthesize keys = _keys;

+ (instancetype)filterWithSeparatorFmt:(NSString *)separatorFmt keys:(id)firstKey, ...
{
ksva_list_to_nsarray(firstKey, keys);
Expand Down Expand Up @@ -342,8 +334,8 @@ - (instancetype)initWithSeparatorFmt:(NSString *)separatorFmt keysArray:(NSArray
}
}

self.separatorFmt = separatorFmt;
self.keys = realKeys;
_separatorFmt = [separatorFmt copy];
_keys = [realKeys copy];
}
return self;
}
Expand Down Expand Up @@ -372,14 +364,12 @@ - (void)filterReports:(NSArray<KSCrashReport *> *)reports onCompletion:(KSCrashR

@interface KSCrashReportFilterSubset ()

@property(nonatomic, readwrite, retain) NSArray *keyPaths;
@property(nonatomic, readwrite, copy) NSArray *keyPaths;

@end

@implementation KSCrashReportFilterSubset

@synthesize keyPaths = _keyPaths;

+ (instancetype)filterWithKeys:(id)firstKeyPath, ...
{
ksva_list_to_nsarray(firstKeyPath, keyPaths);
Expand Down Expand Up @@ -409,7 +399,7 @@ - (instancetype)initWithKeysArray:(NSArray<NSString *> *)keyPaths
}
}

self.keyPaths = realKeyPaths;
_keyPaths = [realKeyPaths copy];
}
return self;
}
Expand Down
4 changes: 1 addition & 3 deletions Sources/KSCrashFilters/KSCrashReportFilterGZip.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ @interface KSCrashReportFilterGZipCompress ()

@implementation KSCrashReportFilterGZipCompress

@synthesize compressionLevel = _compressionLevel;

+ (instancetype)filterWithCompressionLevel:(NSInteger)compressionLevel
{
return [[self alloc] initWithCompressionLevel:compressionLevel];
Expand All @@ -49,7 +47,7 @@ + (instancetype)filterWithCompressionLevel:(NSInteger)compressionLevel
- (instancetype)initWithCompressionLevel:(NSInteger)compressionLevel
{
if ((self = [super init])) {
self.compressionLevel = compressionLevel;
_compressionLevel = compressionLevel;
}
return self;
}
Expand Down
8 changes: 2 additions & 6 deletions Sources/KSCrashFilters/KSCrashReportFilterJSON.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ @interface KSCrashReportFilterJSONEncode ()

@implementation KSCrashReportFilterJSONEncode

@synthesize encodeOptions = _encodeOptions;

+ (instancetype)filterWithOptions:(KSJSONEncodeOption)options
{
return [[self alloc] initWithOptions:options];
Expand All @@ -48,7 +46,7 @@ + (instancetype)filterWithOptions:(KSJSONEncodeOption)options
- (instancetype)initWithOptions:(KSJSONEncodeOption)options
{
if ((self = [super init])) {
self.encodeOptions = options;
_encodeOptions = options;
}
return self;
}
Expand Down Expand Up @@ -86,8 +84,6 @@ @interface KSCrashReportFilterJSONDecode ()

@implementation KSCrashReportFilterJSONDecode

@synthesize decodeOptions = _encodeOptions;

+ (instancetype)filterWithOptions:(KSJSONDecodeOption)options
{
return [[self alloc] initWithOptions:options];
Expand All @@ -96,7 +92,7 @@ + (instancetype)filterWithOptions:(KSJSONDecodeOption)options
- (instancetype)initWithOptions:(KSJSONDecodeOption)options
{
if ((self = [super init])) {
self.decodeOptions = options;
_decodeOptions = options;
}
return self;
}
Expand Down
41 changes: 14 additions & 27 deletions Sources/KSCrashInstallations/KSCrashInstallation.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,17 @@ @interface KSCrashInstReportField : NSObject
@property(nonatomic, readonly, assign) int index;
@property(nonatomic, readonly, assign) ReportField *field;

@property(nonatomic, readwrite, retain) NSString *key;
@property(nonatomic, readwrite, retain) id value;
@property(nonatomic, readwrite, copy) NSString *key;
@property(nonatomic, readwrite, strong) id value;

@property(nonatomic, readwrite, retain) NSMutableData *fieldBacking;
@property(nonatomic, readwrite, retain) KSCString *keyBacking;
@property(nonatomic, readwrite, retain) KSCString *valueBacking;
@property(nonatomic, readwrite, strong) NSMutableData *fieldBacking;
@property(nonatomic, readwrite, strong) KSCString *keyBacking;
@property(nonatomic, readwrite, strong) KSCString *valueBacking;

@end

@implementation KSCrashInstReportField

@synthesize index = _index;
@synthesize key = _key;
@synthesize value = _value;
@synthesize fieldBacking = _fieldBacking;
@synthesize keyBacking = _keyBacking;
@synthesize valueBacking = _valueBacking;

+ (KSCrashInstReportField *)fieldWithIndex:(int)index
{
return [(KSCrashInstReportField *)[self alloc] initWithIndex:index];
Expand All @@ -84,7 +77,7 @@ - (id)initWithIndex:(int)index
{
if ((self = [super init])) {
_index = index;
self.fieldBacking = [NSMutableData dataWithLength:sizeof(*self.field)];
_fieldBacking = [NSMutableData dataWithLength:sizeof(*self.field)];
}
return self;
}
Expand Down Expand Up @@ -132,21 +125,15 @@ @interface KSCrashInstallation ()

@property(nonatomic, readwrite, assign) int nextFieldIndex;
@property(nonatomic, readonly, assign) CrashHandlerData *crashHandlerData;
@property(nonatomic, readwrite, retain) NSMutableData *crashHandlerDataBacking;
@property(nonatomic, readwrite, retain) NSMutableDictionary *fields;
@property(nonatomic, readwrite, retain) NSArray *requiredProperties;
@property(nonatomic, readwrite, retain) KSCrashReportFilterPipeline *prependedFilters;
@property(nonatomic, readwrite, strong) NSMutableData *crashHandlerDataBacking;
@property(nonatomic, readwrite, strong) NSMutableDictionary *fields;
@property(nonatomic, readwrite, copy) NSArray *requiredProperties;
@property(nonatomic, readwrite, strong) KSCrashReportFilterPipeline *prependedFilters;

@end

@implementation KSCrashInstallation

@synthesize nextFieldIndex = _nextFieldIndex;
@synthesize crashHandlerDataBacking = _crashHandlerDataBacking;
@synthesize fields = _fields;
@synthesize requiredProperties = _requiredProperties;
@synthesize prependedFilters = _prependedFilters;

- (id)init
{
[NSException raise:NSInternalInconsistencyException
Expand All @@ -157,12 +144,12 @@ - (id)init
- (id)initWithRequiredProperties:(NSArray *)requiredProperties
{
if ((self = [super init])) {
self.crashHandlerDataBacking =
_crashHandlerDataBacking =
[NSMutableData dataWithLength:sizeof(*self.crashHandlerData) +
sizeof(*self.crashHandlerData->reportFields) * kMaxProperties];
self.fields = [NSMutableDictionary dictionary];
self.requiredProperties = requiredProperties;
self.prependedFilters = [KSCrashReportFilterPipeline filterWithFilters:nil];
_fields = [NSMutableDictionary dictionary];
_requiredProperties = [requiredProperties copy];
_prependedFilters = [KSCrashReportFilterPipeline filterWithFilters:nil];
}
return self;
}
Expand Down
4 changes: 1 addition & 3 deletions Sources/KSCrashInstallations/KSCrashInstallationConsole.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

@implementation KSCrashInstallationConsole

@synthesize printAppleFormat = _printAppleFormat;

+ (instancetype)sharedInstance
{
static KSCrashInstallationConsole *sharedInstance = nil;
Expand All @@ -49,7 +47,7 @@ + (instancetype)sharedInstance
- (id)init
{
if ((self = [super initWithRequiredProperties:nil])) {
self.printAppleFormat = NO;
_printAppleFormat = NO;
}
return self;
}
Expand Down
13 changes: 3 additions & 10 deletions Sources/KSCrashInstallations/KSCrashInstallationEmail.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,12 @@

@interface KSCrashInstallationEmail ()

@property(nonatomic, readwrite, retain) NSDictionary *defaultFilenameFormats;
@property(nonatomic, readwrite, copy) NSDictionary *defaultFilenameFormats;

@end

@implementation KSCrashInstallationEmail

@synthesize recipients = _recipients;
@synthesize subject = _subject;
@synthesize message = _message;
@synthesize filenameFmt = _filenameFmt;
@synthesize reportStyle = _reportStyle;
@synthesize defaultFilenameFormats = _defaultFilenameFormats;

+ (instancetype)sharedInstance
{
static KSCrashInstallationEmail *sharedInstance = nil;
Expand All @@ -60,8 +53,8 @@ - (id)init
if ((self = [super
initWithRequiredProperties:[NSArray arrayWithObjects:@"recipients", @"subject", @"filenameFmt", nil]])) {
NSString *bundleName = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
self.subject = [NSString stringWithFormat:@"Crash Report (%@)", bundleName];
self.defaultFilenameFormats = [NSDictionary
_subject = [NSString stringWithFormat:@"Crash Report (%@)", bundleName];
_defaultFilenameFormats = [NSDictionary
dictionaryWithObjectsAndKeys:[NSString stringWithFormat:@"crash-report-%@-%%d.txt.gz", bundleName],
[NSNumber numberWithInt:KSCrashEmailReportStyleApple],
[NSString stringWithFormat:@"crash-report-%@-%%d.json.gz", bundleName],
Expand Down
2 changes: 0 additions & 2 deletions Sources/KSCrashInstallations/KSCrashInstallationStandard.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@

@implementation KSCrashInstallationStandard

@synthesize url = _url;

+ (instancetype)sharedInstance
{
static KSCrashInstallationStandard *sharedInstance = nil;
Expand Down
Loading

0 comments on commit 18ddf26

Please sign in to comment.