Source/WebCore/ChangeLog

 12011-12-18 Kentaro Hara <haraken@chromium.org>
 2
 3 REGRESSION(r101445): [JSC] Generated code for custom getters and setters
 4 with the [Supplemental] IDL is wrong
 5 https://bugs.webkit.org/show_bug.cgi?id=74837
 6
 7 Reviewed by NOBODY (OOPS!).
 8
 9 In bug 73162, we implemented the [Supplemental] IDL, but the generated code
 10 for custom getters and setters was wrong in JSC. This patch fixes CodeGeneratorJS.pm
 11 so that the result of WebCore/bindings/scripts/test/TestInterface.idl becomes as follows:
 12
 13 Wrong:
 14 JSValue jsTestInterfaceStr3(ExecState* exec, JSValue slotBase, const Identifier&)
 15 {
 16 JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
 17 return JSTestSupplemental::str3(castedThis, exec);
 18 }
 19
 20 Correct:
 21 JSValue jsTestInterfaceStr3(ExecState* exec, JSValue slotBase, const Identifier&)
 22 {
 23 JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
 24 TestInterface* imp = static_cast<TestInterface*>(castedThis->impl());
 25 return castedThis->str3(imp, exec);
 26 }
 27
 28 Tests: bindings/scripts/test/JS/TestInterface.idl
 29
 30 * bindings/scripts/CodeGeneratorJS.pm:
 31 (GenerateHeader):
 32 (GenerateImplementation):
 33 * bindings/scripts/test/JS/JSTestInterface.cpp: Updated run-bindings-tests result.
 34 (WebCore::jsTestInterfaceStr3):
 35 (WebCore::setJSTestInterfaceStr3):
 36 * bindings/scripts/test/JS/JSTestInterface.h: Ditto.
 37
1382011-12-18 Antti Koivisto <antti@apple.com>
239
340 https://bugs.webkit.org/show_bug.cgi?id=73954

Source/WebCore/bindings/scripts/CodeGeneratorJS.pm

@@sub GenerateHeader
875875 foreach (@{$dataNode->attributes}) {
876876 my $attribute = $_;
877877 $numCustomAttributes++ if $attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"};
878  $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) && !$attribute->signature->extendedAttributes->{"ImplementedBy"};
879  $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) && !$attribute->signature->extendedAttributes->{"ImplementedBy"};
 878 $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"});
 879 $numCustomAttributes++ if ($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"});
880880 if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
881881 push(@headerContent, " JSC::WriteBarrier<JSC::Unknown> m_" . $attribute->signature->name . ";\n");
882882 $numCachedAttributes++;

@@sub GenerateHeader
900900 if ($attribute->type !~ /^readonly/) {
901901 push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
902902 }
903  } elsif (($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) && !$attribute->signature->extendedAttributes->{"ImplementedBy"}) {
904  push(@headerContent, " JSC::JSValue " . $codeGenerator->WK_lcfirst($attribute->signature->name) . "(JSC::ExecState*) const;\n");
905  } elsif (($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) && !$attribute->signature->extendedAttributes->{"ImplementedBy"}) {
 903 } elsif (($attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"})) {
 904 my $methodName = $codeGenerator->WK_lcfirst($attribute->signature->name);
 905 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
 906 push(@headerContent, " JSC::JSValue " . $methodName . "(" . $interfaceName . "*, JSC::ExecState*) const;\n");
 907 } else {
 908 push(@headerContent, " JSC::JSValue " . $methodName . "(JSC::ExecState*) const;\n");
 909 }
 910 } elsif (($attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"})) {
906911 if ($attribute->type !~ /^readonly/) {
907  push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
 912 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
 913 push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(" . $interfaceName . "*, JSC::ExecState*, JSC::JSValue);\n");
 914 } else {
 915 push(@headerContent, " void set" . $codeGenerator->WK_ucfirst($attribute->signature->name) . "(JSC::ExecState*, JSC::JSValue);\n");
 916 }
908917 }
909918 }
910919 }

@@sub GenerateImplementation
17161725
17171726 if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomGetter"} || $attribute->signature->extendedAttributes->{"JSCCustomGetter"}) {
17181727 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
1719  my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
1720  $implIncludes{"JS${implementedBy}.h"} = 1;
1721  push(@implContent, " return JS${implementedBy}::$implGetterFunctionName(castedThis, exec);\n");
 1728 push(@implContent, " ${interfaceName}* imp = static_cast<${interfaceName}*>(castedThis->impl());\n");
 1729 push(@implContent, " return castedThis->$implGetterFunctionName(imp, exec);\n");
17221730 } else {
17231731 push(@implContent, " return castedThis->$implGetterFunctionName(exec);\n");
17241732 }

@@sub GenerateImplementation
19051913
19061914 if ($attribute->signature->extendedAttributes->{"Custom"} || $attribute->signature->extendedAttributes->{"JSCCustom"} || $attribute->signature->extendedAttributes->{"CustomSetter"} || $attribute->signature->extendedAttributes->{"JSCCustomSetter"}) {
19071915 if ($attribute->signature->extendedAttributes->{"ImplementedBy"}) {
1908  my $implementedBy = $attribute->signature->extendedAttributes->{"ImplementedBy"};
1909  $implIncludes{"JS${implementedBy}.h"} = 1;
1910  push(@implContent, " JS${implementedBy}::set$implSetterFunctionName(static_cast<$className*>(thisObject), exec, value);\n");
 1916 push(@implContent, " ${className}* castedThis = static_cast<${className}*>(thisObject);\n");
 1917 push(@implContent, " ${interfaceName}* imp = static_cast<${interfaceName}*>(castedThis->impl());\n");
 1918 push(@implContent, " castedThis->set$implSetterFunctionName(imp, exec, value);\n");
19111919 } else {
19121920 push(@implContent, " static_cast<$className*>(thisObject)->set$implSetterFunctionName(exec, value);\n");
19131921 }

Source/WebCore/bindings/scripts/test/JS/JSTestInterface.cpp

2626
2727#include "ExceptionCode.h"
2828#include "JSDOMBinding.h"
29 #include "JSTestSupplemental.h"
3029#include "TestInterface.h"
3130#include "TestSupplemental.h"
3231#include <runtime/Error.h>

@@JSValue jsTestInterfaceStr2(ExecState* exec, JSValue slotBase, const Identifier&
201200JSValue jsTestInterfaceStr3(ExecState* exec, JSValue slotBase, const Identifier&)
202201{
203202 JSTestInterface* castedThis = static_cast<JSTestInterface*>(asObject(slotBase));
204  return JSTestSupplemental::str3(castedThis, exec);
 203 TestInterface* imp = static_cast<TestInterface*>(castedThis->impl());
 204 return castedThis->str3(imp, exec);
205205}
206206
207207#endif

@@void setJSTestInterfaceStr2(ExecState* exec, JSObject* thisObject, JSValue value
232232#if ENABLE(Condition11) || ENABLE(Condition12)
233233void setJSTestInterfaceStr3(ExecState* exec, JSObject* thisObject, JSValue value)
234234{
235  JSTestSupplemental::setStr3(static_cast<JSTestInterface*>(thisObject), exec, value);
 235 JSTestInterface* castedThis = static_cast<JSTestInterface*>(thisObject);
 236 TestInterface* imp = static_cast<TestInterface*>(castedThis->impl());
 237 castedThis->setStr3(imp, exec, value);
236238}
237239
238240#endif

Source/WebCore/bindings/scripts/test/JS/JSTestInterface.h

@@public:
5353 }
5454
5555 static JSC::JSValue getConstructor(JSC::ExecState*, JSC::JSGlobalObject*);
 56
 57 // Custom attributes
 58 JSC::JSValue str3(TestInterface*, JSC::ExecState*) const;
5659 TestInterface* impl() const { return m_impl; }
5760 void releaseImpl() { m_impl->deref(); m_impl = 0; }
5861