Title: [123800] trunk/Source/WebCore
Revision
123800
Author
[email protected]
Date
2012-07-26 15:15:56 -0700 (Thu, 26 Jul 2012)

Log Message

Support constructor-type static readonly attribute for CodeGenerator.
https://bugs.webkit.org/show_bug.cgi?id=92413.

Patch by Chang Shu <[email protected]> on 2012-07-26
Reviewed by Adam Barth.

Added support for constructor-type static readonly attribute for CodeGenerator.
This is achieved by putting the attribute entry in the table where static properties
belong to but leave the implementation same as a non-static constructor-type attribute.

Tested by running run-bindings-tests.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
* bindings/scripts/test/JS/JSTestInterface.cpp:
(WebCore::jsTestInterfaceConstructorSupplementalStaticReadOnlyAttr):
(WebCore::jsTestInterfaceConstructorSupplementalStaticAttr):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore):
(WebCore::jsTestObjConstructorStaticReadOnlyLongAttr):
(WebCore::jsTestObjConstructorStaticStringAttr):
(WebCore::jsTestObjConstructorTestSubObj):
* bindings/scripts/test/JS/JSTestObj.h:
(WebCore):
* bindings/scripts/test/TestObj.idl:
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (123799 => 123800)


--- trunk/Source/WebCore/ChangeLog	2012-07-26 22:10:54 UTC (rev 123799)
+++ trunk/Source/WebCore/ChangeLog	2012-07-26 22:15:56 UTC (rev 123800)
@@ -1,3 +1,32 @@
+2012-07-26  Chang Shu  <[email protected]>
+
+        Support constructor-type static readonly attribute for CodeGenerator.
+        https://bugs.webkit.org/show_bug.cgi?id=92413.
+
+        Reviewed by Adam Barth.
+
+        Added support for constructor-type static readonly attribute for CodeGenerator.
+        This is achieved by putting the attribute entry in the table where static properties
+        belong to but leave the implementation same as a non-static constructor-type attribute.
+
+        Tested by running run-bindings-tests.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        * bindings/scripts/test/JS/JSTestInterface.cpp:
+        (WebCore::jsTestInterfaceConstructorSupplementalStaticReadOnlyAttr):
+        (WebCore::jsTestInterfaceConstructorSupplementalStaticAttr):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore):
+        (WebCore::jsTestObjConstructorStaticReadOnlyLongAttr):
+        (WebCore::jsTestObjConstructorStaticStringAttr):
+        (WebCore::jsTestObjConstructorTestSubObj):
+        * bindings/scripts/test/JS/JSTestObj.h:
+        (WebCore):
+        * bindings/scripts/test/TestObj.idl:
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore):
+
 2012-07-26  Sadrul Habib Chowdhury  <[email protected]>
 
         Propagate gesture events to plugins.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (123799 => 123800)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-07-26 22:10:54 UTC (rev 123799)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2012-07-26 22:15:56 UTC (rev 123800)
@@ -1764,13 +1764,13 @@
                 my $attributeConditionalString = $codeGenerator->GenerateConditionalString($attribute->signature);
                 push(@implContent, "#if ${attributeConditionalString}\n") if $attributeConditionalString;
 
-                push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue");
-                push(@implContent, " slotBase") if !$attribute->isStatic;
-                push(@implContent, ", PropertyName)\n");
+                push(@implContent, "JSValue ${getFunctionName}(ExecState* exec, JSValue slotBase, PropertyName)\n");
                 push(@implContent, "{\n");
 
-                if (!$attribute->isStatic) {
+                if (!$attribute->isStatic || $attribute->signature->type =~ /Constructor$/) {
                     push(@implContent, "    ${className}* castedThis = jsCast<$className*>(asObject(slotBase));\n");
+                } else {
+                    push(@implContent, "    UNUSED_PARAM(slotBase);\n");
                 }
 
                 if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp (123799 => 123800)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2012-07-26 22:10:54 UTC (rev 123799)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp	2012-07-26 22:15:56 UTC (rev 123800)
@@ -242,8 +242,9 @@
 }
 
 #if ENABLE(Condition11) || ENABLE(Condition12)
-JSValue jsTestInterfaceConstructorSupplementalStaticReadOnlyAttr(ExecState* exec, JSValue, PropertyName)
+JSValue jsTestInterfaceConstructorSupplementalStaticReadOnlyAttr(ExecState* exec, JSValue slotBase, PropertyName)
 {
+    UNUSED_PARAM(slotBase);
     UNUSED_PARAM(exec);
     JSValue result = jsNumber(TestSupplemental::supplementalStaticReadOnlyAttr());
     return result;
@@ -252,8 +253,9 @@
 #endif
 
 #if ENABLE(Condition11) || ENABLE(Condition12)
-JSValue jsTestInterfaceConstructorSupplementalStaticAttr(ExecState* exec, JSValue, PropertyName)
+JSValue jsTestInterfaceConstructorSupplementalStaticAttr(ExecState* exec, JSValue slotBase, PropertyName)
 {
+    UNUSED_PARAM(slotBase);
     UNUSED_PARAM(exec);
     JSValue result = jsString(exec, TestSupplemental::supplementalStaticAttr());
     return result;

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (123799 => 123800)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-07-26 22:10:54 UTC (rev 123799)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp	2012-07-26 22:15:56 UTC (rev 123800)
@@ -168,6 +168,7 @@
     { "CONST_JAVASCRIPT", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjCONST_JAVASCRIPT), (intptr_t)0, NoIntrinsic },
     { "staticReadOnlyLongAttr", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticReadOnlyLongAttr), (intptr_t)0, NoIntrinsic },
     { "staticStringAttr", DontDelete, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorStaticStringAttr), (intptr_t)setJSTestObjConstructorStaticStringAttr, NoIntrinsic },
