Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 37263002: Unify the GlobalEventHandlers list on the C++ side (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: one list to rule the C++ side Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org> 1 # Copyright (C) 2005, 2006 Nikolas Zimmermann <zimmermann@kde.org>
2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com> 2 # Copyright (C) 2006 Anders Carlsson <andersca@mac.com>
3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com> 3 # Copyright (C) 2006 Samuel Weinig <sam.weinig@gmail.com>
4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org> 4 # Copyright (C) 2006 Alexey Proskuryakov <ap@webkit.org>
5 # Copyright (C) 2006 Apple Computer, Inc. 5 # Copyright (C) 2006 Apple Computer, Inc.
6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc. 6 # Copyright (C) 2007, 2008, 2009, 2012 Google Inc.
7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au> 7 # Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
8 # Copyright (C) Research In Motion Limited 2010. All rights reserved. 8 # Copyright (C) Research In Motion Limited 2010. All rights reserved.
9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 # Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 # Copyright (C) 2012 Ericsson AB. All rights reserved. 10 # Copyright (C) 2012 Ericsson AB. All rights reserved.
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1628 END 1628 END
1629 } else { 1629 } else {
1630 $code .= <<END; 1630 $code .= <<END;
1631 ScriptValue jsValue = $getterString; 1631 ScriptValue jsValue = $getterString;
1632 info.Holder()->SetHiddenValue(propertyName, jsValue.v8Value()); 1632 info.Holder()->SetHiddenValue(propertyName, jsValue.v8Value());
1633 v8SetReturnValue(info, jsValue.v8Value()); 1633 v8SetReturnValue(info, jsValue.v8Value());
1634 END 1634 END
1635 } 1635 }
1636 } elsif ($attribute->type eq "EventHandler") { 1636 } elsif ($attribute->type eq "EventHandler") {
1637 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h"); 1637 AddToImplIncludes("bindings/v8/V8AbstractEventListener.h");
1638 my $getterFunc = ToMethodName($attribute->name);
1639 # FIXME: Pass the main world ID for main-world-only getters. 1638 # FIXME: Pass the main world ID for main-world-only getters.
1640 $code .= " EventListener* jsValue = imp->${getterFunc}(isolatedWorldF orIsolate(info.GetIsolate()));\n"; 1639 my ($functionName, @arguments) = GetterExpression($interfaceName, $attri bute);
1640 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
1641 if ($implementedBy) {
1642 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
1643 $functionName = "${implementedByImplName}::${functionName}";
1644 push(@arguments, "imp");
1645 } else {
1646 $functionName = "imp->${functionName}";
1647 }
1648 push(@arguments, "isolatedWorldForIsolate(info.GetIsolate())");
1649 $code .= " EventListener* jsValue = ${functionName}(" . join(", ", @a rguments) . ");\n";
1641 $code .= " v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8A bstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n"; 1650 $code .= " v8SetReturnValue(info, jsValue ? v8::Handle<v8::Value>(V8A bstractEventListener::cast(jsValue)->getListenerObject(imp->executionContext())) : v8::Handle<v8::Value>(v8::Null(info.GetIsolate())));\n";
1642 } else { 1651 } else {
1643 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info ", "imp", $forMainWorldSuffix, "return"); 1652 my $nativeValue = NativeToJSValue($attribute->type, $attribute->extended Attributes, $expression, " ", "", "info.Holder()", "info.GetIsolate()", "info ", "imp", $forMainWorldSuffix, "return");
1644 $code .= "${nativeValue}\n"; 1653 $code .= "${nativeValue}\n";
1645 } 1654 }
1646 1655
1647 $code .= "}\n"; # end of getter 1656 $code .= "}\n"; # end of getter
1648 $code .= "#endif // ${conditionalString}\n" if $conditionalString; 1657 $code .= "#endif // ${conditionalString}\n" if $conditionalString;
1649 $code .= "\n"; 1658 $code .= "\n";
1650 $implementation{nameSpaceInternal}->add($code); 1659 $implementation{nameSpaceInternal}->add($code);
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 1958
1950 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; 1959 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1951 1960
1952 if ($useExceptions) { 1961 if ($useExceptions) {
1953 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 1962 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
1954 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1963 AddToImplIncludes("bindings/v8/ExceptionState.h");
1955 $code .= " ExceptionState es(info.GetIsolate());\n"; 1964 $code .= " ExceptionState es(info.GetIsolate());\n";
1956 } 1965 }
1957 1966
1958 if ($attribute->type eq "EventHandler") { 1967 if ($attribute->type eq "EventHandler") {
1959 my $implSetterFunctionName = FirstLetterToUpperCase($attrName); 1968 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
1969 my $implementedByImplName;
1970 if ($implementedBy) {
1971 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy );
1972 }
1960 if (!InheritsInterface($interface, "Node")) { 1973 if (!InheritsInterface($interface, "Node")) {
1961 my $attrImplName = GetImplName($attribute); 1974 my $attrImplName = GetImplName($attribute);
1962 $code .= " transferHiddenDependency(info.Holder(), imp->${attrImp lName}(isolatedWorldForIsolate(info.GetIsolate())), jsValue, ${v8ClassName}::eve ntListenerCacheIndex, info.GetIsolate());\n"; 1975 my @arguments;
1976 if ($implementedBy) {
1977 $attrImplName = "${implementedByImplName}::${attrImplName}";
1978 push(@arguments, "imp");
1979 } else {
1980 $attrImplName = "imp->${attrImplName}";
1981 }
1982 push(@arguments, "isolatedWorldForIsolate(info.GetIsolate())");
1983 $code .= " transferHiddenDependency(info.Holder(), ${attrImplName }(" . join(", ", @arguments) . "), jsValue, ${v8ClassName}::eventListenerCacheIn dex, info.GetIsolate());\n";
1984 }
1985 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute);
1986 if ($implementedBy) {
1987 $functionName = "${implementedByImplName}::${functionName}";
1988 push(@arguments, "imp");
1989 } else {
1990 $functionName = "imp->${functionName}";
1963 } 1991 }
1964 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope" ) and $attribute->name eq "onerror") { 1992 if (($interfaceName eq "Window" or $interfaceName eq "WorkerGlobalScope" ) and $attribute->name eq "onerror") {
1965 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); 1993 AddToImplIncludes("bindings/v8/V8ErrorHandler.h");
1966 $code .= " imp->set$implSetterFunctionName(V8EventListenerList::f indOrCreateWrapper<V8ErrorHandler>(jsValue, true, info.GetIsolate()), isolatedWo rldForIsolate(info.GetIsolate()));\n"; 1994 push(@arguments, "V8EventListenerList::findOrCreateWrapper<V8ErrorHa ndler>(jsValue, true, info.GetIsolate())");
1967 } else { 1995 } else {
1968 $code .= " imp->set$implSetterFunctionName(V8EventListenerList::g etEventListener(jsValue, true, ListenerFindOrCreate), isolatedWorldForIsolate(in fo.GetIsolate()));\n"; 1996 push(@arguments, "V8EventListenerList::getEventListener(jsValue, tru e, ListenerFindOrCreate)");
1969 } 1997 }
1998 push(@arguments, "isolatedWorldForIsolate(info.GetIsolate())");
1999 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
1970 } else { 2000 } else {
1971 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute); 2001 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute);
1972 push(@arguments, $expression); 2002 push(@arguments, $expression);
1973 push(@arguments, "es") if $useExceptions; 2003 push(@arguments, "es") if $useExceptions;
1974 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 2004 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1975 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" }; 2005 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" };
1976 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); 2006 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
1977 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); 2007 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName));
1978 unshift(@arguments, "imp") if !$attribute->isStatic; 2008 unshift(@arguments, "imp") if !$attribute->isStatic;
1979 $functionName = "${implementedByImplName}::${functionName}"; 2009 $functionName = "${implementedByImplName}::${functionName}";
(...skipping 4223 matching lines...) Expand 10 before | Expand all | Expand 10 after
6203 my $interface = shift; 6233 my $interface = shift;
6204 6234
6205 return 1 if $interface->extendedAttributes->{"CustomToV8"}; 6235 return 1 if $interface->extendedAttributes->{"CustomToV8"};
6206 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; 6236 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"};
6207 return 1 if InheritsInterface($interface, "Document"); 6237 return 1 if InheritsInterface($interface, "Document");
6208 6238
6209 return 0; 6239 return 0;
6210 } 6240 }
6211 6241
6212 1; 6242 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/tests/idls/TestImplements.idl » ('j') | Source/core/events/EventTarget.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698