Bug 97251

Summary: GlobalObjectMethodTable initialization should use designated initializers
Product: WebKit Reporter: Pratik Solanki <psolanki>
Component: JavaScriptCoreAssignee: Pratik Solanki <psolanki>
Status: RESOLVED WONTFIX    
Severity: Normal CC: benjamin, ggaren, ojan.autocc, psolanki, sam, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Pratik Solanki
Reported 2012-09-20 12:44:46 PDT
Instead of doing const GlobalObjectMethodTable JSDOMWindowBase::s_globalObjectMethodTable = { &shouldAllowAccessFrom, &supportsProfiling, &supportsRichSourceInfo, &shouldInterruptScript, &javaScriptExperimentsEnabled }; and relying on the order in which the fields are written, we can use designated initializers.
Attachments
Patch (4.15 KB, patch)
2012-09-20 12:53 PDT, Pratik Solanki
no flags
Patch (4.95 KB, text/plain)
2012-12-12 16:50 PST, Pratik Solanki
no flags
Pratik Solanki
Comment 1 2012-09-20 12:45:34 PDT
I'm not sure if we have precedent for using designated initializers in webkit. I'll upload patch for review and see what EWS says.
Pratik Solanki
Comment 2 2012-09-20 12:53:37 PDT
Geoffrey Garen
Comment 3 2012-09-20 12:55:28 PDT
I like this, but I think older versions of GCC object. I guess we'll see...
Gyuyoung Kim
Comment 4 2012-09-20 13:00:54 PDT
Build Bot
Comment 5 2012-09-20 13:05:19 PDT
Early Warning System Bot
Comment 6 2012-09-20 14:09:05 PDT
Pratik Solanki
Comment 7 2012-09-20 14:30:31 PDT
Ok. This isn't going to work due to failures in other ports. What if I added a HAVE(DESIGNATED_INITIALIZERS) macro and move the code there? And then we can turn it on for platforms that support it. Is it worth doing that?
Early Warning System Bot
Comment 8 2012-09-20 15:08:54 PDT
Geoffrey Garen
Comment 9 2012-09-20 21:05:50 PDT
Is there a way to do that without having to write all the initializers twice?
Sam Weinig
Comment 10 2012-09-23 00:04:18 PDT
(In reply to comment #7) > Ok. This isn't going to work due to failures in other ports. What if I added a HAVE(DESIGNATED_INITIALIZERS) macro and move the code there? And then we can turn it on for platforms that support it. Is it worth doing that? If you do end up doing it with a #if check, please use a COMPILER_SUPPORTS() macro instead of HAVE().
Sam Weinig
Comment 11 2012-09-23 00:05:09 PDT
(In reply to comment #9) > Is there a way to do that without having to write all the initializers twice? Macros of course!
Sam Weinig
Comment 12 2012-09-25 00:55:20 PDT
Comment on attachment 164967 [details] Patch r-ing given how much this breaks.
Pratik Solanki
Comment 13 2012-12-12 16:50:40 PST
Pratik Solanki
Comment 14 2012-12-12 16:52:15 PST
Couldn't figure out a way to avoid the code duplication. I'm enabling the code for clang only. I'm sure newer versions of gcc support designated initializers but I didn't test. Anyone who compiles with gcc can test and enable the code path on that compiler.
Darin Adler
Comment 15 2012-12-12 20:03:32 PST
Comment on attachment 179151 [details] Patch Given that we can use this only in certain compilers, and still have to keep the #else branch working, this doesn’t seem worth doing to me. Does this solve a concrete problem?
Pratik Solanki
Comment 16 2012-12-12 23:32:13 PST
(In reply to comment #15) > (From update of attachment 179151 [details]) > Given that we can use this only in certain compilers, and still have to keep the #else branch working, this doesn’t seem worth doing to me. Does this solve a concrete problem? This was motivated by <rdar://12329156>. Having designated initializers would have prevented that. But I do I agree this does add more complexity. Is there anything better we can do?
Pratik Solanki
Comment 17 2013-05-03 12:28:56 PDT
This is probably not worth doing. Closing.
Zan Dobersek
Comment 18 2013-09-05 08:35:09 PDT
Comment on attachment 179151 [details] Patch The work on this bug has ceased, removing the r? flag on the patch.
Note You need to log in before you can comment on or make changes to this bug.