Diff
Modified: trunk/Source/WebCore/ChangeLog (98754 => 98755)
--- trunk/Source/WebCore/ChangeLog 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/ChangeLog 2011-10-28 20:20:50 UTC (rev 98755)
@@ -1,3 +1,46 @@
+2011-10-28 Adam Barth <[email protected]>
+
+ Autogenerate Exception-downcast code in bindings
+ https://bugs.webkit.org/show_bug.cgi?id=71108
+
+ Reviewed by Eric Seidel.
+
+ This patch uses the same generated code style as we're using for Events
+ to generate the downcasts for the Exception types in the bindings.
+ This cause me to refactor more code from make_event_factory.pl into
+ InFilesCompiler.pm.
+
+ After this patch, some of these files and scripts are misnamed. I'll
+ rename them in a followup patch.
+
+ * DerivedSources.make:
+ * GNUmakefile.am:
+ * GNUmakefile.list.am:
+ * WebCore.gyp/WebCore.gyp:
+ * WebCore.gypi:
+ * WebCore.vcproj/WebCore.vcproj:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::setDOMException):
+ * bindings/objc/ExceptionHandlers.mm:
+ (WebCore::raiseDOMException):
+ * bindings/scripts/InFilesCompiler.pm:
+ (initializeFromCommandLine):
+ (compile):
+ (interfaceForItem):
+ (toMacroStyle):
+ (generateInterfacesHeader):
+ (generateHeadersHeader):
+ * bindings/v8/V8Proxy.cpp:
+ (WebCore::V8Proxy::setDOMException):
+ * dom/ExceptionCodeDescription.in:
+ * dom/make_event_factory.pl:
+ (generateCode):
+ (generateImplementation):
+ * dom/make_exception_code_description.pl:
+ (defaultItemFactory):
+ (generateCode):
+
2011-10-28 Simon Fraser <[email protected]>
Fix builds which have ACCELERATED_COMPOSITING disabled.
Modified: trunk/Source/WebCore/DerivedSources.make (98754 => 98755)
--- trunk/Source/WebCore/DerivedSources.make 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/DerivedSources.make 2011-10-28 20:20:50 UTC (rev 98755)
@@ -857,7 +857,7 @@
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
+ExceptionCodeDescription.cpp ExceptionCodeDescription.h ExceptionHeaders.h ExceptionInterfaces.h : dom/make_exception_code_description.pl dom/ExceptionCodeDescription.in
perl -I $(WebCore)/bindings/scripts $< --input $(WebCore)/dom/ExceptionCodeDescription.in
# --------
Modified: trunk/Source/WebCore/GNUmakefile.am (98754 => 98755)
--- trunk/Source/WebCore/GNUmakefile.am 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/GNUmakefile.am 2011-10-28 20:20:50 UTC (rev 98755)
@@ -696,7 +696,7 @@
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
+DerivedSources/WebCore/ExceptionCodeDescription.cpp DerivedSources/WebCore/ExceptionCodeDescription.h DerivedSources/WebCore/ExceptionHeaders.h DerivedSources/WebCore/ExceptionInterfaces.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
Modified: trunk/Source/WebCore/GNUmakefile.list.am (98754 => 98755)
--- trunk/Source/WebCore/GNUmakefile.list.am 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2011-10-28 20:20:50 UTC (rev 98755)
@@ -15,6 +15,8 @@
DerivedSources/WebCore/EventTargetHeaders.h \
DerivedSources/WebCore/EventTargetInterfaces.h \
DerivedSources/WebCore/ExceptionCodeDescription.cpp \
+ DerivedSources/WebCore/ExceptionHeaders.h \
+ DerivedSources/WebCore/ExceptionInterfaces.h \
DerivedSources/WebCore/HTMLElementFactory.cpp \
DerivedSources/WebCore/HTMLElementFactory.h \
DerivedSources/WebCore/HTMLEntityTable.cpp \
Modified: trunk/Source/WebCore/WebCore.gyp/WebCore.gyp (98754 => 98755)
--- trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/WebCore.gyp/WebCore.gyp 2011-10-28 20:20:50 UTC (rev 98755)
@@ -704,6 +704,8 @@
'outputs': [
'<(SHARED_INTERMEDIATE_DIR)/webkit/ExceptionCodeDescription.cpp',
'<(SHARED_INTERMEDIATE_DIR)/webkit/ExceptionCodeDescription.h',
+ '<(SHARED_INTERMEDIATE_DIR)/webkit/ExceptionHeaders.h',
+ '<(SHARED_INTERMEDIATE_DIR)/webkit/ExceptionInterfaces.h',
],
'action': [
'python',
Modified: trunk/Source/WebCore/WebCore.gypi (98754 => 98755)
--- trunk/Source/WebCore/WebCore.gypi 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/WebCore.gypi 2011-10-28 20:20:50 UTC (rev 98755)
@@ -7081,6 +7081,8 @@
'<(PRODUCT_DIR)/DerivedSources/WebCore/EventTargetInterfaces.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/ExceptionCodeDescription.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/ExceptionCodeDescription.h',
+ '<(PRODUCT_DIR)/DerivedSources/WebCore/ExceptionHeaders.h',
+ '<(PRODUCT_DIR)/DerivedSources/WebCore/ExceptionInterfaces.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 (98754 => 98755)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2011-10-28 20:20:50 UTC (rev 98755)
@@ -570,6 +570,14 @@
>
</File>
<File
+ RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\ExceptionHeaders.h"
+ >
+ </File>
+ <File
+ RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\ExceptionInterfaces.h"
+ >
+ </File>
+ <File
RelativePath="$(ConfigurationBuildDir)\obj\$(ProjectName)\DerivedSources\HTMLElementFactory.h"
>
</File>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (98754 => 98755)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2011-10-28 20:20:50 UTC (rev 98755)
@@ -3211,6 +3211,8 @@
975CA2A21303679D00E99AD9 /* JSCrypto.h in Headers */ = {isa = PBXBuildFile; fileRef = 975CA2A01303679D00E99AD9 /* JSCrypto.h */; };
97665013144FAA4200F6BB51 /* EventFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 97665011144FAA4200F6BB51 /* EventFactory.h */; };
9766504F144FBFFE00F6BB51 /* EventFactory.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9766504E144FBFFE00F6BB51 /* EventFactory.cpp */; };
+ 9767CE0B145ABC13005E64DB /* ExceptionHeaders.h in Headers */ = {isa = PBXBuildFile; fileRef = 9767CE09145ABC12005E64DB /* ExceptionHeaders.h */; };
+ 9767CE0C145ABC13005E64DB /* ExceptionInterfaces.h in Headers */ = {isa = PBXBuildFile; fileRef = 9767CE0A145ABC13005E64DB /* ExceptionInterfaces.h */; };
976D6C77122B8A3D001FD1F7 /* AsyncFileWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C58122B8A3D001FD1F7 /* AsyncFileWriter.h */; };
976D6C78122B8A3D001FD1F7 /* Blob.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 976D6C59122B8A3D001FD1F7 /* Blob.cpp */; };
976D6C79122B8A3D001FD1F7 /* Blob.h in Headers */ = {isa = PBXBuildFile; fileRef = 976D6C5A122B8A3D001FD1F7 /* Blob.h */; };
@@ -10356,6 +10358,8 @@
975CA2A01303679D00E99AD9 /* JSCrypto.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCrypto.h; sourceTree = "<group>"; };
97665011144FAA4200F6BB51 /* EventFactory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventFactory.h; sourceTree = "<group>"; };
9766504E144FBFFE00F6BB51 /* EventFactory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventFactory.cpp; sourceTree = "<group>"; };
+ 9767CE09145ABC12005E64DB /* ExceptionHeaders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionHeaders.h; sourceTree = "<group>"; };
+ 9767CE0A145ABC13005E64DB /* ExceptionInterfaces.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionInterfaces.h; sourceTree = "<group>"; };
976D6C58122B8A3D001FD1F7 /* AsyncFileWriter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AsyncFileWriter.h; path = fileapi/AsyncFileWriter.h; sourceTree = "<group>"; };
976D6C59122B8A3D001FD1F7 /* Blob.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Blob.cpp; path = fileapi/Blob.cpp; sourceTree = "<group>"; };
976D6C5A122B8A3D001FD1F7 /* Blob.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Blob.h; path = fileapi/Blob.h; sourceTree = "<group>"; };
@@ -15185,6 +15189,8 @@
97AA3CA4145237CC003E1DA6 /* EventTargetInterfaces.h */,
973DC63D145A9409002842C2 /* ExceptionCodeDescription.cpp */,
973DC63E145A9409002842C2 /* ExceptionCodeDescription.h */,
+ 9767CE09145ABC12005E64DB /* ExceptionHeaders.h */,
+ 9767CE0A145ABC13005E64DB /* ExceptionInterfaces.h */,
A17C81200F2A5CF7005DAAEB /* HTMLElementFactory.cpp */,
A17C81210F2A5CF7005DAAEB /* HTMLElementFactory.h */,
A8BC04911214F69600B5F122 /* HTMLEntityTable.cpp */,
@@ -24529,6 +24535,8 @@
97665013144FAA4200F6BB51 /* EventFactory.h in Headers */,
A0EE0DF6144F825500F80B0D /* WebGLDebugRendererInfo.h in Headers */,
A0EE0DF8144F825500F80B0D /* WebGLDebugShaders.h in Headers */,
+ 9767CE0B145ABC13005E64DB /* ExceptionHeaders.h in Headers */,
+ 9767CE0C145ABC13005E64DB /* ExceptionInterfaces.h in Headers */,
973DC640145A9409002842C2 /* ExceptionCodeDescription.h in Headers */,
97AA3CA5145237CC003E1DA6 /* EventTargetHeaders.h in Headers */,
97AA3CA6145237CC003E1DA6 /* EventTargetInterfaces.h in Headers */,
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp (98754 => 98755)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp 2011-10-28 20:20:50 UTC (rev 98755)
@@ -21,38 +21,14 @@
#include "config.h"
#include "JSDOMBinding.h"
-#include "DOMCoreException.h"
#include "DOMObjectHashTableMap.h"
-#include "EventException.h"
-#include "ExceptionBase.h"
#include "ExceptionCode.h"
-#include "FileException.h"
+#include "ExceptionHeaders.h"
+#include "ExceptionInterfaces.h"
#include "Frame.h"
-#include "IDBDatabaseException.h"
-#include "JSDOMCoreException.h"
#include "JSDOMWindowCustom.h"
-#include "JSEventException.h"
#include "JSExceptionBase.h"
-#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
-#include "JSFileException.h"
-#include "JSOperationNotAllowedException.h"
-#endif
-#include "JSRangeException.h"
-#if ENABLE(SQL_DATABASE)
-#include "JSSQLException.h"
-#endif
-#if ENABLE(SVG)
-#include "JSSVGException.h"
-#endif
-#include "JSXMLHttpRequestException.h"
-#include "JSXPathException.h"
-#include "OperationNotAllowedException.h"
-#include "RangeException.h"
-#include "SQLException.h"
-#include "SVGException.h"
#include "ScriptCallStack.h"
-#include "XMLHttpRequestException.h"
-#include "XPathException.h"
#include <runtime/DateInstance.h>
#include <runtime/Error.h>
#include <runtime/ExceptionHelpers.h>
@@ -199,6 +175,11 @@
reportException(exec, exception);
}
+#define TRY_TO_CREATE_EXCEPTION(interfaceName) \
+ case interfaceName##Type: \
+ errorObject = toJS(exec, globalObject, interfaceName::create(description)); \
+ break;
+
void setDOMException(ExecState* exec, ExceptionCode ec)
{
if (!ec || exec->hadException())
@@ -213,50 +194,15 @@
JSValue errorObject;
switch (description.type) {
- case DOMCoreExceptionType:
- errorObject = toJS(exec, globalObject, DOMCoreException::create(description));
- break;
- case RangeExceptionType:
- errorObject = toJS(exec, globalObject, RangeException::create(description));
- break;
- case EventExceptionType:
- errorObject = toJS(exec, globalObject, EventException::create(description));
- break;
- case XMLHttpRequestExceptionType:
- errorObject = toJS(exec, globalObject, XMLHttpRequestException::create(description));
- break;
-#if ENABLE(SVG)
- case SVGExceptionType:
- errorObject = toJS(exec, globalObject, SVGException::create(description).get());
- break;
-#endif
- case XPathExceptionType:
- errorObject = toJS(exec, globalObject, XPathException::create(description));
- break;
-#if ENABLE(SQL_DATABASE)
- case SQLExceptionType:
- errorObject = toJS(exec, globalObject, SQLException::create(description));
- break;
-#endif
-#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
- case FileExceptionType:
- errorObject = toJS(exec, globalObject, FileException::create(description));
- break;
- case OperationNotAllowedExceptionType:
- errorObject = toJS(exec, globalObject, OperationNotAllowedException::create(description));
- break;
-#endif
-#if ENABLE(INDEXED_DATABASE)
- case IDBDatabaseExceptionType:
- errorObject = toJS(exec, globalObject, IDBDatabaseException::create(description));
- break;
-#endif
+ DOM_EXCEPTION_INTERFACES_FOR_EACH(TRY_TO_CREATE_EXCEPTION)
}
ASSERT(errorObject);
throwError(exec, errorObject);
}
+#undef TRY_TO_CREATE_EXCEPTION
+
DOMWindow* activeDOMWindow(ExecState* exec)
{
return asJSDOMWindow(exec->lexicalGlobalObject())->impl();
Modified: trunk/Source/WebCore/bindings/objc/ExceptionHandlers.mm (98754 => 98755)
--- trunk/Source/WebCore/bindings/objc/ExceptionHandlers.mm 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/bindings/objc/ExceptionHandlers.mm 2011-10-28 20:20:50 UTC (rev 98755)
@@ -46,6 +46,7 @@
ExceptionCodeDescription description(ec);
NSString *exceptionName;
+ // FIXME: We can use the enum to do these comparisons faster.
if (strcmp(description.typeName, "DOM Range") == 0)
exceptionName = DOMRangeException;
else if (strcmp(description.typeName, "DOM Events") == 0)
Modified: trunk/Source/WebCore/bindings/scripts/InFilesCompiler.pm (98754 => 98755)
--- trunk/Source/WebCore/bindings/scripts/InFilesCompiler.pm 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/bindings/scripts/InFilesCompiler.pm 2011-10-28 20:20:50 UTC (rev 98755)
@@ -26,11 +26,19 @@
use strict;
+use Config;
+use Getopt::Long;
+use File::Path;
+use File::Spec;
use IO::File;
use InFilesParser;
+require Config;
+
package InFilesCompiler;
+my $inputFile = "";
+my $outputDir = ".";
my $defaultItemFactory;
my %parsedItems;
@@ -71,11 +79,24 @@
return $reference;
}
+sub initializeFromCommandLine()
+{
+ ::GetOptions(
+ 'input=s' => \$inputFile,
+ 'outputDir=s' => \$outputDir,
+ );
+
+ die "You must specify --input <file>" unless length($inputFile);
+
+ ::mkpath($outputDir);
+
+ # FIXME: Should we provide outputDir via an accessor?
+ return $outputDir;
+}
+
sub compile()
{
my $object = shift;
-
- my $inputFile = shift;
my $generateCode = shift;
my $file = new IO::File;
@@ -122,4 +143,135 @@
";
}
+sub interfaceForItem($)
+{
+ my $object = shift;
+ my $itemName = shift;
+
+ my $interfaceName = $parsedItems{$itemName}{"interfaceName"};
+ $interfaceName = $itemName unless $interfaceName;
+
+ return $interfaceName;
+}
+
+sub toMacroStyle($$)
+{
+ my $object = shift;
+ my $camelCase = shift;
+
+ return "EVENT" if $camelCase eq "Event";
+ return "EVENT_TARGET" if $camelCase eq "EventTarget";
+ return "EXCEPTION" if $camelCase eq "Exception";
+
+ die "Ok, you got me. This script is really just a giant hack. (\$camelCase=${camelCase})";
+}
+
+sub generateInterfacesHeader()
+{
+ my $object = shift;
+
+ my $F;
+ my $namespace = $parsedParameters{"namespace"};
+ my $outputFile = "$outputDir/${namespace}Interfaces.h";
+
+ open F, ">$outputFile" or die "Failed to open file: $!";
+
+ print F license();
+
+ print F "#ifndef ${namespace}Interfaces_h\n";
+ print F "#define ${namespace}Interfaces_h\n";
+ print F "\n";
+
+ my %unconditionalInterfaces = ();
+ my %interfacesByConditional = ();
+
+ for my $itemName (sort keys %parsedItems) {
+ my $conditional = $parsedItems{$itemName}{"conditional"};
+ my $interfaceName = $object->interfaceForItem($itemName);
+
+ if ($conditional) {
+ if (!defined($interfacesByConditional{$conditional})) {
+ $interfacesByConditional{$conditional} = ();
+ }
+ $interfacesByConditional{$conditional}{$interfaceName} = 1;
+ } else {
+ $unconditionalInterfaces{$interfaceName} = 1
+ }
+ }
+
+ my $macroStyledNamespace = $object->toMacroStyle($namespace);
+
+ for my $conditional (sort keys %interfacesByConditional) {
+ print F "#if ENABLE($conditional)\n";
+ print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro) \\\n";
+
+ for my $interface (sort keys %{ $interfacesByConditional{$conditional} }) {
+ next if defined($unconditionalInterfaces{$interface});
+ print F " macro($interface) \\\n";
+ }
+
+ print F "// End of DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional\n";
+ print F "#else\n";
+ print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro)\n";
+ print F "#endif\n";
+ print F "\n";
+ }
+
+ print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH(macro) \\\n";
+ print F " \\\n";
+ for my $interface (sort keys %unconditionalInterfaces) {
+ print F " macro($interface) \\\n";
+ }
+ print F " \\\n";
+ for my $conditional (sort keys %interfacesByConditional) {
+ print F " DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro) \\\n";
+ }
+
+ print F "\n";
+ print F "#endif // ${namespace}Interfaces_h\n";
+
+ close F;
+}
+
+sub generateHeadersHeader()
+{
+ my $object = shift;
+
+ my $F;
+ my $namespace = $parsedParameters{"namespace"};
+ my $outputFile = "$outputDir/${namespace}Headers.h";
+
+ open F, ">$outputFile" or die "Failed to open file: $!";
+
+ print F license();
+
+ print F "#ifndef ${namespace}Headers_h\n";
+ print F "#define ${namespace}Headers_h\n";
+ print F "\n";
+
+ my %includedInterfaces = ();
+
+ for my $itemName (sort keys %parsedItems) {
+ my $conditional = $parsedItems{$itemName}{"conditional"};
+ my $interfaceName = $object->interfaceForItem($itemName);
+
+ next if defined($includedInterfaces{$interfaceName});
+ $includedInterfaces{$interfaceName} = 1;
+
+ print F "#if ENABLE($conditional)\n" if $conditional;
+ print F "#include \"$interfaceName.h\"\n";
+ print F "#if USE(JSC)\n";
+ print F "#include \"JS$interfaceName.h\"\n";
+ print F "#elif USE(V8)\n";
+ print F "#include \"V8$interfaceName.h\"\n";
+ print F "#endif\n";
+ print F "#endif\n" if $conditional;
+ }
+
+ print F "\n";
+ print F "#endif // ${namespace}Headers_h\n";
+
+ close F;
+}
+
1;
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (98754 => 98755)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2011-10-28 20:20:50 UTC (rev 98755)
@@ -37,9 +37,10 @@
#include "DateExtension.h"
#include "Document.h"
#include "DocumentLoader.h"
+#include "ExceptionHeaders.h"
+#include "ExceptionInterfaces.h"
#include "Frame.h"
#include "FrameLoaderClient.h"
-#include "IDBDatabaseException.h"
#include "IDBFactoryBackendInterface.h"
#include "IDBPendingTransactionMonitor.h"
#include "InspectorInstrumentation.h"
@@ -56,27 +57,12 @@
#include "V8DOMCoreException.h"
#include "V8DOMMap.h"
#include "V8DOMWindow.h"
-#include "V8EventException.h"
-#include "V8FileException.h"
#include "V8HiddenPropertyName.h"
#include "V8IsolatedContext.h"
-#include "V8OperationNotAllowedException.h"
-#include "V8RangeException.h"
-#include "V8SQLException.h"
-#include "V8XMLHttpRequestException.h"
-#include "V8XPathException.h"
#include "WebKitMutationObserver.h"
#include "WorkerContext.h"
#include "WorkerContextExecutionProxy.h"
-#if ENABLE(INDEXED_DATABASE)
-#include "V8IDBDatabaseException.h"
-#endif
-
-#if ENABLE(SVG)
-#include "V8SVGException.h"
-#endif
-
#include <algorithm>
#include <stdio.h>
#include <utility>
@@ -649,6 +635,11 @@
windowShell()->clearForNavigation();
}
+#define TRY_TO_CREATE_EXCEPTION(interfaceName) \
+ case interfaceName##Type: \
+ exception = toV8(interfaceName::create(description)); \
+ break;
+
void V8Proxy::setDOMException(int ec)
{
if (ec <= 0)
@@ -658,52 +649,15 @@
v8::Handle<v8::Value> exception;
switch (description.type) {
- case DOMCoreExceptionType:
- exception = toV8(DOMCoreException::create(description));
- break;
- case RangeExceptionType:
- exception = toV8(RangeException::create(description));
- break;
- case EventExceptionType:
- exception = toV8(EventException::create(description));
- break;
- case XMLHttpRequestExceptionType:
- exception = toV8(XMLHttpRequestException::create(description));
- break;
-#if ENABLE(SVG)
- case SVGExceptionType:
- exception = toV8(SVGException::create(description));
- break;
-#endif
- case XPathExceptionType:
- exception = toV8(XPathException::create(description));
- break;
-#if ENABLE(SQL_DATABASE)
- case SQLExceptionType:
- exception = toV8(SQLException::create(description));
- break;
-#endif
-#if ENABLE(BLOB) || ENABLE(FILE_SYSTEM)
- case FileExceptionType:
- exception = toV8(FileException::create(description));
- break;
- case OperationNotAllowedExceptionType:
- exception = toV8(OperationNotAllowedException::create(description));
- break;
-#endif
-#if ENABLE(INDEXED_DATABASE)
- case IDBDatabaseExceptionType:
- exception = toV8(IDBDatabaseException::create(description));
- break;
-#endif
- default:
- ASSERT_NOT_REACHED();
+ DOM_EXCEPTION_INTERFACES_FOR_EACH(TRY_TO_CREATE_EXCEPTION)
}
if (!exception.IsEmpty())
v8::ThrowException(exception);
}
+#undef TRY_TO_CREATE_EXCEPTION
+
v8::Handle<v8::Value> V8Proxy::throwError(ErrorType type, const char* message)
{
switch (type) {
Modified: trunk/Source/WebCore/dom/ExceptionCodeDescription.in (98754 => 98755)
--- trunk/Source/WebCore/dom/ExceptionCodeDescription.in 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/dom/ExceptionCodeDescription.in 2011-10-28 20:20:50 UTC (rev 98755)
@@ -1,4 +1,4 @@
-namespace=ExceptionCodeDescription
+namespace=Exception
DOMCoreException
EventException
Modified: trunk/Source/WebCore/dom/make_event_factory.pl (98754 => 98755)
--- trunk/Source/WebCore/dom/make_event_factory.pl 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/dom/make_event_factory.pl 2011-10-28 20:20:50 UTC (rev 98755)
@@ -32,35 +32,12 @@
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 (
@@ -69,39 +46,22 @@
);
}
-sub interfaceForEvent($$)
-{
- my ($eventName, $parsedItemsRef) = @_;
+my $InCompiler = InFilesCompiler->new(\%defaultParameters, \&defaultItemFactory);
- my %parsedItems = %{ $parsedItemsRef };
+my $outputDir = $InCompiler->initializeFromCommandLine();
+$InCompiler->compile(\&generateCode);
- my $interfaceName = $parsedItems{$eventName}{"interfaceName"};
- $interfaceName = $eventName unless $interfaceName;
-
- return $interfaceName;
-}
-
-sub toMacroStyle($)
-{
- my ($camelCase) = @_;
-
- return "EVENT" if $camelCase eq "Event";
- return "EVENT_TARGET" if $camelCase eq "EventTarget";
-
- die "Ok, you got me. This script is really just a giant hack. (\$camelCase=${camelCase})";
-}
-
sub generateCode()
{
my $parsedParametersRef = shift;
my $parsedItemsRef = shift;
- printFactoryFile($parsedParametersRef, $parsedItemsRef);
- printMacroFile($parsedParametersRef, $parsedItemsRef);
- printHeadersFile($parsedParametersRef, $parsedItemsRef);
+ generateImplementation($parsedParametersRef, $parsedItemsRef);
+ $InCompiler->generateInterfacesHeader();
+ $InCompiler->generateHeadersHeader()
}
-sub printFactoryFile()
+sub generateImplementation()
{
my $parsedParametersRef = shift;
my $parsedItemsRef = shift;
@@ -133,7 +93,7 @@
for my $eventName (sort keys %parsedEvents) {
my $conditional = $parsedEvents{$eventName}{"conditional"};
- my $interfaceName = interfaceForEvent($eventName, $parsedItemsRef);
+ my $interfaceName = $InCompiler->interfaceForItem($eventName);
print F "#if ENABLE($conditional)\n" if $conditional;
print F " if (type == \"$eventName\")\n";
@@ -148,121 +108,3 @@
close F;
}
-
-sub printMacroFile()
-{
- my $parsedParametersRef = shift;
- my $parsedItemsRef = shift;
-
- my $F;
- my %parsedEvents = %{ $parsedItemsRef };
- my %parsedParameters = %{ $parsedParametersRef };
-
- my $namespace = $parsedParameters{"namespace"};
-
- my $outputFile = "$outputDir/${namespace}Interfaces.h";
-
- open F, ">$outputFile" or die "Failed to open file: $!";
-
- print F $InCompiler->license();
-
- print F "#ifndef ${namespace}Interfaces_h\n";
- print F "#define ${namespace}Interfaces_h\n";
- print F "\n";
-
- my %unconditionalInterfaces = ();
- my %interfacesByConditional = ();
-
- for my $eventName (sort keys %parsedEvents) {
- my $conditional = $parsedEvents{$eventName}{"conditional"};
- my $interfaceName = interfaceForEvent($eventName, $parsedItemsRef);
-
- if ($conditional) {
- if (!defined($interfacesByConditional{$conditional})) {
- $interfacesByConditional{$conditional} = ();
- }
- $interfacesByConditional{$conditional}{$interfaceName} = 1;
- } else {
- $unconditionalInterfaces{$interfaceName} = 1
- }
- }
-
- my $macroStyledNamespace = toMacroStyle($namespace);
-
- for my $conditional (sort keys %interfacesByConditional) {
- print F "#if ENABLE($conditional)\n";
- print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro) \\\n";
-
- for my $interface (sort keys %{ $interfacesByConditional{$conditional} }) {
- next if defined($unconditionalInterfaces{$interface});
- print F " macro($interface) \\\n";
- }
-
- print F "// End of DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional\n";
- print F "#else\n";
- print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro)\n";
- print F "#endif\n";
- print F "\n";
- }
-
- print F "#define DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH(macro) \\\n";
- print F " \\\n";
- for my $interface (sort keys %unconditionalInterfaces) {
- print F " macro($interface) \\\n";
- }
- print F " \\\n";
- for my $conditional (sort keys %interfacesByConditional) {
- print F " DOM_${macroStyledNamespace}_INTERFACES_FOR_EACH_$conditional(macro) \\\n";
- }
-
- print F "\n";
- print F "#endif // ${namespace}Interfaces_h\n";
-
- close F;
-}
-
-sub printHeadersFile()
-{
- my $parsedParametersRef = shift;
- my $parsedItemsRef = shift;
-
- my $F;
- my %parsedEvents = %{ $parsedItemsRef };
- my %parsedParameters = %{ $parsedParametersRef };
-
- my $namespace = $parsedParameters{"namespace"};
-
- my $outputFile = "$outputDir/${namespace}Headers.h";
-
- open F, ">$outputFile" or die "Failed to open file: $!";
-
- print F $InCompiler->license();
-
- print F "#ifndef ${namespace}Headers_h\n";
- print F "#define ${namespace}Headers_h\n";
- print F "\n";
-
- my %includedInterfaces = ();
-
- for my $eventName (sort keys %parsedEvents) {
- my $conditional = $parsedEvents{$eventName}{"conditional"};
- my $interfaceName = interfaceForEvent($eventName, $parsedItemsRef);
-
- next if defined($includedInterfaces{$interfaceName});
- $includedInterfaces{$interfaceName} = 1;
-
- print F "#if ENABLE($conditional)\n" if $conditional;
- print F "#include \"$interfaceName.h\"\n";
- print F "#if USE(JSC)\n";
- print F "#include \"JS$interfaceName.h\"\n";
- print F "#elif USE(V8)\n";
- print F "#include \"V8$interfaceName.h\"\n";
- print F "#endif\n";
- print F "#endif\n" if $conditional;
- }
-
- print F "\n";
- print F "#endif // ${namespace}Headers_h\n";
-
- close F;
-}
Modified: trunk/Source/WebCore/dom/make_exception_code_description.pl (98754 => 98755)
--- trunk/Source/WebCore/dom/make_exception_code_description.pl 2011-10-28 20:10:24 UTC (rev 98754)
+++ trunk/Source/WebCore/dom/make_exception_code_description.pl 2011-10-28 20:20:50 UTC (rev 98755)
@@ -32,49 +32,34 @@
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 (
+ 'interfaceName' => 0,
'conditional' => 0
);
}
+my $InCompiler = InFilesCompiler->new(\%defaultParameters, \&defaultItemFactory);
+
+my $outputDir = $InCompiler->initializeFromCommandLine();
+$InCompiler->compile(\&generateCode);
+
sub generateCode()
{
- my $parsedParameters = shift;
- my $parsedItems = shift;
+ my $parsedParametersRef = shift;
+ my $parsedItemsRef = shift;
- generateHeader($parsedParameters, $parsedItems);
- generateImplementation($parsedParameters, $parsedItems);
+ generateHeader($parsedParametersRef, $parsedItemsRef);
+ generateImplementation($parsedParametersRef, $parsedItemsRef);
+ $InCompiler->generateInterfacesHeader();
+ $InCompiler->generateHeadersHeader()
}
sub generateHeader()