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

[TIMOB-24009] Properly generate properties and methods from protocols #121

Merged
merged 6 commits into from Mar 3, 2017

Conversation

janvennemann
Copy link
Contributor

JIRA: https://jira.appcelerator.org/browse/TIMOB-24009

To skip unnecessary merging it will be checked if a parent class
already implemented a protocol. The function doing this check contained
a bug which would also skip the property and method merging even if the
protocol wasn't implemented by parent class.

To skip unnecessary merging it will be checked if a parent class
already implemented a protocol. The function doing this check contained
a bug which would also skip the property and method merging even if the
protocol wasn't implemented by parent class.
*
* @param {Object} json Native code metabase
* @param {Object} cls Class to traverse upwards from
* @param {String} proto The protocoll to look for in parent classes
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo protocoll

* @return {bool} True if protocol already implemented in a parent class, false otherwise.
*/
function isProtocolImplementedBySuperClass (json, cls, proto) {
var currentClass = cls.superclass;
Copy link
Contributor

Choose a reason for hiding this comment

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

This was checked against null before. Are there no cases where cls could be null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No because in the previous implementation cls was overwritten by cls.superclass and that could be undefined once NSObject was reached. Nevertheless i'll make an additional check just to be sure ;)

@hansemannn
Copy link
Contributor

CR looks good. Will FT next, is the FB example supposed to work with this change?

@janvennemann
Copy link
Contributor Author

Yes, i was able to successfully call all methods on FBSDKShareLinkContent although i don't have any FB app on the simulator so nothing happened. But no errors anymore ;)

var logIntendation = logIntendationCharacter.repeat(logIntendationLevel++);
var parentProtocols = protocol.protocols;
var protocolSignature = parentProtocols ? protocol.name + ' <' + parentProtocols.join(', ') + '>' : protocol.name;
util.logger.trace(logIntendation + 'Processing incorporated protocols for ' + protocolSignature);
Copy link
Contributor

Choose a reason for hiding this comment

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

"incorporate" sounds wrong here. Rather use "integrate" or "merge".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I couldn't really decide on the wording here. Sometimes Apple refers to it as inherited protocols, sometimes as incorporated protocols. But i do agree incorporated sound odd here, i'll reword that.

return;
}
if (!parentProtocols) {
util.logger.trace(logIntendation + protocol.name + ' does not incoporates any other protocols.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the "s" from the verb, the 3rd person singular is already in "does" 😅.

},
src: ['*.js','lib/**/*.js','test/**/*.js']
src: ['*.js', 'lib/**/*.js'],
Copy link
Contributor

Choose a reason for hiding this comment

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

What happened to the test-files? And why the comma at the end?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Most of the test files don't pass jshint because of the way should assertions are written, that's why i removed them from the list. The comma is leftover from when i used more options during testing, i'll fix that.

Copy link
Contributor

@hansemannn hansemannn left a comment

Choose a reason for hiding this comment

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

Left some comments

@janvennemann
Copy link
Contributor Author

Addressed!

@hansemannn
Copy link
Contributor

Approved!

@hansemannn hansemannn merged commit 168f74f into tidev:master Mar 3, 2017
@janvennemann janvennemann deleted the TIMOB-24009 branch March 23, 2017 13:55
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.

None yet

2 participants