-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sequences and rose trees are encodable and copyable.
Added internal debugging method of repr. Fixed some warnings.
- Loading branch information
Showing
21 changed files
with
371 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#import "FOXMacros.h" | ||
|
||
@protocol FOXObjectiveCRepresentation <NSObject> | ||
|
||
- (NSString *)objectiveCStringRepresentation; | ||
|
||
@end | ||
|
||
/*! Internal Debugging Tool. Useful to make certain Fox data structures | ||
* Dump an objective-c compatible representation. | ||
*/ | ||
FOX_EXPORT NSString *FOXRepr(id obj); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#import "FOXObjectiveCRepresentation.h" | ||
|
||
FOX_EXPORT NSString *FOXRepr(id obj) { | ||
if (!obj) { | ||
return nil; | ||
} | ||
if ([obj respondsToSelector:@selector(objectiveCStringRepresentation)]) { | ||
return [obj objectiveCStringRepresentation]; | ||
} | ||
if ([obj isKindOfClass:[NSNull class]]) { | ||
return @"[NSNull null]"; | ||
} | ||
if ([obj isKindOfClass:[NSNumber class]]) { | ||
return [NSString stringWithFormat:@"@%@", obj]; | ||
} | ||
if ([obj isKindOfClass:[NSString class]]) { | ||
return [NSString stringWithFormat:@"@\"%@\"", [[obj stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] | ||
stringByReplacingOccurrencesOfString:@"\"" | ||
withString:@"\\\""]]; | ||
} | ||
if ([obj isKindOfClass:[NSArray class]]) { | ||
NSMutableString *result = [NSMutableString stringWithFormat:@"@["]; | ||
for (id item in obj) { | ||
[result appendFormat:@"%@,\n", FOXRepr(item)]; | ||
} | ||
[result appendString:@"]"]; | ||
return result; | ||
} | ||
if ([obj isKindOfClass:[NSDictionary class]]) { | ||
NSMutableString *result = [NSMutableString stringWithFormat:@"@{"]; | ||
for (id key in obj) { | ||
[result appendFormat:@"%@: %@,\n", FOXRepr(key), FOXRepr(obj[key])]; | ||
} | ||
[result appendString:@"}"]; | ||
return result; | ||
} | ||
[NSException raise:NSInvalidArgumentException format:@"object is not supported to dump: %@ (%@)", | ||
obj, NSStringFromClass([obj class])]; | ||
return nil; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#import "FOXRunnerResult.h" | ||
#import "FOXRoseTree.h" | ||
|
||
@interface FOXRunnerResult (Protected) | ||
@property (nonatomic) FOXRunnerResult *failingRoseTree; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#import "FOXRunnerResult+Protected.h" | ||
#import <objc/runtime.h> | ||
|
||
@implementation FOXRunnerResult (Protected) | ||
|
||
const char *FOXRunnerResultFailingRoseTreeKey; | ||
|
||
- (FOXRoseTree *)failingRoseTree | ||
{ | ||
return objc_getAssociatedObject(self, &FOXRunnerResultFailingRoseTreeKey); | ||
} | ||
|
||
- (void)setFailingRoseTree:(FOXRunnerResult *)failingRoseTree | ||
{ | ||
objc_setAssociatedObject(self, &FOXRunnerResultFailingRoseTreeKey, failingRoseTree, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.