RESOLVED FIXED 173311
Do not mix C and C++ API error constants
https://bugs.webkit.org/show_bug.cgi?id=173311
Summary Do not mix C and C++ API error constants
Carlos Garcia Campos
Reported 2017-06-13 06:05:30 PDT
In r214934 I added error constants to API::Error, but not for all errors exposed in the C API. Because of this we are mixing both constants in WebErrors and in GTk+ WebKitPrivate.
Attachments
Patch (11.61 KB, patch)
2017-06-13 06:07 PDT, Carlos Garcia Campos
achristensen: review+
Carlos Garcia Campos
Comment 1 2017-06-13 06:07:44 PDT
Build Bot
Comment 2 2017-06-13 06:08:51 PDT
Thanks for the patch. If this patch contains new public API please make sure it follows the guidelines for new WebKit2 GTK+ API. See http://trac.webkit.org/wiki/WebKitGTK/AddingNewWebKit2API
Alex Christensen
Comment 3 2017-06-13 09:56:55 PDT
Comment on attachment 312766 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=312766&action=review > Source/WebKit2/Shared/API/APIError.h:51 > + enum General { We're trying to use more enum classes in WebKit unless there's a good reason not to. And we need to be sure to have source and binary compatibility, which I think this patch has.
Carlos Garcia Campos
Comment 4 2017-06-13 10:38:01 PDT
(In reply to Alex Christensen from comment #3) > Comment on attachment 312766 [details] > Patch > > View in context: > https://bugs.webkit.org/attachment.cgi?id=312766&action=review > > > Source/WebKit2/Shared/API/APIError.h:51 > > + enum General { > > We're trying to use more enum classes in WebKit unless there's a good reason > not to. And we need to be sure to have source and binary compatibility, > which I think this patch has. Yes, in this particular case we don't use enum class, because we are interested in the integer values, we would need to cast everywhere if we used enum class.
Alex Christensen
Comment 5 2017-06-13 12:31:30 PDT
I think the necessity of including from c headers is the only good reason to use an enum instead of an enum class.
Carlos Garcia Campos
Comment 6 2017-06-13 23:31:22 PDT
Darin Adler
Comment 7 2017-06-14 07:30:17 PDT
If there are two sets of constants, that must be identical, what keeps them in sync? If nothing else, should we write static_assert statements that check that they are equal?
Carlos Garcia Campos
Comment 8 2017-06-14 08:26:38 PDT
(In reply to Darin Adler from comment #7) > If there are two sets of constants, that must be identical, what keeps them > in sync? If nothing else, should we write static_assert statements that > check that they are equal? I think we should make WKErrorGetErrorCode return the value using a switch and checking the API::Error value, even if they are currently the same values. That's what we do in the GTK+ API implementation. I'll do it in a follow up if you agree.
Darin Adler
Comment 9 2017-06-14 16:35:03 PDT
I do agree.
Note You need to log in before you can comment on or make changes to this bug.