Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swiftify API #504

Merged
merged 33 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
5533e5f
Fixes and nullability in `KSCrash.h`
GLinnik21 Jun 17, 2024
4cd99bb
Update `KSCrashAppTransitionState` API
GLinnik21 Jun 17, 2024
16f9fb7
Swiftify KSCrashReportFields
GLinnik21 Jun 17, 2024
26ca00e
Remove boilerplate in ReportFields
GLinnik21 Jun 17, 2024
a37e973
Rename to `sharedInstance` in `KSCrashAppStateTracker`
GLinnik21 Jun 18, 2024
c6f2f9c
Swiftify `KSCrash.h`
GLinnik21 Jun 18, 2024
b74286b
Swiftify `KSCrashAppMemory.h`
GLinnik21 Jun 18, 2024
cfa0ca6
Swiftify `KSCrashAppMemoryTracker.h`
GLinnik21 Jun 18, 2024
08c6510
Swiftify `KSCrashAppStateTracker.h`
GLinnik21 Jun 18, 2024
5ed89d2
Swiftify `KSCrashAppTransitionState.h`
GLinnik21 Jun 18, 2024
0a247ba
Swiftify `KSCrashConfiguration.h`
GLinnik21 Jun 18, 2024
8293eea
Swiftify `KSCrashMonitorType.h`
GLinnik21 Jun 18, 2024
ca45aad
Swiftify `KSCrashReportFields.h`
GLinnik21 Jun 18, 2024
b251255
Swiftify `KSCrashReportFilter.h`
GLinnik21 Jun 18, 2024
701812c
Swiftify `KSCrashReportWriter.h`
GLinnik21 Jun 18, 2024
8f37903
Fix Integer types
GLinnik21 Jun 18, 2024
db090eb
Swiftify `KSCrashReportFilterAlert.h`
GLinnik21 Jun 19, 2024
dd274f5
Swiftify `KSCrashReportFilterAppleFmt.h`
GLinnik21 Jun 19, 2024
d4779ba
Swiftify `KSCrashReportFilterBasic.h`
GLinnik21 Jun 20, 2024
fa8c8ab
Swiftify `KSCrashReportFilterGZip.h`
GLinnik21 Jun 20, 2024
7dcdcde
Remove duplicate declaration in `KSCrashReportFilterBasic.m`
GLinnik21 Jun 20, 2024
3ad09fd
Swiftify `KSCrashReportFilterJSON.h`
GLinnik21 Jun 20, 2024
6d6e4e6
Swiftify `KSCrashReportFilterSets.h`
GLinnik21 Jun 20, 2024
df96db4
Swiftify `KSCrashReportFilterStringify.h`
GLinnik21 Jun 20, 2024
c106293
Swiftify `Sinks`
GLinnik21 Jun 20, 2024
0ae17c7
Swiftify `Installations`
GLinnik21 Jun 20, 2024
6ea521c
Use `instancetype` everywhere. Use ARC property specifiers
GLinnik21 Jun 20, 2024
3199f5a
Fix failing tests and nullability warnings
GLinnik21 Jun 21, 2024
a5bf8e4
Refactor filter assignment to use direct ivar access and remove unnec…
GLinnik21 Jun 22, 2024
8c3aba0
Adjust NS_SWIFT_NAME macro placement for clarity
GLinnik21 Jun 22, 2024
3344bae
Refactor property attributes: switch from retain to copy/strong for a…
GLinnik21 Jun 22, 2024
b7af9c0
Fix formatting issue in sinkWithURL: method declaration
GLinnik21 Jun 22, 2024
0da787f
Update `NS_SWIFT_NAME` attributes to more descriptive names across In…
GLinnik21 Jun 22, 2024
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
16 changes: 8 additions & 8 deletions Sources/KSCrashFilters/KSCrashReportFilterAlert.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,21 +144,21 @@ @implementation KSCrashReportFilterAlert
@synthesize yesAnswer = _yesAnswer;
@synthesize noAnswer = _noAnswer;

+ (KSCrashReportFilterAlert*) filterWithTitle:(NSString*) title
message:(NSString*) message
yesAnswer:(NSString*) yesAnswer
noAnswer:(NSString*) noAnswer
+ (instancetype) filterWithTitle:(NSString*) title
message:(nullable NSString*) message
yesAnswer:(NSString*) yesAnswer
noAnswer:(nullable NSString*) noAnswer;
{
return [[self alloc] initWithTitle:title
message:message
yesAnswer:yesAnswer
noAnswer:noAnswer];
}

