Bug 157235 - Stop using old-style string-based enums in Internals.idl
Summary: Stop using old-style string-based enums in Internals.idl
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Bindings (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Darin Adler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-30 12:19 PDT by Darin Adler
Modified: 2016-04-30 14:37 PDT (History)
3 users (show)

See Also:


Attachments
Patch (56.99 KB, patch)
2016-04-30 12:36 PDT, Darin Adler
cdumez: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Darin Adler 2016-04-30 12:19:44 PDT
Stop using old-style string-based enums in Internals.idl
Comment 1 Darin Adler 2016-04-30 12:36:51 PDT
Created attachment 277823 [details]
Patch
Comment 2 Chris Dumez 2016-04-30 12:49:16 PDT
Comment on attachment 277823 [details]
Patch

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

> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:-3897
> -            if (!$function->signature->extendedAttributes->{"Custom"} && GetNativeType($function->signature->type) ne "bool") {

How about this check? I don't think we support generating callbacks whose return value is not bool. That said, the compile assert is not great. Maybe this should be a "die" statement in the script. I think it is important to let the developer know they need to use [Custom] in this case.

> Source/WebCore/testing/Internals.cpp:2945
> +void Internals::sendMediaControlEvent(MediControlEvent event)

Typo: Media
Comment 3 Darin Adler 2016-04-30 13:00:46 PDT
Comment on attachment 277823 [details]
Patch

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

I’m also noticing that the builds seem to be failing on EWS. Will have to fix that before landing.

>> Source/WebCore/bindings/scripts/CodeGeneratorJS.pm:-3897
>> -            if (!$function->signature->extendedAttributes->{"Custom"} && GetNativeType($function->signature->type) ne "bool") {
> 
> How about this check? I don't think we support generating callbacks whose return value is not bool. That said, the compile assert is not great. Maybe this should be a "die" statement in the script. I think it is important to let the developer know they need to use [Custom] in this case.

I even considered changing this to a die. Here’s why I didn’t (although I am willing to do it):

Generally our bindings script gets a lot of things wrong; it supports the cases we have tested, but it doesn’t exhaustively check for all the many cases it doesn’t create correct code for. Here was a check for a specific case, but written so poorly that clearly it never did anyone any good.

I assume there would be some kind of compile error anyway when we try to generate a callback with a return value other than bool. I don’t think it would make incorrect code that would happen to compile but do the wrong thing.

The reason to write the "die" is to make an easier to understand error message. In my defense, the COMPILE_ASSERT wasn’t being correctly generated so it was definitely not an easy to understand message before! I don’t think my change made it worse.

Once the topic becomes making good error messages that are easy to address, I realize that I don’t know how easy it is to understand messages that come from die. How easy it is to spot them in the build log, what other stuff gets dumped along with them to help pinpoint the source line of the IDL file with the error, etc.

>> Source/WebCore/testing/Internals.cpp:2945
>> +void Internals::sendMediaControlEvent(MediControlEvent event)
> 
> Typo: Media

Oops.
Comment 4 Darin Adler 2016-04-30 13:03:18 PDT
Looks like I will have to implement [Conditional] for enumerations to fix the build.
Comment 5 Darin Adler 2016-04-30 13:26:08 PDT
Committed r200294: <http://trac.webkit.org/changeset/200294>
Comment 7 Darin Adler 2016-04-30 14:37:46 PDT
Oh, I know how to fix that.