diff options
author | Steve Block <steveblock@google.com> | 2011-05-18 13:36:51 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-24 15:38:28 +0100 |
commit | 2fc2651226baac27029e38c9d6ef883fa32084db (patch) | |
tree | e396d4bf89dcce6ed02071be66212495b1df1dec /Source/WebCore/bindings/scripts | |
parent | b3725cedeb43722b3b175aaeff70552e562d2c94 (diff) | |
download | external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2 |
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'Source/WebCore/bindings/scripts')
4 files changed, 45 insertions, 32 deletions
diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm b/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm index 9b3f21e..7d3d613 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorCPP.pm @@ -233,6 +233,7 @@ sub GetCPPType return "int" if $type eq "long"; return "unsigned" if $name eq "unsigned long"; return "unsigned short" if $type eq "CompareHow"; + return "double" if $name eq "Date"; if ($codeGenerator->IsStringType($type)) { if ($useConstReference) { diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm index abef04e..d2309e9 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm @@ -1434,7 +1434,7 @@ sub GenerateImplementation push(@implContent, "{\n"); if ($numCachedAttributes > 0) { push(@implContent, " for (unsigned i = Base::AnonymousSlotCount; i < AnonymousSlotCount; i++)\n"); - push(@implContent, " putAnonymousValue(i, JSValue());\n"); + push(@implContent, " putAnonymousValue(globalObject->globalData(), i, JSValue());\n"); } push(@implContent, "}\n\n"); @@ -1602,7 +1602,7 @@ sub GenerateImplementation } } - push(@implContent, " castedThis->putAnonymousValue(" . $className . "::" . $attribute->signature->name . "Slot, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"}); + push(@implContent, " castedThis->putAnonymousValue(exec->globalData(), " . $className . "::" . $attribute->signature->name . "Slot, result);\n") if ($attribute->signature->extendedAttributes->{"CachedAttribute"}); push(@implContent, " return result;\n"); } else { @@ -1735,13 +1735,13 @@ sub GenerateImplementation } push(@implContent, " // Shadowing a built-in constructor\n"); if ($interfaceName eq "DOMWindow" && $className eq "JSblah") { - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->propertyNames().constructor, value);\n"); + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n"); } else { - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(Identifier(exec, \"$name\"), value);\n"); + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); } } elsif ($attribute->signature->extendedAttributes->{"Replaceable"}) { push(@implContent, " // Shadowing a built-in object\n"); - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(Identifier(exec, \"$name\"), value);\n"); + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); } else { push(@implContent, " $className* castedThis = static_cast<$className*>(thisObject);\n"); push(@implContent, " $implType* imp = static_cast<$implType*>(castedThis->impl());\n"); @@ -1824,9 +1824,9 @@ sub GenerateImplementation push(@implContent, " // Shadowing a built-in constructor\n"); if ($interfaceName eq "DOMWindow") { - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->propertyNames().constructor, value);\n"); + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), exec->propertyNames().constructor, value);\n"); } else { - push(@implContent, " static_cast<$className*>(thisObject)->putDirect(Identifier(exec, \"$name\"), value);\n"); + push(@implContent, " static_cast<$className*>(thisObject)->putDirect(exec->globalData(), Identifier(exec, \"$name\"), value);\n"); } push(@implContent, "}\n"); push(@implContent, "\n"); @@ -2942,11 +2942,11 @@ sub GenerateConstructorDefinition push(@$outputArray, " : DOMConstructorObject(${constructorClassName}::createStructure(globalObject->objectPrototype()), globalObject)\n"); push(@$outputArray, "{\n"); if ($interfaceName eq "DOMWindow") { - push(@$outputArray, " putDirect(exec->propertyNames().prototype, globalObject->prototype(), DontDelete | ReadOnly);\n"); + push(@$outputArray, " putDirect(exec->globalData(), exec->propertyNames().prototype, globalObject->prototype(), DontDelete | ReadOnly);\n"); } else { - push(@$outputArray, " putDirect(exec->propertyNames().prototype, ${protoClassName}::self(exec, globalObject), DontDelete | ReadOnly);\n"); + push(@$outputArray, " putDirect(exec->globalData(), exec->propertyNames().prototype, ${protoClassName}::self(exec, globalObject), DontDelete | ReadOnly);\n"); } - push(@$outputArray, " putDirect(exec->propertyNames().length, jsNumber(${numberOfconstructParameters}), ReadOnly | DontDelete | DontEnum);\n") if $numberOfconstructParameters; + push(@$outputArray, " putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(${numberOfconstructParameters}), ReadOnly | DontDelete | DontEnum);\n") if $numberOfconstructParameters; push(@$outputArray, "}\n\n"); push(@$outputArray, "bool ${constructorClassName}::getOwnPropertySlot(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)\n"); diff --git a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm index 7d36db1..f393230 100644 --- a/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm +++ b/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm @@ -2393,7 +2393,7 @@ END @args = (); foreach my $param (@params) { my $paramName = $param->name; - push(@implContent, " v8::Handle<v8::Value> ${paramName}Handle = toV8(${paramName});\n"); + push(@implContent, " v8::Handle<v8::Value> ${paramName}Handle = " . NativeToJSValue($param, $paramName) . ";\n"); push(@implContent, " if (${paramName}Handle.IsEmpty()) {\n"); push(@implContent, " CRASH();\n"); push(@implContent, " return true;\n"); @@ -2565,6 +2565,7 @@ sub IsActiveDomType return 1 if $type eq "Worker"; return 1 if $type eq "SharedWorker"; return 1 if $type eq "IDBRequest"; + return 1 if $type eq "IDBTransaction"; return 1 if $type eq "FileReader"; return 1 if $type eq "FileWriter"; return 0; @@ -2832,6 +2833,8 @@ sub GetNativeType return "RefPtr<MediaQueryListListener>" if $type eq "MediaQueryListListener"; + return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; + # Default, assume native type is a pointer with same type name as idl type return "${type}*"; } @@ -2885,6 +2888,7 @@ sub JSValueToNative return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "CompareHow"; return "static_cast<SVGPaint::SVGPaintType>($value->ToInt32()->Int32Value())" if $type eq "SVGPaintType"; return "toWebCoreDate($value)" if $type eq "Date"; + return "v8ValueToWebCoreDOMStringList($value)" if $type eq "DOMStringList"; if ($type eq "DOMString" or $type eq "DOMUserData") { return $value; @@ -3086,76 +3090,81 @@ sub IsDOMNodeType } -sub ReturnNativeToJSValue +sub NativeToJSValue { my $signature = shift; my $value = shift; my $indent = shift; my $type = GetTypeFromSignature($signature); - return "return v8Boolean($value)" if $type eq "boolean"; - return "return v8::Handle<v8::Value>()" if $type eq "void"; # equivalent to v8::Undefined() + return "v8Boolean($value)" if $type eq "boolean"; + return "v8::Handle<v8::Value>()" if $type eq "void"; # equivalent to v8::Undefined() # HTML5 says that unsigned reflected attributes should be in the range # [0, 2^31). When a value isn't in this range, a default value (or 0) # should be returned instead. if ($signature->extendedAttributes->{"Reflect"} and ($type eq "unsigned long" or $type eq "unsigned short")) { $value =~ s/getUnsignedIntegralAttribute/getIntegralAttribute/g; - return "return v8::Integer::NewFromUnsigned(std::max(0, " . $value . "))"; + return "v8::Integer::NewFromUnsigned(std::max(0, " . $value . "))"; } # For all the types where we use 'int' as the representation type, # we use Integer::New which has a fast Smi conversion check. my $nativeType = GetNativeType($type); - return "return v8::Integer::New($value)" if $nativeType eq "int"; - return "return v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned"; + return "v8::Integer::New($value)" if $nativeType eq "int"; + return "v8::Integer::NewFromUnsigned($value)" if $nativeType eq "unsigned"; - return "return v8DateOrNull($value)" if $type eq "Date"; + return "v8DateOrNull($value)" if $type eq "Date"; # long long and unsigned long long are not representable in ECMAScript. - return "return v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp"; - return "return v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType"; - return "return $value.v8Value()" if $nativeType eq "ScriptValue"; + return "v8::Number::New(static_cast<double>($value))" if $type eq "long long" or $type eq "unsigned long long" or $type eq "DOMTimeStamp"; + return "v8::Number::New($value)" if $codeGenerator->IsPrimitiveType($type) or $type eq "SVGPaintType"; + return "$value.v8Value()" if $nativeType eq "ScriptValue"; if ($codeGenerator->IsStringType($type)) { my $conv = $signature->extendedAttributes->{"ConvertNullStringTo"}; if (defined $conv) { - return "return v8StringOrNull($value)" if $conv eq "Null"; - return "return v8StringOrUndefined($value)" if $conv eq "Undefined"; - return "return v8StringOrFalse($value)" if $conv eq "False"; + return "v8StringOrNull($value)" if $conv eq "Null"; + return "v8StringOrUndefined($value)" if $conv eq "Undefined"; + return "v8StringOrFalse($value)" if $conv eq "False"; die "Unknown value for ConvertNullStringTo extended attribute"; } $conv = $signature->extendedAttributes->{"ConvertScriptString"}; - return "return v8StringOrNull($value)" if $conv; - return "return v8String($value)"; + return "v8StringOrNull($value)" if $conv; + return "v8String($value)"; } AddIncludesForType($type); # special case for non-DOM node interfaces if (IsDOMNodeType($type)) { - return "return toV8(${value}" . ($signature->extendedAttributes->{"ReturnsNew"} ? ", true)" : ")"); + return "toV8(${value}" . ($signature->extendedAttributes->{"ReturnsNew"} ? ", true)" : ")"); } if ($type eq "EventTarget") { - return "return V8DOMWrapper::convertEventTargetToV8Object($value)"; + return "V8DOMWrapper::convertEventTargetToV8Object($value)"; } if ($type eq "EventListener") { $implIncludes{"V8AbstractEventListener.h"} = 1; - return "return ${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())"; + return "${value} ? v8::Handle<v8::Value>(static_cast<V8AbstractEventListener*>(${value})->getListenerObject(imp->scriptExecutionContext())) : v8::Handle<v8::Value>(v8::Null())"; } if ($type eq "SerializedScriptValue") { $implIncludes{"$type.h"} = 1; - return "return $value->deserialize()"; + return "$value->deserialize()"; } $implIncludes{"wtf/RefCounted.h"} = 1; $implIncludes{"wtf/RefPtr.h"} = 1; $implIncludes{"wtf/GetPtr.h"} = 1; - return "return toV8($value)"; + return "toV8($value)"; +} + +sub ReturnNativeToJSValue +{ + return "return " . NativeToJSValue(@_); } # Internal helper diff --git a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp index 36a5ca2..057302d 100644 --- a/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp +++ b/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp @@ -29,6 +29,9 @@ #include "V8CustomVoidCallback.h" #include "V8DOMString.h" #include "V8Proxy.h" +#include <wtf/GetPtr.h> +#include <wtf/RefCounted.h> +#include <wtf/RefPtr.h> #include <wtf/Assertions.h> @@ -113,7 +116,7 @@ bool V8TestCallback::callbackWithClass2Param(Class2* class2Param, const String& CRASH(); return true; } - v8::Handle<v8::Value> strArgHandle = toV8(strArg); + v8::Handle<v8::Value> strArgHandle = v8String(strArg); if (strArgHandle.IsEmpty()) { CRASH(); return true; |