+    { "TestSubObj", DontDelete | ReadOnly, (intptr_t)static_cast<PropertySlot::GetValueFunc>(jsTestObjConstructorTestSubObj), (intptr_t)0, NoIntrinsic },
     { "classMethod", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethod), (intptr_t)0, NoIntrinsic },
     { "classMethodWithOptional", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethodWithOptional), (intptr_t)1, NoIntrinsic },
     { "classMethod2", DontDelete | JSC::Function, (intptr_t)static_cast<NativeFunction>(jsTestObjConstructorFunctionClassMethod2), (intptr_t)1, NoIntrinsic },
@@ -413,22 +414,31 @@
 }
 
 
-JSValue jsTestObjConstructorStaticReadOnlyLongAttr(ExecState* exec, JSValue, PropertyName)
+JSValue jsTestObjConstructorStaticReadOnlyLongAttr(ExecState* exec, JSValue slotBase, PropertyName)
 {
+    UNUSED_PARAM(slotBase);
     UNUSED_PARAM(exec);
     JSValue result = jsNumber(TestObj::staticReadOnlyLongAttr());
     return result;
 }
 
 
-JSValue jsTestObjConstructorStaticStringAttr(ExecState* exec, JSValue, PropertyName)
+JSValue jsTestObjConstructorStaticStringAttr(ExecState* exec, JSValue slotBase, PropertyName)
 {
+    UNUSED_PARAM(slotBase);
     UNUSED_PARAM(exec);
     JSValue result = jsString(exec, TestObj::staticStringAttr());
     return result;
 }
 
 
+JSValue jsTestObjConstructorTestSubObj(ExecState* exec, JSValue slotBase, PropertyName)
+{
+    JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
+    return JSTestSubObj::getConstructor(exec, castedThis);
+}
+
+
 JSValue jsTestObjShortAttr(ExecState* exec, JSValue slotBase, PropertyName)
 {
     JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));

Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h (123799 => 123800)


--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2012-07-26 22:10:54 UTC (rev 123799)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.h	2012-07-26 22:15:56 UTC (rev 123800)
@@ -223,6 +223,7 @@
 JSC::JSValue jsTestObjConstructorStaticReadOnlyLongAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
 JSC::JSValue jsTestObjConstructorStaticStringAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
 void setJSTestObjConstructorStaticStringAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
+JSC::JSValue jsTestObjConstructorTestSubObj(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
 JSC::JSValue jsTestObjShortAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);
 void setJSTestObjShortAttr(JSC::ExecState*, JSC::JSObject*, JSC::JSValue);
 JSC::JSValue jsTestObjUnsignedShortAttr(JSC::ExecState*, JSC::JSValue, JSC::PropertyName);

Modified: trunk/Source/WebCore/bindings/scripts/test/TestObj.idl (123799 => 123800)


--- trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2012-07-26 22:10:54 UTC (rev 123799)
+++ trunk/Source/WebCore/bindings/scripts/test/TestObj.idl	2012-07-26 22:15:56 UTC (rev 123800)
@@ -41,6 +41,7 @@
 #if defined(TESTING_JS) || defined(TESTING_V8)
         static readonly attribute long     staticReadOnlyLongAttr;
         static attribute DOMString         staticStringAttr;
+        static readonly attribute TestSubObjConstructor TestSubObj;
 #endif
         attribute short                    shortAttr;
         attribute unsigned short           unsignedShortAttr;

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp (123799 => 123800)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-07-26 22:10:54 UTC (rev 123799)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp	2012-07-26 22:15:56 UTC (rev 123800)
@@ -48,6 +48,7 @@
 #include "V8SVGPoint.h"
 #include "V8ScriptProfile.h"
 #include "V8TestCallback.h"
+#include "V8TestSubObj.h"
 #include "V8a.h"
 #include "V8any.h"
 #include "V8b.h"
@@ -1910,6 +1911,8 @@
     {"staticReadOnlyLongAttr", TestObjV8Internal::staticReadOnlyLongAttrAttrGetter, 0, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
     // Attribute 'staticStringAttr' (Type: 'attribute' ExtAttr: '')
     {"staticStringAttr", TestObjV8Internal::staticStringAttrAttrGetter, TestObjV8Internal::staticStringAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
+    // Attribute 'TestSubObj' (Type: 'readonly attribute' ExtAttr: '')
+    {"TestSubObj", TestObjV8Internal::TestObjConstructorGetter, 0, &V8TestSubObj::info, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
     // Attribute 'shortAttr' (Type: 'attribute' ExtAttr: '')
     {"shortAttr", TestObjV8Internal::shortAttrAttrGetter, TestObjV8Internal::shortAttrAttrSetter, 0 /* no data */, static_cast<v8::AccessControl>(v8::DEFAULT), static_cast<v8::PropertyAttribute>(v8::None), 0 /* on instance */},
     // Attribute 'unsignedShortAttr' (Type: 'attribute' ExtAttr: '')
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to