Add support for InterfaceName in the bindings
authorarv@chromium.org <arv@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 21:23:11 +0000 (21:23 +0000)
committerarv@chromium.org <arv@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Feb 2012 21:23:11 +0000 (21:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=79384

Reviewed by Adam Barth.

This makes the interface name part of the idl file instead of being hard coded into the code generators.

* bindings/scripts/CodeGenerator.pm:
(GetVisibleInterfaceName): Extracted from CodeGenerator{JS,V8}.pm and changed to look at the extended attribute.
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
(GenerateConstructorDefinition):
* bindings/scripts/CodeGeneratorV8.pm:
(GenerateImplementation):
* bindings/scripts/IDLAttributes.txt:
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore):
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::ConfigureV8TestObjTemplate):
* dom/DOMCoreException.idl: Set the InterfaceName.
* html/DOMFormData.idl: Ditto.
* plugins/DOMMimeType.idl: Ditto.
* plugins/DOMMimeTypeArray.idl: Ditto.
* plugins/DOMPlugin.idl: Ditto.
* plugins/DOMPluginArray.idl: Ditto.

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

14 files changed:
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/IDLAttributes.txt
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/dom/DOMCoreException.idl
Source/WebCore/html/DOMFormData.idl
Source/WebCore/plugins/DOMMimeType.idl
Source/WebCore/plugins/DOMMimeTypeArray.idl
Source/WebCore/plugins/DOMPlugin.idl
Source/WebCore/plugins/DOMPluginArray.idl

index 3d34ea7b54e4fe47d9fbc63ca87b06713cab40ab..bc96fc8d5ea6acb95733ef8a86dcbfde6edcfd15 100644 (file)
@@ -1,3 +1,32 @@
+2012-02-23  Erik Arvidsson  <arv@chromium.org>
+
+        Add support for InterfaceName in the bindings
+        https://bugs.webkit.org/show_bug.cgi?id=79384
+
+        Reviewed by Adam Barth.
+
+        This makes the interface name part of the idl file instead of being hard coded into the code generators.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (GetVisibleInterfaceName): Extracted from CodeGenerator{JS,V8}.pm and changed to look at the extended attribute.
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        (GenerateConstructorDefinition):
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateImplementation):
+        * bindings/scripts/IDLAttributes.txt:
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore):
+        * bindings/scripts/test/TestObj.idl:
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::ConfigureV8TestObjTemplate):
+        * dom/DOMCoreException.idl: Set the InterfaceName.
+        * html/DOMFormData.idl: Ditto.
+        * plugins/DOMMimeType.idl: Ditto.
+        * plugins/DOMMimeTypeArray.idl: Ditto.
+        * plugins/DOMPlugin.idl: Ditto.
+        * plugins/DOMPluginArray.idl: Ditto.
+
 2012-02-22  Ryosuke Niwa  <rniwa@webkit.org>
 
         REGRESSION(r99076): WebKit pastes the trailing newline into a single-line text field
index 7e8f6ff20dd180feeb01443935cea0d7dff069dd..ea5835996718c118bc2801f7f0e0c023a2553a9e 100644 (file)
@@ -653,4 +653,14 @@ sub ExtendedAttributeContains
     return grep { $_ eq $keyword } @callWithKeywords;
 }
 
+# FIXME: This is backwards. We currently name the interface and the IDL files with the implementation name. We
+# should use the real interface name in the IDL files and then use ImplementedAs to map this to the implementation name.
+sub GetVisibleInterfaceName
+{
+    my $object = shift;
+    my $dataNode = shift;
+    my $interfaceName = $dataNode->extendedAttributes->{"InterfaceName"};
+    return $interfaceName ? $interfaceName : $dataNode->name;
+}
+
 1;
index 1b6832dfe556d32ad09617b3b0d7699a9d99187b..b983c46d13cac8231b7a5654a393cbdd9d8e3af5 100644 (file)
@@ -189,20 +189,6 @@ sub GetParentClassName
     return "JS" . $codeGenerator->StripModule($dataNode->parents(0));
 }
 
