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

ObjectiveCDictionaryExtension to correctly handle maps of root objects #81

Merged
merged 10 commits into from
Sep 22, 2017

Conversation

nguyenhuy
Copy link
Member

@nguyenhuy nguyenhuy commented Sep 21, 2017

No description provided.

sourceTree = "<group>";
tabWidth = 4;
Copy link
Member Author

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 :)

Copy link
Contributor

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

@@ -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]) &&
Copy link
Contributor

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?

Copy link
Member Author

@nguyenhuy nguyenhuy Sep 21, 2017

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 :)

sourceTree = "<group>";
tabWidth = 4;
Copy link
Contributor

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;
Copy link
Contributor

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?

Copy link
Member Author

@nguyenhuy nguyenhuy Sep 21, 2017

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;
Copy link
Contributor

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

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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 :)

Copy link
Contributor

@maicki maicki left a 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;
Copy link
Contributor

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?

@@ -172,7 +172,9 @@
OBJ_23 /* Utility */,
OBJ_24 /* Products */,
);
indentWidth = 2;
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Collaborator

@rahul-malik rahul-malik left a 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") {[
Copy link
Collaborator

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())

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

},
"visual_search_attrs": {
"type": "object"
}
Copy link
Collaborator

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!

@nguyenhuy
Copy link
Member Author

nguyenhuy commented Sep 21, 2017

@rahul-malik @maicki Thanks for reviewing. Comments addressed!

return [
ObjCIR.ifStmt("\(propIVarName) != nil && [NSValueTransformer allowsReverseTransformation]") {[
return
ObjCIR.ifElseStmt("\(propIVarName) != nil && [NSValueTransformer allowsReverseTransformation]") {[
Copy link
Collaborator

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?

Copy link
Collaborator

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

@rahul-malik
Copy link
Collaborator

Thanks @nguyenhuy - I caught another issue in that code if you don't mind fixing. I'll look again in the morning

@ghost
Copy link

ghost commented Sep 22, 2017

1 Warning
⚠️ Any source code changes should have an entry in CHANGELOG.md or have #trivial in their title.

Generated by 🚫 Danger

@nguyenhuy
Copy link
Member Author

@rahul-malik Done!

@rahul-malik rahul-malik merged commit 6399daf into pinterest:master Sep 22, 2017
@nguyenhuy nguyenhuy deleted the HNDictExtension branch September 22, 2017 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants