-
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
ObjectiveCDictionaryExtension to correctly handle maps of root objects #81
Conversation
plank.xcodeproj/project.pbxproj
Outdated
sourceTree = "<group>"; | ||
tabWidth = 4; |
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.
Just a little ride along :)
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.
We may should have a different PR for it, but I would let @rahul-malik make the call
Examples/Cocoa/Sources/objc/Pin.m
Outdated
@@ -307,8 +346,10 @@ - (BOOL)isEqualToPin:(Pin *)anObject | |||
(_counts == anObject.counts || [_counts isEqualToDictionary:anObject.counts]) && | |||
(_descriptionText == anObject.descriptionText || [_descriptionText isEqualToString:anObject.descriptionText]) && | |||
(_creator == anObject.creator || [_creator isEqualToDictionary:anObject.creator]) && | |||
(_tags == anObject.tags || [_tags isEqual:anObject.tags]) && |
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.
Can we use isEqualToArray:
here?
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 point. Here is the PR :)
plank.xcodeproj/project.pbxproj
Outdated
sourceTree = "<group>"; | ||
tabWidth = 4; |
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.
We may should have a different PR for it, but I would let @rahul-malik make the call
@@ -676,6 +757,11 @@ - (void)setCreator:(NSDictionary<NSString *, User *> *)creator | |||
_creator = creator; | |||
_pinDirtyProperties.PinDirtyPropertyCreator = 1; | |||
} | |||
- (void)setTags:(NSArray<NSDictionary *> *)tags | |||
{ | |||
_tags = tags; |
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.
Should we copy in here and same for NSDictionary cases?
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.
Yeap, but not in this PR :)
for (id obj0 in items) { | ||
if (obj0 != (id)kCFNull) { | ||
id tmp0 = nil; | ||
tmp0 = obj0; |
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.
Can obj0
ever nil
in here as we iterate through an NSArray
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.
Not that I know of.
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.
So should we remove this tmp0 copy than and just add the obj0 in the result0 directly?
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.
Agree, although these lines were generated by ObjectiveCInitExtension
, so out of scope :)
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.
LGTM, but would like to have @rahul-malik another look over it.
for (id obj0 in items) { | ||
if (obj0 != (id)kCFNull) { | ||
id tmp0 = nil; | ||
tmp0 = obj0; |
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.
So should we remove this tmp0 copy than and just add the obj0 in the result0 directly?
plank.xcodeproj/project.pbxproj
Outdated
@@ -172,7 +172,9 @@ | |||
OBJ_23 /* Utility */, | |||
OBJ_24 /* Products */, | |||
); | |||
indentWidth = 2; |
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.
Are 2 indentations the default we have?
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.
Haha, I should have removed those lines. Sorry.
830d86f
to
29794bd
Compare
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.
Looks good, please address comments and let me know if you're ready to land
switch type.unsafelyUnwrapped { | ||
case .map(valueType: .none): | ||
return [ | ||
ObjCIR.ifStmt("\(propIVarName) != nil") {[ |
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.
You should use ObjCIR.ifElseStmt
here :)
@@ -205,7 +205,7 @@ public struct ObjCModelRenderer: ObjCFileRenderer { | |||
(.privateM, self.renderHash()), | |||
(.publicM, self.renderMergeWithModel()), | |||
(.publicM, self.renderMergeWithModelWithInitType()), | |||
(.publicM, self.renderGenerateDictionary()) | |||
(self.isBaseClass ? .publicM : .privateM, self.renderGenerateDictionary()) | |||
|
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.
nice!
Examples/PDK/pin.json
Outdated
}, | ||
"visual_search_attrs": { | ||
"type": "object" | ||
} |
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.
thanks for adding these cases!
- Update Pin example - Minor change in plank.xcodeproj
0776381
to
d293d0e
Compare
@rahul-malik @maicki Thanks for reviewing. Comments addressed! |
return [ | ||
ObjCIR.ifStmt("\(propIVarName) != nil && [NSValueTransformer allowsReverseTransformation]") {[ | ||
return | ||
ObjCIR.ifElseStmt("\(propIVarName) != nil && [NSValueTransformer allowsReverseTransformation]") {[ |
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.
I don't think I saw this the first time, don't we have to get the actual NSValueTransformer
subclass here?
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.
We should be able to get the transformer instance with dateValueTransformerKey
, get it's class and then ask it if it allowsReverseTransformation
Thanks @nguyenhuy - I caught another issue in that code if you don't mind fixing. I'll look again in the morning |
Generated by 🚫 Danger |
@rahul-malik Done! |
No description provided.