Bug 71747 - DateMath.cpp should not depend on JavaScriptCore
Summary: DateMath.cpp should not depend on JavaScriptCore
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Adam Barth
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-11-07 16:25 PST by Mark Rowe (bdash)
Modified: 2011-11-14 16:05 PST (History)
6 users (show)

See Also:


Attachments
Patch (112.45 KB, patch)
2011-11-14 12:50 PST, Adam Barth
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Mark Rowe (bdash) 2011-11-07 16:25:31 PST
While working on making WTF build outside of JavaScriptCore I noticed that wtf/DateMath.cpp includes several headers from JavaScriptCore, and makes use of some JavaScriptCore types such as ExecState, JSGlobalData and DSTOffsetCache. This layering violation needs to be addressed before WTF can be correctly split out of JavaScriptCore.
Comment 1 Mark Rowe (bdash) 2011-11-07 16:44:09 PST
It looks like it may be possible to simply move the USE(JSC) parts of DateMath.h / DateMath.cpp in to a more appropriate file inside JavaScriptCore itself.
Comment 2 Adam Barth 2011-11-14 12:50:33 PST
Created attachment 115014 [details]
Patch
Comment 3 WebKit Review Bot 2011-11-14 12:53:41 PST
Attachment 115014 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/JavaScriptCore/CMakeLists.txt', u'S..." exit_code: 1

Source/JavaScriptCore/runtime/JSDateMath.cpp:76:  Alphabetical sorting problem.  [build/include_order] [4]
Source/JavaScriptCore/runtime/JSDateMath.cpp:147:  More than one command on the same line in if  [whitespace/parens] [4]
Source/JavaScriptCore/runtime/JSDateMath.cpp:154:  An else statement can be removed when the prior "if" concludes with a return, break, continue or goto statement.  [readability/control_flow] [4]
Source/JavaScriptCore/runtime/JSDateMath.cpp:244:  Tests for true/false, null/non-null, and zero/non-zero should all be done without equality comparisons.  [readability/comparison_to_zero] [5]
Total errors found: 4 in 17 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Darin Adler 2011-11-14 15:12:31 PST
Comment on attachment 115014 [details]
Patch

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

>> Source/JavaScriptCore/runtime/JSDateMath.cpp:76
>>  #include "ASCIICType.h"
> 
> Alphabetical sorting problem.  [build/include_order] [4]

It’s true, ASCIICType.h should come before Assertions.h.

> Source/JavaScriptCore/runtime/JSDateMath.cpp:82
>  #include "Assertions.h"
>  #include "ASCIICType.h"
>  #include "CurrentTime.h"
> -#if USE(JSC)
>  #include "JSObject.h"
> -#endif
>  #include "MathExtras.h"
> -#if USE(JSC)
>  #include "ScopeChain.h"
> -#endif
>  #include "StdLibExtras.h"
>  #include "StringExtras.h"

Is there a chance we could cut these includes down a bit more? Guess someone can look into that later.

> Source/JavaScriptCore/wtf/DateMath.h:108
> +using WTF::isLeapYear;
>  using WTF::dateToDaysFrom1970;

Entire "using" list should be sorted alphabetically.
Comment 5 WebKit Review Bot 2011-11-14 16:05:10 PST
Comment on attachment 115014 [details]
Patch

Clearing flags on attachment: 115014

Committed r100205: <http://trac.webkit.org/changeset/100205>
Comment 6 WebKit Review Bot 2011-11-14 16:05:16 PST
All reviewed patches have been landed.  Closing bug.