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

Rename dictionaryRepresentation method so it doesn't conflict with Foundation's one #94

Merged
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
6 changes: 3 additions & 3 deletions Examples/Cocoa/Sources/Objective_C/Board.m
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ - (instancetype)mergeWithModel:(Board *)modelObject initType:(PlankModelInitType
[builder mergeWithModel:modelObject];
return [[Board alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryRepresentation
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:9];
if (_boardDirtyProperties.BoardDirtyPropertyName) {
Expand All @@ -299,7 +299,7 @@ - (NSDictionary *)dictionaryRepresentation
}
if (_boardDirtyProperties.BoardDirtyPropertyImage) {
if (_image != nil) {
[dict setObject:[_image dictionaryRepresentation] forKey:@"image"];
[dict setObject:[_image dictionaryObjectRepresentation] forKey:@"image"];
} else {
[dict setObject:[NSNull null] forKey:@"image"];
}
Expand All @@ -324,7 +324,7 @@ - (NSDictionary *)dictionaryRepresentation
NSMutableSet *result0 = [NSMutableSet setWithCapacity:items0.count];
for (id obj0 in items0) {
if (obj0 != (id)kCFNull) {
[result0 addObject:[obj0 dictionaryRepresentation]];
[result0 addObject:[obj0 dictionaryObjectRepresentation]];
}
}
[dict setObject:result0 forKey:@"contributors"];
Expand Down
2 changes: 1 addition & 1 deletion Examples/Cocoa/Sources/Objective_C/Image.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ - (instancetype)mergeWithModel:(Image *)modelObject initType:(PlankModelInitType
[builder mergeWithModel:modelObject];
return [[Image alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryRepresentation
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:3];
if (_imageDirtyProperties.ImageDirtyPropertyHeight) {
Expand Down
16 changes: 8 additions & 8 deletions Examples/Cocoa/Sources/Objective_C/Pin.m
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ - (NSUInteger)hash
};
return PINIntegerArrayHash(subhashes, sizeof(subhashes) / sizeof(subhashes[0]));
}
- (id)dictionaryRepresentation
- (id)dictionaryObjectRepresentation
{
switch (self.internalType) {
case PinAttributionObjectsInternalTypeBoard:
return [[NSDictionary alloc]initWithDictionary:[self.value0 dictionaryRepresentation]];
return [[NSDictionary alloc]initWithDictionary:[self.value0 dictionaryObjectRepresentation]];
break;
case PinAttributionObjectsInternalTypeUser:
return [[NSDictionary alloc]initWithDictionary:[self.value1 dictionaryRepresentation]];
return [[NSDictionary alloc]initWithDictionary:[self.value1 dictionaryObjectRepresentation]];
break;
}
}
Expand Down Expand Up @@ -527,7 +527,7 @@ - (instancetype)mergeWithModel:(Pin *)modelObject initType:(PlankModelInitType)i
[builder mergeWithModel:modelObject];
return [[Pin alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryRepresentation
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:16];
if (_pinDirtyProperties.PinDirtyPropertyNote) {
Expand Down Expand Up @@ -562,7 +562,7 @@ - (NSDictionary *)dictionaryRepresentation
NSMutableDictionary *items0 = [NSMutableDictionary new];
for (id key in _creator) {
if ([_creator objectForKey:key] != (id)kCFNull) {
[items0 setObject:[[_creator objectForKey:key] dictionaryRepresentation] forKey:key];
[items0 setObject:[[_creator objectForKey:key] dictionaryObjectRepresentation] forKey:key];
}
}
[dict setObject:items0 forKey: @"_creator" ];
Expand All @@ -586,7 +586,7 @@ - (NSDictionary *)dictionaryRepresentation
}
if (_pinDirtyProperties.PinDirtyPropertyBoard) {
if (_board != nil) {
[dict setObject:[_board dictionaryRepresentation] forKey:@"board"];
[dict setObject:[_board dictionaryObjectRepresentation] forKey:@"board"];
} else {
[dict setObject:[NSNull null] forKey:@"board"];
}
Expand Down Expand Up @@ -621,7 +621,7 @@ - (NSDictionary *)dictionaryRepresentation
}
if (_pinDirtyProperties.PinDirtyPropertyImage) {
if (_image != nil) {
[dict setObject:[_image dictionaryRepresentation] forKey:@"image"];
[dict setObject:[_image dictionaryObjectRepresentation] forKey:@"image"];
} else {
[dict setObject:[NSNull null] forKey:@"image"];
}
Expand All @@ -639,7 +639,7 @@ - (NSDictionary *)dictionaryRepresentation
NSMutableArray *result0 = [NSMutableArray arrayWithCapacity:items0.count];
for (id obj0 in items0) {
if (obj0 != (id)kCFNull) {
[result0 addObject:[obj0 dictionaryRepresentation]];
[result0 addObject:[obj0 dictionaryObjectRepresentation]];
}
}
[dict setObject:result0 forKey:@"attribution_objects"];
Expand Down
4 changes: 2 additions & 2 deletions Examples/Cocoa/Sources/Objective_C/User.m
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ - (instancetype)mergeWithModel:(User *)modelObject initType:(PlankModelInitType)
[builder mergeWithModel:modelObject];
return [[User alloc] initWithBuilder:builder initType:initType];
}
- (NSDictionary *)dictionaryRepresentation
- (NSDictionary *)dictionaryObjectRepresentation
{
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:8];
if (_userDirtyProperties.UserDirtyPropertyLastName) {
Expand All @@ -271,7 +271,7 @@ - (NSDictionary *)dictionaryRepresentation
}
if (_userDirtyProperties.UserDirtyPropertyImage) {
if (_image != nil) {
[dict setObject:[_image dictionaryRepresentation] forKey:@"image"];
[dict setObject:[_image dictionaryObjectRepresentation] forKey:@"image"];
} else {
[dict setObject:[NSNull null] forKey:@"image"];
}
Expand Down
2 changes: 1 addition & 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,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isEqualToBoard:(Board *)anObject;
- (instancetype)mergeWithModel:(Board *)modelObject;
- (instancetype)mergeWithModel:(Board *)modelObject initType:(PlankModelInitType)initType;
- (NSDictionary *)dictionaryRepresentation;
- (NSDictionary *)dictionaryObjectRepresentation;
@end

@interface BoardBuilder : NSObject
Expand Down
2 changes: 1 addition & 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,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isEqualToImage:(Image *)anObject;
- (instancetype)mergeWithModel:(Image *)modelObject;
- (instancetype)mergeWithModel:(Image *)modelObject initType:(PlankModelInitType)initType;
- (NSDictionary *)dictionaryRepresentation;
- (NSDictionary *)dictionaryObjectRepresentation;
@end

@interface ImageBuilder : NSObject
Expand Down
4 changes: 2 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,7 @@ 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)dictionaryRepresentation;
- (id)dictionaryObjectRepresentation;
@end

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

@interface PinBuilder : NSObject
Expand Down
2 changes: 1 addition & 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,7 @@ NS_ASSUME_NONNULL_BEGIN
- (BOOL)isEqualToUser:(User *)anObject;
- (instancetype)mergeWithModel:(User *)modelObject;
- (instancetype)mergeWithModel:(User *)modelObject initType:(PlankModelInitType)initType;
- (NSDictionary *)dictionaryRepresentation;
- (NSDictionary *)dictionaryObjectRepresentation;
@end

@interface UserBuilder : NSObject
Expand Down
14 changes: 7 additions & 7 deletions Sources/Core/ObjCADTRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ struct ObjCADTRenderer: ObjCFileRenderer {
}
}

func renderDictionaryRepresentation() -> ObjCIR.Method {
return ObjCIR.method("- (id)dictionaryRepresentation") {
func renderDictionaryObjectRepresentation() -> ObjCIR.Method {
return ObjCIR.method("- (id)dictionaryObjectRepresentation") {
[
ObjCIR.switchStmt("self.internalType") {
self.dataTypes.enumerated().map { (index, schemaObj) -> ObjCIR.SwitchCase in
switch schemaObj.schema {
case .object:
return ObjCIR.caseStmt(self.internalTypeEnumName + ObjCADTRenderer.objectName(schemaObj.schema)) {[
ObjCIR.stmt("return [[NSDictionary alloc]initWithDictionary:[self.value\(index) dictionaryRepresentation]]")
ObjCIR.stmt("return [[NSDictionary alloc]initWithDictionary:[self.value\(index) dictionaryObjectRepresentation]]")
]}
case .reference:
return ObjCIR.caseStmt(self.internalTypeEnumName + ObjCADTRenderer.objectName(schemaObj.schema)) {[
ObjCIR.stmt("return [[NSDictionary alloc]initWithDictionary:[self.value\(index) dictionaryRepresentation]]")
ObjCIR.stmt("return [[NSDictionary alloc]initWithDictionary:[self.value\(index) dictionaryObjectRepresentation]]")
]}
case .float:
return ObjCIR.caseStmt(self.internalTypeEnumName + ObjCADTRenderer.objectName(schemaObj.schema)) {[
Expand All @@ -137,11 +137,11 @@ struct ObjCADTRenderer: ObjCFileRenderer {
]}
case .array(itemType: _):
return ObjCIR.caseStmt(self.internalTypeEnumName + ObjCADTRenderer.objectName(schemaObj.schema)) {[
ObjCIR.stmt("return [[NSDictionary alloc]initWithDictionary:[self.value\(index) dictionaryRepresentation]]")
ObjCIR.stmt("return [[NSDictionary alloc]initWithDictionary:[self.value\(index) dictionaryObjectRepresentation]]")
]}
case .set(itemType: _):
return ObjCIR.caseStmt(self.internalTypeEnumName + ObjCADTRenderer.objectName(schemaObj.schema)) {[
ObjCIR.stmt("return [[NSDictionary alloc]initWithDictionary:[self.value\(index) dictionaryRepresentation]]")
ObjCIR.stmt("return [[NSDictionary alloc]initWithDictionary:[self.value\(index) dictionaryObjectRepresentation]]")
]}
case .map(valueType: _):
return ObjCIR.caseStmt(self.internalTypeEnumName + ObjCADTRenderer.objectName(schemaObj.schema)) {[
Expand Down Expand Up @@ -229,7 +229,7 @@ struct ObjCADTRenderer: ObjCFileRenderer {
(.privateM, self.renderIsEqual()),
(.publicM, self.renderIsEqualToClass()),
(.privateM, self.renderHash()),
(.publicM, self.renderDictionaryRepresentation())
(.publicM, self.renderDictionaryObjectRepresentation())
],
properties: [],
protocols: protocols),
Expand Down
12 changes: 6 additions & 6 deletions Sources/Core/ObjectiveCDictionaryExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ extension ObjCModelRenderer {
[renderAddObjectStatement(param, schemaObj.schema, dictionary)]
}
}.joined(separator: "\n")
return ObjCIR.method("- (NSDictionary *)dictionaryRepresentation") {[
return ObjCIR.method("- (NSDictionary *)dictionaryObjectRepresentation") {[
"NSMutableDictionary *\(dictionary) = " +
(self.isBaseClass ? "[[NSMutableDictionary alloc] initWithCapacity:\(self.properties.count)];" :
"[[super dictionaryRepresentation] mutableCopy];"),
"[[super dictionaryObjectRepresentation] mutableCopy];"),
props,
"return \(dictionary);"
]}
Expand Down Expand Up @@ -69,7 +69,7 @@ extension ObjCFileRenderer {
case .object:
return
ObjCIR.ifElseStmt("\(propIVarName) != nil") {[
"[\(dictionary) setObject:[\(propIVarName) dictionaryRepresentation] forKey:@\"\(param)\"];"
"[\(dictionary) setObject:[\(propIVarName) dictionaryObjectRepresentation] forKey:@\"\(param)\"];"
]} {[
"[\(dictionary) setObject:[NSNull null] forKey:@\"\(param)\"];"
]}
Expand Down Expand Up @@ -115,7 +115,7 @@ extension ObjCFileRenderer {
func createCollection(destCollection: String, processObject: String, collectionSchema: Schema, collectionCounter: Int = 0) -> String {
switch collectionSchema {
case .reference, .object, .oneOf(types: _):
return "[\(destCollection) addObject:[\(processObject) dictionaryRepresentation]];"
return "[\(destCollection) addObject:[\(processObject) dictionaryObjectRepresentation]];"
case .array(itemType: let type), .set(itemType: let type):
let currentResult = "result\(collectionCounter)"
let parentResult = "result\(collectionCounter-1)"
Expand Down Expand Up @@ -194,7 +194,7 @@ extension ObjCFileRenderer {
"NSMutableDictionary *items\(counter) = [NSMutableDictionary new];",
ObjCIR.forStmt("id key in \(propIVarName)") { [
ObjCIR.ifStmt("[\(propIVarName) objectForKey:key] != (id)kCFNull") { [
"[items\(counter) setObject:[[\(propIVarName) objectForKey:key] dictionaryRepresentation] forKey:key];"
"[items\(counter) setObject:[[\(propIVarName) objectForKey:key] dictionaryObjectRepresentation] forKey:key];"
]}
]},
"[\(dictionary) setObject:items\(counter) forKey: @\"\(propIVarName)\" ];"
Expand All @@ -213,7 +213,7 @@ extension ObjCFileRenderer {
ObjCIR.switchStmt("\(propIVarName).internalType") {
avTypes.enumerated().map { (_, schema) -> ObjCIR.SwitchCase in
return ObjCIR.caseStmt(self.className+propIVarName.snakeCaseToCamelCase()+"InternalType"+ObjCADTRenderer.objectName(schema)) {[
"[\(dictionary) setObject:[\(propIVarName) dictionaryRepresentation] forKey:@\"\(param)\"];"
"[\(dictionary) setObject:[\(propIVarName) dictionaryObjectRepresentation] forKey:@\"\(param)\"];"
]}
}
}
Expand Down