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

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

Issue 68893018: Rename es => exceptionState in bindings/ (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/v8_attributes.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 1263
1264 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1264 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1265 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1265 AddToImplIncludes("bindings/v8/ExceptionState.h");
1266 $implementation{nameSpaceInternal}->add(<<END); 1266 $implementation{nameSpaceInternal}->add(<<END);
1267 static void ${implClassName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 1267 static void ${implClassName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
1268 { 1268 {
1269 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 1269 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
1270 if (holder.IsEmpty()) 1270 if (holder.IsEmpty())
1271 return; 1271 return;
1272 ${implClassName}* imp = ${v8ClassName}::toNative(holder); 1272 ${implClassName}* imp = ${v8ClassName}::toNative(holder);
1273 ExceptionState es(info.GetIsolate()); 1273 ExceptionState exceptionState(info.GetIsolate());
1274 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { 1274 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
1275 es.throwIfNeeded(); 1275 exceptionState.throwIfNeeded();
1276 return; 1276 return;
1277 } 1277 }
1278 1278
1279 info.This()->SetHiddenValue(name, jsValue); 1279 info.This()->SetHiddenValue(name, jsValue);
1280 } 1280 }
1281 1281
1282 END 1282 END
1283 } 1283 }
1284 1284
1285 sub GenerateConstructorGetter 1285 sub GenerateConstructorGetter
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1502 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1503 END 1503 END
1504 } 1504 }
1505 } 1505 }
1506 1506
1507 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; 1507 my $raisesException = $attribute->extendedAttributes->{"RaisesException"};
1508 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Getter"); 1508 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Getter");
1509 if ($useExceptions || $attribute->extendedAttributes->{"CheckSecurity"}) { 1509 if ($useExceptions || $attribute->extendedAttributes->{"CheckSecurity"}) {
1510 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 1510 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
1511 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1511 AddToImplIncludes("bindings/v8/ExceptionState.h");
1512 $code .= " ExceptionState es(info.GetIsolate());\n"; 1512 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
1513 } 1513 }
1514 1514
1515 # Generate security checks if necessary 1515 # Generate security checks if necessary
1516 if ($attribute->extendedAttributes->{"CheckSecurity"}) { 1516 if ($attribute->extendedAttributes->{"CheckSecurity"}) {
1517 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1517 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1518 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "(), es)) {\n"; 1518 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "(), exceptionState)) {\n";
1519 $code .= " v8SetReturnValueNull(info);\n"; 1519 $code .= " v8SetReturnValueNull(info);\n";
1520 $code .= " es.throwIfNeeded();\n"; 1520 $code .= " exceptionState.throwIfNeeded();\n";
1521 $code .= " return;\n"; 1521 $code .= " return;\n";
1522 $code .= " }\n"; 1522 $code .= " }\n";
1523 } 1523 }
1524 1524
1525 my $isNullable = $attribute->isNullable; 1525 my $isNullable = $attribute->isNullable;
1526 if ($isNullable) { 1526 if ($isNullable) {
1527 $code .= " bool isNull = false;\n"; 1527 $code .= " bool isNull = false;\n";
1528 } 1528 }
1529 1529
1530 my $returnType = $attribute->type; 1530 my $returnType = $attribute->type;
1531 AddIncludesForType($returnType); 1531 AddIncludesForType($returnType);
1532 1532
1533 my $getterString; 1533 my $getterString;
1534 my ($functionName, @arguments) = GetterExpression($interfaceName, $attribute ); 1534 my ($functionName, @arguments) = GetterExpression($interfaceName, $attribute );
1535 push(@arguments, "isNull") if $isNullable; 1535 push(@arguments, "isNull") if $isNullable;
1536 push(@arguments, "es") if $useExceptions; 1536 push(@arguments, "exceptionState") if $useExceptions;
1537 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 1537 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
1538 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; 1538 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
1539 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ; 1539 my $implementedByImplName = GetImplNameFromImplementedBy($implementedBy) ;
1540 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName)); 1540 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implementedBy ImplName));
1541 unshift(@arguments, "imp") if !$attribute->isStatic; 1541 unshift(@arguments, "imp") if !$attribute->isStatic;
1542 $functionName = "${implementedByImplName}::${functionName}"; 1542 $functionName = "${implementedByImplName}::${functionName}";
1543 } elsif ($attribute->isStatic) { 1543 } elsif ($attribute->isStatic) {
1544 $functionName = "${implClassName}::${functionName}"; 1544 $functionName = "${implClassName}::${functionName}";
1545 } else { 1545 } else {
1546 $functionName = "imp->${functionName}"; 1546 $functionName = "imp->${functionName}";
(...skipping 18 matching lines...) Expand all
1565 1565
1566 if ($isNullable) { 1566 if ($isNullable) {
1567 $code .= " if (isNull) {\n"; 1567 $code .= " if (isNull) {\n";
1568 $code .= " v8SetReturnValueNull(info);\n"; 1568 $code .= " v8SetReturnValueNull(info);\n";
1569 $code .= " return;\n"; 1569 $code .= " return;\n";
1570 $code .= " }\n"; 1570 $code .= " }\n";
1571 } 1571 }
1572 1572
1573 if ($useExceptions) { 1573 if ($useExceptions) {
1574 if ($useExceptions) { 1574 if ($useExceptions) {
1575 $code .= " if (UNLIKELY(es.throwIfNeeded()))\n"; 1575 $code .= " if (UNLIKELY(exceptionState.throwIfNeeded()))\n";
1576 $code .= " return;\n"; 1576 $code .= " return;\n";
1577 } 1577 }
1578 1578
1579 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) { 1579 if (ExtendedAttributeContains($attribute->extendedAttributes->{"Call With"}, "ScriptState")) {
1580 $code .= " if (state.hadException()) {\n"; 1580 $code .= " if (state.hadException()) {\n";
1581 $code .= " throwError(state.exception(), info.GetIsolate( ));\n"; 1581 $code .= " throwError(state.exception(), info.GetIsolate( ));\n";
1582 $code .= " return;\n"; 1582 $code .= " return;\n";
1583 $code .= " }\n"; 1583 $code .= " }\n";
1584 } 1584 }
1585 } 1585 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 1771
1772 my $code = ""; 1772 my $code = "";
1773 $code .= <<END; 1773 $code .= <<END;
1774 static void ${implClassName}ReplaceableAttributeSetter(v8::Local<v8::String> nam e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 1774 static void ${implClassName}ReplaceableAttributeSetter(v8::Local<v8::String> nam e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
1775 { 1775 {
1776 END 1776 END
1777 if ($interface->extendedAttributes->{"CheckSecurity"}) { 1777 if ($interface->extendedAttributes->{"CheckSecurity"}) {
1778 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1778 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1779 $code .= <<END; 1779 $code .= <<END;
1780 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1780 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1781 ExceptionState es(info.GetIsolate()); 1781 ExceptionState exceptionState(info.GetIsolate());
1782 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { 1782 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
1783 es.throwIfNeeded(); 1783 exceptionState.throwIfNeeded();
1784 return; 1784 return;
1785 } 1785 }
1786 END 1786 END
1787 } 1787 }
1788 1788
1789 $code .= <<END; 1789 $code .= <<END;
1790 info.This()->ForceSet(name, jsValue); 1790 info.This()->ForceSet(name, jsValue);
1791 } 1791 }
1792 1792
1793 END 1793 END
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 END 2005 END
2006 $expression = $expression . "->propertyReference()"; 2006 $expression = $expression . "->propertyReference()";
2007 } 2007 }
2008 2008
2009 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; 2009 my $raisesException = $attribute->extendedAttributes->{"RaisesException"};
2010 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Setter"); 2010 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Setter");
2011 2011
2012 if ($useExceptions) { 2012 if ($useExceptions) {
2013 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 2013 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
2014 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2014 AddToImplIncludes("bindings/v8/ExceptionState.h");
2015 $code .= " ExceptionState es(info.GetIsolate());\n"; 2015 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
2016 } 2016 }
2017 2017
2018 if ($attribute->type eq "EventHandler") { 2018 if ($attribute->type eq "EventHandler") {
2019 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; 2019 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
2020 my $implementedByImplName; 2020 my $implementedByImplName;
2021 if ($implementedBy) { 2021 if ($implementedBy) {
2022 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy ); 2022 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy );
2023 } 2023 }
2024 if (!InheritsInterface($interface, "Node")) { 2024 if (!InheritsInterface($interface, "Node")) {
2025 my $attrImplName = GetImplName($attribute); 2025 my $attrImplName = GetImplName($attribute);
(...skipping 18 matching lines...) Expand all
2044 AddToImplIncludes("bindings/v8/V8ErrorHandler.h"); 2044 AddToImplIncludes("bindings/v8/V8ErrorHandler.h");
2045 push(@arguments, "V8EventListenerList::findOrCreateWrapper<V8ErrorHa ndler>(jsValue, true, info.GetIsolate())"); 2045 push(@arguments, "V8EventListenerList::findOrCreateWrapper<V8ErrorHa ndler>(jsValue, true, info.GetIsolate())");
2046 } else { 2046 } else {
2047 push(@arguments, "V8EventListenerList::getEventListener(jsValue, tru e, ListenerFindOrCreate)"); 2047 push(@arguments, "V8EventListenerList::getEventListener(jsValue, tru e, ListenerFindOrCreate)");
2048 } 2048 }
2049 push(@arguments, "isolatedWorldForIsolate(info.GetIsolate())"); 2049 push(@arguments, "isolatedWorldForIsolate(info.GetIsolate())");
2050 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; 2050 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
2051 } else { 2051 } else {
2052 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute); 2052 my ($functionName, @arguments) = SetterExpression($interfaceName, $attri bute);
2053 push(@arguments, $expression); 2053 push(@arguments, $expression);
2054 push(@arguments, "es") if $useExceptions; 2054 push(@arguments, "exceptionState") if $useExceptions;
2055 if ($attribute->extendedAttributes->{"ImplementedBy"}) { 2055 if ($attribute->extendedAttributes->{"ImplementedBy"}) {
2056 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" }; 2056 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy" };
2057 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy); 2057 my $implementedByImplName = GetImplNameFromImplementedBy($implemente dBy);
2058 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName)); 2058 AddToImplIncludes(HeaderFilesForInterface($implementedBy, $implement edByImplName));
2059 unshift(@arguments, "imp") if !$attribute->isStatic; 2059 unshift(@arguments, "imp") if !$attribute->isStatic;
2060 $functionName = "${implementedByImplName}::${functionName}"; 2060 $functionName = "${implementedByImplName}::${functionName}";
2061 } elsif ($attribute->isStatic) { 2061 } elsif ($attribute->isStatic) {
2062 $functionName = "${implClassName}::${functionName}"; 2062 $functionName = "${implClassName}::${functionName}";
2063 } else { 2063 } else {
2064 $functionName = "imp->${functionName}"; 2064 $functionName = "imp->${functionName}";
2065 } 2065 }
2066 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{ "SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1); 2066 my ($arg, $subCode) = GenerateCallWith($attribute->extendedAttributes->{ "SetterCallWith"} || $attribute->extendedAttributes->{"CallWith"}, " ", 1);
2067 $code .= $subCode; 2067 $code .= $subCode;
2068 unshift(@arguments, @$arg); 2068 unshift(@arguments, @$arg);
2069 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n"; 2069 $code .= " ${functionName}(" . join(", ", @arguments) . ");\n";
2070 } 2070 }
2071 2071
2072 if ($useExceptions) { 2072 if ($useExceptions) {
2073 $code .= " es.throwIfNeeded();\n"; 2073 $code .= " exceptionState.throwIfNeeded();\n";
2074 } 2074 }
2075 2075
2076 if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) { 2076 if (ExtendedAttributeContains($attribute->extendedAttributes->{"CallWith"}, "ScriptState")) {
2077 $code .= " if (state.hadException())\n"; 2077 $code .= " if (state.hadException())\n";
2078 $code .= " throwError(state.exception(), info.GetIsolate());\n"; 2078 $code .= " throwError(state.exception(), info.GetIsolate());\n";
2079 } 2079 }
2080 2080
2081 if ($svgNativeType) { 2081 if ($svgNativeType) {
2082 if ($useExceptions) { 2082 if ($useExceptions) {
2083 $code .= " if (!es.hadException())\n"; 2083 $code .= " if (!exceptionState.hadException())\n";
2084 $code .= " wrapper->commitChange();\n"; 2084 $code .= " wrapper->commitChange();\n";
2085 } else { 2085 } else {
2086 $code .= " wrapper->commitChange();\n"; 2086 $code .= " wrapper->commitChange();\n";
2087 } 2087 }
2088 } 2088 }
2089 2089
2090 if ($attrCached) { 2090 if ($attrCached) {
2091 $code .= <<END; 2091 $code .= <<END;
2092 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value. 2092 info.Holder()->DeleteHiddenValue(v8::String::NewSymbol("${attrName}")); // I nvalidate the cached value.
2093 END 2093 END
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
2308 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; 2308 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()";
2309 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove"; 2309 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove";
2310 2310
2311 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2311 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2312 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2312 AddToImplIncludes("bindings/v8/ExceptionState.h");
2313 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); 2313 AddToImplIncludes("bindings/v8/V8EventListenerList.h");
2314 AddToImplIncludes("core/frame/DOMWindow.h"); 2314 AddToImplIncludes("core/frame/DOMWindow.h");
2315 $code .= <<END; 2315 $code .= <<END;
2316 EventTarget* impl = ${v8ClassName}::toNative(info.Holder()); 2316 EventTarget* impl = ${v8ClassName}::toNative(info.Holder());
2317 if (DOMWindow* window = impl->toDOMWindow()) { 2317 if (DOMWindow* window = impl->toDOMWindow()) {
2318 ExceptionState es(info.GetIsolate()); 2318 ExceptionState exceptionState(info.GetIsolate());
2319 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), es)) { 2319 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), exceptio nState)) {
2320 es.throwIfNeeded(); 2320 exceptionState.throwIfNeeded();
2321 return; 2321 return;
2322 } 2322 }
2323 if (!window->document()) 2323 if (!window->document())
2324 return; 2324 return;
2325 } 2325 }
2326 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[ 1], false, ListenerFind${lookupType}); 2326 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[ 1], false, ListenerFind${lookupType});
2327 if (listener) { 2327 if (listener) {
2328 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev entName, info[0]); 2328 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, ev entName, info[0]);
2329 impl->${implName}(eventName, listener${passRefPtrHandling}, info[2]->Boo leanValue()); 2329 impl->${implName}(eventName, listener${passRefPtrHandling}, info[2]->Boo leanValue());
2330 if (!impl->toNode()) 2330 if (!impl->toNode())
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 2375 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
2376 END 2376 END
2377 } 2377 }
2378 2378
2379 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); 2379 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt);
2380 2380
2381 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} || ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extendedAttri butes->{"DoNotCheckSecurity"}); 2381 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} || ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extendedAttri butes->{"DoNotCheckSecurity"});
2382 if ($raisesExceptions) { 2382 if ($raisesExceptions) {
2383 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 2383 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
2384 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2384 AddToImplIncludes("bindings/v8/ExceptionState.h");
2385 $code .= " ExceptionState es(info.GetIsolate());\n"; 2385 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
2386 } 2386 }
2387 2387
2388 # Check domain security if needed 2388 # Check domain security if needed
2389 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende dAttributes->{"DoNotCheckSecurity"}) { 2389 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende dAttributes->{"DoNotCheckSecurity"}) {
2390 # We have not find real use cases yet. 2390 # We have not find real use cases yet.
2391 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2391 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2392 $code .= <<END; 2392 $code .= <<END;
2393 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { 2393 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), exceptionState) ) {
2394 es.throwIfNeeded(); 2394 exceptionState.throwIfNeeded();
2395 return; 2395 return;
2396 } 2396 }
2397 END 2397 END
2398 } 2398 }
2399 2399
2400 if ($function->extendedAttributes->{"CheckSecurity"}) { 2400 if ($function->extendedAttributes->{"CheckSecurity"}) {
2401 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2401 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2402 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(es), es)) {\n"; 2402 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($function) . "(exceptionState), exceptionState)) {\n";
2403 $code .= " v8SetReturnValueNull(info);\n"; 2403 $code .= " v8SetReturnValueNull(info);\n";
2404 $code .= " es.throwIfNeeded();\n"; 2404 $code .= " exceptionState.throwIfNeeded();\n";
2405 $code .= " return;\n"; 2405 $code .= " return;\n";
2406 $code .= " }\n"; 2406 $code .= " }\n";
2407 END 2407 END
2408 } 2408 }
2409 2409
2410 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix); 2410 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix);
2411 $code .= $parameterCheckString; 2411 $code .= $parameterCheckString;
2412 2412
2413 # Build the function call string. 2413 # Build the function call string.
2414 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, %replacements); 2414 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, %replacements);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
2702 { 2702 {
2703 END 2703 END
2704 2704
2705 if ($function->overloadedIndex == 0) { 2705 if ($function->overloadedIndex == 0) {
2706 $code .= GenerateArgumentsCountCheck($function, $interface); 2706 $code .= GenerateArgumentsCountCheck($function, $interface);
2707 } 2707 }
2708 2708
2709 if ($raisesExceptions) { 2709 if ($raisesExceptions) {
2710 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 2710 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
2711 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2711 AddToImplIncludes("bindings/v8/ExceptionState.h");
2712 $code .= " ExceptionState es(info.GetIsolate());\n"; 2712 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
2713 } 2713 }
2714 2714
2715 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] 2715 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...]
2716 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, ""); 2716 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "");
2717 $code .= $parameterCheckString; 2717 $code .= $parameterCheckString;
2718 2718
2719 if ($interface->extendedAttributes->{"ConstructorCallWith"}) { 2719 if ($interface->extendedAttributes->{"ConstructorCallWith"}) {
2720 if ($interface->extendedAttributes->{"ConstructorCallWith"} eq "Executio nContext") { 2720 if ($interface->extendedAttributes->{"ConstructorCallWith"} eq "Executio nContext") {
2721 push(@beforeArgumentList, "context"); 2721 push(@beforeArgumentList, "context");
2722 $code .= "\n"; 2722 $code .= "\n";
2723 $code .= " ExecutionContext* context = getExecutionContext();"; 2723 $code .= " ExecutionContext* context = getExecutionContext();";
2724 } elsif ($interface->extendedAttributes->{"ConstructorCallWith"} eq "Doc ument") { 2724 } elsif ($interface->extendedAttributes->{"ConstructorCallWith"} eq "Doc ument") {
2725 push(@beforeArgumentList, "document"); 2725 push(@beforeArgumentList, "document");
2726 $code .= "\n"; 2726 $code .= "\n";
2727 $code .= " Document& document = *toDocument(getExecutionContext() );"; 2727 $code .= " Document& document = *toDocument(getExecutionContext() );";
2728 } 2728 }
2729 } 2729 }
2730 2730
2731 if ($constructorRaisesException) { 2731 if ($constructorRaisesException) {
2732 push(@afterArgumentList, "es"); 2732 push(@afterArgumentList, "exceptionState");
2733 } 2733 }
2734 2734
2735 my @argumentList; 2735 my @argumentList;
2736 my $index = 0; 2736 my $index = 0;
2737 foreach my $parameter (@{$function->parameters}) { 2737 foreach my $parameter (@{$function->parameters}) {
2738 last if $index eq $paramIndex; 2738 last if $index eq $paramIndex;
2739 if ($replacements{$parameter->name}) { 2739 if ($replacements{$parameter->name}) {
2740 push(@argumentList, $replacements{$parameter->name}); 2740 push(@argumentList, $replacements{$parameter->name});
2741 } else { 2741 } else {
2742 push(@argumentList, $parameter->name); 2742 push(@argumentList, $parameter->name);
2743 } 2743 }
2744 $index++; 2744 $index++;
2745 } 2745 }
2746 2746
2747 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 2747 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
2748 $code .= "\n"; 2748 $code .= "\n";
2749 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n"; 2749 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::create(${arg umentString});\n";
2750 $code .= " v8::Handle<v8::Object> wrapper = info.Holder();\n"; 2750 $code .= " v8::Handle<v8::Object> wrapper = info.Holder();\n";
2751 2751
2752 if ($constructorRaisesException) { 2752 if ($constructorRaisesException) {
2753 $code .= " if (es.throwIfNeeded())\n"; 2753 $code .= " if (exceptionState.throwIfNeeded())\n";
2754 $code .= " return;\n"; 2754 $code .= " return;\n";
2755 } 2755 }
2756 2756
2757 $code .= <<END; 2757 $code .= <<END;
2758 2758
2759 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration: :Dependent); 2759 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperConfiguration: :Dependent);
2760 info.GetReturnValue().Set(wrapper); 2760 info.GetReturnValue().Set(wrapper);
2761 } 2761 }
2762 2762
2763 END 2763 END
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2992 // may end up being the only node in the map and get garbage-collected prema turely. 2992 // may end up being the only node in the map and get garbage-collected prema turely.
2993 toV8(document, info.Holder(), info.GetIsolate()); 2993 toV8(document, info.Holder(), info.GetIsolate());
2994 2994
2995 END 2995 END
2996 2996
2997 $code .= GenerateArgumentsCountCheck($function, $interface); 2997 $code .= GenerateArgumentsCountCheck($function, $interface);
2998 2998
2999 if ($raisesExceptions) { 2999 if ($raisesExceptions) {
3000 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 3000 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
3001 AddToImplIncludes("bindings/v8/ExceptionState.h"); 3001 AddToImplIncludes("bindings/v8/ExceptionState.h");
3002 $code .= " ExceptionState es(info.GetIsolate());\n"; 3002 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
3003 } 3003 }
3004 3004
3005 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface); 3005 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface);
3006 $code .= $parameterCheckString; 3006 $code .= $parameterCheckString;
3007 3007
3008 push(@beforeArgumentList, "*document"); 3008 push(@beforeArgumentList, "*document");
3009 3009
3010 if ($constructorRaisesException) { 3010 if ($constructorRaisesException) {
3011 push(@afterArgumentList, "es"); 3011 push(@afterArgumentList, "exceptionState");
3012 } 3012 }
3013 3013
3014 my @argumentList; 3014 my @argumentList;
3015 my $index = 0; 3015 my $index = 0;
3016 foreach my $parameter (@{$function->parameters}) { 3016 foreach my $parameter (@{$function->parameters}) {
3017 last if $index eq $paramIndex; 3017 last if $index eq $paramIndex;
3018 if ($replacements{$parameter->name}) { 3018 if ($replacements{$parameter->name}) {
3019 push(@argumentList, $replacements{$parameter->name}); 3019 push(@argumentList, $replacements{$parameter->name});
3020 } else { 3020 } else {
3021 push(@argumentList, $parameter->name); 3021 push(@argumentList, $parameter->name);
3022 } 3022 }
3023 $index++; 3023 $index++;
3024 } 3024 }
3025 3025
3026 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList); 3026 my $argumentString = join(", ", @beforeArgumentList, @argumentList, @afterAr gumentList);
3027 $code .= "\n"; 3027 $code .= "\n";
3028 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n"; 3028 $code .= " RefPtr<${implClassName}> impl = ${implClassName}::createForJSC onstructor(${argumentString});\n";
3029 $code .= " v8::Handle<v8::Object> wrapper = info.Holder();\n"; 3029 $code .= " v8::Handle<v8::Object> wrapper = info.Holder();\n";
3030 3030
3031 if ($constructorRaisesException) { 3031 if ($constructorRaisesException) {
3032 $code .= " if (es.throwIfNeeded())\n"; 3032 $code .= " if (exceptionState.throwIfNeeded())\n";
3033 $code .= " return;\n"; 3033 $code .= " return;\n";
3034 } 3034 }
3035 3035
3036 $code .= <<END; 3036 $code .= <<END;
3037 3037
3038 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperCon figuration::Dependent); 3038 V8DOMWrapper::associateObjectWithWrapper<${v8ClassName}>(impl.release(), &${ v8ClassName}Constructor::wrapperTypeInfo, wrapper, info.GetIsolate(), WrapperCon figuration::Dependent);
3039 info.GetReturnValue().Set(wrapper); 3039 info.GetReturnValue().Set(wrapper);
3040 } 3040 }
3041 3041
3042 END 3042 END
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
3496 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); 3496 $nativeValue .= ".release()" if (IsRefPtrType($returnType));
3497 my $isNull = GenerateIsNullExpression($returnType, "element"); 3497 my $isNull = GenerateIsNullExpression($returnType, "element");
3498 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.GetIsolate ()", "info", "collection", "", "return"); 3498 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.GetIsolate ()", "info", "collection", "", "return");
3499 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"}; 3499 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"};
3500 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions); 3500 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions);
3501 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n"; 3501 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n";
3502 $getterCode .= "{\n"; 3502 $getterCode .= "{\n";
3503 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ; 3503 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ;
3504 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n"; 3504 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n";
3505 if ($raisesExceptions) { 3505 if ($raisesExceptions) {
3506 $getterCode .= " ExceptionState es(info.GetIsolate());\n"; 3506 $getterCode .= " ExceptionState exceptionState(info.GetIsolate());\n" ;
3507 } 3507 }
3508 $getterCode .= $methodCallCode . "\n"; 3508 $getterCode .= $methodCallCode . "\n";
3509 if ($raisesExceptions) { 3509 if ($raisesExceptions) {
3510 $getterCode .= " if (es.throwIfNeeded())\n"; 3510 $getterCode .= " if (exceptionState.throwIfNeeded())\n";
3511 $getterCode .= " return;\n"; 3511 $getterCode .= " return;\n";
3512 } 3512 }
3513 if (IsUnionType($returnType)) { 3513 if (IsUnionType($returnType)) {
3514 $getterCode .= "${returnJSValueCode}\n"; 3514 $getterCode .= "${returnJSValueCode}\n";
3515 $getterCode .= " return;\n"; 3515 $getterCode .= " return;\n";
3516 } else { 3516 } else {
3517 $getterCode .= " if (${isNull})\n"; 3517 $getterCode .= " if (${isNull})\n";
3518 $getterCode .= " return;\n"; 3518 $getterCode .= " return;\n";
3519 $getterCode .= $returnJSValueCode . "\n"; 3519 $getterCode .= $returnJSValueCode . "\n";
3520 } 3520 }
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
3596 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"}; 3596 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"};
3597 my $asSetterValue = 0; 3597 my $asSetterValue = 0;
3598 3598
3599 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; 3599 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
3600 $code .= "{\n"; 3600 $code .= "{\n";
3601 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3601 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3602 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "pro pertyValue", " ", "info.GetIsolate()"); 3602 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "pro pertyValue", " ", "info.GetIsolate()");
3603 3603
3604 my $extraArguments = ""; 3604 my $extraArguments = "";
3605 if ($raisesExceptions) { 3605 if ($raisesExceptions) {
3606 $code .= " ExceptionState es(info.GetIsolate());\n"; 3606 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
3607 $extraArguments = ", es"; 3607 $extraArguments = ", exceptionState";
3608 } 3608 }
3609 my @conditions = (); 3609 my @conditions = ();
3610 my @statements = (); 3610 my @statements = ();
3611 if ($treatNullAs && $treatNullAs ne "NullString") { 3611 if ($treatNullAs && $treatNullAs ne "NullString") {
3612 push @conditions, "jsValue->IsNull()"; 3612 push @conditions, "jsValue->IsNull()";
3613 push @statements, "collection->${treatNullAs}(index$extraArguments);"; 3613 push @statements, "collection->${treatNullAs}(index$extraArguments);";
3614 } 3614 }
3615 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3615 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3616 push @conditions, "jsValue->IsUndefined()"; 3616 push @conditions, "jsValue->IsUndefined()";
3617 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;"; 3617 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;";
3618 } 3618 }
3619 push @conditions, ""; 3619 push @conditions, "";
3620 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);"; 3620 push @statements, "collection->${methodName}(index, propertyValue$extraArgum ents);";
3621 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3621 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3622 3622
3623 $code .= " if (!result)\n"; 3623 $code .= " if (!result)\n";
3624 $code .= " return;\n"; 3624 $code .= " return;\n";
3625 if ($raisesExceptions) { 3625 if ($raisesExceptions) {
3626 $code .= " if (es.throwIfNeeded())\n"; 3626 $code .= " if (exceptionState.throwIfNeeded())\n";
3627 $code .= " return;\n"; 3627 $code .= " return;\n";
3628 } 3628 }
3629 $code .= " v8SetReturnValue(info, jsValue);\n"; 3629 $code .= " v8SetReturnValue(info, jsValue);\n";
3630 $code .= "}\n\n"; 3630 $code .= "}\n\n";
3631 $implementation{nameSpaceInternal}->add($code); 3631 $implementation{nameSpaceInternal}->add($code);
3632 } 3632 }
3633 3633
3634 sub GenerateImplementationNamedPropertyAccessors 3634 sub GenerateImplementationNamedPropertyAccessors
3635 { 3635 {
3636 my $interface = shift; 3636 my $interface = shift;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
3805 { 3805 {
3806 my $returnType = shift; # string or UnionType 3806 my $returnType = shift; # string or UnionType
3807 my $returnName = shift; 3807 my $returnName = shift;
3808 my $functionExpression = shift; 3808 my $functionExpression = shift;
3809 my $firstArgument = shift; 3809 my $firstArgument = shift;
3810 my $raisesExceptions = shift; 3810 my $raisesExceptions = shift;
3811 3811
3812 my @arguments = (); 3812 my @arguments = ();
3813 push @arguments, $firstArgument; 3813 push @arguments, $firstArgument;
3814 if ($raisesExceptions) { 3814 if ($raisesExceptions) {
3815 push @arguments, "es"; 3815 push @arguments, "exceptionState";
3816 } 3816 }
3817 3817
3818 if (IsUnionType($returnType)) { 3818 if (IsUnionType($returnType)) {
3819 my $code = ""; 3819 my $code = "";
3820 my @extraArguments = (); 3820 my @extraArguments = ();
3821 for my $i (0..scalar(@{$returnType->unionMemberTypes})-1) { 3821 for my $i (0..scalar(@{$returnType->unionMemberTypes})-1) {
3822 my $unionMemberType = $returnType->unionMemberTypes->[$i]; 3822 my $unionMemberType = $returnType->unionMemberTypes->[$i];
3823 my $nativeType = GetNativeType($unionMemberType); 3823 my $nativeType = GetNativeType($unionMemberType);
3824 my $unionMemberVariable = $returnName . $i; 3824 my $unionMemberVariable = $returnName . $i;
3825 my $unionMemberEnabledVariable = $returnName . $i . "Enabled"; 3825 my $unionMemberEnabledVariable = $returnName . $i . "Enabled";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3861 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3861 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3862 $code .= " return;\n"; 3862 $code .= " return;\n";
3863 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3863 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3864 $code .= " return;\n"; 3864 $code .= " return;\n";
3865 } 3865 }
3866 $code .= "\n"; 3866 $code .= "\n";
3867 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n"; 3867 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n";
3868 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3868 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3869 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3869 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3870 if ($raisesExceptions) { 3870 if ($raisesExceptions) {
3871 $code .= " ExceptionState es(info.GetIsolate());\n"; 3871 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
3872 } 3872 }
3873 $code .= $methodCallCode . "\n"; 3873 $code .= $methodCallCode . "\n";
3874 if ($raisesExceptions) { 3874 if ($raisesExceptions) {
3875 $code .= " if (es.throwIfNeeded())\n"; 3875 $code .= " if (exceptionState.throwIfNeeded())\n";
3876 $code .= " return;\n"; 3876 $code .= " return;\n";
3877 } 3877 }
3878 if (IsUnionType($returnType)) { 3878 if (IsUnionType($returnType)) {
3879 $code .= "${returnJSValueCode}\n"; 3879 $code .= "${returnJSValueCode}\n";
3880 $code .= " return;\n"; 3880 $code .= " return;\n";
3881 } else { 3881 } else {
3882 $code .= " if (${isNull})\n"; 3882 $code .= " if (${isNull})\n";
3883 $code .= " return;\n"; 3883 $code .= " return;\n";
3884 $code .= $returnJSValueCode . "\n"; 3884 $code .= $returnJSValueCode . "\n";
3885 } 3885 }
(...skipping 22 matching lines...) Expand all
3908 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3908 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3909 $code .= " return;\n"; 3909 $code .= " return;\n";
3910 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3910 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3911 $code .= " return;\n"; 3911 $code .= " return;\n";
3912 } 3912 }
3913 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3913 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3914 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "name", "propertyNa me", " ", "info.GetIsolate()"); 3914 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "name", "propertyNa me", " ", "info.GetIsolate()");
3915 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "propert yValue", " ", "info.GetIsolate()"); 3915 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "propert yValue", " ", "info.GetIsolate()");
3916 my $extraArguments = ""; 3916 my $extraArguments = "";
3917 if ($raisesExceptions) { 3917 if ($raisesExceptions) {
3918 $code .= " ExceptionState es(info.GetIsolate());\n"; 3918 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
3919 $extraArguments = ", es"; 3919 $extraArguments = ", exceptionState";
3920 } 3920 }
3921 3921
3922 my @conditions = (); 3922 my @conditions = ();
3923 my @statements = (); 3923 my @statements = ();
3924 if ($treatNullAs && $treatNullAs ne "NullString") { 3924 if ($treatNullAs && $treatNullAs ne "NullString") {
3925 push @conditions, "jsValue->IsNull()"; 3925 push @conditions, "jsValue->IsNull()";
3926 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);"; 3926 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);";
3927 } 3927 }
3928 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3928 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3929 push @conditions, "jsValue->IsUndefined()"; 3929 push @conditions, "jsValue->IsUndefined()";
3930 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);"; 3930 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);";
3931 } 3931 }
3932 push @conditions, ""; 3932 push @conditions, "";
3933 push @statements, "collection->${methodName}(propertyName, propertyValue$ext raArguments);"; 3933 push @statements, "collection->${methodName}(propertyName, propertyValue$ext raArguments);";
3934 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s); 3934 $code .= GenerateIfElseStatement("bool", "result", \@conditions, \@statement s);
3935 3935
3936 $code .= " if (!result)\n"; 3936 $code .= " if (!result)\n";
3937 $code .= " return;\n"; 3937 $code .= " return;\n";
3938 if ($raisesExceptions) { 3938 if ($raisesExceptions) {
3939 $code .= " if (es.throwIfNeeded())\n"; 3939 $code .= " if (exceptionState.throwIfNeeded())\n";
3940 $code .= " return;\n"; 3940 $code .= " return;\n";
3941 } 3941 }
3942 $code .= " v8SetReturnValue(info, jsValue);\n"; 3942 $code .= " v8SetReturnValue(info, jsValue);\n";
3943 $code .= "}\n\n"; 3943 $code .= "}\n\n";
3944 $implementation{nameSpaceInternal}->add($code); 3944 $implementation{nameSpaceInternal}->add($code);
3945 } 3945 }
3946 3946
3947 sub GenerateImplementationIndexedPropertyDeleter 3947 sub GenerateImplementationIndexedPropertyDeleter
3948 { 3948 {
3949 my $interface = shift; 3949 my $interface = shift;
3950 my $indexedDeleterFunction = shift; 3950 my $indexedDeleterFunction = shift;
3951 my $implClassName = GetImplName($interface); 3951 my $implClassName = GetImplName($interface);
3952 my $v8ClassName = GetV8ClassName($interface); 3952 my $v8ClassName = GetV8ClassName($interface);
3953 my $methodName = GetImplName($indexedDeleterFunction); 3953 my $methodName = GetImplName($indexedDeleterFunction);
3954 3954
3955 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"}; 3955 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"};
3956 3956
3957 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n"; 3957 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n";
3958 $code .= "{\n"; 3958 $code .= "{\n";
3959 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3959 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3960 my $extraArguments = ""; 3960 my $extraArguments = "";
3961 if ($raisesExceptions) { 3961 if ($raisesExceptions) {
3962 $code .= " ExceptionState es(info.GetIsolate());\n"; 3962 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
3963 $extraArguments = ", es"; 3963 $extraArguments = ", exceptionState";
3964 } 3964 }
3965 $code .= " bool result = collection->${methodName}(index$extraArguments); \n"; 3965 $code .= " bool result = collection->${methodName}(index$extraArguments); \n";
3966 if ($raisesExceptions) { 3966 if ($raisesExceptions) {
3967 $code .= " if (es.throwIfNeeded())\n"; 3967 $code .= " if (exceptionState.throwIfNeeded())\n";
3968 $code .= " return;\n"; 3968 $code .= " return;\n";
3969 } 3969 }
3970 $code .= " return v8SetReturnValueBool(info, result);\n"; 3970 $code .= " return v8SetReturnValueBool(info, result);\n";
3971 $code .= "}\n\n"; 3971 $code .= "}\n\n";
3972 $implementation{nameSpaceInternal}->add($code); 3972 $implementation{nameSpaceInternal}->add($code);
3973 } 3973 }
3974 3974
3975 sub GenerateImplementationNamedPropertyDeleter 3975 sub GenerateImplementationNamedPropertyDeleter
3976 { 3976 {
3977 my $interface = shift; 3977 my $interface = shift;
3978 my $namedDeleterFunction = shift; 3978 my $namedDeleterFunction = shift;
3979 my $implClassName = GetImplName($interface); 3979 my $implClassName = GetImplName($interface);
3980 my $v8ClassName = GetV8ClassName($interface); 3980 my $v8ClassName = GetV8ClassName($interface);
3981 my $methodName = GetImplName($namedDeleterFunction); 3981 my $methodName = GetImplName($namedDeleterFunction);
3982 3982
3983 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"}; 3983 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"};
3984 3984
3985 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n"; 3985 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n";
3986 $code .= "{\n"; 3986 $code .= "{\n";
3987 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3987 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3988 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3988 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3989 my $extraArguments = ""; 3989 my $extraArguments = "";
3990 if ($raisesExceptions) { 3990 if ($raisesExceptions) {
3991 $code .= " ExceptionState es(info.GetIsolate());\n"; 3991 $code .= " ExceptionState exceptionState(info.GetIsolate());\n";
3992 $extraArguments = ", es"; 3992 $extraArguments = ", exceptionState";
3993 } 3993 }
3994 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n"; 3994 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n";
3995 if ($raisesExceptions) { 3995 if ($raisesExceptions) {
3996 $code .= " if (es.throwIfNeeded())\n"; 3996 $code .= " if (exceptionState.throwIfNeeded())\n";
3997 $code .= " return;\n"; 3997 $code .= " return;\n";
3998 } 3998 }
3999 $code .= " return v8SetReturnValueBool(info, result);\n"; 3999 $code .= " return v8SetReturnValueBool(info, result);\n";
4000 $code .= "}\n\n"; 4000 $code .= "}\n\n";
4001 $implementation{nameSpaceInternal}->add($code); 4001 $implementation{nameSpaceInternal}->add($code);
4002 } 4002 }
4003 4003
4004 sub GenerateImplementationNamedPropertyEnumerator 4004 sub GenerateImplementationNamedPropertyEnumerator
4005 { 4005 {
4006 my $interface = shift; 4006 my $interface = shift;
4007 my $implClassName = GetImplName($interface); 4007 my $implClassName = GetImplName($interface);
4008 my $v8ClassName = GetV8ClassName($interface); 4008 my $v8ClassName = GetV8ClassName($interface);
4009 4009
4010 $implementation{nameSpaceInternal}->add(<<END); 4010 $implementation{nameSpaceInternal}->add(<<END);
4011 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) 4011 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo)
4012 { 4012 {
4013 ExceptionState es(info.GetIsolate()); 4013 ExceptionState exceptionState(info.GetIsolate());
4014 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 4014 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
4015 Vector<String> names; 4015 Vector<String> names;
4016 collection->namedPropertyEnumerator(names, es); 4016 collection->namedPropertyEnumerator(names, exceptionState);
4017 if (es.throwIfNeeded()) 4017 if (exceptionState.throwIfNeeded())
4018 return; 4018 return;
4019 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); 4019 v8::Handle<v8::Array> v8names = v8::Array::New(names.size());
4020 for (size_t i = 0; i < names.size(); ++i) 4020 for (size_t i = 0; i < names.size(); ++i)
4021 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate())); 4021 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate()));
4022 v8SetReturnValue(info, v8names); 4022 v8SetReturnValue(info, v8names);
4023 } 4023 }
4024 4024
4025 END 4025 END
4026 } 4026 }
4027 4027
4028 sub GenerateImplementationNamedPropertyQuery 4028 sub GenerateImplementationNamedPropertyQuery
4029 { 4029 {
4030 my $interface = shift; 4030 my $interface = shift;
4031 my $implClassName = GetImplName($interface); 4031 my $implClassName = GetImplName($interface);
4032 my $v8ClassName = GetV8ClassName($interface); 4032 my $v8ClassName = GetV8ClassName($interface);
4033 4033
4034 $implementation{nameSpaceInternal}->add(<<END); 4034 $implementation{nameSpaceInternal}->add(<<END);
4035 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info) 4035 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info)
4036 { 4036 {
4037 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 4037 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
4038 AtomicString propertyName = toWebCoreAtomicString(name); 4038 AtomicString propertyName = toWebCoreAtomicString(name);
4039 ExceptionState es(info.GetIsolate()); 4039 ExceptionState exceptionState(info.GetIsolate());
4040 bool result = collection->namedPropertyQuery(propertyName, es); 4040 bool result = collection->namedPropertyQuery(propertyName, exceptionState);
4041 if (es.throwIfNeeded()) 4041 if (exceptionState.throwIfNeeded())
4042 return; 4042 return;
4043 if (!result) 4043 if (!result)
4044 return; 4044 return;
4045 v8SetReturnValueInt(info, v8::None); 4045 v8SetReturnValueInt(info, v8::None);
4046 } 4046 }
4047 4047
4048 END 4048 END
4049 } 4049 }
4050 4050
4051 sub GenerateImplementationLegacyCall 4051 sub GenerateImplementationLegacyCall
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after
5145 push @arguments, "$paramName.get()"; 5145 push @arguments, "$paramName.get()";
5146 } elsif ($parameter->isNullable && !IsRefPtrType($parameter->type)) { 5146 } elsif ($parameter->isNullable && !IsRefPtrType($parameter->type)) {
5147 push @arguments, "${paramName}IsNull ? 0 : &$paramName"; 5147 push @arguments, "${paramName}IsNull ? 0 : &$paramName";
5148 } else { 5148 } else {
5149 push @arguments, $paramName; 5149 push @arguments, $paramName;
5150 } 5150 }
5151 $index++; 5151 $index++;
5152 } 5152 }
5153 5153
5154 if ($function->extendedAttributes->{"RaisesException"}) { 5154 if ($function->extendedAttributes->{"RaisesException"}) {
5155 push @arguments, "es"; 5155 push @arguments, "exceptionState";
5156 } 5156 }
5157 5157
5158 my $functionString = "$functionName(" . join(", ", @arguments) . ")"; 5158 my $functionString = "$functionName(" . join(", ", @arguments) . ")";
5159 5159
5160 my $return = "result"; 5160 my $return = "result";
5161 my $returnIsRef = IsRefPtrType($returnType); 5161 my $returnIsRef = IsRefPtrType($returnType);
5162 5162
5163 if ($returnType eq "void") { 5163 if ($returnType eq "void") {
5164 $code .= $indent . "$functionString;\n"; 5164 $code .= $indent . "$functionString;\n";
5165 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) { 5165 } elsif (ExtendedAttributeContains($callWith, "ScriptState") or $function->e xtendedAttributes->{"RaisesException"}) {
5166 $code .= $indent . $nativeReturnType . " result = $functionString;\n"; 5166 $code .= $indent . $nativeReturnType . " result = $functionString;\n";
5167 } else { 5167 } else {
5168 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary 5168 # Can inline the function call into the return statement to avoid overhe ad of using a Ref<> temporary
5169 $return = $functionString; 5169 $return = $functionString;
5170 $returnIsRef = 0; 5170 $returnIsRef = 0;
5171 5171
5172 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) { 5172 if ($interfaceName eq "SVGTransformList" and IsRefPtrType($returnType)) {
5173 $return = "WTF::getPtr(" . $return . ")"; 5173 $return = "WTF::getPtr(" . $return . ")";
5174 } 5174 }
5175 } 5175 }
5176 5176
5177 if ($function->extendedAttributes->{"RaisesException"}) { 5177 if ($function->extendedAttributes->{"RaisesException"}) {
5178 $code .= $indent . "if (es.throwIfNeeded())\n"; 5178 $code .= $indent . "if (exceptionState.throwIfNeeded())\n";
5179 $code .= $indent . " return;\n"; 5179 $code .= $indent . " return;\n";
5180 } 5180 }
5181 5181
5182 if (ExtendedAttributeContains($callWith, "ScriptState")) { 5182 if (ExtendedAttributeContains($callWith, "ScriptState")) {
5183 $code .= $indent . "if (state.hadException()) {\n"; 5183 $code .= $indent . "if (state.hadException()) {\n";
5184 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n"; 5184 $code .= $indent . " v8::Local<v8::Value> exception = state.exception ();\n";
5185 $code .= $indent . " state.clearException();\n"; 5185 $code .= $indent . " state.clearException();\n";
5186 $code .= $indent . " throwError(exception, info.GetIsolate());\n"; 5186 $code .= $indent . " throwError(exception, info.GetIsolate());\n";
5187 $code .= $indent . " return;\n"; 5187 $code .= $indent . " return;\n";
5188 $code .= $indent . "}\n"; 5188 $code .= $indent . "}\n";
(...skipping 1081 matching lines...) Expand 10 before | Expand all | Expand 10 after
6270 my $interface = shift; 6270 my $interface = shift;
6271 6271
6272 return 1 if $interface->extendedAttributes->{"CustomToV8"}; 6272 return 1 if $interface->extendedAttributes->{"CustomToV8"};
6273 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; 6273 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"};
6274 return 1 if InheritsInterface($interface, "Document"); 6274 return 1 if InheritsInterface($interface, "Document");
6275 6275
6276 return 0; 6276 return 0;
6277 } 6277 }
6278 6278
6279 1; 6279 1;
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/unstable/v8_attributes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698