-sub GetVisibleClassName
-{
-    my $className = shift;
-
-    return "DOMException" if $className eq "DOMCoreException";
-    return "FormData" if $className eq "DOMFormData";
-    return "MimeType" if $className eq "DOMMimeType";
-    return "MimeTypeArray" if $className eq "DOMMimeTypeArray";
-    return "Plugin" if $className eq "DOMPlugin";
-    return "PluginArray" if $className eq "DOMPluginArray";
-    
-    return $className;
-}
-
 sub GetCallbackClassName
 {
     my $className = shift;
@@ -1323,7 +1309,7 @@ sub GenerateImplementation
     my $hasRealParent = @{$dataNode->parents} > 0;
     my $hasParent = $hasLegacyParent || $hasRealParent;
     my $parentClassName = GetParentClassName($dataNode);
-    my $visibleClassName = GetVisibleClassName($interfaceName);
+    my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($dataNode);
     my $eventTarget = $dataNode->extendedAttributes->{"EventTarget"};
     my $needsMarkChildren = $dataNode->extendedAttributes->{"JSCustomMarkFunction"} || $dataNode->extendedAttributes->{"EventTarget"};
 
@@ -1412,7 +1398,7 @@ sub GenerateImplementation
         push(@implContent, $codeGenerator->GenerateCompileTimeCheckForEnumsIfNeeded($dataNode));
 
         my $protoClassName = "${className}Prototype";
-        GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $visibleClassName, $dataNode);
+        GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $visibleInterfaceName, $dataNode);
         if ($dataNode->extendedAttributes->{"NamedConstructor"}) {
             GenerateConstructorDefinition(\@implContent, $className, $protoClassName, $interfaceName, $dataNode->extendedAttributes->{"NamedConstructor"}, $dataNode, "GeneratingNamedConstructor");
         }
@@ -1478,9 +1464,9 @@ sub GenerateImplementation
         push(@implContent, "{\n");
         push(@implContent, "    return getHashTableForGlobalData(exec->globalData(), &${className}PrototypeTable);\n");
         push(@implContent, "}\n\n");
-        push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", &Base::s_info, 0, get${className}PrototypeTable, CREATE_METHOD_TABLE(${className}Prototype) };\n\n");
+        push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleInterfaceName}Prototype\", &Base::s_info, 0, get${className}PrototypeTable, CREATE_METHOD_TABLE(${className}Prototype) };\n\n");
     } else {
-        push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleClassName}Prototype\", &Base::s_info, &${className}PrototypeTable, 0, CREATE_METHOD_TABLE(${className}Prototype) };\n\n");
+        push(@implContent, "const ClassInfo ${className}Prototype::s_info = { \"${visibleInterfaceName}Prototype\", &Base::s_info, &${className}PrototypeTable, 0, CREATE_METHOD_TABLE(${className}Prototype) };\n\n");
     }
     if ($interfaceName ne "DOMWindow" && !$dataNode->extendedAttributes->{"IsWorkerContext"}) {
         push(@implContent, "JSObject* ${className}Prototype::self(ExecState* exec, JSGlobalObject* globalObject)\n");
@@ -1539,7 +1525,7 @@ sub GenerateImplementation
         push(@implContent, "}\n\n");
     }
 
-    push(@implContent, "const ClassInfo $className" . "::s_info = { \"${visibleClassName}\", &Base::s_info, ");
+    push(@implContent, "const ClassInfo $className" . "::s_info = { \"${visibleInterfaceName}\", &Base::s_info, ");
 
     if ($numAttributes > 0 && !$dataNode->extendedAttributes->{"JSNoStaticTables"}) {
         push(@implContent, "&${className}Table");
@@ -3373,7 +3359,7 @@ sub GenerateConstructorDefinition
     my $className = shift;
     my $protoClassName = shift;
     my $interfaceName = shift;
-    my $visibleClassName = shift;
+    my $visibleInterfaceName = shift;
     my $dataNode = shift;
     my $generatingNamedConstructor = shift;
 
@@ -3388,13 +3374,13 @@ sub GenerateConstructorDefinition
     }
 
     if ($generatingNamedConstructor) {
-        push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleClassName}Constructor\", &Base::s_info, 0, 0, CREATE_METHOD_TABLE($constructorClassName) };\n\n");
+        push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleInterfaceName}Constructor\", &Base::s_info, 0, 0, CREATE_METHOD_TABLE($constructorClassName) };\n\n");
         push(@$outputArray, "${constructorClassName}::${constructorClassName}(Structure* structure, JSDOMGlobalObject* globalObject)\n");
         push(@$outputArray, "    : DOMConstructorWithDocument(structure, globalObject)\n");
         push(@$outputArray, "{\n");
         push(@$outputArray, "}\n\n");
     } else {
-        push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleClassName}Constructor\", &Base::s_info, &${constructorClassName}Table, 0, CREATE_METHOD_TABLE($constructorClassName) };\n\n");
+        push(@$outputArray, "const ClassInfo ${constructorClassName}::s_info = { \"${visibleInterfaceName}Constructor\", &Base::s_info, &${constructorClassName}Table, 0, CREATE_METHOD_TABLE($constructorClassName) };\n\n");
         push(@$outputArray, "${constructorClassName}::${constructorClassName}(Structure* structure, JSDOMGlobalObject* globalObject)\n");
         push(@$outputArray, "    : DOMConstructorObject(structure, globalObject)\n");
         push(@$outputArray, "{\n");
