Skip to content

src: explicitly disallow assign and copy#590

Closed
legendecas wants to merge 1 commit intonodejs:masterfrom
legendecas:disallow
Closed

src: explicitly disallow assign and copy#590
legendecas wants to merge 1 commit intonodejs:masterfrom
legendecas:disallow

Conversation

@legendecas
Copy link
Copy Markdown
Member

Use macros to explicitly disallow assign and copy.

  • npm test passed.

@NickNaso
Copy link
Copy Markdown
Member

NickNaso commented Nov 7, 2019

Hi @legendecas,
the code it's ok and works, but is it really necessary disallow the copy constructor using a macro?
In this way se avoid to manually disallow the copy constructor in 9 classes, but we will lose in code readability.
What do you think?

@legendecas
Copy link
Copy Markdown
Member Author

@NickNaso I found that this is what's done in Node.js core, v8, and NAN, lots of C++ projects.

It can not be denied that with macros we could not get first sight of what's done after the macro expansion. Yet since disallowing assign/copy/move operations are so commonly used, and I cannot assume it would be easy to write such things every time without missing something. So a macro with a straightforward name describing what it would do will be helpful. And I'd assume it would not be confusing very much on this use case.

@gabrielschulhof
Copy link
Copy Markdown
Contributor

@legendecas could you please rebase?

@legendecas
Copy link
Copy Markdown
Member Author

@gabrielschulhof rebased :D

@gabrielschulhof
Copy link
Copy Markdown
Contributor

gabrielschulhof commented Dec 24, 2019

gabrielschulhof pushed a commit that referenced this pull request Dec 24, 2019
PR-URL: #590
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
@gabrielschulhof
Copy link
Copy Markdown
Contributor

Landed in 79deefb.

@legendecas legendecas deleted the disallow branch January 1, 2020 13:31
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
PR-URL: nodejs/node-addon-api#590
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
PR-URL: nodejs/node-addon-api#590
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
PR-URL: nodejs/node-addon-api#590
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
PR-URL: nodejs/node-addon-api#590
Reviewed-By: Gabriel Schulhof <gabriel.schulhof@intel.com>
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