RESOLVED FIXED70890
ExceptionCode.cpp shouldn't need to know about every feature that throws exceptions
https://bugs.webkit.org/show_bug.cgi?id=70890
Summary ExceptionCode.cpp shouldn't need to know about every feature that throws exce...
Adam Barth
Reported 2011-10-26 02:18:20 PDT
ExceptionCode.h shouldn't need to know about every feature that throws exceptions
Attachments
Work in progress (11.42 KB, patch)
2011-10-26 02:19 PDT, Adam Barth
no flags
work in progress (21.72 KB, patch)
2011-10-26 23:51 PDT, Adam Barth
no flags
Work in progress (94.07 KB, patch)
2011-10-27 15:48 PDT, Adam Barth
no flags
Work in progress (18.12 KB, patch)
2011-10-28 01:10 PDT, Adam Barth
no flags
Patch (30.41 KB, patch)
2011-10-28 01:32 PDT, Adam Barth
eric: review+
Adam Barth
Comment 1 2011-10-26 02:19:08 PDT
Created attachment 112472 [details] Work in progress
Adam Barth
Comment 2 2011-10-26 02:20:01 PDT
My plan is to add InFilesCompiler.pm in this patch and then refactor the event code generators to use InFilesCompiler.pm in a followup patch.
Alexey Proskuryakov
Comment 3 2011-10-26 12:23:52 PDT
What is the rationale for this change? Without a good reason, this looks like over-engineering.
Adam Barth
Comment 4 2011-10-26 13:38:11 PDT
> What is the rationale for this change? Without a good reason, this looks like over-engineering. The goal is to reduce the cost the project pays for implementing new features by reducing the number of #ifdefs features impose on the rest of WebCore. I'm happy to discuss more on webkit-dev if you'd like, but I'd rather not discuss further on this bug.
Alexey Proskuryakov
Comment 5 2011-10-26 14:03:12 PDT
Makes sense to discuss on webkit-dev. Would you be willing to send an e-mail?
Eric Seidel (no email)
Comment 6 2011-10-26 14:06:01 PDT
Alexey Proskuryakov
Comment 7 2011-10-26 14:10:18 PDT
Unless I missed some of the e-mails, that thread was not discussing anything close to this patch. Of course, that work was undoubtedly an inspiration.
Adam Barth
Comment 8 2011-10-26 14:49:26 PDT
http://trac.webkit.org/browser/trunk/Source/WebCore/dom/ExceptionCode.cpp#L259 has the same problem as Event.cpp used to have. Namely, every feature needs to "register" itself with ExceptionCode.cpp if it wants to use exceptions, leading to a nest of ifdefs that grows in complexity as WebCore adds features. Anyway, if you have feedback on this work, please feel encouraged to reply to the thread on webkit-dev.
Alexey Proskuryakov
Comment 9 2011-10-26 16:11:33 PDT
I can see some value in generating parts of ExceptionCode.cpp. Whoever reviews the final patch will need to clearly think about whether it's an overall improvement or not, not just about technical correctness. Looking at ExceptionCode.h alone, replacing conditional blocks with conditional lines in ExceptionCodeDescription.in would be useless, of course. Please re-title the bug accordingly, as it isn't about the header alone.
Adam Barth
Comment 10 2011-10-26 23:51:10 PDT
Created attachment 112642 [details] work in progress
Adam Barth
Comment 11 2011-10-27 15:48:36 PDT
Created attachment 112773 [details] Work in progress
Eric Seidel (no email)
Comment 12 2011-10-27 16:04:35 PDT
Comment on attachment 112773 [details] Work in progress View in context: https://bugs.webkit.org/attachment.cgi?id=112773&action=review Another way to break this down smaller, woudl be to not autogen any of this. Or rathe rjust check in the autogen'd bit. i.e. do the logic-refactor, before doing the autogen of the logic refactor. I think that would make this much easier to follow. > Source/WebCore/bindings/scripts/InFilesCompiler.pm:3 > +#!/usr/bin/perl -w > + > +# Copyright (C) 2011 Adam Barth <abarth@webkit.org> I would do this InFilesCompiler refactor in a first pass-change. > Source/WebCore/dom/DOMCoreException.cpp:38 > +static const char* const exceptionNames[] = { > + "INDEX_SIZE_ERR", > + "DOMSTRING_SIZE_ERR", > + "HIERARCHY_REQUEST_ERR", > + "WRONG_DOCUMENT_ERR", I would do this as a table of structs. which you can easily define this same way. If you don't do that, please add a FIXME about doing so. > Source/WebCore/dom/EventException.h:39 > + { It would be better if you ddid the un-indent of these files in a separate change. git stash your current work. :) > Source/WebCore/dom/make_exception_code_description.pl:179 > + print F "ExceptionCodeDescription::ExceptionCodeDescription(ExceptionCode ec)\n"; > + print F "{\n"; > + > + for my $exceptionType (sort keys %parsedItems) { > + my $conditional = $parsedItems{$exceptionType}{"conditional"}; > + > + print F "#if ENABLE($conditional)\n" if $conditional; When you write your changelog, it woudl be helpful to explain that this code will die, in the next iteration. I also might suggest adding a FIXME here about that plan.
Adam Barth
Comment 13 2011-10-27 16:13:17 PDT
Good idea. I'll start a series of bugs blocking this bug.
Adam Barth
Comment 14 2011-10-28 01:10:22 PDT
Created attachment 112827 [details] Work in progress
Adam Barth
Comment 15 2011-10-28 01:32:07 PDT
WebKit Review Bot
Comment 16 2011-10-28 01:33:28 PDT
Attachment 112831 [details] did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'ChangeLog', u'Source/WebCore/CMakeLists.tx..." exit_code: 1 Source/WebCore/bindings/js/JSDOMBinding.cpp:217: A case label should not be indented, but line up with its switch statement. [whitespace/indent] [4] Total errors found: 1 in 20 files If any of these errors are false positives, please file a bug against check-webkit-style.
Eric Seidel (no email)
Comment 17 2011-10-28 01:53:24 PDT
Comment on attachment 112831 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=112831&action=review OK. I get the sense you're setting the stage here. > Source/WebCore/dom/ExceptionCode.cpp:37 > + description = ExceptionCodeDescription(ec); Seems you also want to inline this into ExceptionCode. I assume there will be some sort of ExceptionCodeFactory?
Adam Barth
Comment 18 2011-10-28 01:54:57 PDT
> Seems you also want to inline this into ExceptionCode. I assume there will be some sort of ExceptionCodeFactory? Yeah, that function disappears in the next patch.
Adam Barth
Comment 19 2011-10-28 02:11:56 PDT
Adam Roben (:aroben)
Comment 20 2011-10-28 05:38:01 PDT
Mac build fix in r98720.
Adam Barth
Comment 21 2011-10-28 11:06:36 PDT
> Mac build fix in r98720. Thanks Adam.
Note You need to log in before you can comment on or make changes to this bug.