- (id) initWithTitle:(NSString*) title
message:(NSString*) message
yesAnswer:(NSString*) yesAnswer
noAnswer:(NSString*) noAnswer
- (instancetype) initWithTitle:(NSString*) title
message:(nullable NSString*) message
yesAnswer:(NSString*) yesAnswer
noAnswer:(nullable NSString*) noAnswer;
{
if((self = [super init]))
{
Expand Down
220 changes: 111 additions & 109 deletions Sources/KSCrashFilters/KSCrashReportFilterAppleFmt.m

Large diffs are not rendered by default.

67 changes: 41 additions & 26 deletions Sources/KSCrashFilters/KSCrashReportFilterBasic.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

@implementation KSCrashReportFilterPassthrough

+ (KSCrashReportFilterPassthrough*) filter
+ (instancetype) filter
{
return [[self alloc] init];
}
Expand All @@ -55,8 +55,6 @@ @interface KSCrashReportFilterCombine ()
@property(nonatomic,readwrite,retain) NSArray* filters;
@property(nonatomic,readwrite,retain) NSArray* keys;

- (id) initWithFilters:(NSArray*) filters keys:(NSArray*) keys;

@end


Expand All @@ -65,7 +63,7 @@ @implementation KSCrashReportFilterCombine
@synthesize filters = _filters;
@synthesize keys = _keys;

- (id) initWithFilters:(NSArray*) filters keys:(NSArray*) keys
- (instancetype) initWithFilters:(NSArray*) filters keys:(NSArray<NSString*>*) keys
{
if((self = [super init]))
{
Expand Down Expand Up @@ -113,15 +111,20 @@ + (KSVA_Block) argBlockWithFilters:(NSMutableArray*) filters andKeys:(NSMutableA
return [block copy];
}

+ (KSCrashReportFilterCombine*) filterWithFiltersAndKeys:(id) firstFilter, ...
+ (instancetype) filterWithFiltersAndKeys:(id) firstFilter, ...
{
NSMutableArray* filters = [NSMutableArray array];
NSMutableArray* keys = [NSMutableArray array];
ksva_iterate_list(firstFilter, [self argBlockWithFilters:filters andKeys:keys]);
return [[self class] filterWithFilters:filters keys:keys];
}

+ (instancetype)filterWithFilters:(NSArray*)filters keys:(NSArray<NSString*>*)keys
{
return [[self alloc] initWithFilters:filters keys:keys];
}

- (id) initWithFiltersAndKeys:(id) firstFilter, ...
- (instancetype) initWithFiltersAndKeys:(id) firstFilter, ...
{
NSMutableArray* filters = [NSMutableArray array];
NSMutableArray* keys = [NSMutableArray array];
Expand Down Expand Up @@ -233,7 +236,7 @@ - (void) filterReports:(NSArray*) reports

@interface KSCrashReportFilterPipeline ()

@property(nonatomic,readwrite,retain) NSArray* filters;
@property(nonatomic,readwrite,copy) NSArray<id<KSCrashReportFilter>>* filters;

@end

Expand All @@ -242,19 +245,24 @@ @implementation KSCrashReportFilterPipeline

@synthesize filters = _filters;

+ (KSCrashReportFilterPipeline*) filterWithFilters:(id) firstFilter, ...
+ (instancetype) filterWithFilters:(id) firstFilter, ...
{
ksva_list_to_nsarray(firstFilter, filters);
return [[self class] filterWithFiltersArray:filters];
}

+ (instancetype) filterWithFiltersArray:(NSArray*) filters
{
return [[self alloc] initWithFiltersArray:filters];
}

- (id) initWithFilters:(id) firstFilter, ...
- (instancetype) initWithFilters:(id) firstFilter, ...
{
ksva_list_to_nsarray(firstFilter, filters);
return [self initWithFiltersArray:filters];
}

- (id) initWithFiltersArray:(NSArray*) filters
- (instancetype) initWithFiltersArray:(NSArray*) filters
{
if((self = [super init]))
{
Expand All @@ -270,15 +278,14 @@ - (id) initWithFiltersArray:(NSArray*) filters
[expandedFilters addObject:filter];
}
}
self.filters = expandedFilters;
_filters = [expandedFilters copy];
}
return self;
}

- (void) addFilter:(id<KSCrashReportFilter>) filter
{
NSMutableArray* mutableFilters = (NSMutableArray*)self.filters; // Shh! Don't tell anyone!
[mutableFilters insertObject:filter atIndex:0];
self.filters = [@[filter] arrayByAddingObjectsFromArray:self.filters];
}

- (void) filterReports:(NSArray*) reports
Expand Down Expand Up @@ -363,14 +370,12 @@ @implementation KSCrashReportFilterObjectForKey
@synthesize key = _key;
@synthesize allowNotFound = _allowNotFound;

+ (KSCrashReportFilterObjectForKey*) filterWithKey:(id)key
allowNotFound:(BOOL) allowNotFound
+ (instancetype) filterWithKey:(id)key allowNotFound:(BOOL) allowNotFound
{
return [[self alloc] initWithKey:key allowNotFound:allowNotFound];
}

- (id) initWithKey:(id)key
allowNotFound:(BOOL) allowNotFound
- (instancetype) initWithKey:(id)key allowNotFound:(BOOL) allowNotFound
{
if((self = [super init]))
{
Expand Down Expand Up @@ -421,7 +426,7 @@ - (void) filterReports:(NSArray*) reports
@interface KSCrashReportFilterConcatenate ()

@property(nonatomic, readwrite, retain) NSString* separatorFmt;
@property(nonatomic, readwrite, retain) NSArray* keys;
@property(nonatomic, readwrite, retain) NSArray<NSString*>* keys;
GLinnik21 marked this conversation as resolved.
Show resolved Hide resolved

@end

Expand All @@ -430,19 +435,24 @@ @implementation KSCrashReportFilterConcatenate
@synthesize separatorFmt = _separatorFmt;
@synthesize keys = _keys;

+ (KSCrashReportFilterConcatenate*) filterWithSeparatorFmt:(NSString*) separatorFmt keys:(id) firstKey, ...
+ (instancetype) filterWithSeparatorFmt:(NSString*) separatorFmt keys:(id) firstKey, ...
{
ksva_list_to_nsarray(firstKey, keys);
return [[self class] filterWithSeparatorFmt:separatorFmt keysArray:keys];
}

+ (instancetype) filterWithSeparatorFmt:(NSString*) separatorFmt keysArray:(NSArray<NSString*>*) keys
{
return [[self alloc] initWithSeparatorFmt:separatorFmt keysArray:keys];
}

- (id) initWithSeparatorFmt:(NSString*) separatorFmt keys:(id) firstKey, ...
- (instancetype) initWithSeparatorFmt:(NSString*) separatorFmt keys:(id) firstKey, ...
{
ksva_list_to_nsarray(firstKey, keys);
return [self initWithSeparatorFmt:separatorFmt keysArray:keys];
}

- (id) initWithSeparatorFmt:(NSString*) separatorFmt keysArray:(NSArray*) keys
- (instancetype) initWithSeparatorFmt:(NSString*) separatorFmt keysArray:(NSArray<NSString*>*) keys
{
if((self = [super init]))
{
Expand Down Expand Up @@ -504,19 +514,24 @@ @implementation KSCrashReportFilterSubset

@synthesize keyPaths = _keyPaths;

+ (KSCrashReportFilterSubset*) filterWithKeys:(id) firstKeyPath, ...
+ (instancetype) filterWithKeys:(id) firstKeyPath, ...
{
ksva_list_to_nsarray(firstKeyPath, keyPaths);
return [[self class] filterWithKeysArray:keyPaths];
}

+ (instancetype) filterWithKeysArray:(NSArray<NSString*>*) keyPaths
{
return [[self alloc] initWithKeysArray:keyPaths];
}

- (id) initWithKeys:(id) firstKeyPath, ...
- (instancetype) initWithKeys:(id) firstKeyPath, ...
{
ksva_list_to_nsarray(firstKeyPath, keyPaths);
return [self initWithKeysArray:keyPaths];
}

- (id) initWithKeysArray:(NSArray*) keyPaths
- (instancetype) initWithKeysArray:(NSArray<NSString*>*) keyPaths
{
if((self = [super init]))
{
Expand Down Expand Up @@ -568,7 +583,7 @@ - (void) filterReports:(NSArray*) reports

@implementation KSCrashReportFilterDataToString

+ (KSCrashReportFilterDataToString*) filter
+ (instancetype) filter
{
return [[self alloc] init];
}
Expand All @@ -591,7 +606,7 @@ - (void) filterReports:(NSArray*) reports

@implementation KSCrashReportFilterStringToData

+ (KSCrashReportFilterStringToData*) filter
+ (instancetype) filter
{
return [[self alloc] init];
}
Expand Down
10 changes: 5 additions & 5 deletions Sources/KSCrashFilters/KSCrashReportFilterGZip.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@

@interface KSCrashReportFilterGZipCompress ()

@property(nonatomic,readwrite,assign) int compressionLevel;
@property(nonatomic,readwrite,assign) NSInteger compressionLevel;

@end

@implementation KSCrashReportFilterGZipCompress

@synthesize compressionLevel = _compressionLevel;

+ (KSCrashReportFilterGZipCompress*) filterWithCompressionLevel:(int) compressionLevel
+ (instancetype) filterWithCompressionLevel:(NSInteger) compressionLevel
{
return [[self alloc] initWithCompressionLevel:compressionLevel];
}

- (id) initWithCompressionLevel:(int) compressionLevel
- (instancetype) initWithCompressionLevel:(NSInteger) compressionLevel
{
if((self = [super init]))
{
Expand All @@ -60,7 +60,7 @@ - (void) filterReports:(NSArray*) reports
for(NSData* report in reports)
{
NSError* error = nil;
NSData* compressedData = [report gzippedWithCompressionLevel:self.compressionLevel
NSData* compressedData = [report gzippedWithCompressionLevel:(int)self.compressionLevel
error:&error];
if(compressedData == nil)
{
Expand All @@ -81,7 +81,7 @@ - (void) filterReports:(NSArray*) reports

@implementation KSCrashReportFilterGZipDecompress

+ (KSCrashReportFilterGZipDecompress*) filter
+ (instancetype) filter
{
return [[self alloc] init];
}
Expand Down
12 changes: 6 additions & 6 deletions Sources/KSCrashFilters/KSCrashReportFilterJSON.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ @implementation KSCrashReportFilterJSONEncode

@synthesize encodeOptions = _encodeOptions;

+ (KSCrashReportFilterJSONEncode*) filterWithOptions:(KSJSONEncodeOption) options
+ (instancetype) filterWithOptions:(KSJSONEncodeOption) options
{
return [(KSCrashReportFilterJSONEncode*)[self alloc] initWithOptions:options];
return [[self alloc] initWithOptions:options];
}

- (id) initWithOptions:(KSJSONEncodeOption) options
- (instancetype) initWithOptions:(KSJSONEncodeOption) options
{
if((self = [super init]))
{
Expand Down Expand Up @@ -94,12 +94,12 @@ @implementation KSCrashReportFilterJSONDecode

@synthesize decodeOptions = _encodeOptions;

+ (KSCrashReportFilterJSONDecode*) filterWithOptions:(KSJSONDecodeOption) options
+ (instancetype) filterWithOptions:(KSJSONDecodeOption) options
{
return [(KSCrashReportFilterJSONDecode*)[self alloc] initWithOptions:options];
return [[self alloc] initWithOptions:options];
}

- (id) initWithOptions:(KSJSONDecodeOption) options
- (instancetype) initWithOptions:(KSJSONDecodeOption) options
{
if((self = [super init]))
{
Expand Down
4 changes: 2 additions & 2 deletions Sources/KSCrashFilters/KSCrashReportFilterSets.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ @implementation KSCrashFilterSets
id<KSCrashReportFilter> appleFilter = [KSCrashReportFilterAppleFmt filterWithReportStyle:reportStyle];
id<KSCrashReportFilter> userSystemFilter = [KSCrashReportFilterPipeline filterWithFilters:
[KSCrashReportFilterSubset filterWithKeys:
@KSCrashField_System,
@KSCrashField_User,
KSCrashField_System,
KSCrashField_User,
nil],
[KSCrashReportFilterJSONEncode filterWithOptions:KSJSONEncodeOptionPretty | KSJSONEncodeOptionSorted],
[KSCrashReportFilterDataToString filter],
Expand Down
2 changes: 1 addition & 1 deletion Sources/KSCrashFilters/KSCrashReportFilterStringify.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

@implementation KSCrashReportFilterStringify

+ (KSCrashReportFilterStringify*) filter
+ (instancetype) filter
{
return [[self alloc] init];
}
Expand Down
20 changes: 12 additions & 8 deletions Sources/KSCrashFilters/include/KSCrashReportFilterAlert.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#import <Foundation/Foundation.h>
#import "KSCrashReportFilter.h"

NS_ASSUME_NONNULL_BEGIN

/** Pops up a standard alert window and awaits a user response before continuing.
*
Expand All @@ -39,6 +40,7 @@
* Input: Any
* Output: Same as input (passthrough)
*/
NS_SWIFT_NAME(CrashReportFilterAlert)
@interface KSCrashReportFilterAlert : NSObject <KSCrashReportFilter>

/**
Expand All @@ -48,10 +50,10 @@
* @param noAnswer The text to put in the "no" button. If nil, the filter will
* proceed unconditionally.
*/
+ (KSCrashReportFilterAlert*) filterWithTitle:(NSString*) title
message:(NSString*) message
yesAnswer:(NSString*) yesAnswer
noAnswer:(NSString*) noAnswer;
+ (instancetype) filterWithTitle:(NSString*) title
message:(nullable NSString*) message
yesAnswer:(NSString*) yesAnswer
noAnswer:(nullable NSString*) noAnswer;

/**
* @param title The title of the alert.
Expand All @@ -60,9 +62,11 @@
* @param noAnswer The text to put in the "no" button. If nil, the filter will
* proceed unconditionally.
*/
- (id) initWithTitle:(NSString*) title
message:(NSString*) message
yesAnswer:(NSString*) yesAnswer
noAnswer:(NSString*) noAnswer;
- (instancetype) initWithTitle:(NSString*) title
message:(nullable NSString*) message
yesAnswer:(NSString*) yesAnswer
noAnswer:(nullable NSString*) noAnswer;

@end

NS_ASSUME_NONNULL_END
Loading
Loading