Skip to content

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

Merged
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
deokjinkim:221127_use_enum_class
Nov 30, 2022
Merged

src: use enum class instead of enum in node_i18n#45646
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
deokjinkim:221127_use_enum_class

Conversation

@deokjinkim

Copy link
Copy Markdown
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-botnodejs-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
deokjinkimforce-pushed the 221127_use_enum_class branch 2 times, most recently from 2ea515e to eb666b2CompareNovember 27, 2022 12:13
Comment threadsrc/node_i18n.h Outdated

Copy link
Copy Markdown
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.

@deokjinkimdeokjinkimNov 28, 2022

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

@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
Copy Markdown
Member

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.
Comment threadsrc/node_i18n.h Outdated
@deokjinkim

Copy link
Copy Markdown
ContributorAuthor

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.

@tniessentniessen 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-actionsgithub-actionsBot 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
Copy Markdown
Collaborator

@tniessentniessen 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-botnodejs-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:mainNov 30, 2022
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in 1750a94

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>
@targostargos mentioned this pull request Dec 12, 2022
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 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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs 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-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.i18n-apiIssues and PRs related to the i18n implementation.needs-ciPRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@deokjinkim@targos@nodejs-github-bot@tniessen@JungMinu@RaisinTen