RESOLVED FIXED 175172
Use enum classes within FileSystem
https://bugs.webkit.org/show_bug.cgi?id=175172
Summary Use enum classes within FileSystem
Don Olmstead
Reported 2017-08-03 19:00:33 PDT
Turn FileOpenMode, FileSeekOrigin, and FileLock mode enums into enum classes.
Attachments
Patch (29.88 KB, patch)
2017-08-03 19:27 PDT, Don Olmstead
no flags
Patch (46.38 KB, patch)
2017-11-06 10:11 PST, Christopher Reid
no flags
Patch (46.38 KB, patch)
2017-11-06 10:18 PST, Christopher Reid
no flags
Patch (46.33 KB, patch)
2017-11-06 10:53 PST, Christopher Reid
no flags
Patch - Additional Cleanup (32.77 KB, patch)
2017-11-08 16:52 PST, Christopher Reid
no flags
Patch - Additional Cleanup (32.84 KB, patch)
2017-11-08 17:24 PST, Christopher Reid
no flags
Don Olmstead
Comment 1 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.
Don Olmstead
Comment 2 2017-08-03 19:56:17 PDT
Well at least it worked on windows
Christopher Reid
Comment 3 2017-11-06 10:11:48 PST
Build Bot
Comment 4 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.
Christopher Reid
Comment 5 2017-11-06 10:18:10 PST
Christopher Reid
Comment 6 2017-11-06 10:53:38 PST
Created attachment 326133 [details] Patch Removing what seems to be unnecessary explicit templates
Christopher Reid
Comment 7 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.
WebKit Commit Bot
Comment 8 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>
WebKit Commit Bot
Comment 9 2017-11-06 12:20:34 PST
All reviewed patches have been landed. Closing bug.
Darin Adler
Comment 10 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.
Darin Adler
Comment 11 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".
Christopher Reid
Comment 12 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.
Don Olmstead
Comment 13 2017-11-08 17:00:45 PST
Reopening for cleanup
Christopher Reid
Comment 14 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.
WebKit Commit Bot
Comment 15 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>
WebKit Commit Bot
Comment 16 2017-11-09 10:33:39 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 17 2017-11-15 09:41:48 PST
Note You need to log in before you can comment on or make changes to this bug.