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

Don't generate dictionary representation #96

Merged
merged 1 commit into from
Nov 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
72 changes: 0 additions & 72 deletions Examples/Cocoa/Sources/Objective_C/Board.m
Original file line number Diff line number Diff line change
Expand Up @@ -280,78 +280,6 @@ - (instancetype)mergeWithModel:(Board *)modelObject initType:(PlankModelInitType
[builder mergeWithModel:modelObject];
return [[Board alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:9];
if (_boardDirtyProperties.BoardDirtyPropertyName) {
if (_name != nil) {
[dict setObject:_name forKey:@"name"];
} else {
[dict setObject:[NSNull null] forKey:@"name"];
}
}
if (_boardDirtyProperties.BoardDirtyPropertyIdentifier) {
if (_identifier != nil) {
[dict setObject:_identifier forKey:@"id"];
} else {
[dict setObject:[NSNull null] forKey:@"id"];
}
}
if (_boardDirtyProperties.BoardDirtyPropertyImage) {
if (_image != nil) {
[dict setObject:[_image dictionaryObjectRepresentation] forKey:@"image"];
} else {
[dict setObject:[NSNull null] forKey:@"image"];
}
}
if (_boardDirtyProperties.BoardDirtyPropertyCounts) {
if (_counts != nil) {
[dict setObject:_counts forKey:@"counts"];
} else {
[dict setObject:[NSNull null] forKey:@"counts"];
}
}
if (_boardDirtyProperties.BoardDirtyPropertyCreatedAt) {
NSValueTransformer *valueTransformer = [NSValueTransformer valueTransformerForName:kPlankDateValueTransformerKey];
if (_createdAt != nil && [[valueTransformer class] allowsReverseTransformation]) {
[dict setObject:[valueTransformer reverseTransformedValue:_createdAt] forKey:@"created_at"];
} else {
[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 dictionaryObjectRepresentation]];
}
}
[dict setObject:result0 forKey:@"contributors"];
}
if (_boardDirtyProperties.BoardDirtyPropertyDescriptionText) {
if (_descriptionText != nil) {
[dict setObject:_descriptionText forKey:@"description"];
} else {
[dict setObject:[NSNull null] forKey:@"description"];
}
}
if (_boardDirtyProperties.BoardDirtyPropertyCreator) {
if (_creator != nil) {
[dict setObject:_creator forKey:@"creator"];
} else {
[dict setObject:[NSNull null] forKey:@"creator"];
}
}
if (_boardDirtyProperties.BoardDirtyPropertyUrl) {
if (_url != nil) {
[dict setObject:[_url absoluteString] forKey:@"url"];
} else {
[dict setObject:[NSNull null] forKey:@"url"];
}
}
return dict;
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
{
Expand Down
18 changes: 0 additions & 18 deletions Examples/Cocoa/Sources/Objective_C/Image.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,24 +164,6 @@ - (instancetype)mergeWithModel:(Image *)modelObject initType:(PlankModelInitType
[builder mergeWithModel:modelObject];
return [[Image alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:3];
if (_imageDirtyProperties.ImageDirtyPropertyHeight) {
[dict setObject:@(_height) forKey: @"height" ];
}
if (_imageDirtyProperties.ImageDirtyPropertyUrl) {
if (_url != nil) {
[dict setObject:[_url absoluteString] forKey:@"url"];
} else {
[dict setObject:[NSNull null] forKey:@"url"];
}
}
if (_imageDirtyProperties.ImageDirtyPropertyWidth) {
[dict setObject:@(_width) forKey: @"width" ];
}
return dict;
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
{
Expand Down
137 changes: 0 additions & 137 deletions Examples/Cocoa/Sources/Objective_C/Pin.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ - (NSUInteger)hash
};
return PINIntegerArrayHash(subhashes, sizeof(subhashes) / sizeof(subhashes[0]));
}
- (id)dictionaryObjectRepresentation
{
switch (self.internalType) {
case PinAttributionObjectsInternalTypeBoard:
return [[NSDictionary alloc]initWithDictionary:[self.value0 dictionaryObjectRepresentation]];
break;
case PinAttributionObjectsInternalTypeUser:
return [[NSDictionary alloc]initWithDictionary:[self.value1 dictionaryObjectRepresentation]];
break;
}
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
{
Expand Down Expand Up @@ -527,132 +516,6 @@ - (instancetype)mergeWithModel:(Pin *)modelObject initType:(PlankModelInitType)i
[builder mergeWithModel:modelObject];
return [[Pin alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:16];
if (_pinDirtyProperties.PinDirtyPropertyNote) {
if (_note != nil) {
[dict setObject:_note forKey:@"note"];
} else {
[dict setObject:[NSNull null] forKey:@"note"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyMedia) {
if (_media != nil) {
[dict setObject:_media forKey:@"media"];
} else {
[dict setObject:[NSNull null] forKey:@"media"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyCounts) {
if (_counts != nil) {
[dict setObject:_counts forKey:@"counts"];
} else {
[dict setObject:[NSNull null] forKey:@"counts"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyDescriptionText) {
if (_descriptionText != nil) {
[dict setObject:_descriptionText forKey:@"description"];
} else {
[dict setObject:[NSNull null] forKey:@"description"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyCreator) {
NSMutableDictionary *items0 = [NSMutableDictionary new];
for (id key in _creator) {
if ([_creator objectForKey:key] != (id)kCFNull) {
[items0 setObject:[[_creator objectForKey:key] dictionaryObjectRepresentation] forKey:key];
}
}
[dict setObject:items0 forKey: @"_creator" ];
}
if (_pinDirtyProperties.PinDirtyPropertyTags) {
NSArray *items0 = _tags;
NSMutableArray *result0 = [NSMutableArray arrayWithCapacity:items0.count];
for (id obj0 in items0) {
if (obj0 != (id)kCFNull) {
[result0 addObject:obj0];
}
}
[dict setObject:result0 forKey:@"tags"];
}
if (_pinDirtyProperties.PinDirtyPropertyAttribution) {
if (_attribution != nil) {
[dict setObject:_attribution forKey:@"attribution"];
} else {
[dict setObject:[NSNull null] forKey:@"attribution"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyBoard) {
if (_board != nil) {
[dict setObject:[_board dictionaryObjectRepresentation] forKey:@"board"];
} else {
[dict setObject:[NSNull null] forKey:@"board"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyVisualSearchAttrs) {
if (_visualSearchAttrs != nil) {
[dict setObject:_visualSearchAttrs forKey:@"visual_search_attrs"];
} else {
[dict setObject:[NSNull null] forKey:@"visual_search_attrs"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyColor) {
if (_color != nil) {
[dict setObject:_color forKey:@"color"];
} else {
[dict setObject:[NSNull null] forKey:@"color"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyLink) {
if (_link != nil) {
[dict setObject:[_link absoluteString] forKey:@"link"];
} else {
[dict setObject:[NSNull null] forKey:@"link"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyIdentifier) {
if (_identifier != nil) {
[dict setObject:_identifier forKey:@"id"];
} else {
[dict setObject:[NSNull null] forKey:@"id"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyImage) {
if (_image != nil) {
[dict setObject:[_image dictionaryObjectRepresentation] forKey:@"image"];
} else {
[dict setObject:[NSNull null] forKey:@"image"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyCreatedAt) {
NSValueTransformer *valueTransformer = [NSValueTransformer valueTransformerForName:kPlankDateValueTransformerKey];
if (_createdAt != nil && [[valueTransformer class] allowsReverseTransformation]) {
[dict setObject:[valueTransformer reverseTransformedValue:_createdAt] forKey:@"created_at"];
} else {
[dict setObject:[NSNull null] forKey:@"created_at"];
}
}
if (_pinDirtyProperties.PinDirtyPropertyAttributionObjects) {
NSArray *items0 = _attributionObjects;
NSMutableArray *result0 = [NSMutableArray arrayWithCapacity:items0.count];
for (id obj0 in items0) {
if (obj0 != (id)kCFNull) {
[result0 addObject:[obj0 dictionaryObjectRepresentation]];
}
}
[dict setObject:result0 forKey:@"attribution_objects"];
}
if (_pinDirtyProperties.PinDirtyPropertyUrl) {
if (_url != nil) {
[dict setObject:[_url absoluteString] forKey:@"url"];
} else {
[dict setObject:[NSNull null] forKey:@"url"];
}
}
return dict;
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
{
Expand Down
62 changes: 0 additions & 62 deletions Examples/Cocoa/Sources/Objective_C/User.m
Original file line number Diff line number Diff line change
Expand Up @@ -245,68 +245,6 @@ - (instancetype)mergeWithModel:(User *)modelObject initType:(PlankModelInitType)
[builder mergeWithModel:modelObject];
return [[User alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:8];
if (_userDirtyProperties.UserDirtyPropertyLastName) {
if (_lastName != nil) {
[dict setObject:_lastName forKey:@"last_name"];
} else {
[dict setObject:[NSNull null] forKey:@"last_name"];
}
}
if (_userDirtyProperties.UserDirtyPropertyIdentifier) {
if (_identifier != nil) {
[dict setObject:_identifier forKey:@"id"];
} else {
[dict setObject:[NSNull null] forKey:@"id"];
}
}
if (_userDirtyProperties.UserDirtyPropertyFirstName) {
if (_firstName != nil) {
[dict setObject:_firstName forKey:@"first_name"];
} else {
[dict setObject:[NSNull null] forKey:@"first_name"];
}
}
if (_userDirtyProperties.UserDirtyPropertyImage) {
if (_image != nil) {
[dict setObject:[_image dictionaryObjectRepresentation] forKey:@"image"];
} else {
[dict setObject:[NSNull null] forKey:@"image"];
}
}
if (_userDirtyProperties.UserDirtyPropertyCounts) {
if (_counts != nil) {
[dict setObject:_counts forKey:@"counts"];
} else {
[dict setObject:[NSNull null] forKey:@"counts"];
}
}
if (_userDirtyProperties.UserDirtyPropertyCreatedAt) {
NSValueTransformer *valueTransformer = [NSValueTransformer valueTransformerForName:kPlankDateValueTransformerKey];
if (_createdAt != nil && [[valueTransformer class] allowsReverseTransformation]) {
[dict setObject:[valueTransformer reverseTransformedValue:_createdAt] forKey:@"created_at"];
} else {
[dict setObject:[NSNull null] forKey:@"created_at"];
}
}
if (_userDirtyProperties.UserDirtyPropertyUsername) {
if (_username != nil) {
[dict setObject:_username forKey:@"username"];
} else {
[dict setObject:[NSNull null] forKey:@"username"];
}
}
if (_userDirtyProperties.UserDirtyPropertyBio) {
if (_bio != nil) {
[dict setObject:_bio forKey:@"bio"];
} else {
[dict setObject:[NSNull null] forKey:@"bio"];
}
}
return dict;
}
#pragma mark - NSCopying
- (id)copyWithZone:(NSZone *)zone
{
Expand Down
1 change: 0 additions & 1 deletion Examples/Cocoa/Sources/Objective_C/include/Board.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isEqualToBoard:(Board *)anObject;
- (instancetype)mergeWithModel:(Board *)modelObject;
- (instancetype)mergeWithModel:(Board *)modelObject initType:(PlankModelInitType)initType;
- (NSDictionary *)dictionaryObjectRepresentation;
@end

@interface BoardBuilder : NSObject
Expand Down
1 change: 0 additions & 1 deletion Examples/Cocoa/Sources/Objective_C/include/Image.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isEqualToImage:(Image *)anObject;
- (instancetype)mergeWithModel:(Image *)modelObject;
- (instancetype)mergeWithModel:(Image *)modelObject initType:(PlankModelInitType)initType;
- (NSDictionary *)dictionaryObjectRepresentation;
@end

@interface ImageBuilder : NSObject
Expand Down
2 changes: 0 additions & 2 deletions Examples/Cocoa/Sources/Objective_C/include/Pin.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ typedef NS_ENUM(NSInteger, PinAttributionObjectsInternalType) {
+ (instancetype)objectWithUser:(User *)user;
- (void)matchBoard:(nullable PLANK_NOESCAPE void (^)(Board * board))boardMatchHandler orUser:(nullable PLANK_NOESCAPE void (^)(User * user))userMatchHandler;
- (BOOL)isEqualToPinAttributionObjects:(PinAttributionObjects *)anObject;
- (id)dictionaryObjectRepresentation;
@end

NS_ASSUME_NONNULL_END
Expand Down Expand Up @@ -60,7 +59,6 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isEqualToPin:(Pin *)anObject;
- (instancetype)mergeWithModel:(Pin *)modelObject;
- (instancetype)mergeWithModel:(Pin *)modelObject initType:(PlankModelInitType)initType;
- (NSDictionary *)dictionaryObjectRepresentation;
@end

@interface PinBuilder : NSObject
Expand Down
1 change: 0 additions & 1 deletion Examples/Cocoa/Sources/Objective_C/include/User.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isEqualToUser:(User *)anObject;
- (instancetype)mergeWithModel:(User *)modelObject;
- (instancetype)mergeWithModel:(User *)modelObject initType:(PlankModelInitType)initType;
- (NSDictionary *)dictionaryObjectRepresentation;
@end

@interface UserBuilder : NSObject
Expand Down
4 changes: 2 additions & 2 deletions Sources/Core/ObjCADTRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ struct ObjCADTRenderer: ObjCFileRenderer {
(.publicM, self.renderMatchFunction()),
(.privateM, self.renderIsEqual()),
(.publicM, self.renderIsEqualToClass()),
(.privateM, self.renderHash()),
(.publicM, self.renderDictionaryObjectRepresentation())
(.privateM, self.renderHash())
// (.publicM, self.renderDictionaryObjectRepresentation())
],
properties: [],
protocols: protocols),
Expand Down
5 changes: 2 additions & 3 deletions Sources/Core/ObjCModelRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,8 @@ public struct ObjCModelRenderer: ObjCFileRenderer {
(.publicM, self.renderIsEqualToClass()),
(.privateM, self.renderHash()),
(.publicM, self.renderMergeWithModel()),
(.publicM, self.renderMergeWithModelWithInitType()),
(self.isBaseClass ? .publicM : .privateM, self.renderGenerateDictionary())

(.publicM, self.renderMergeWithModelWithInitType())
//(self.isBaseClass ? .publicM : .privateM, self.renderGenerateDictionary())
],
properties: properties.map { param, prop in (param, objcClassFromSchema(param, prop.schema), prop, .readonly) },
protocols: protocols
Expand Down