Chromium Code Reviews| Index: Source/bindings/scripts/CodeGeneratorV8.pm |
| diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm |
| index e7e4d64e6237b93a2137140c99435b7ca7930fb0..db8237153975d2addf8297438fccf0766d2c61e5 100644 |
| --- a/Source/bindings/scripts/CodeGeneratorV8.pm |
| +++ b/Source/bindings/scripts/CodeGeneratorV8.pm |
| @@ -188,6 +188,8 @@ my %typedArrayHash = ("ArrayBuffer" => [], |
| "Float64Array" => ["double", "v8::kExternalDoubleArray"], |
| ); |
| +my %callbackFunctionTypeHash = (); |
| + |
| my %enumTypeHash = (); |
| my %svgAnimatedTypeHash = ("SVGAnimatedAngle" => 1, "SVGAnimatedBoolean" => 1, |
| @@ -325,6 +327,7 @@ sub GenerateInterface |
| my $object = shift; |
| my $interface = shift; |
| + %callbackFunctionTypeHash = map { $_->name => $_ } @{$idlDocument->callbackFunctions}; |
| %enumTypeHash = map { $_->name => $_->values } @{$idlDocument->enumerations}; |
| my $v8ClassName = GetV8ClassName($interface); |
| my $defineName = $v8ClassName . "_h"; |
| @@ -415,6 +418,7 @@ sub SkipIncludeHeader |
| return 1 if IsPrimitiveType($type); |
| return 1 if IsEnumType($type); |
| + return 1 if IsCallbackFunctionType($type); |
| return 1 if $type eq "DOMString"; |
| # Special case: SVGPoint.h / SVGNumber.h do not exist. |
| @@ -433,7 +437,7 @@ sub AddIncludesForType |
| AddToImplIncludes("core/dom/EventListener.h"); |
| } elsif ($type eq "SerializedScriptValue") { |
| AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
| - } elsif ($type eq "any") { |
| + } elsif ($type eq "any" || IsCallbackFunctionType($type)) { |
| AddToImplIncludes("bindings/v8/ScriptValue.h"); |
| } else { |
| AddToImplIncludes("V8${type}.h"); |
| @@ -661,20 +665,13 @@ END |
| $header{class}->addHeader("class $v8ClassName {"); |
| $header{class}->addFooter("};"); |
| - my $fromFunctionOpening = ""; |
| - my $fromFunctionClosing = ""; |
| - if ($interface->extendedAttributes->{"WrapAsFunction"}) { |
|
haraken
2013/06/10 09:11:03
Now you can remove [WrapAsFunction] from IDLAttrib
|
| - $fromFunctionOpening = "V8DOMWrapper::fromFunction("; |
| - $fromFunctionClosing = ")"; |
| - } |
| - |
| $header{classPublic}->add(<<END); |
| static bool HasInstance(v8::Handle<v8::Value>, v8::Isolate*, WrapperWorldType); |
| static bool HasInstanceInAnyWorld(v8::Handle<v8::Value>, v8::Isolate*); |
| static v8::Handle<v8::FunctionTemplate> GetTemplate(v8::Isolate*, WrapperWorldType); |
| static ${nativeType}* toNative(v8::Handle<v8::Object> object) |
| { |
| - return reinterpret_cast<${nativeType}*>(${fromFunctionOpening}object${fromFunctionClosing}->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)); |
| + return reinterpret_cast<${nativeType}*>(object->GetAlignedPointerFromInternalField(v8DOMWrapperObjectIndex)); |
| } |
| static void derefObject(void*); |
| static WrapperTypeInfo info; |
| @@ -847,9 +844,6 @@ END |
| } else { |
| my $createWrapperCall = $customWrap ? "${v8ClassName}::wrap" : "${v8ClassName}::createWrapper"; |
| - my $returningWrapper = $interface->extendedAttributes->{"WrapAsFunction"} ? "V8DOMWrapper::toFunction(wrapper)" : "wrapper"; |
| - my $returningCreatedWrapperOpening = $interface->extendedAttributes->{"WrapAsFunction"} ? "V8DOMWrapper::toFunction(" : ""; |
| - my $returningCreatedWrapperClosing = $interface->extendedAttributes->{"WrapAsFunction"} ? ", \"${implClassName}\", isolate)" : ""; |
| if ($customWrap) { |
| $header{nameSpaceWebCore}->add(<<END); |
| @@ -869,7 +863,7 @@ inline v8::Handle<v8::Object> wrap(${nativeType}* impl, v8::Handle<v8::Object> c |
| // the same object de-ref functions, though, so use that as the basis of the check. |
| RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(actualInfo->derefObjectFunction == ${v8ClassName}::info.derefObjectFunction); |
| } |
| - return ${returningCreatedWrapperOpening}$createWrapperCall(impl, creationContext, isolate)${returningCreatedWrapperClosing}; |
| + return $createWrapperCall(impl, creationContext, isolate); |
| } |
| END |
| } |
| @@ -882,7 +876,7 @@ inline v8::Handle<v8::Value> toV8(${nativeType}* impl, v8::Handle<v8::Object> cr |
| return v8NullWithCheck(isolate); |
| v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapper(impl, isolate); |
| if (!wrapper.IsEmpty()) |
| - return $returningWrapper; |
| + return wrapper; |
| return wrap(impl, creationContext, isolate); |
| } |
| @@ -893,7 +887,7 @@ inline v8::Handle<v8::Value> toV8ForMainWorld(${nativeType}* impl, v8::Handle<v8 |
| return v8NullWithCheck(isolate); |
| v8::Handle<v8::Value> wrapper = DOMDataStore::getWrapperForMainWorld(impl); |
| if (!wrapper.IsEmpty()) |
| - return $returningWrapper; |
| + return wrapper; |
| return wrap(impl, creationContext, isolate); |
| } |
| @@ -904,7 +898,7 @@ inline v8::Handle<v8::Value> toV8Fast(${nativeType}* impl, const HolderContainer |
| return v8Null(container.GetIsolate()); |
| v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperFast(impl, container, wrappable); |
| if (!wrapper.IsEmpty()) |
| - return $returningWrapper; |
| + return wrapper; |
| return wrap(impl, container.Holder(), container.GetIsolate()); |
| } |
| @@ -916,7 +910,7 @@ inline v8::Handle<v8::Value> toV8FastForMainWorld(${nativeType}* impl, const Hol |
| return v8Null(container.GetIsolate()); |
| v8::Handle<v8::Object> wrapper = DOMDataStore::getWrapperForMainWorld(impl); |
| if (!wrapper.IsEmpty()) |
| - return $returningWrapper; |
| + return wrapper; |
| return wrap(impl, container.Holder(), container.GetIsolate()); |
| } |
| @@ -4815,7 +4809,7 @@ sub GetNativeType |
| return "Range::CompareHow" if $type eq "CompareHow"; |
| return "DOMTimeStamp" if $type eq "DOMTimeStamp"; |
| return "double" if $type eq "Date"; |
| - return "ScriptValue" if $type eq "any"; |
| + return "ScriptValue" if $type eq "any" or IsCallbackFunctionType($type); |
| return "Dictionary" if $type eq "Dictionary"; |
| return "RefPtr<DOMStringList>" if $type eq "DOMStringList"; |
| @@ -4899,7 +4893,7 @@ sub JSValueToNative |
| return "Dictionary($value, $getIsolate)"; |
| } |
| - if ($type eq "any") { |
| + if ($type eq "any" || IsCallbackFunctionType($type)) { |
| AddToImplIncludes("bindings/v8/ScriptValue.h"); |
| return "ScriptValue($value)"; |
| } |
| @@ -5031,6 +5025,7 @@ sub IsWrapperType |
| my $type = shift; |
| return 0 if GetArrayType($type); |
| return 0 if GetSequenceType($type); |
| + return 0 if IsCallbackFunctionType($type); |
| return 0 if IsEnumType($type); |
| return 0 if IsPrimitiveType($type); |
| return 0 if $type eq "DOMString"; |
| @@ -5456,6 +5451,14 @@ sub IsPrimitiveType |
| return 0; |
| } |
| +sub IsCallbackFunctionType |
| +{ |
| + my $type = shift; |
| + |
| + return 1 if $callbackFunctionTypeHash{$type}; |
| + return 0; |
| +} |
| + |
| sub IsEnumType |
| { |
| my $type = shift; |
| @@ -5498,10 +5501,12 @@ sub IsRefPtrType |
| { |
| my $type = shift; |
| + return 0 if $type eq "any"; |
| return 0 if IsPrimitiveType($type); |
| return 0 if GetArrayType($type); |
| return 0 if GetSequenceType($type); |
| return 0 if $type eq "DOMString"; |
| + return 0 if IsCallbackFunctionType($type); |
| return 0 if IsEnumType($type); |
| return 0 if IsUnionType($type); |