Bug 175172 - Use enum classes within FileSystem
Summary: Use enum classes within FileSystem
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Don Olmstead
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-08-03 19:00 PDT by Don Olmstead
Modified: 2017-11-15 09:41 PST (History)
8 users (show)

See Also:


Attachments
Patch (29.88 KB, patch)
2017-08-03 19:27 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
Patch (46.38 KB, patch)
2017-11-06 10:11 PST, Christopher Reid
no flags Details | Formatted Diff | Diff
Patch (46.38 KB, patch)
2017-11-06 10:18 PST, Christopher Reid
no flags Details | Formatted Diff | Diff
Patch (46.33 KB, patch)
2017-11-06 10:53 PST, Christopher Reid
no flags Details | Formatted Diff | Diff
Patch - Additional Cleanup (32.77 KB, patch)
2017-11-08 16:52 PST, Christopher Reid
no flags Details | Formatted Diff | Diff
Patch - Additional Cleanup (32.84 KB, patch)
2017-11-08 17:24 PST, Christopher Reid
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Don Olmstead 2017-08-03 19:00:33 PDT
Turn FileOpenMode, FileSeekOrigin, and FileLock mode enums into enum classes.
Comment 1 Don Olmstead 2017-08-03 19:27:24 PDT
Created attachment 317198 [details]
Patch

Moves over to enum classes. Let me know if I should use a fixed type for the enum.
Comment 2 Don Olmstead 2017-08-03 19:56:17 PDT
Well at least it worked on windows
Comment 3 Christopher Reid 2017-11-06 10:11:48 PST
Created attachment 326129 [details]
Patch
Comment 4 Build Bot 2017-11-06 10:13:44 PST
Attachment 326129 [details] did not pass style-queue:


ERROR: Source/WTF/wtf/EnumTraits.h:63:  Place brace on its own line for function definitions.  [whitespace/braces] [4]
Total errors found: 1 in 30 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Christopher Reid 2017-11-06 10:18:10 PST
Created attachment 326130 [details]
Patch
Comment 6 Christopher Reid 2017-11-06 10:53:38 PST
Created attachment 326133 [details]
Patch

Removing what seems to be unnecessary explicit templates
Comment 7 Christopher Reid 2017-11-06 11:22:17 PST
Comment on attachment 326133 [details]
Patch

r?

One concern is that WebCore::FileSystem::FileOpenMode::<Enum> is a bit namespace heavy.
I added 'using namespace WebCore::FileSystem' where this namespace chain occurs multiple times.
Let me know if it is preferable to move these enum classes out of the filesystem namespace or even in to its own file.
Comment 8 WebKit Commit Bot 2017-11-06 12:20:32 PST
Comment on attachment 326133 [details]
Patch

Clearing flags on attachment: 326133

Committed r224505: <https://trac.webkit.org/changeset/224505>
Comment 9 WebKit Commit Bot 2017-11-06 12:20:34 PST
All reviewed patches have been landed.  Closing bug.
Comment 10 Darin Adler 2017-11-07 09:14:25 PST
Comment on attachment 326133 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=326133&action=review

> Source/WebCore/platform/FileSystem.h:77
> +enum class FileOpenMode {

When changing to an enum class we should consider shortening names, since the enum name is always a qualifier. For example, these names should just be Read/Write/EventsOnly or possibly ForRead/ForWrite/ForEventsOnly if that seems much clearer. There is no need for the OpenFor prefix when FileOpenMode:: is already a prefix.

Also no need for the "= 0".

> Source/WebCore/platform/FileSystem.h:85
> +enum class FileSeekOrigin {

Same here: Beginning/Current/End.

Also no need for the "= 0".

> Source/WebCore/platform/FileSystem.h:91
> +enum class FileLockMode {

Same here: Shared, Exclusive, Nonblocking.

But an enum class is not a good fit for masks that need to be or-ed together. In modern WebKit code this should be an OptionSet instead.
Comment 11 Darin Adler 2017-11-07 09:15:20 PST
Comment on attachment 326133 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=326133&action=review

>> Source/WebCore/platform/FileSystem.h:91
>> +enum class FileLockMode {
> 
> Same here: Shared, Exclusive, Nonblocking.
> 
> But an enum class is not a good fit for masks that need to be or-ed together. In modern WebKit code this should be an OptionSet instead.

Note that "nonblocking" is a single word so it’s incorrect to capitalize the "B".
Comment 12 Christopher Reid 2017-11-08 16:52:42 PST
Created attachment 326406 [details]
Patch - Additional Cleanup

Thanks for the feedback Darin. Here's a patch addressing your suggestions.

> But an enum class is not a good fit for masks that need to be or-ed together. In modern WebKit code this should be an OptionSet instead.

Ah, I didn't realize WebKit had that. I have updated uses of the FileLockMode enum class to use an OptionSet instead.
Comment 13 Don Olmstead 2017-11-08 17:00:45 PST
Reopening for cleanup
Comment 14 Christopher Reid 2017-11-08 17:24:26 PST
Created attachment 326412 [details]
Patch - Additional Cleanup

Reuploading the last patch so it can get queued in to EWS.
Comment 15 WebKit Commit Bot 2017-11-09 10:33:37 PST
Comment on attachment 326412 [details]
Patch - Additional Cleanup

Clearing flags on attachment: 326412

Committed r224635: <https://trac.webkit.org/changeset/224635>
Comment 16 WebKit Commit Bot 2017-11-09 10:33:39 PST
All reviewed patches have been landed.  Closing bug.
Comment 17 Radar WebKit Bug Importer 2017-11-15 09:41:48 PST
<rdar://problem/35562251>