[Supplemental] should support constants
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 04:24:02 +0000 (04:24 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 04:24:02 +0000 (04:24 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79303

Reviewed by Adam Barth.

Given that we have

    interface [Supplemental=Y] X { constant int A = 123; }

then the code generator should generate

    X::A

to refer to the constant. However, the current code generator generates Y::A instead.
This patch fixes it.

Test: bindings/scripts/test/TestSupplemental.idl

* bindings/scripts/CodeGenerator.pm: Modified as described above.
(GenerateCompileTimeCheckForEnumsIfNeeded):

* bindings/scripts/test/JS/JSTestInterface.cpp: Updated run-bindings-tests results.
(WebCore):
* bindings/scripts/test/V8/V8TestInterface.cpp: Ditto.
(WebCore):

* page/DOMWindow.h: Moved DOMWindow::FileSystemType to DOMWindowFileSystem::FileSystemType.
(DOMWindow):
* fileapi/DOMWindowFileSystem.h: Ditto.
(DOMWindowFileSystem):
* fileapi/DOMWindowFileSystem.cpp: Ditto.
(WebCore):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@108603 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestInterface.cpp
Source/WebCore/fileapi/DOMWindowFileSystem.cpp
Source/WebCore/fileapi/DOMWindowFileSystem.h
Source/WebCore/page/DOMWindow.h

index 3f0756f..cc80c81 100644 (file)
@@ -1,3 +1,38 @@
+2012-02-22  Kentaro Hara  <haraken@chromium.org>
+
+        [Supplemental] should support constants
+        https://bugs.webkit.org/show_bug.cgi?id=79303
+
+        Reviewed by Adam Barth.
+
+        Given that we have
+
+            interface [Supplemental=Y] X { constant int A = 123; }
+
+        then the code generator should generate
+
+            X::A
+
+        to refer to the constant. However, the current code generator generates Y::A instead.
+        This patch fixes it.
+
+        Test: bindings/scripts/test/TestSupplemental.idl
+
+        * bindings/scripts/CodeGenerator.pm: Modified as described above.
+        (GenerateCompileTimeCheckForEnumsIfNeeded):
+
+        * bindings/scripts/test/JS/JSTestInterface.cpp: Updated run-bindings-tests results.
+        (WebCore):
+        * bindings/scripts/test/V8/V8TestInterface.cpp: Ditto.
+        (WebCore):
+
+        * page/DOMWindow.h: Moved DOMWindow::FileSystemType to DOMWindowFileSystem::FileSystemType.
+        (DOMWindow):
+        * fileapi/DOMWindowFileSystem.h: Ditto.
+        (DOMWindowFileSystem):
+        * fileapi/DOMWindowFileSystem.cpp: Ditto.
+        (WebCore):
+
 2012-02-22  MORITA Hajime  <morrita@google.com>
 
         Adding a ShadowRoot to image-backed element causes a crash
index 0aea3a3..7e8f6ff 100644 (file)
@@ -627,7 +627,11 @@ sub GenerateCompileTimeCheckForEnumsIfNeeded
                 push(@checks, "#if ${conditionalString}\n");
             }
 
-            push(@checks, "COMPILE_ASSERT($value == ${interfaceName}::$name, ${interfaceName}Enum${name}IsWrongUseDoNotCheckConstants);\n");
+            if ($constant->extendedAttributes->{"ImplementedBy"}) {
+                push(@checks, "COMPILE_ASSERT($value == " . $constant->extendedAttributes->{"ImplementedBy"} . "::$name, ${interfaceName}Enum${name}IsWrongUseDoNotCheckConstants);\n");
+            } else {
+                push(@checks, "COMPILE_ASSERT($value == ${interfaceName}::$name, ${interfaceName}Enum${name}IsWrongUseDoNotCheckConstants);\n");
+            }
 
             if ($conditional) {
                 push(@checks, "#endif\n");
index ac703cd..1b6832d 100644 (file)
@@ -1369,6 +1369,10 @@ sub GenerateImplementation
             push(@hashValue2, "0");
             push(@hashSpecials, "DontDelete | ReadOnly");
 
+            my $implementedBy = $constant->extendedAttributes->{"ImplementedBy"};
+            if ($implementedBy) {
+                $implIncludes{"${implementedBy}.h"} = 1;
+            }
             my $conditional = $constant->extendedAttributes->{"Conditional"};
             if ($conditional) {
                 $conditionals{$name} = $conditional;
index ca5b8e6..ae9e721 100644 (file)
@@ -2428,6 +2428,10 @@ END
         my $value = $constant->value;
         my $attrExt = $constant->extendedAttributes;
         my $conditional = $attrExt->{"Conditional"};
+        my $implementedBy = $attrExt->{"ImplementedBy"};
+        if ($implementedBy) {
+            AddToImplIncludes("${implementedBy}.h");
+        }
         if ($attrExt->{"V8EnabledAtRuntime"}) {
             push(@constantsEnabledAtRuntime, $constant);
         } else {
index 41f7061..8699f1b 100644 (file)
@@ -86,10 +86,10 @@ static const HashTableValue JSTestInterfaceConstructorTableValues[] =
 static const HashTable JSTestInterfaceConstructorTable = { 4, 3, JSTestInterfaceConstructorTableValues, 0 };
 
 #if ENABLE(Condition11) || ENABLE(Condition12)
-COMPILE_ASSERT(1 == TestInterface::SUPPLEMENTALCONSTANT1, TestInterfaceEnumSUPPLEMENTALCONSTANT1IsWrongUseDoNotCheckConstants);
+COMPILE_ASSERT(1 == TestSupplemental::SUPPLEMENTALCONSTANT1, TestInterfaceEnumSUPPLEMENTALCONSTANT1IsWrongUseDoNotCheckConstants);
 #endif
 #if ENABLE(Condition11) || ENABLE(Condition12)
-COMPILE_ASSERT(2 == TestInterface::CONST_IMPL, TestInterfaceEnumCONST_IMPLIsWrongUseDoNotCheckConstants);
+COMPILE_ASSERT(2 == TestSupplemental::CONST_IMPL, TestInterfaceEnumCONST_IMPLIsWrongUseDoNotCheckConstants);
 #endif
 
 const ClassInfo JSTestInterfaceConstructor::s_info = { "TestInterfaceConstructor", &Base::s_info, &JSTestInterfaceConstructorTable, 0, CREATE_METHOD_TABLE(JSTestInterfaceConstructor) };
index bfc69e9..03be297 100644 (file)
@@ -186,10 +186,10 @@ static const BatchedConstant TestInterfaceConsts[] = {
 
 
 #if ENABLE(Condition11) || ENABLE(Condition12)
-COMPILE_ASSERT(1 == TestInterface::SUPPLEMENTALCONSTANT1, TestInterfaceEnumSUPPLEMENTALCONSTANT1IsWrongUseDoNotCheckConstants);
+COMPILE_ASSERT(1 == TestSupplemental::SUPPLEMENTALCONSTANT1, TestInterfaceEnumSUPPLEMENTALCONSTANT1IsWrongUseDoNotCheckConstants);
 #endif
 #if ENABLE(Condition11) || ENABLE(Condition12)
-COMPILE_ASSERT(2 == TestInterface::CONST_IMPL, TestInterfaceEnumCONST_IMPLIsWrongUseDoNotCheckConstants);
+COMPILE_ASSERT(2 == TestSupplemental::CONST_IMPL, TestInterfaceEnumCONST_IMPLIsWrongUseDoNotCheckConstants);
 #endif
 
 v8::Handle<v8::Value> V8TestInterface::constructorCallback(const v8::Arguments& args)
index 068a233..570c39d 100644 (file)
@@ -99,8 +99,8 @@ void DOMWindowFileSystem::webkitResolveLocalFileSystemURL(DOMWindow* window, con
     LocalFileSystem::localFileSystem().readFileSystem(document, type, ResolveURICallbacks::create(successCallback, errorCallback, document, filePath));
 }
 
-COMPILE_ASSERT(static_cast<int>(DOMWindow::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
-COMPILE_ASSERT(static_cast<int>(DOMWindow::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
+COMPILE_ASSERT(static_cast<int>(DOMWindowFileSystem::TEMPORARY) == static_cast<int>(AsyncFileSystem::Temporary), enum_mismatch);
+COMPILE_ASSERT(static_cast<int>(DOMWindowFileSystem::PERSISTENT) == static_cast<int>(AsyncFileSystem::Persistent), enum_mismatch);
 
 } // namespace WebCore
 
index f6e14b3..2783553 100644 (file)
@@ -44,6 +44,13 @@ public:
     static void webkitRequestFileSystem(DOMWindow*, int type, long long size, PassRefPtr<FileSystemCallback>, PassRefPtr<ErrorCallback>);
     static void webkitResolveLocalFileSystemURL(DOMWindow*, const String&, PassRefPtr<EntryCallback>, PassRefPtr<ErrorCallback>);
 
+    // They are placed here and in all capital letters so they can be checked against the constants in the
+    // IDL at compile time.
+    enum FileSystemType {
+        TEMPORARY,
+        PERSISTENT,
+    };
+
 private:
     DOMWindowFileSystem();
     ~DOMWindowFileSystem();
index 659c4c1..9fa6a5c 100644 (file)
@@ -352,16 +352,6 @@ namespace WebCore {
         Storage* sessionStorage(ExceptionCode&) const;
         Storage* localStorage(ExceptionCode&) const;
 
-#if ENABLE(FILE_SYSTEM)
-        // They are placed here and in all capital letters so they can be checked against the constants in the
-        // IDL at compile time.
-        // FIXME: Move these constants to DOMWindowFileSystem.
-        enum FileSystemType {
-            TEMPORARY,
-            PERSISTENT,
-        };
-#endif
-
 #if ENABLE(NOTIFICATIONS)
         NotificationCenter* webkitNotifications() const;
         // Renders webkitNotifications object safely inoperable, disconnects