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

src: use enum class instead of enum in node_i18n #45646

Merged
merged 4 commits into from Nov 30, 2022

Conversation

deokjinkim
Copy link
Contributor

"enum class" has more advantages than "enum" because it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. i18n-api Issues and PRs related to the i18n implementation. needs-ci PRs that need a full CI run. labels Nov 27, 2022
@deokjinkim deokjinkim force-pushed the 221127_use_enum_class branch 2 times, most recently from 2ea515e to eb666b2 Compare November 27, 2022 12:13
@@ -42,7 +42,7 @@ bool InitializeICUDirectory(const std::string& path);

void SetDefaultTimeZone(const char* tzid);

enum idna_mode {
enum class idna_mode {
Copy link
Member

Choose a reason for hiding this comment

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

I suggest removing the IDNA_ prefix from the members of idna_mode since the scope is changing. For example, idna_mode::IDNA_STRICT should just be idna_mode::STRICT.

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 think good suggestion from a clean code point of view. Removed IDNA_ prefix.

"enum class" has more advantages than "enum" because
it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
@deokjinkim
Copy link
Contributor Author

@tniessen BTW, I have one question about test. For now, Build Windows and Coverage Windows are failed, but I don't know why these tests are failed. It's very helpful if you let me know how I can resolve this case.

@targos
Copy link
Member

targos commented Nov 28, 2022

Windows errors:

https://github.com/nodejs/node/actions/runs/3561646551/jobs/5983757408#step:6:2624

D:\a\node\node\src\node_i18n.h(53,3): error C2143: syntax error: missing '}' before 'constant' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(53,3): error C2059: syntax error: 'constant' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(54,1): error C2143: syntax error: missing ';' before '}' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(61,17): error C2061: syntax error: identifier 'idna_mode' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(139,1): error C2059: syntax error: '}' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(139,1): error C2143: syntax error: missing ';' before '}' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\inspector_socket.h(12,16): error C2143: syntax error: missing ';' before '{' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\inspector_socket.h(12,16): error C2447: '{': missing function header (old-style formal list?) [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\inspector_socket_server.h(85,25): error C2061: syntax error: identifier 'InspectorSocket' [D:\a\node\node\libnode.vcxproj]

This change is needed to fix error of window build.
src/node_i18n.h Outdated Show resolved Hide resolved
@deokjinkim
Copy link
Contributor Author

Windows errors:

https://github.com/nodejs/node/actions/runs/3561646551/jobs/5983757408#step:6:2624

D:\a\node\node\src\node_i18n.h(53,3): error C2143: syntax error: missing '}' before 'constant' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(53,3): error C2059: syntax error: 'constant' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(54,1): error C2143: syntax error: missing ';' before '}' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(61,17): error C2061: syntax error: identifier 'idna_mode' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(139,1): error C2059: syntax error: '}' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\node_i18n.h(139,1): error C2143: syntax error: missing ';' before '}' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\inspector_socket.h(12,16): error C2143: syntax error: missing ';' before '{' [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\inspector_socket.h(12,16): error C2447: '{': missing function header (old-style formal list?) [D:\a\node\node\libnode.vcxproj]
D:\a\node\node\src\inspector_socket_server.h(85,25): error C2061: syntax error: identifier 'InspectorSocket' [D:\a\node\node\libnode.vcxproj]

Thanks to your sharing, I could find solution to avoid error of window build.

@tniessen tniessen added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 28, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 28, 2022
@nodejs-github-bot

This comment was marked as outdated.

@nodejs-github-bot
Copy link
Collaborator

@tniessen tniessen added commit-queue Add this label to land a pull request using GitHub Actions. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Nov 30, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 30, 2022
@nodejs-github-bot nodejs-github-bot merged commit 1750a94 into nodejs:main Nov 30, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 1750a94

ErickWendel pushed a commit to ErickWendel/node that referenced this pull request Nov 30, 2022
"enum class" has more advantages than "enum" because
it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
PR-URL: nodejs#45646
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
targos pushed a commit that referenced this pull request Dec 12, 2022
"enum class" has more advantages than "enum" because
it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
PR-URL: #45646
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
"enum class" has more advantages than "enum" because
it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
PR-URL: #45646
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
"enum class" has more advantages than "enum" because
it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
PR-URL: #45646
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
"enum class" has more advantages than "enum" because
it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
PR-URL: #45646
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 4, 2023
"enum class" has more advantages than "enum" because
it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
PR-URL: #45646
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 5, 2023
"enum class" has more advantages than "enum" because
it's strongly typed and scoped.

Refs: https://isocpp.org/wiki/faq/cpp11-language-types#enum-class
PR-URL: #45646
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. c++ Issues and PRs that require attention from people who are familiar with C++. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. i18n-api Issues and PRs related to the i18n implementation. needs-ci PRs that need a full CI run.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants