Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (147479 => 147480)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-04-02 18:42:10 UTC (rev 147479)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2013-04-02 18:54:53 UTC (rev 147480)
@@ -1823,7 +1823,6 @@
my $name = $attribute->signature->name;
my $type = $attribute->signature->type;
my $isNullable = $attribute->signature->isNullable;
- my $isCachedAttribute = $attribute->signature->extendedAttributes->{"CachedAttribute"};
$codeGenerator->AssertNotSequenceType($type);
my $getFunctionName = GetAttributeGetterName($interfaceName, $className, $attribute);
my $implGetterFunctionName = $codeGenerator->WK_lcfirst($name);
@@ -1840,7 +1839,7 @@
push(@implContent, " UNUSED_PARAM(slotBase);\n");
}
- if ($isCachedAttribute) {
+ if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
$needsMarkChildren = 1;
}
@@ -1889,7 +1888,7 @@
push(@implContent, " bool isNull = false;\n") if $isNullable;
my $cacheIndex = 0;
- if ($isCachedAttribute) {
+ if ($attribute->signature->extendedAttributes->{"CachedAttribute"}) {
$cacheIndex = $currentCachedAttribute;
$currentCachedAttribute++;
push(@implContent, " if (JSValue cachedValue = castedThis->m_" . $attribute->signature->name . ".get())\n");
@@ -1897,7 +1896,6 @@
}
my @callWithArgs = GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()");
- my $returnValue = "result";
if ($svgListPropertyType) {
push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "castedThis->impl()->$implGetterFunctionName(" . (join ", ", @callWithArgs) . ")", "castedThis") . ";\n");
@@ -1925,30 +1923,23 @@
unshift(@arguments, @callWithArgs);
+ my $jsType = NativeToJSValue($attribute->signature, 0, $interfaceName, "${functionName}(" . join(", ", @arguments) . ")", "castedThis");
push(@implContent, " $interfaceName* impl = static_cast<$interfaceName*>(castedThis->impl());\n") if !$attribute->isStatic;
+ if ($codeGenerator->IsSVGAnimatedType($type)) {
+ push(@implContent, " RefPtr<$type> obj = $jsType;\n");
+ push(@implContent, " JSValue result = toJS(exec, castedThis->globalObject(), obj.get());\n");
+ } else {
+ push(@implContent, " JSValue result = $jsType;\n");
+ }
+
if ($isNullable) {
- my $nativeType = GetNativeType($type);
- push(@implContent, " $nativeType nativeResult = " . NativeValueToLocal("$functionName(" . join(", ", @arguments) . ")", $nativeType) . ";\n");
push(@implContent, " if (isNull)\n");
push(@implContent, " return jsNull();\n");
- if ($isCachedAttribute) {
- push(@implContent, " JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "nativeResult", "castedThis") . ";\n");
- } else {
- $returnValue = NativeToJSValue($attribute->signature, 0, $interfaceName, "nativeResult", "castedThis");
- }
- } else {
- my $jsType = NativeToJSValue($attribute->signature, 0, $interfaceName, "${functionName}(" . join(", ", @arguments) . ")", "castedThis");
- if ($codeGenerator->IsSVGAnimatedType($type)) {
- push(@implContent, " RefPtr<$type> obj = $jsType;\n");
- push(@implContent, " JSValue result = toJS(exec, castedThis->globalObject(), obj.get());\n");
- } else {
- push(@implContent, " JSValue result = $jsType;\n");
- }
}
}
- push(@implContent, " castedThis->m_" . $attribute->signature->name . ".set(exec->globalData(), castedThis, result);\n") if $isCachedAttribute;
- push(@implContent, " return $returnValue;\n");
+ push(@implContent, " castedThis->m_" . $attribute->signature->name . ".set(exec->globalData(), castedThis, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"});
+ push(@implContent, " return result;\n");
} else {
my @arguments = ("ec");
@@ -1960,14 +1951,13 @@
}
unshift(@arguments, GenerateCallWith($attribute->signature->extendedAttributes->{"CallWith"}, \@implContent, "jsUndefined()"));
- my $nativeType = GetNativeType($type);
if ($svgPropertyOrListPropertyType) {
push(@implContent, " $svgPropertyOrListPropertyType impl(*castedThis->impl());\n");
- push(@implContent, " $nativeType nativeResult = " . NativeValueToLocal("impl.$implGetterFunctionName(" . join(", ", @arguments) . ")", $nativeType) . ";\n");
+ push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "impl.$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
} else {
push(@implContent, " $interfaceName* impl = static_cast<$interfaceName*>(castedThis->impl());\n");
- push(@implContent, " $nativeType nativeResult = " . NativeValueToLocal("impl->$implGetterFunctionName(" . join(", ", @arguments) . ")", $nativeType) . ";\n");
+ push(@implContent, " JSC::JSValue result = " . NativeToJSValue($attribute->signature, 0, $interfaceName, "impl->$implGetterFunctionName(" . join(", ", @arguments) . ")", "castedThis") . ";\n");
}
if ($isNullable) {
@@ -1976,7 +1966,7 @@
}
push(@implContent, " setDOMException(exec, ec);\n");
- push(@implContent, " return " . NativeToJSValue($attribute->signature, 0, $interfaceName, "nativeResult", "castedThis") . ";\n");
+ push(@implContent, " return result;\n");
}
push(@implContent, "}\n\n");
@@ -3207,15 +3197,6 @@
return exists $nativeType{$type};
}
-sub NativeValueToLocal
-{
- my $value = shift;
- my $type = shift;
-
- return "WTF::getPtr($value)" if $type =~ /\*$/;
- return $value;
-}
-
sub JSValueToNative
{
my $signature = shift;
Modified: trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp (147479 => 147480)
--- trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2013-04-02 18:42:10 UTC (rev 147479)
+++ trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp 2013-04-02 18:54:53 UTC (rev 147480)
@@ -657,9 +657,9 @@
JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
ExceptionCode ec = 0;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- int nativeResult = impl->attrWithGetterException(ec);
+ JSC::JSValue result = jsNumber(impl->attrWithGetterException(ec));
setDOMException(exec, ec);
- return jsNumber(nativeResult);
+ return result;
}
@@ -678,9 +678,9 @@
JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
ExceptionCode ec = 0;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- const String& nativeResult = impl->stringAttrWithGetterException(ec);
+ JSC::JSValue result = jsStringWithCache(exec, impl->stringAttrWithGetterException(ec));
setDOMException(exec, ec);
- return jsStringWithCache(exec, nativeResult);
+ return result;
}
@@ -727,9 +727,9 @@
JSTestObj* castedThis = jsCast<JSTestObj*>(asObject(slotBase));
ExceptionCode ec = 0;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- TestObj* nativeResult = WTF::getPtr(impl->withScriptStateAttributeRaises(exec, ec));
+ JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->withScriptStateAttributeRaises(exec, ec)));
setDOMException(exec, ec);
- return toJS(exec, castedThis->globalObject(), WTF::getPtr(nativeResult));
+ return result;
}
@@ -741,9 +741,9 @@
if (!scriptContext)
return jsUndefined();
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- TestObj* nativeResult = WTF::getPtr(impl->withScriptExecutionContextAttributeRaises(scriptContext, ec));
+ JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->withScriptExecutionContextAttributeRaises(scriptContext, ec)));
setDOMException(exec, ec);
- return toJS(exec, castedThis->globalObject(), WTF::getPtr(nativeResult));
+ return result;
}
@@ -767,9 +767,9 @@
if (!scriptContext)
return jsUndefined();
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- TestObj* nativeResult = WTF::getPtr(impl->withScriptExecutionContextAndScriptStateAttributeRaises(exec, scriptContext, ec));
+ JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->withScriptExecutionContextAndScriptStateAttributeRaises(exec, scriptContext, ec)));
setDOMException(exec, ec);
- return toJS(exec, castedThis->globalObject(), WTF::getPtr(nativeResult));
+ return result;
}
@@ -987,10 +987,10 @@
UNUSED_PARAM(exec);
bool isNull = false;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- double nativeResult = impl->nullableDoubleAttribute(isNull);
+ JSValue result = jsNumber(impl->nullableDoubleAttribute(isNull));
if (isNull)
return jsNull();
- return jsNumber(nativeResult);
+ return result;
}
@@ -1000,10 +1000,10 @@
UNUSED_PARAM(exec);
bool isNull = false;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- int nativeResult = impl->nullableLongAttribute(isNull);
+ JSValue result = jsNumber(impl->nullableLongAttribute(isNull));
if (isNull)
return jsNull();
- return jsNumber(nativeResult);
+ return result;
}
@@ -1013,10 +1013,10 @@
UNUSED_PARAM(exec);
bool isNull = false;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- bool nativeResult = impl->nullableBooleanAttribute(isNull);
+ JSValue result = jsBoolean(impl->nullableBooleanAttribute(isNull));
if (isNull)
return jsNull();
- return jsBoolean(nativeResult);
+ return result;
}
@@ -1026,10 +1026,10 @@
UNUSED_PARAM(exec);
bool isNull = false;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- const String& nativeResult = impl->nullableStringAttribute(isNull);
+ JSValue result = jsStringWithCache(exec, impl->nullableStringAttribute(isNull));
if (isNull)
return jsNull();
- return jsStringWithCache(exec, nativeResult);
+ return result;
}
@@ -1039,10 +1039,10 @@
UNUSED_PARAM(exec);
bool isNull = false;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- int nativeResult = impl->nullableLongSettableAttribute(isNull);
+ JSValue result = jsNumber(impl->nullableLongSettableAttribute(isNull));
if (isNull)
return jsNull();
- return jsNumber(nativeResult);
+ return result;
}
@@ -1052,11 +1052,11 @@
ExceptionCode ec = 0;
bool isNull = false;
TestObj* impl = static_cast<TestObj*>(castedThis->impl());
- int nativeResult = impl->nullableStringValue(isNull, ec);
+ JSC::JSValue result = jsNumber(impl->nullableStringValue(isNull, ec));
if (isNull)
return jsNull();
setDOMException(exec, ec);
- return jsNumber(nativeResult);
+ return result;
}