-
Notifications
You must be signed in to change notification settings - Fork 43
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
Added support for NSSet properties #91
Changes from all commits
1a90da9
8b5e426
e66b8c4
0b0f200
352ed8a
8e68094
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,10 @@ | |
|
||
#import "Board.h" | ||
#import "Image.h" | ||
#import "User.h" | ||
|
||
struct BoardDirtyProperties { | ||
unsigned int BoardDirtyPropertyContributors:1; | ||
unsigned int BoardDirtyPropertyCounts:1; | ||
unsigned int BoardDirtyPropertyCreatedAt:1; | ||
unsigned int BoardDirtyPropertyCreator:1; | ||
|
@@ -99,6 +101,26 @@ - (instancetype)initWithModelDictionary:(NS_VALID_UNTIL_END_OF_SCOPE NSDictionar | |
self->_boardDirtyProperties.BoardDirtyPropertyCreatedAt = 1; | ||
} | ||
} | ||
{ | ||
__unsafe_unretained id value = modelDictionary[@"contributors"]; // Collection will retain. | ||
if (value != nil) { | ||
if (value != (id)kCFNull) { | ||
NSArray *items = value; | ||
NSMutableSet *result0 = [NSMutableSet setWithCapacity:items.count]; | ||
for (id obj0 in items) { | ||
if (obj0 != (id)kCFNull) { | ||
id tmp0 = nil; | ||
tmp0 = [User modelObjectWithDictionary:obj0]; | ||
if (tmp0 != nil) { | ||
[result0 addObject:tmp0]; | ||
} | ||
} | ||
} | ||
self->_contributors = result0; | ||
} | ||
self->_boardDirtyProperties.BoardDirtyPropertyContributors = 1; | ||
} | ||
} | ||
{ | ||
__unsafe_unretained id value = modelDictionary[@"description"]; // Collection will retain. | ||
if (value != nil) { | ||
|
@@ -154,6 +176,7 @@ - (instancetype)initWithBuilder:(BoardBuilder *)builder initType:(PlankModelInit | |
_image = builder.image; | ||
_counts = builder.counts; | ||
_createdAt = builder.createdAt; | ||
_contributors = builder.contributors; | ||
_descriptionText = builder.descriptionText; | ||
_creator = builder.creator; | ||
_url = builder.url; | ||
|
@@ -166,7 +189,7 @@ - (instancetype)initWithBuilder:(BoardBuilder *)builder initType:(PlankModelInit | |
- (NSString *)debugDescription | ||
{ | ||
NSArray<NSString *> *parentDebugDescription = [[super debugDescription] componentsSeparatedByString:@"\n"]; | ||
NSMutableArray *descriptionFields = [NSMutableArray arrayWithCapacity:8]; | ||
NSMutableArray *descriptionFields = [NSMutableArray arrayWithCapacity:9]; | ||
[descriptionFields addObject:parentDebugDescription]; | ||
struct BoardDirtyProperties props = _boardDirtyProperties; | ||
if (props.BoardDirtyPropertyName) { | ||
|
@@ -184,6 +207,9 @@ - (NSString *)debugDescription | |
if (props.BoardDirtyPropertyCreatedAt) { | ||
[descriptionFields addObject:[@"_createdAt = " stringByAppendingFormat:@"%@", _createdAt]]; | ||
} | ||
if (props.BoardDirtyPropertyContributors) { | ||
[descriptionFields addObject:[@"_contributors = " stringByAppendingFormat:@"%@", _contributors]]; | ||
} | ||
if (props.BoardDirtyPropertyDescriptionText) { | ||
[descriptionFields addObject:[@"_descriptionText = " stringByAppendingFormat:@"%@", _descriptionText]]; | ||
} | ||
|
@@ -221,6 +247,7 @@ - (BOOL)isEqualToBoard:(Board *)anObject | |
(_image == anObject.image || [_image isEqual:anObject.image]) && | ||
(_counts == anObject.counts || [_counts isEqualToDictionary:anObject.counts]) && | ||
(_createdAt == anObject.createdAt || [_createdAt isEqualToDate:anObject.createdAt]) && | ||
(_contributors == anObject.contributors || [_contributors isEqualToSet:anObject.contributors]) && | ||
(_descriptionText == anObject.descriptionText || [_descriptionText isEqualToString:anObject.descriptionText]) && | ||
(_creator == anObject.creator || [_creator isEqualToDictionary:anObject.creator]) && | ||
(_url == anObject.url || [_url isEqual:anObject.url]) | ||
|
@@ -235,6 +262,7 @@ - (NSUInteger)hash | |
[_image hash], | ||
[_counts hash], | ||
[_createdAt hash], | ||
[_contributors hash], | ||
[_descriptionText hash], | ||
[_creator hash], | ||
[_url hash] | ||
|
@@ -254,7 +282,7 @@ - (instancetype)mergeWithModel:(Board *)modelObject initType:(PlankModelInitType | |
} | ||
- (NSDictionary *)dictionaryRepresentation | ||
{ | ||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:8]; | ||
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:9]; | ||
if (_boardDirtyProperties.BoardDirtyPropertyName) { | ||
if (_name != nil) { | ||
[dict setObject:_name forKey:@"name"]; | ||
|
@@ -291,6 +319,16 @@ - (NSDictionary *)dictionaryRepresentation | |
[dict setObject:[NSNull null] forKey:@"created_at"]; | ||
} | ||
} | ||
if (_boardDirtyProperties.BoardDirtyPropertyContributors) { | ||
NSSet *items0 = _contributors; | ||
NSMutableSet *result0 = [NSMutableSet setWithCapacity:items0.count]; | ||
for (id obj0 in items0) { | ||
if (obj0 != (id)kCFNull) { | ||
[result0 addObject:[obj0 dictionaryRepresentation]]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we're going to have to add a cast here to avoid hitting warnings for strict selector matching. Added an issue here #90 |
||
} | ||
} | ||
[dict setObject:result0 forKey:@"contributors"]; | ||
} | ||
if (_boardDirtyProperties.BoardDirtyPropertyDescriptionText) { | ||
if (_descriptionText != nil) { | ||
[dict setObject:_descriptionText forKey:@"description"]; | ||
|
@@ -334,6 +372,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder | |
_image = [aDecoder decodeObjectOfClass:[Image class] forKey:@"image"]; | ||
_counts = [aDecoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSNumber class]]] forKey:@"counts"]; | ||
_createdAt = [aDecoder decodeObjectOfClass:[NSDate class] forKey:@"created_at"]; | ||
_contributors = [aDecoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSSet class], [User class]]] forKey:@"contributors"]; | ||
_descriptionText = [aDecoder decodeObjectOfClass:[NSString class] forKey:@"description"]; | ||
_creator = [aDecoder decodeObjectOfClasses:[NSSet setWithArray:@[[NSDictionary class], [NSString class]]] forKey:@"creator"]; | ||
_url = [aDecoder decodeObjectOfClass:[NSURL class] forKey:@"url"]; | ||
|
@@ -342,6 +381,7 @@ - (instancetype)initWithCoder:(NSCoder *)aDecoder | |
_boardDirtyProperties.BoardDirtyPropertyImage = [aDecoder decodeIntForKey:@"image_dirty_property"] & 0x1; | ||
_boardDirtyProperties.BoardDirtyPropertyCounts = [aDecoder decodeIntForKey:@"counts_dirty_property"] & 0x1; | ||
_boardDirtyProperties.BoardDirtyPropertyCreatedAt = [aDecoder decodeIntForKey:@"created_at_dirty_property"] & 0x1; | ||
_boardDirtyProperties.BoardDirtyPropertyContributors = [aDecoder decodeIntForKey:@"contributors_dirty_property"] & 0x1; | ||
_boardDirtyProperties.BoardDirtyPropertyDescriptionText = [aDecoder decodeIntForKey:@"description_dirty_property"] & 0x1; | ||
_boardDirtyProperties.BoardDirtyPropertyCreator = [aDecoder decodeIntForKey:@"creator_dirty_property"] & 0x1; | ||
_boardDirtyProperties.BoardDirtyPropertyUrl = [aDecoder decodeIntForKey:@"url_dirty_property"] & 0x1; | ||
|
@@ -357,6 +397,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder | |
[aCoder encodeObject:self.image forKey:@"image"]; | ||
[aCoder encodeObject:self.counts forKey:@"counts"]; | ||
[aCoder encodeObject:self.createdAt forKey:@"created_at"]; | ||
[aCoder encodeObject:self.contributors forKey:@"contributors"]; | ||
[aCoder encodeObject:self.descriptionText forKey:@"description"]; | ||
[aCoder encodeObject:self.creator forKey:@"creator"]; | ||
[aCoder encodeObject:self.url forKey:@"url"]; | ||
|
@@ -365,6 +406,7 @@ - (void)encodeWithCoder:(NSCoder *)aCoder | |
[aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyImage forKey:@"image_dirty_property"]; | ||
[aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyCounts forKey:@"counts_dirty_property"]; | ||
[aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyCreatedAt forKey:@"created_at_dirty_property"]; | ||
[aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyContributors forKey:@"contributors_dirty_property"]; | ||
[aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyDescriptionText forKey:@"description_dirty_property"]; | ||
[aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyCreator forKey:@"creator_dirty_property"]; | ||
[aCoder encodeInt:_boardDirtyProperties.BoardDirtyPropertyUrl forKey:@"url_dirty_property"]; | ||
|
@@ -394,6 +436,9 @@ - (instancetype)initWithModel:(Board *)modelObject | |
if (boardDirtyProperties.BoardDirtyPropertyCreatedAt) { | ||
_createdAt = modelObject.createdAt; | ||
} | ||
if (boardDirtyProperties.BoardDirtyPropertyContributors) { | ||
_contributors = modelObject.contributors; | ||
} | ||
if (boardDirtyProperties.BoardDirtyPropertyDescriptionText) { | ||
_descriptionText = modelObject.descriptionText; | ||
} | ||
|
@@ -434,6 +479,9 @@ - (void)mergeWithModel:(Board *)modelObject | |
if (modelObject.boardDirtyProperties.BoardDirtyPropertyCreatedAt) { | ||
builder.createdAt = modelObject.createdAt; | ||
} | ||
if (modelObject.boardDirtyProperties.BoardDirtyPropertyContributors) { | ||
builder.contributors = modelObject.contributors; | ||
} | ||
if (modelObject.boardDirtyProperties.BoardDirtyPropertyDescriptionText) { | ||
builder.descriptionText = modelObject.descriptionText; | ||
} | ||
|
@@ -469,6 +517,11 @@ - (void)setCreatedAt:(NSDate *)createdAt | |
_createdAt = createdAt; | ||
_boardDirtyProperties.BoardDirtyPropertyCreatedAt = 1; | ||
} | ||
- (void)setContributors:(NSSet<User *> *)contributors | ||
{ | ||
_contributors = contributors; | ||
_boardDirtyProperties.BoardDirtyPropertyContributors = 1; | ||
} | ||
- (void)setDescriptionText:(NSString *)descriptionText | ||
{ | ||
_descriptionText = descriptionText; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,13 +9,15 @@ | |
|
||
import type { PlankDate, PlankURI } from './runtime.flow.js'; | ||
import type { ImageType } from './ImageType.js'; | ||
import type { UserType } from './UserType.js'; | ||
|
||
export type BoardType = $Shape<{| | ||
+name: ?string, | ||
+id: ?string, | ||
+image: ?ImageType, | ||
+image: ImageType, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this change? Seems not related to this change though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maicki I don't know exactly. This was all generated code. |
||
+counts: ?{ +[string]: number } /* Integer */, | ||
+created_at: ?PlankDate, | ||
+contributors: ?Set<UserType>, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @maicki - Can you sign off on the flow changes? |
||
+description: ?string, | ||
+creator: ?{ +[string]: string }, | ||
+url: ?PlankURI, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this need to be converted to
NSSet
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I just added it.