Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
src: avoid prototype access in binding templates#47913
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
Uh oh!
There was an error while loading. Please reload this page.
Conversation
nodejs-github-bot commented May 8, 2023
Review requested:
|
nodejs-github-bot commented May 8, 2023
nodejs-github-bot commented May 10, 2023
nodejs-github-bot commented May 11, 2023
Commit Queue failed- Loading data for nodejs/node/pull/47913 ✔ Done loading data for nodejs/node/pull/47913 ----------------------------------- PR info ------------------------------------ Title src: avoid prototype access in binding templates (#47913) Author Joyee Cheung (@joyeecheung) Branch joyeecheung:binding -> nodejs:main Labels c++, lib / src, needs-ci Commits 1 - src: avoid prototype access in binding templates Committers 1 - Joyee Cheung PR-URL: https://github.com/nodejs/node/pull/47913 Reviewed-By: Chengzhong Wu Reviewed-By: James M Snell ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/47913 Reviewed-By: Chengzhong Wu Reviewed-By: James M Snell -------------------------------------------------------------------------------- ℹ This PR was created on Mon, 08 May 2023 03:16:57 GMT ✔ Approvals: 2 ✔ - Chengzhong Wu (@legendecas) (TSC): https://github.com/nodejs/node/pull/47913#pullrequestreview-1418106668 ✔ - James M Snell (@jasnell) (TSC): https://github.com/nodejs/node/pull/47913#pullrequestreview-1419744904 ✘ Last GitHub CI failed ℹ Last Full PR CI on 2023-05-10T11:42:30Z: https://ci.nodejs.org/job/node-test-pull-request/51743/ - Querying data for job/node-test-pull-request/51743/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ Aborted `git node land` session in /home/runner/work/node/node/.ncuhttps://github.com/nodejs/node/actions/runs/4948851579 |
addaleax commented May 11, 2023
I think what would be nice for the PR description/commit message is a motivation for why this change is right, not just what it does. |
joyeecheung commented May 12, 2023 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Do you have any suggestions? I am not sure how to formulate the motivation (because falling back to prototype lookup for these is unnecessary and a bit awkward?). It's like when you define a module.exports you don't do this weird dance: and just do |
joyeecheung commented May 18, 2023
Ping @addaleax Do you have any specific suggestions about the commit message? Or should I just use that example above to explain it? |
addaleax commented May 19, 2023
@joyeecheung No strong preferences, just wanted to make sure that it’s just a simplification of the code and otherwise doesn’t really change anything |
legendecas commented May 22, 2023
Yeah, I believe this is a simplification of the code. The cpp format linter is complaining. A re-format might be needed. |
This patch makes the binding templates ObjectTemplates, since we don't actually need the constructor function. This also avoids setting the properties on prototype, and instead initializes them directly on the object template. Previously the initialization was similar to: ``` function Binding(){} Binding.prototype.property = ...; module.exports = new Binding; ``` Now it's similar to: ``` module.exports ={property: ... }; ```084dfdd to be2d7edComparenodejs-github-bot commented May 23, 2023
nodejs-github-bot commented May 23, 2023
nodejs-github-bot commented May 24, 2023
This patch makes the binding templates ObjectTemplates, since we don't actually need the constructor function. This also avoids setting the properties on prototype, and instead initializes them directly on the object template. Previously the initialization was similar to: ``` function Binding(){} Binding.prototype.property = ...; module.exports = new Binding; ``` Now it's similar to: ``` module.exports ={property: ... }; ``` PR-URL: #47913 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]>joyeecheung commented May 24, 2023
Landed in c0365fd with the commit message fixed. |
This patch makes the binding templates ObjectTemplates, since we don't actually need the constructor function. This also avoids setting the properties on prototype, and instead initializes them directly on the object template. Previously the initialization was similar to: ``` function Binding(){} Binding.prototype.property = ...; module.exports = new Binding; ``` Now it's similar to: ``` module.exports ={property: ... }; ``` PR-URL: #47913 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]>This patch makes the binding templates ObjectTemplates, since we don't actually need the constructor function. This also avoids setting the properties on prototype, and instead initializes them directly on the object template. Previously the initialization was similar to: ``` function Binding(){} Binding.prototype.property = ...; module.exports = new Binding; ``` Now it's similar to: ``` module.exports ={property: ... }; ``` PR-URL: nodejs#47913 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]>This patch makes the binding templates ObjectTemplates, since we don't actually need the constructor function. This also avoids setting the properties on prototype, and instead initializes them directly on the object template. Previously the initialization was similar to: ``` function Binding(){} Binding.prototype.property = ...; module.exports = new Binding; ``` Now it's similar to: ``` module.exports ={property: ... }; ``` PR-URL: nodejs#47913 Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]>
This patch makes the binding templates ObjectTemplates, since we don't actually need the constructor function. This also avoids setting the properties on prototype, and instead initializes them directly on the object template.