index ae9e7218887c794e7f729fa73cccbee8b2ba4378..b805a3290f4cd468dde1bd565f62b1ad1bc4f9a5 100644 (file)
@@ -2224,7 +2224,7 @@ sub GenerateImplementation
     my $object = shift;
     my $dataNode = shift;
     my $interfaceName = $dataNode->name;
-    my $visibleInterfaceName = GetVisibleInterfaceName($interfaceName);
+    my $visibleInterfaceName = $codeGenerator->GetVisibleInterfaceName($dataNode);
     my $className = "V8$interfaceName";
     my $implClassName = $interfaceName;
 
@@ -3783,15 +3783,6 @@ sub WriteData
     @headerContent = ();
 }
 
-sub GetVisibleInterfaceName
-{
-    my $interfaceName = shift;
-
-    return "DOMException" if $interfaceName eq "DOMCoreException";
-    return "FormData" if $interfaceName eq "DOMFormData";
-    return $interfaceName;
-}
-
 sub GetCallbackClassName
 {
     my $interfaceName = shift;
index 7e44a8db6cfc7daa34802bf3dd460f4763748d23..d105e08727de91177ef51920d71744ff790d9c98 100644 (file)
@@ -54,6 +54,7 @@ ExtendsDOMGlobalObject
 Immutable
 ImplementedAs=*
 IndexedGetter
+InterfaceName=*
 InitializedByEventConstructor
 IsIndex
 IsWorkerContext
index def431f377dcbdad78184cf2a9859d6c15cb62b6..97dcc8f2fed6dd1340f08e0509f2fe2149007a05 100644 (file)
@@ -187,7 +187,7 @@ COMPILE_ASSERT(0X20 == TestObj::CONST_VALUE_13, TestObjEnumCONST_VALUE_13IsWrong
 COMPILE_ASSERT(0x1abc == TestObj::CONST_VALUE_14, TestObjEnumCONST_VALUE_14IsWrongUseDoNotCheckConstants);
 COMPILE_ASSERT(15 == TestObj::CONST_IMPL, TestObjEnumCONST_IMPLIsWrongUseDoNotCheckConstants);
 
-const ClassInfo JSTestObjConstructor::s_info = { "TestObjConstructor", &Base::s_info, &JSTestObjConstructorTable, 0, CREATE_METHOD_TABLE(JSTestObjConstructor) };
+const ClassInfo JSTestObjConstructor::s_info = { "TestObjectConstructor", &Base::s_info, &JSTestObjConstructorTable, 0, CREATE_METHOD_TABLE(JSTestObjConstructor) };
 
 JSTestObjConstructor::JSTestObjConstructor(Structure* structure, JSDOMGlobalObject* globalObject)
     : DOMConstructorObject(structure, globalObject)
@@ -302,7 +302,7 @@ static const HashTableValue JSTestObjPrototypeTableValues[] =
 };
 
 static const HashTable JSTestObjPrototypeTable = { 266, 255, JSTestObjPrototypeTableValues, 0 };
-const ClassInfo JSTestObjPrototype::s_info = { "TestObjPrototype", &Base::s_info, &JSTestObjPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestObjPrototype) };
+const ClassInfo JSTestObjPrototype::s_info = { "TestObjectPrototype", &Base::s_info, &JSTestObjPrototypeTable, 0, CREATE_METHOD_TABLE(JSTestObjPrototype) };
 
 JSObject* JSTestObjPrototype::self(ExecState* exec, JSGlobalObject* globalObject)
 {
@@ -321,7 +321,7 @@ bool JSTestObjPrototype::getOwnPropertyDescriptor(JSObject* object, ExecState* e
     return getStaticPropertyDescriptor<JSTestObjPrototype, JSObject>(exec, &JSTestObjPrototypeTable, thisObject, propertyName, descriptor);
 }
 
-const ClassInfo JSTestObj::s_info = { "TestObj", &Base::s_info, &JSTestObjTable, 0 , CREATE_METHOD_TABLE(JSTestObj) };
+const ClassInfo JSTestObj::s_info = { "TestObject", &Base::s_info, &JSTestObjTable, 0 , CREATE_METHOD_TABLE(JSTestObj) };
 
 JSTestObj::JSTestObj(Structure* structure, JSDOMGlobalObject* globalObject, PassRefPtr<TestObj> impl)
     : JSDOMWrapper(structure, globalObject)
index dc2a1a1be332cdc3e508fc07d01b440771de472b..171fda48c9ed109cf2fce1fbd7ebdbcd42c94ada 100644 (file)
@@ -31,7 +31,8 @@
 // changes in its ouput.
 module test {
     interface [
-        Constructor
+        Constructor,
+        InterfaceName=TestObject
     ] TestObj {
         // Attributes
         readonly attribute long            readOnlyIntAttr;
index 59ce9d703374d0bfbaa54b2d28b982719f9441b1..4a2029a221a145bf418e2bbba4bf3282a14427dc 100644 (file)
@@ -1963,7 +1963,7 @@ static v8::Persistent<v8::FunctionTemplate> ConfigureV8TestObjTemplate(v8::Persi
     desc->ReadOnlyPrototype();
 
     v8::Local<v8::Signature> defaultSignature;
-    defaultSignature = configureTemplate(desc, "TestObj", v8::Persistent<v8::FunctionTemplate>(), V8TestObj::internalFieldCount,
+    defaultSignature = configureTemplate(desc, "TestObject", v8::Persistent<v8::FunctionTemplate>(), V8TestObj::internalFieldCount,
         TestObjAttrs, WTF_ARRAY_LENGTH(TestObjAttrs),
         TestObjCallbacks, WTF_ARRAY_LENGTH(TestObjCallbacks));
     UNUSED_PARAM(defaultSignature); // In some cases, it will not be used.
index 3f25b021ac37662e4399812df35f9192e70991b6..add5bd9a13d7e7bf40e2051f10716778d25cc540 100644 (file)
@@ -30,7 +30,8 @@ module core {
 
     interface [
         JSNoStaticTables,
-        DoNotCheckConstants
+        DoNotCheckConstants,
+        InterfaceName=DOMException
     ] DOMCoreException {
 
         readonly attribute unsigned short   code;
index b747cdeb2688bb40105c3fd72f7982ffb3a17b53..4bab556bebbfbc2bf661d3111953bf222dddf010 100644 (file)
@@ -33,7 +33,8 @@ module html {
     interface [
         CustomConstructor,
         JSGenerateToNativeObject,
-        JSGenerateToJSObject
+        JSGenerateToJSObject,
+        InterfaceName=FormData
     ] DOMFormData {
         // void append(DOMString name, DOMString value);
         // void append(DOMString name, Blob value, optional DOMString filename);
index 1d97a6b61f8466261c0d84e15e363ca9fabd7efd..942060f10700e204fedc7d904284a48b86d166f7 100644 (file)
@@ -20,7 +20,9 @@
 
 module window {
 
-    interface DOMMimeType {
+    interface [
+        InterfaceName=MimeType
+    ] DOMMimeType {
         readonly attribute DOMString type;
         readonly attribute DOMString suffixes;
         readonly attribute DOMString description;
index 51575789b5885cb4ee193018e98fd41937b097a2..3de7f8d6d67beab5c11a858dc2ed70167bab448c 100644 (file)
@@ -23,7 +23,8 @@ module window {
     interface [
         JSGenerateIsReachable=ImplFrame,
         NamedGetter,
-        IndexedGetter
+        IndexedGetter,
+        InterfaceName=MimeTypeArray
     ] DOMMimeTypeArray {
         readonly attribute unsigned long length;
         DOMMimeType item(in [Optional=DefaultIsUndefined] unsigned long index);
index 41b71c3b85d6e6dab7addb36e51edcee3aeab3a1..f645a0b6e0f7f42e548633e3579d1db1bb0db498 100644 (file)
@@ -22,7 +22,8 @@ module window {
 
     interface [
         NamedGetter,
-        IndexedGetter
+        IndexedGetter,
+        InterfaceName=Plugin
     ] DOMPlugin {
         readonly attribute DOMString name;
         readonly attribute DOMString filename;
index 270b07e649ae793eac22550ac18c28852abb711d..f042f924c628e65dbb2aaed851df2d40568ae02f 100644 (file)
@@ -23,7 +23,8 @@ module window {
     interface [
         JSGenerateIsReachable=ImplFrame,
         NamedGetter,
-        IndexedGetter
+        IndexedGetter,
+        InterfaceName=PluginArray
     ] DOMPluginArray {
         readonly attribute unsigned long length;
         DOMPlugin item(in [Optional=DefaultIsUndefined] unsigned long index);