WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
108279
webdatabase: Introducing WTF::TypeSafeEnum and DatabaseError
https://bugs.webkit.org/show_bug.cgi?id=108279
Summary
webdatabase: Introducing WTF::TypeSafeEnum and DatabaseError
Mark Lam
Reported
2013-01-29 18:33:19 PST
This is a sub-task of
https://bugs.webkit.org/show_bug.cgi?id=107475
. Breaking out as a step for easier review. This patch introduces the WTF TypeSafeEnum template and the DatabaseError enum list which instantiates an instance of TypeSafeEnum. The enums in DatabaseError is currently unused, but will be put to use later in
bug 107475
.
Attachments
the patch.
(16.99 KB, patch)
2013-01-29 20:46 PST
,
Mark Lam
no flags
Details
Formatted Diff
Diff
Patch
(7.58 KB, patch)
2013-01-29 21:22 PST
,
Benjamin Poulain
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Mark Lam
Comment 1
2013-01-29 20:46:22 PST
Created
attachment 185386
[details]
the patch.
Geoffrey Garen
Comment 2
2013-01-29 20:50:29 PST
Comment on
attachment 185386
[details]
the patch. View in context:
https://bugs.webkit.org/attachment.cgi?id=185386&action=review
r=me
> Source/WTF/wtf/TypeSafeEnum.h:51 > +// MyEnum value1; // value1 is assigned MyEnum::VALUE_DEFAULT by default.
Typo: MyEnumDef.
> Source/WebCore/Modules/webdatabase/DatabaseError.h:35 > +struct DatabaseErrorDef {
We don't usually use abbreviations like "Def". How about calling this "DatabaseErrorStruct" or "DatabaseErrorDefinition"?
Mark Lam
Comment 3
2013-01-29 20:54:32 PST
Comment on
attachment 185386
[details]
the patch. View in context:
https://bugs.webkit.org/attachment.cgi?id=185386&action=review
>> Source/WTF/wtf/TypeSafeEnum.h:51 >> +// MyEnum value1; // value1 is assigned MyEnum::VALUE_DEFAULT by default. > > Typo: MyEnumDef.
This is not a typo. With the TypeSafeEnum template, you can say MyEnum::VALUE_DEFAULT and it gets redirected to MyEnumDef::VALUE_DEFAULT. ... which reminds me, I should change that to MyEnum::ValueDefault which is what the style checker says is preferred. I will update before committing.
>> Source/WebCore/Modules/webdatabase/DatabaseError.h:35 >> +struct DatabaseErrorDef { > > We don't usually use abbreviations like "Def". How about calling this "DatabaseErrorStruct" or "DatabaseErrorDefinition"?
Will change to DatabaseErrorDefinition.
Benjamin Poulain
Comment 4
2013-01-29 21:04:29 PST
C++ 11 has strongly typed enum. Can't we use that and people without C++ 11 would have weak typed enums? That would make the code simpler.
Mark Lam
Comment 5
2013-01-29 21:11:01 PST
(In reply to
comment #4
)
> C++ 11 has strongly typed enum. > > Can't we use that and people without C++ 11 would have weak typed enums? That would make the code simpler.
The code is not all that complicated, and the type safety actually has an added benefit of scoping e.g. DatabaseError::None. Otherwise, I will have to add a prefix. I'm landing this for now, and will look into how we can abstract this to use C++11 enums if available later.
Benjamin Poulain
Comment 6
2013-01-29 21:15:44 PST
> The code is not all that complicated, and the type safety actually has an added benefit of scoping e.g. DatabaseError::None. Otherwise, I will have to add a prefix.
enum class are scoped.
> I'm landing this for now, and will look into how we can abstract this to use C++11 enums if available later.
I looked into supporting both but that makes things worse. :( Ignore me, go ahead with the patch.
Mark Lam
Comment 7
2013-01-29 21:19:25 PST
Landed in
r141219
: <
http://trac.webkit.org/changeset/141219
>.
Benjamin Poulain
Comment 8
2013-01-29 21:22:05 PST
Reopening to attach new patch.
Benjamin Poulain
Comment 9
2013-01-29 21:22:06 PST
Created
attachment 185390
[details]
Patch
Benjamin Poulain
Comment 10
2013-01-29 21:22:40 PST
Comment on
attachment 185390
[details]
Patch sorry, wrong copy paste :(
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug