Title: [98711] trunk
Revision
98711
Author
[email protected]
Date
2011-10-28 02:11:50 -0700 (Fri, 28 Oct 2011)

Log Message

ExceptionCode.cpp shouldn't need to know about every feature that throws exceptions
https://bugs.webkit.org/show_bug.cgi?id=70890

Reviewed by Eric Seidel.

.: 

Add a code generation step.

* Source/cmake/WebKitMacros.cmake:

Source/WebCore: 

Generate the feature-specific parts of ExceptionCode.cpp from a ".in"
file.  This is an incremental step towards inlining
getExceptionCodeDescription into its callers and replacing the switch
statements at those locations with autogenerated code.

* CMakeLists.txt:
* CodeGenerators.pri:
* DerivedSources.make:
* GNUmakefile.am:
* GNUmakefile.list.am:
* WebCore.gyp/WebCore.gyp:
* WebCore.gyp/scripts/action_makenames.py:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSDOMBinding.cpp:
(WebCore::setDOMException):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::setDOMException):
* dom/DOMCoreException.cpp:
(WebCore::DOMCoreException::initializeDescription):
* dom/ExceptionCode.cpp:
(WebCore::getExceptionCodeDescription):
* dom/ExceptionCode.h:
* dom/ExceptionCodeDescription.in: Added.
* dom/make_exception_code_description.pl: Added.
(defaultItemFactory):
(generateCode):
(generateHeader):
(generateImplementation):

Modified Paths

Added Paths

Diff

Modified: trunk/ChangeLog (98710 => 98711)


--- trunk/ChangeLog	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/ChangeLog	2011-10-28 09:11:50 UTC (rev 98711)
@@ -1,3 +1,14 @@
+2011-10-28  Adam Barth  <[email protected]>
+
+        ExceptionCode.cpp shouldn't need to know about every feature that throws exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=70890
+
+        Reviewed by Eric Seidel.
+
+        Add a code generation step.
+
+        * Source/cmake/WebKitMacros.cmake:
+
 2011-10-27  Priit Laes  <[email protected]>
 
         [GTK] Create .xz tarballs during distcheck

Modified: trunk/Source/WebCore/CMakeLists.txt (98710 => 98711)


--- trunk/Source/WebCore/CMakeLists.txt	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/CMakeLists.txt	2011-10-28 09:11:50 UTC (rev 98711)
@@ -2332,6 +2332,10 @@
 ADD_SOURCE_WEBCORE_DERIVED_DEPENDENCIES(${WEBCORE_DIR}/dom/EventNames.cpp EventTargetInterfaces.h)
 
 
+GENERATE_EXCEPTION_CODE_DESCRIPTION(${WEBCORE_DIR}/dom/ExceptionCodeDescription.in ExceptionCodeDescription.cpp)
+LIST(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/ExceptionCodeDescription.cpp)
+
+
 GENERATE_FONT_NAMES(${WEBCORE_DIR}/css/WebKitFontFamilyNames.in)
 LIST(APPEND WebCore_SOURCES ${DERIVED_SOURCES_WEBCORE_DIR}/WebKitFontFamilyNames.cpp)
 

Modified: trunk/Source/WebCore/ChangeLog (98710 => 98711)


--- trunk/Source/WebCore/ChangeLog	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/ChangeLog	2011-10-28 09:11:50 UTC (rev 98711)
@@ -1,3 +1,41 @@
+2011-10-28  Adam Barth  <[email protected]>
+
+        ExceptionCode.cpp shouldn't need to know about every feature that throws exceptions
+        https://bugs.webkit.org/show_bug.cgi?id=70890
+
+        Reviewed by Eric Seidel.
+
+        Generate the feature-specific parts of ExceptionCode.cpp from a ".in"
+        file.  This is an incremental step towards inlining
+        getExceptionCodeDescription into its callers and replacing the switch
+        statements at those locations with autogenerated code.
+
+        * CMakeLists.txt:
+        * CodeGenerators.pri:
+        * DerivedSources.make:
+        * GNUmakefile.am:
+        * GNUmakefile.list.am:
+        * WebCore.gyp/WebCore.gyp:
+        * WebCore.gyp/scripts/action_makenames.py:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSDOMBinding.cpp:
+        (WebCore::setDOMException):
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::setDOMException):
+        * dom/DOMCoreException.cpp:
+        (WebCore::DOMCoreException::initializeDescription):
+        * dom/ExceptionCode.cpp:
+        (WebCore::getExceptionCodeDescription):
+        * dom/ExceptionCode.h:
+        * dom/ExceptionCodeDescription.in: Added.
+        * dom/make_exception_code_description.pl: Added.
+        (defaultItemFactory):
+        (generateCode):
+        (generateHeader):
+        (generateImplementation):
+
 2011-10-28  Yury Semikhatsky  <[email protected]>
 
         Web Inspector: CallStackSidebarPane should remove discarded Placards from RawSourceCode listeners list

Modified: trunk/Source/WebCore/CodeGenerators.pri (98710 => 98711)


--- trunk/Source/WebCore/CodeGenerators.pri	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/CodeGenerators.pri	2011-10-28 09:11:50 UTC (rev 98711)
@@ -36,6 +36,8 @@
 
 EVENT_TARGET_FACTORY = $$PWD/dom/EventTargetFactory.in
 
+EXCEPTION_CODE_DESCRIPTION = $$PWD/dom/ExceptionCodeDescription.in
+
 COLORDATA_GPERF = $$PWD/platform/ColorData.gperf
 
 WALDOCSSPROPS = $$PWD/css/CSSPropertyNames.in
@@ -770,6 +772,14 @@
 eventtargetfactory.depends = $$PWD/dom/make_event_factory.pl $$EVENT_TARGET_FACTORY
 addExtraCompiler(eventtargetfactory)
 
+# GENERATOR 5-G:
+exceptioncodedescription.output = $${WC_GENERATED_SOURCES_DIR}/ExceptionCodeDescription.cpp
+exceptioncodedescription.input = EXCEPTION_CODE_DESCRIPTION
+exceptioncodedescription.wkScript = $$PWD/dom/make_exception_code_description.pl
+exceptioncodedescription.commands = perl -I$$PWD/bindings/scripts $$eventfactory.wkScript --input $$EXCEPTION_CODE_DESCRIPTION --outputDir $$WC_GENERATED_SOURCES_DIR
+exceptioncodedescription.depends = $$PWD/dom/make_exception_code_description.pl $$EXCEPTION_CODE_DESCRIPTION
+addExtraCompiler(exceptioncodedescription)
+
 # GENERATOR 8-A:
 entities.output = $${WC_GENERATED_SOURCES_DIR}/HTMLEntityTable.cpp
 entities.input = HTML_ENTITIES

Modified: trunk/Source/WebCore/DerivedSources.make (98710 => 98711)


--- trunk/Source/WebCore/DerivedSources.make	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/DerivedSources.make	2011-10-28 09:11:50 UTC (rev 98711)
@@ -588,6 +588,7 @@
     ColorData.cpp \
     EventFactory.cpp \
     EventTargetInterfaces.h \
+    ExceptionCodeDescription.cpp \
     HTMLElementFactory.cpp \
     HTMLEntityTable.cpp \
     HTMLNames.cpp \
@@ -856,6 +857,9 @@
 EventTargetHeaders.h EventTargetInterfaces.h : dom/make_event_factory.pl dom/EventTargetFactory.in
 	perl -I $(WebCore)/bindings/scripts $< --input $(WebCore)/dom/EventTargetFactory.in
 
+ExceptionCodeDescription.cpp ExceptionCodeDescription.h : dom/make_exception_code_description.pl dom/ExceptionCodeDescription.in
+	perl -I $(WebCore)/bindings/scripts $< --input $(WebCore)/dom/ExceptionCodeDescription.in
+
 # --------
  
 # MathML tag and attribute names, and element factory

Modified: trunk/Source/WebCore/GNUmakefile.am (98710 => 98711)


--- trunk/Source/WebCore/GNUmakefile.am	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/GNUmakefile.am	2011-10-28 09:11:50 UTC (rev 98711)
@@ -696,6 +696,9 @@
 DerivedSources/WebCore/EventTargetHeaders.h DerivedSources/WebCore/EventTargetInterfaces.h: $(WebCore)/dom/make_event_factory.pl $(WebCore)/dom/EventTargetFactory.in
 	$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --input $(WebCore)/dom/EventTargetFactory.in --outputDir "$(GENSOURCES_WEBCORE)"
 
+DerivedSources/WebCore/ExceptionCodeDescription.cpp DerivedSources/WebCore/ExceptionCodeDescription.h: $(WebCore)/dom/make_exception_code_description.pl $(WebCore)/dom/ExceptionCodeDescription.in
+	$(AM_V_GEN)$(PERL) -I$(WebCore)/bindings/scripts $< --input $(WebCore)/dom/ExceptionCodeDescription.in --outputDir "$(GENSOURCES_WEBCORE)"
+
 # All Web Inspector generated files are created with this one call to CodeGeneratorInspector.py
 DerivedSources/WebCore/InspectorProtocolVersion.h : $(WebCore)/inspector/Inspector.json $(WebCore)/inspector/generate-inspector-protocol-version
 	$(PYTHON) $(WebCore)/inspector/generate-inspector-protocol-version -o $(GENSOURCES_WEBCORE)/InspectorProtocolVersion.h $(WebCore)/inspector/Inspector.json
@@ -892,8 +895,10 @@
 	Source/WebCore/css/WebKitFontFamilyNames.in \
 	Source/WebCore/dom/EventFactory.in \
 	Source/WebCore/dom/EventTargetFactory.in \
+	Source/WebCore/dom/ExceptionCodeDescription.in \
 	Source/WebCore/dom/make_names.pl \
 	Source/WebCore/dom/make_event_factory.pl \
+	Source/WebCore/dom/make_exception_code_description.pl \
 	Source/WebCore/html/HTMLAttributeNames.in \
 	Source/WebCore/html/HTMLTagNames.in \
 	Source/WebCore/html/parser/create-html-entity-table \

Modified: trunk/Source/WebCore/GNUmakefile.list.am (98710 => 98711)


--- trunk/Source/WebCore/GNUmakefile.list.am	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2011-10-28 09:11:50 UTC (rev 98711)
@@ -14,6 +14,7 @@
 	DerivedSources/WebCore/EventInterfaces.h \
 	DerivedSources/WebCore/EventTargetHeaders.h \
 	DerivedSources/WebCore/EventTargetInterfaces.h \
+	DerivedSources/WebCore/ExceptionCodeDescription.cpp \
 	DerivedSources/WebCore/HTMLElementFactory.cpp \
 	DerivedSources/WebCore/HTMLElementFactory.h \
 	DerivedSources/WebCore/HTMLEntityTable.cpp \

Modified: trunk/Source/WebCore/WebCore.gyp/WebCore.gyp (98710 => 98711)


--- trunk/Source/WebCore/WebCore.gyp/WebCore.gyp	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/WebCore.gyp/WebCore.gyp	2011-10-28 09:11:50 UTC (rev 98711)
@@ -696,6 +696,24 @@
           ],
         },
         {
+          'action_name': 'ExceptionCodeDescription',
+          'inputs': [
+            '../dom/make_exception_code_description.pl',
+            '../dom/ExceptionCodeDescription.in',
+          ],
+          'outputs': [
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/ExceptionCodeDescription.cpp',
+            '<(SHARED_INTERMEDIATE_DIR)/webkit/ExceptionCodeDescription.h',
+          ],
+          'action': [
+            'python',
+            'scripts/action_makenames.py',
+            '<@(_outputs)',
+            '--',
+            '<@(_inputs)',
+          ],
+        },
+        {
           'action_name': 'MathMLNames',
           'inputs': [
             '../dom/make_names.pl',
@@ -1016,6 +1034,7 @@
         '<(SHARED_INTERMEDIATE_DIR)/webkit/EventInterfaces.h',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/EventTargetHeaders.h',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/EventTargetInterfaces.h',
+        '<(SHARED_INTERMEDIATE_DIR)/webkit/ExceptionCodeDescription.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/UserAgentStyleSheetsData.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/V8HTMLElementWrapperFactory.cpp',
         '<(SHARED_INTERMEDIATE_DIR)/webkit/XLinkNames.cpp',

Modified: trunk/Source/WebCore/WebCore.gyp/scripts/action_makenames.py (98710 => 98711)


--- trunk/Source/WebCore/WebCore.gyp/scripts/action_makenames.py	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/WebCore.gyp/scripts/action_makenames.py	2011-10-28 09:11:50 UTC (rev 98711)
@@ -118,7 +118,8 @@
         inputAbsPosix = inputAbs.replace(os.path.sep, posixpath.sep)
         inputBasename = os.path.basename(input)
         if inputBasename == 'make_names.pl' \
-            or inputBasename == 'make_event_factory.pl':
+            or inputBasename == 'make_event_factory.pl' \
+            or inputBasename == 'make_exception_code_description.pl':
             assert makeNamesInput == None
             makeNamesInput = inputAbs
         elif inputBasename.endswith('TagNames.in') \
@@ -129,7 +130,9 @@
              or inputBasename.endswith('attrs.in'):
             assert attrInput == None
             attrInput = inputAbsPosix
-        elif inputBasename.endswith('EventFactory.in') or inputBasename.endswith('EventTargetFactory.in'):
+        elif inputBasename.endswith('EventFactory.in') \
+            or inputBasename.endswith('EventTargetFactory.in') \
+            or inputBasename.endswith('ExceptionCodeDescription.in'):
             eventsInput = inputAbsPosix
         elif inputBasename.endswith('Names.in'):
             options.append(inputAbsPosix)

Modified: trunk/Source/WebCore/WebCore.gypi (98710 => 98711)


--- trunk/Source/WebCore/WebCore.gypi	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/WebCore.gypi	2011-10-28 09:11:50 UTC (rev 98711)
@@ -7079,6 +7079,8 @@
             '<(PRODUCT_DIR)/DerivedSources/WebCore/EventInterfaces.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/EventTargetHeaders.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/EventTargetInterfaces.h',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/ExceptionCodeDescription.cpp',
+            '<(PRODUCT_DIR)/DerivedSources/WebCore/ExceptionCodeDescription.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/HTMLElementFactory.cpp',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/HTMLElementFactory.h',
             '<(PRODUCT_DIR)/DerivedSources/WebCore/HTMLEntityTable.cpp',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (98710 => 98711)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-10-28 09:11:50 UTC (rev 98711)
@@ -562,6 +562,14 @@
 				>
 			</File>
 			<File
+				RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\ExceptionCodeDescription.cpp"
+				>
+			</File>
+			<File
+				RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\ExceptionCodeDescription.h"
+				>
+			</File>
+			<File
 				RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\HTMLElementFactory.h"
 				>
 			</File>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (98710 => 98711)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-10-28 09:11:50 UTC (rev 98711)
@@ -3199,6 +3199,8 @@
 		9728C3141268E4390041E89B /* MarkupAccumulator.h in Headers */ = {isa = PBXBuildFile; fileRef = 9728C3121268E4390041E89B /* MarkupAccumulator.h */; };
 		973889A0116EA9DC00ADF313 /* DocumentWriter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9738899E116EA9DC00ADF313 /* DocumentWriter.cpp */; };
 		973889A1116EA9DC00ADF313 /* DocumentWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 9738899F116EA9DC00ADF313 /* DocumentWriter.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		973DC63F145A9409002842C2 /* ExceptionCodeDescription.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 973DC63D145A9409002842C2 /* ExceptionCodeDescription.cpp */; };
+		973DC640145A9409002842C2 /* ExceptionCodeDescription.h in Headers */ = {isa = PBXBuildFile; fileRef = 973DC63E145A9409002842C2 /* ExceptionCodeDescription.h */; };
 		973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */; };
 		973E325710883B7C005BC493 /* ResourceLoadNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 973E325510883B7C005BC493 /* ResourceLoadNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		9752D38D1413104B003305BD /* JSHTMLSpanElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9752D38B1413104B003305BD /* JSHTMLSpanElement.cpp */; };
@@ -10341,6 +10343,8 @@
 		9728C3121268E4390041E89B /* MarkupAccumulator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MarkupAccumulator.h; sourceTree = "<group>"; };
 		9738899E116EA9DC00ADF313 /* DocumentWriter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentWriter.cpp; sourceTree = "<group>"; };
 		9738899F116EA9DC00ADF313 /* DocumentWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentWriter.h; sourceTree = "<group>"; };
+		973DC63D145A9409002842C2 /* ExceptionCodeDescription.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExceptionCodeDescription.cpp; sourceTree = "<group>"; };
+		973DC63E145A9409002842C2 /* ExceptionCodeDescription.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionCodeDescription.h; sourceTree = "<group>"; };
 		973E325410883B7C005BC493 /* ResourceLoadNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ResourceLoadNotifier.cpp; sourceTree = "<group>"; };
 		973E325510883B7C005BC493 /* ResourceLoadNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadNotifier.h; sourceTree = "<group>"; };
 		9752D38B1413104B003305BD /* JSHTMLSpanElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSHTMLSpanElement.cpp; sourceTree = "<group>"; };
@@ -15179,6 +15183,8 @@
 				970B7289144FFAC600F00A37 /* EventInterfaces.h */,
 				97AA3CA3145237CC003E1DA6 /* EventTargetHeaders.h */,
 				97AA3CA4145237CC003E1DA6 /* EventTargetInterfaces.h */,
+				973DC63D145A9409002842C2 /* ExceptionCodeDescription.cpp */,
+				973DC63E145A9409002842C2 /* ExceptionCodeDescription.h */,
 				A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */,
 				A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */,
 				A8BC04911214F69600B5F122 /* HTMLEntityTable.cpp */,
@@ -24523,6 +24529,7 @@
 				97665013144FAA4200F6BB51 /* EventFactory.h in Headers */,
 				A0EE0DF6144F825500F80B0D /* WebGLDebugRendererInfo.h in Headers */,
 				A0EE0DF8144F825500F80B0D /* WebGLDebugShaders.h in Headers */,
+				973DC640145A9409002842C2 /* ExceptionCodeDescription.h in Headers */,
 				97AA3CA5145237CC003E1DA6 /* EventTargetHeaders.h in Headers */,
 				97AA3CA6145237CC003E1DA6 /* EventTargetInterfaces.h in Headers */,
 				970B728A144FFAC600F00A37 /* EventInterfaces.h in Headers */,
@@ -27366,6 +27373,7 @@
 				978D07CE145A10370096908D /* XMLHttpRequestException.cpp in Sources */,
 				0F09087F1444FDB200028917 /* ScrollbarTheme.cpp in Sources */,
 				9B375EDA14478A0100F3CAE5 /* MicroDataItemList.cpp in Sources */,
+				973DC63F145A9409002842C2 /* ExceptionCodeDescription.cpp in Sources */,
 				49AF2D6C14435D210016A784 /* DisplayRefreshMonitorMac.cpp in Sources */,
 				49FC7A501444AF5F00A5D864 /* DisplayRefreshMonitor.cpp in Sources */,
 				71CCB49C144824AC00C676D6 /* ImageBySizeCache.cpp in Sources */,

Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (98710 => 98711)


--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp	2011-10-28 09:11:50 UTC (rev 98711)
@@ -214,7 +214,7 @@
 
     JSValue errorObject;
     switch (description.type) {
-        case DOMExceptionType:
+        case DOMCoreExceptionType:
             errorObject = toJS(exec, globalObject, DOMCoreException::create(description));
             break;
         case RangeExceptionType:

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (98710 => 98711)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2011-10-28 09:11:50 UTC (rev 98711)
@@ -659,7 +659,7 @@
 
     v8::Handle<v8::Value> exception;
     switch (description.type) {
-    case DOMExceptionType:
+    case DOMCoreExceptionType:
         exception = toV8(DOMCoreException::create(description));
         break;
     case RangeExceptionType:

Modified: trunk/Source/WebCore/dom/DOMCoreException.cpp (98710 => 98711)


--- trunk/Source/WebCore/dom/DOMCoreException.cpp	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/dom/DOMCoreException.cpp	2011-10-28 09:11:50 UTC (rev 98711)
@@ -95,7 +95,7 @@
 {
     description->typeName = "DOM";
     description->code = ec;
-    description->type = DOMExceptionType;
+    description->type = DOMCoreExceptionType;
 
     size_t tableSize = WTF_ARRAY_LENGTH(coreExceptionNames);
     size_t tableIndex = ec - INDEX_SIZE_ERR;

Modified: trunk/Source/WebCore/dom/ExceptionCode.cpp (98710 => 98711)


--- trunk/Source/WebCore/dom/ExceptionCode.cpp	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/dom/ExceptionCode.cpp	2011-10-28 09:11:50 UTC (rev 98711)
@@ -26,65 +26,15 @@
 #include "config.h"
 #include "ExceptionCode.h"
 
-#include "DOMCoreException.h"
-#include "EventException.h"
-#if ENABLE(BLOB)
-#include "FileException.h"
-#endif
-#if ENABLE(INDEXED_DATABASE)
-#include "IDBDatabaseException.h"
-#endif
-#if ENABLE(BLOB)
-#include "OperationNotAllowedException.h"
-#endif
-#include "RangeException.h"
-#if ENABLE(SQL_DATABASE)
-#include "SQLException.h"
-#endif
-#if ENABLE(SVG)
-#include "SVGException.h"
-#endif
-#include "XMLHttpRequestException.h"
-#include "XPathException.h"
+#include "ExceptionCodeDescription.h"
 
 namespace WebCore {
 
+// FIXME: Inline this function into its callers.
 void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& description)
 {
     ASSERT(ec);
-
-    if (EventException::initializeDescription(ec, &description))
-        return;
-#if ENABLE(BLOB)
-    if (FileException::initializeDescription(ec, &description))
-        return;
-#endif
-#if ENABLE(INDEXED_DATABASE)
-    if (IDBDatabaseException::initializeDescription(ec, &description))
-        return;
-#endif
-#if ENABLE(BLOB)
-    if (OperationNotAllowedException::initializeDescription(ec, &description))
-        return;
-#endif
-    if (RangeException::initializeDescription(ec, &description))
-        return;
-#if ENABLE(SQL_DATABASE)
-    if (SQLException::initializeDescription(ec, &description))
-        return;
-#endif
-#if ENABLE(SVG)
-    if (SVGException::initializeDescription(ec, &description))
-        return;
-#endif
-    if (XMLHttpRequestException::initializeDescription(ec, &description))
-        return;
-    if (XPathException::initializeDescription(ec, &description))
-        return;
-    if (DOMCoreException::initializeDescription(ec, &description))
-        return;
-
-    ASSERT_NOT_REACHED();
+    description = ExceptionCodeDescription(ec);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/dom/ExceptionCode.h (98710 => 98711)


--- trunk/Source/WebCore/dom/ExceptionCode.h	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/WebCore/dom/ExceptionCode.h	2011-10-28 09:11:50 UTC (rev 98711)
@@ -19,6 +19,8 @@
 #ifndef ExceptionCode_h
 #define ExceptionCode_h
 
+#include "ExceptionCodeDescription.h"
+
 namespace WebCore {
 
     // The DOM standards use unsigned short for exception codes.
@@ -63,37 +65,6 @@
         DATA_CLONE_ERR = 25
     };
 
-    enum ExceptionType {
-        DOMExceptionType,
-        RangeExceptionType,
-        EventExceptionType,
-        XMLHttpRequestExceptionType,
-        XPathExceptionType
-#if ENABLE(SVG)
-        , SVGExceptionType
-#endif
-#if ENABLE(SQL_DATABASE)
-        , SQLExceptionType
-#endif
-#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
-        , FileExceptionType
-#endif
-#if ENABLE(INDEXED_DATABASE)
-        , IDBDatabaseExceptionType
-#endif
-#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
-        , OperationNotAllowedExceptionType
-#endif
-    };
-
-
-    struct ExceptionCodeDescription {
-        const char* typeName; // has spaces and is suitable for use in exception description strings; maximum length is 10 characters
-        const char* name; // exception name, also intended for use in exception description strings; 0 if name not known; maximum length is 27 characters
-        const char* description; // exception description, intended for use in exception strings; more readable explanation of error
-        int code; // numeric value of the exception within a particular type
-        ExceptionType type;
-    };
     void getExceptionCodeDescription(ExceptionCode, ExceptionCodeDescription&);
 
 } // namespace WebCore

Added: trunk/Source/WebCore/dom/ExceptionCodeDescription.in (0 => 98711)


--- trunk/Source/WebCore/dom/ExceptionCodeDescription.in	                        (rev 0)
+++ trunk/Source/WebCore/dom/ExceptionCodeDescription.in	2011-10-28 09:11:50 UTC (rev 98711)
@@ -0,0 +1,12 @@
+namespace=ExceptionCodeDescription
+
+DOMCoreException
+EventException
+FileException conditional=BLOB
+IDBDatabaseException conditional=INDEXED_DATABASE
+OperationNotAllowedException conditional=BLOB
+RangeException
+SQLException conditional=SQL_DATABASE
+SVGException conditional=SVG
+XMLHttpRequestException
+XPathException

Added: trunk/Source/WebCore/dom/make_exception_code_description.pl (0 => 98711)


--- trunk/Source/WebCore/dom/make_exception_code_description.pl	                        (rev 0)
+++ trunk/Source/WebCore/dom/make_exception_code_description.pl	2011-10-28 09:11:50 UTC (rev 98711)
@@ -0,0 +1,196 @@
+#!/usr/bin/perl -w
+
+# Copyright (C) 2005, 2006, 2007, 2009 Apple Inc. All rights reserved.
+# Copyright (C) 2009, Julien Chaffraix <[email protected]>
+# Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
+# Copyright (C) 2011 Ericsson AB. All rights reserved.
+# Copyright (C) 2011 Google, Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer. 
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution. 
+# 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+#     its contributors may be used to endorse or promote products derived
+#     from this software without specific prior written permission. 
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+use strict;
+
+use Config;
+use Getopt::Long;
+use File::Path;
+use File::Spec;
+use IO::File;
+use InFilesCompiler;
+
+require Config;
+
+my $inputFile;
+my $outputDir = ".";
+
+GetOptions(
+    'input=s' => \$inputFile,
+    'outputDir=s' => \$outputDir,
+);
+
+mkpath($outputDir);
+
+die "You must specify --input <file>" unless length($inputFile);
+
+my %defaultParameters = (
+    'namespace' => 0
+);
+
+my $InCompiler = InFilesCompiler->new(\%defaultParameters, \&defaultItemFactory);
+
+$InCompiler->compile($inputFile, \&generateCode);
+
+sub defaultItemFactory
+{
+    return (
+        'conditional' => 0
+    );
+}
+
+sub generateCode()
+{
+    my $parsedParameters = shift;
+    my $parsedItems = shift;
+
+    generateHeader($parsedParameters, $parsedItems);
+    generateImplementation($parsedParameters, $parsedItems);
+}
+
+sub generateHeader()
+{
+    my $parsedParametersRef = shift;
+    my $parsedItemsRef = shift;
+
+    my $F;
+    my %parsedItems = %{ $parsedItemsRef };
+
+    my $outputFile = "$outputDir/ExceptionCodeDescription.h";
+
+    open F, ">$outputFile" or die "Failed to open file: $!";
+
+    print F $InCompiler->license();
+
+    print F "#ifndef ExceptionCodeDescription_h\n";
+    print F "#define ExceptionCodeDescription_h\n";
+    print F "\n";
+    print F "namespace WebCore {\n";
+    print F "\n";
+    print F "typedef int ExceptionCode;\n";
+    print F "\n";
+    print F "enum ExceptionType {\n";
+
+    for my $exceptionType (sort keys %parsedItems) {
+        my $conditional = $parsedItems{$exceptionType}{"conditional"};
+
+        print F "#if ENABLE($conditional)\n" if $conditional;
+        print F "    ${exceptionType}Type,\n";
+        print F "#endif\n" if $conditional;
+    }
+
+    print F "};\n";
+    print F "\n";
+    print F "struct ExceptionCodeDescription {\n";
+    print F "    ExceptionCodeDescription() { }\n";
+    print F "    explicit ExceptionCodeDescription(ExceptionCode);\n";
+    print F "\n";
+    print F "    // |typeName| has spaces and is suitable for use in exception\n";
+    print F "    // description strings; maximum length is 10 characters.\n";
+    print F "    const char* typeName; \n";
+    print F "\n";
+    print F "    // |name| is the exception name, also intended for use in exception\n";
+    print F "    // description strings; 0 if name not known; maximum length is 27\n";
+    print F "    // characters.\n";
+    print F "    const char* name; \n";
+    print F "\n";
+    print F "    // |description| is the exception description, intended for use in\n";
+    print F "    // exception strings. It is a more readable explanation of error.\n";
+    print F "    const char* description;\n";
+    print F "\n";
+    print F "    // |code| is the numeric value of the exception within a particular type.\n";
+    print F "    int code; \n";
+    print F "\n";
+    print F "    ExceptionType type;\n";
+    print F "};\n";
+    print F "\n";
+    print F "} // namespace WebCore\n";
+    print F "\n";
+    print F "#endif // ExceptionCodeDescription_h\n";
+
+    close F;
+}
+
+sub generateImplementation()
+{
+    my $parsedParametersRef = shift;
+    my $parsedItemsRef = shift;
+
+    my $F;
+    my %parsedItems = %{ $parsedItemsRef };
+
+    my $outputFile = "$outputDir/ExceptionCodeDescription.cpp";
+
+    open F, ">$outputFile" or die "Failed to open file: $!";
+
+    print F $InCompiler->license();
+
+    print F "#include \"config.h\"\n";
+    print F "#include \"ExceptionCodeDescription.h\"\n";
+    print F "\n";
+    print F "#include \"ExceptionCode.h\"\n";
+
+    for my $exceptionType (sort keys %parsedItems) {
+        my $conditional = $parsedItems{$exceptionType}{"conditional"};
+
+        print F "#if ENABLE($conditional)\n" if $conditional;
+        print F "#include \"$exceptionType.h\"\n";
+        print F "#endif\n" if $conditional;
+    }
+
+    print F "\n";
+    print F "namespace WebCore {\n";
+    print F "\n";
+    print F "ExceptionCodeDescription::ExceptionCodeDescription(ExceptionCode ec)\n";
+    print F "{\n";
+
+    for my $exceptionType (sort keys %parsedItems) {
+        # DOMCoreException needs to be last because it's a catch-all.
+        next if $exceptionType eq "DOMCoreException";
+
+        my $conditional = $parsedItems{$exceptionType}{"conditional"};
+
+        print F "#if ENABLE($conditional)\n" if $conditional;
+        print F "    if (${exceptionType}::initializeDescription(ec, this))\n";
+        print F "        return;\n";
+        print F "#endif\n" if $conditional;
+    }
+
+    print F "    if (DOMCoreException::initializeDescription(ec, this))\n";
+    print F "        return;\n";
+    print F "    ASSERT_NOT_REACHED();\n";
+    print F "}\n";
+    print F "\n";
+    print F "} // namespace WebCore\n";
+
+    close F;
+}

Modified: trunk/Source/cmake/WebKitMacros.cmake (98710 => 98711)


--- trunk/Source/cmake/WebKitMacros.cmake	2011-10-28 09:09:29 UTC (rev 98710)
+++ trunk/Source/cmake/WebKitMacros.cmake	2011-10-28 09:11:50 UTC (rev 98711)
@@ -48,6 +48,17 @@
 ENDMACRO ()
 
 
+MACRO (GENERATE_EXCEPTION_CODE_DESCRIPTION _infile _outfile)
+    SET(NAMES_GENERATOR ${WEBCORE_DIR}/dom/make_exception_code_description.pl)
+
+    ADD_CUSTOM_COMMAND(
+        OUTPUT  ${DERIVED_SOURCES_WEBCORE_DIR}/${_outfile}
+        DEPENDS ${NAMES_GENERATOR} ${SCRIPTS_BINDINGS} ${_infile}
+        COMMAND ${PERL_EXECUTABLE} -I${WEBCORE_DIR}/bindings/scripts ${NAMES_GENERATOR} --input ${_infile} --outputDir ${DERIVED_SOURCES_WEBCORE_DIR}
+        VERBATIM)
+ENDMACRO ()
+
+
 MACRO (GENERATE_DOM_NAMES _namespace _attrs)
     SET(NAMES_GENERATOR ${WEBCORE_DIR}/dom/make_names.pl)
     SET(_arguments  --attrs ${_attrs})
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to