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

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

Issue 68563003: Create DOM exceptions in the correct context. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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
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 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1250
1251 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1251 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1252 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1252 AddToImplIncludes("bindings/v8/ExceptionState.h");
1253 $implementation{nameSpaceInternal}->add(<<END); 1253 $implementation{nameSpaceInternal}->add(<<END);
1254 static void ${implClassName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 1254 static void ${implClassName}DomainSafeFunctionSetter(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
1255 { 1255 {
1256 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate()))); 1256 v8::Handle<v8::Object> holder = info.This()->FindInstanceInPrototypeChain(${ v8ClassName}::GetTemplate(info.GetIsolate(), worldType(info.GetIsolate())));
1257 if (holder.IsEmpty()) 1257 if (holder.IsEmpty())
1258 return; 1258 return;
1259 ${implClassName}* imp = ${v8ClassName}::toNative(holder); 1259 ${implClassName}* imp = ${v8ClassName}::toNative(holder);
1260 ExceptionState es(info.GetIsolate()); 1260 ExceptionState es(info.Holder(), info.GetIsolate());
1261 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { 1261 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) {
1262 es.throwIfNeeded(); 1262 es.throwIfNeeded();
1263 return; 1263 return;
1264 } 1264 }
1265 1265
1266 info.This()->SetHiddenValue(name, jsValue); 1266 info.This()->SetHiddenValue(name, jsValue);
1267 } 1267 }
1268 1268
1269 END 1269 END
1270 } 1270 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
1488 $code .= <<END; 1488 $code .= <<END;
1489 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1489 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1490 END 1490 END
1491 } 1491 }
1492 } 1492 }
1493 1493
1494 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; 1494 my $useExceptions = 1 if $attribute->extendedAttributes->{"GetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1495 if ($useExceptions || $attribute->extendedAttributes->{"CheckSecurityForNode "}) { 1495 if ($useExceptions || $attribute->extendedAttributes->{"CheckSecurityForNode "}) {
1496 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 1496 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
1497 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1497 AddToImplIncludes("bindings/v8/ExceptionState.h");
1498 $code .= " ExceptionState es(info.GetIsolate());\n"; 1498 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
1499 } 1499 }
1500 1500
1501 # Generate security checks if necessary 1501 # Generate security checks if necessary
1502 if ($attribute->extendedAttributes->{"CheckSecurityForNode"}) { 1502 if ($attribute->extendedAttributes->{"CheckSecurityForNode"}) {
1503 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1503 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1504 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "(), es)) {\n"; 1504 $code .= " if (!BindingSecurity::shouldAllowAccessToNode(imp->" . Get ImplName($attribute) . "(), es)) {\n";
1505 $code .= " v8SetReturnValueNull(info);\n"; 1505 $code .= " v8SetReturnValueNull(info);\n";
1506 $code .= " es.throwIfNeeded();\n"; 1506 $code .= " es.throwIfNeeded();\n";
1507 $code .= " return;\n"; 1507 $code .= " return;\n";
1508 $code .= " }\n"; 1508 $code .= " }\n";
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 1757
1758 my $code = ""; 1758 my $code = "";
1759 $code .= <<END; 1759 $code .= <<END;
1760 static void ${implClassName}ReplaceableAttributeSetter(v8::Local<v8::String> nam e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info) 1760 static void ${implClassName}ReplaceableAttributeSetter(v8::Local<v8::String> nam e, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
1761 { 1761 {
1762 END 1762 END
1763 if ($interface->extendedAttributes->{"CheckSecurity"}) { 1763 if ($interface->extendedAttributes->{"CheckSecurity"}) {
1764 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 1764 AddToImplIncludes("bindings/v8/BindingSecurity.h");
1765 $code .= <<END; 1765 $code .= <<END;
1766 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 1766 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
1767 ExceptionState es(info.GetIsolate()); 1767 ExceptionState es(info.Holder(), info.GetIsolate());
1768 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { 1768 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) {
1769 es.throwIfNeeded(); 1769 es.throwIfNeeded();
1770 return; 1770 return;
1771 } 1771 }
1772 END 1772 END
1773 } 1773 }
1774 1774
1775 $code .= <<END; 1775 $code .= <<END;
1776 info.This()->ForceSet(name, jsValue); 1776 info.This()->ForceSet(name, jsValue);
1777 } 1777 }
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 } 1990 }
1991 END 1991 END
1992 $expression = $expression . "->propertyReference()"; 1992 $expression = $expression . "->propertyReference()";
1993 } 1993 }
1994 1994
1995 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"}; 1995 my $useExceptions = 1 if $attribute->extendedAttributes->{"SetterRaisesExcep tion"} || $attribute->extendedAttributes->{"RaisesException"};
1996 1996
1997 if ($useExceptions) { 1997 if ($useExceptions) {
1998 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 1998 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
1999 AddToImplIncludes("bindings/v8/ExceptionState.h"); 1999 AddToImplIncludes("bindings/v8/ExceptionState.h");
2000 $code .= " ExceptionState es(info.GetIsolate());\n"; 2000 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
2001 } 2001 }
2002 2002
2003 if ($attribute->type eq "EventHandler") { 2003 if ($attribute->type eq "EventHandler") {
2004 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"}; 2004 my $implementedBy = $attribute->extendedAttributes->{"ImplementedBy"};
2005 my $implementedByImplName; 2005 my $implementedByImplName;
2006 if ($implementedBy) { 2006 if ($implementedBy) {
2007 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy ); 2007 $implementedByImplName = GetImplNameFromImplementedBy($implementedBy );
2008 } 2008 }
2009 if (!InheritsInterface($interface, "Node")) { 2009 if (!InheritsInterface($interface, "Node")) {
2010 my $attrImplName = GetImplName($attribute); 2010 my $attrImplName = GetImplName($attribute);
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; 2293 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()";
2294 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove"; 2294 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove";
2295 2295
2296 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2296 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2297 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2297 AddToImplIncludes("bindings/v8/ExceptionState.h");
2298 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); 2298 AddToImplIncludes("bindings/v8/V8EventListenerList.h");
2299 AddToImplIncludes("core/frame/DOMWindow.h"); 2299 AddToImplIncludes("core/frame/DOMWindow.h");
2300 $code .= <<END; 2300 $code .= <<END;
2301 EventTarget* impl = ${v8ClassName}::toNative(info.Holder()); 2301 EventTarget* impl = ${v8ClassName}::toNative(info.Holder());
2302 if (DOMWindow* window = impl->toDOMWindow()) { 2302 if (DOMWindow* window = impl->toDOMWindow()) {
2303 ExceptionState es(info.GetIsolate()); 2303 ExceptionState es(info.Holder(), info.GetIsolate());
2304 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), es)) { 2304 if (!BindingSecurity::shouldAllowAccessToFrame(window->frame(), es)) {
2305 es.throwIfNeeded(); 2305 es.throwIfNeeded();
2306 return; 2306 return;
2307 } 2307 }
2308 2308
2309 if (!window->document()) 2309 if (!window->document())
2310 return; 2310 return;
2311 } 2311 }
2312 2312
2313 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[ 1], false, ListenerFind${lookupType}); 2313 RefPtr<EventListener> listener = V8EventListenerList::getEventListener(info[ 1], false, ListenerFind${lookupType});
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2362 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder()); 2362 ${implClassName}* imp = ${v8ClassName}::toNative(info.Holder());
2363 END 2363 END
2364 } 2364 }
2365 2365
2366 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt); 2366 $code .= GenerateCustomElementInvocationScopeIfNeeded($funcExt);
2367 2367
2368 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} || ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extendedAttri butes->{"DoNotCheckSecurity"}); 2368 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} || ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extendedAttri butes->{"DoNotCheckSecurity"});
2369 if ($raisesExceptions) { 2369 if ($raisesExceptions) {
2370 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 2370 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
2371 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2371 AddToImplIncludes("bindings/v8/ExceptionState.h");
2372 $code .= " ExceptionState es(info.GetIsolate());\n"; 2372 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
2373 } 2373 }
2374 2374
2375 # Check domain security if needed 2375 # Check domain security if needed
2376 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende dAttributes->{"DoNotCheckSecurity"}) { 2376 if ($interface->extendedAttributes->{"CheckSecurity"} && !$function->extende dAttributes->{"DoNotCheckSecurity"}) {
2377 # We have not find real use cases yet. 2377 # We have not find real use cases yet.
2378 AddToImplIncludes("bindings/v8/BindingSecurity.h"); 2378 AddToImplIncludes("bindings/v8/BindingSecurity.h");
2379 $code .= <<END; 2379 $code .= <<END;
2380 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) { 2380 if (!BindingSecurity::shouldAllowAccessToFrame(imp->frame(), es)) {
2381 es.throwIfNeeded(); 2381 es.throwIfNeeded();
2382 return; 2382 return;
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2691 { 2691 {
2692 END 2692 END
2693 2693
2694 if ($function->overloadedIndex == 0) { 2694 if ($function->overloadedIndex == 0) {
2695 $code .= GenerateArgumentsCountCheck($function, $interface); 2695 $code .= GenerateArgumentsCountCheck($function, $interface);
2696 } 2696 }
2697 2697
2698 if ($raisesExceptions) { 2698 if ($raisesExceptions) {
2699 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 2699 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
2700 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2700 AddToImplIncludes("bindings/v8/ExceptionState.h");
2701 $code .= " ExceptionState es(info.GetIsolate());\n"; 2701 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
2702 } 2702 }
2703 2703
2704 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] 2704 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...]
2705 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, ""); 2705 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "");
2706 $code .= $parameterCheckString; 2706 $code .= $parameterCheckString;
2707 2707
2708 if ($interface->extendedAttributes->{"ConstructorCallWith"}) { 2708 if ($interface->extendedAttributes->{"ConstructorCallWith"}) {
2709 if ($interface->extendedAttributes->{"ConstructorCallWith"} eq "Executio nContext") { 2709 if ($interface->extendedAttributes->{"ConstructorCallWith"} eq "Executio nContext") {
2710 push(@beforeArgumentList, "context"); 2710 push(@beforeArgumentList, "context");
2711 $code .= "\n"; 2711 $code .= "\n";
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2983 // may end up being the only node in the map and get garbage-collected prema turely. 2983 // may end up being the only node in the map and get garbage-collected prema turely.
2984 toV8(document, info.Holder(), info.GetIsolate()); 2984 toV8(document, info.Holder(), info.GetIsolate());
2985 2985
2986 END 2986 END
2987 2987
2988 $code .= GenerateArgumentsCountCheck($function, $interface); 2988 $code .= GenerateArgumentsCountCheck($function, $interface);
2989 2989
2990 if ($raisesExceptions) { 2990 if ($raisesExceptions) {
2991 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); 2991 AddToImplIncludes("bindings/v8/ExceptionMessages.h");
2992 AddToImplIncludes("bindings/v8/ExceptionState.h"); 2992 AddToImplIncludes("bindings/v8/ExceptionState.h");
2993 $code .= " ExceptionState es(info.GetIsolate());\n"; 2993 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
2994 } 2994 }
2995 2995
2996 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface); 2996 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface);
2997 $code .= $parameterCheckString; 2997 $code .= $parameterCheckString;
2998 2998
2999 push(@beforeArgumentList, "*document"); 2999 push(@beforeArgumentList, "*document");
3000 3000
3001 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) { 3001 if ($interface->extendedAttributes->{"ConstructorRaisesException"}) {
3002 push(@afterArgumentList, "es"); 3002 push(@afterArgumentList, "es");
3003 } 3003 }
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
3485 $nativeValue .= ".release()" if (IsRefPtrType($returnType)); 3485 $nativeValue .= ".release()" if (IsRefPtrType($returnType));
3486 my $isNull = GenerateIsNullExpression($returnType, "element"); 3486 my $isNull = GenerateIsNullExpression($returnType, "element");
3487 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.GetIsolate ()", "info", "collection", "", "return"); 3487 my $returnJSValueCode = NativeToJSValue($indexedGetterFunction->type, $index edGetterFunction->extendedAttributes, $nativeValue, " ", "", "info.GetIsolate ()", "info", "collection", "", "return");
3488 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"}; 3488 my $raisesExceptions = $indexedGetterFunction->extendedAttributes->{"RaisesE xception"};
3489 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions); 3489 my $methodCallCode = GenerateMethodCall($returnType, "element", "collection- >${methodName}", "index", $raisesExceptions);
3490 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n"; 3490 my $getterCode = "static void indexedPropertyGetter(uint32_t index, const v8 ::PropertyCallbackInfo<v8::Value>& info)\n";
3491 $getterCode .= "{\n"; 3491 $getterCode .= "{\n";
3492 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ; 3492 $getterCode .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n" ;
3493 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n"; 3493 $getterCode .= " ${implClassName}* collection = ${v8ClassName}::toNative( info.Holder());\n";
3494 if ($raisesExceptions) { 3494 if ($raisesExceptions) {
3495 $getterCode .= " ExceptionState es(info.GetIsolate());\n"; 3495 $getterCode .= " ExceptionState es(info.Holder(), info.GetIsolate()); \n";
3496 } 3496 }
3497 $getterCode .= $methodCallCode . "\n"; 3497 $getterCode .= $methodCallCode . "\n";
3498 if ($raisesExceptions) { 3498 if ($raisesExceptions) {
3499 $getterCode .= " if (es.throwIfNeeded())\n"; 3499 $getterCode .= " if (es.throwIfNeeded())\n";
3500 $getterCode .= " return;\n"; 3500 $getterCode .= " return;\n";
3501 } 3501 }
3502 if (IsUnionType($returnType)) { 3502 if (IsUnionType($returnType)) {
3503 $getterCode .= "${returnJSValueCode}\n"; 3503 $getterCode .= "${returnJSValueCode}\n";
3504 $getterCode .= " return;\n"; 3504 $getterCode .= " return;\n";
3505 } else { 3505 } else {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3585 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"}; 3585 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"};
3586 my $asSetterValue = 0; 3586 my $asSetterValue = 0;
3587 3587
3588 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; 3588 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
3589 $code .= "{\n"; 3589 $code .= "{\n";
3590 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3590 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3591 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "pro pertyValue", " ", "info.GetIsolate()"); 3591 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "pro pertyValue", " ", "info.GetIsolate()");
3592 3592
3593 my $extraArguments = ""; 3593 my $extraArguments = "";
3594 if ($raisesExceptions) { 3594 if ($raisesExceptions) {
3595 $code .= " ExceptionState es(info.GetIsolate());\n"; 3595 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
3596 $extraArguments = ", es"; 3596 $extraArguments = ", es";
3597 } 3597 }
3598 my @conditions = (); 3598 my @conditions = ();
3599 my @statements = (); 3599 my @statements = ();
3600 if ($treatNullAs && $treatNullAs ne "NullString") { 3600 if ($treatNullAs && $treatNullAs ne "NullString") {
3601 push @conditions, "jsValue->IsNull()"; 3601 push @conditions, "jsValue->IsNull()";
3602 push @statements, "collection->${treatNullAs}(index$extraArguments);"; 3602 push @statements, "collection->${treatNullAs}(index$extraArguments);";
3603 } 3603 }
3604 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3604 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
3605 push @conditions, "jsValue->IsUndefined()"; 3605 push @conditions, "jsValue->IsUndefined()";
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
3850 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3850 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3851 $code .= " return;\n"; 3851 $code .= " return;\n";
3852 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3852 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3853 $code .= " return;\n"; 3853 $code .= " return;\n";
3854 } 3854 }
3855 $code .= "\n"; 3855 $code .= "\n";
3856 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n"; 3856 $code .= " ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));\n";
3857 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3857 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3858 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3858 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3859 if ($raisesExceptions) { 3859 if ($raisesExceptions) {
3860 $code .= " ExceptionState es(info.GetIsolate());\n"; 3860 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
3861 } 3861 }
3862 $code .= $methodCallCode . "\n"; 3862 $code .= $methodCallCode . "\n";
3863 if ($raisesExceptions) { 3863 if ($raisesExceptions) {
3864 $code .= " if (es.throwIfNeeded())\n"; 3864 $code .= " if (es.throwIfNeeded())\n";
3865 $code .= " return;\n"; 3865 $code .= " return;\n";
3866 } 3866 }
3867 if (IsUnionType($returnType)) { 3867 if (IsUnionType($returnType)) {
3868 $code .= "${returnJSValueCode}\n"; 3868 $code .= "${returnJSValueCode}\n";
3869 $code .= " return;\n"; 3869 $code .= " return;\n";
3870 } else { 3870 } else {
(...skipping 26 matching lines...) Expand all
3897 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; 3897 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
3898 $code .= " return;\n"; 3898 $code .= " return;\n";
3899 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; 3899 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n";
3900 $code .= " return;\n"; 3900 $code .= " return;\n";
3901 } 3901 }
3902 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3902 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3903 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "name", "propertyNa me", " ", "info.GetIsolate()"); 3903 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "name", "propertyNa me", " ", "info.GetIsolate()");
3904 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "propert yValue", " ", "info.GetIsolate()"); 3904 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "propert yValue", " ", "info.GetIsolate()");
3905 my $extraArguments = ""; 3905 my $extraArguments = "";
3906 if ($raisesExceptions) { 3906 if ($raisesExceptions) {
3907 $code .= " ExceptionState es(info.GetIsolate());\n"; 3907 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
3908 $extraArguments = ", es"; 3908 $extraArguments = ", es";
3909 } 3909 }
3910 3910
3911 my @conditions = (); 3911 my @conditions = ();
3912 my @statements = (); 3912 my @statements = ();
3913 if ($treatNullAs && $treatNullAs ne "NullString") { 3913 if ($treatNullAs && $treatNullAs ne "NullString") {
3914 push @conditions, "jsValue->IsNull()"; 3914 push @conditions, "jsValue->IsNull()";
3915 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);"; 3915 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);";
3916 } 3916 }
3917 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { 3917 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") {
(...skipping 23 matching lines...) Expand all
3941 my $v8ClassName = GetV8ClassName($interface); 3941 my $v8ClassName = GetV8ClassName($interface);
3942 my $methodName = GetImplName($indexedDeleterFunction); 3942 my $methodName = GetImplName($indexedDeleterFunction);
3943 3943
3944 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"}; 3944 my $raisesExceptions = $indexedDeleterFunction->extendedAttributes->{"Raises Exception"};
3945 3945
3946 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n"; 3946 my $code = "static void indexedPropertyDeleter(unsigned index, const v8::Pro pertyCallbackInfo<v8::Boolean>& info)\n";
3947 $code .= "{\n"; 3947 $code .= "{\n";
3948 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3948 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3949 my $extraArguments = ""; 3949 my $extraArguments = "";
3950 if ($raisesExceptions) { 3950 if ($raisesExceptions) {
3951 $code .= " ExceptionState es(info.GetIsolate());\n"; 3951 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
3952 $extraArguments = ", es"; 3952 $extraArguments = ", es";
3953 } 3953 }
3954 $code .= " bool result = collection->${methodName}(index$extraArguments); \n"; 3954 $code .= " bool result = collection->${methodName}(index$extraArguments); \n";
3955 if ($raisesExceptions) { 3955 if ($raisesExceptions) {
3956 $code .= " if (es.throwIfNeeded())\n"; 3956 $code .= " if (es.throwIfNeeded())\n";
3957 $code .= " return;\n"; 3957 $code .= " return;\n";
3958 } 3958 }
3959 $code .= " return v8SetReturnValueBool(info, result);\n"; 3959 $code .= " return v8SetReturnValueBool(info, result);\n";
3960 $code .= "}\n\n"; 3960 $code .= "}\n\n";
3961 $implementation{nameSpaceInternal}->add($code); 3961 $implementation{nameSpaceInternal}->add($code);
3962 } 3962 }
3963 3963
3964 sub GenerateImplementationNamedPropertyDeleter 3964 sub GenerateImplementationNamedPropertyDeleter
3965 { 3965 {
3966 my $interface = shift; 3966 my $interface = shift;
3967 my $namedDeleterFunction = shift; 3967 my $namedDeleterFunction = shift;
3968 my $implClassName = GetImplName($interface); 3968 my $implClassName = GetImplName($interface);
3969 my $v8ClassName = GetV8ClassName($interface); 3969 my $v8ClassName = GetV8ClassName($interface);
3970 my $methodName = GetImplName($namedDeleterFunction); 3970 my $methodName = GetImplName($namedDeleterFunction);
3971 3971
3972 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"}; 3972 my $raisesExceptions = $namedDeleterFunction->extendedAttributes->{"RaisesEx ception"};
3973 3973
3974 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n"; 3974 my $code = "static void namedPropertyDeleter(v8::Local<v8::String> name, con st v8::PropertyCallbackInfo<v8::Boolean>& info)\n";
3975 $code .= "{\n"; 3975 $code .= "{\n";
3976 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; 3976 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n";
3977 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n"; 3977 $code .= " AtomicString propertyName = toWebCoreAtomicString(name);\n";
3978 my $extraArguments = ""; 3978 my $extraArguments = "";
3979 if ($raisesExceptions) { 3979 if ($raisesExceptions) {
3980 $code .= " ExceptionState es(info.GetIsolate());\n"; 3980 $code .= " ExceptionState es(info.Holder(), info.GetIsolate());\n";
3981 $extraArguments = ", es"; 3981 $extraArguments = ", es";
3982 } 3982 }
3983 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n"; 3983 $code .= " bool result = collection->${methodName}(propertyName$extraArgu ments);\n";
3984 if ($raisesExceptions) { 3984 if ($raisesExceptions) {
3985 $code .= " if (es.throwIfNeeded())\n"; 3985 $code .= " if (es.throwIfNeeded())\n";
3986 $code .= " return;\n"; 3986 $code .= " return;\n";
3987 } 3987 }
3988 $code .= " return v8SetReturnValueBool(info, result);\n"; 3988 $code .= " return v8SetReturnValueBool(info, result);\n";
3989 $code .= "}\n\n"; 3989 $code .= "}\n\n";
3990 $implementation{nameSpaceInternal}->add($code); 3990 $implementation{nameSpaceInternal}->add($code);
3991 } 3991 }
3992 3992
3993 sub GenerateImplementationNamedPropertyEnumerator 3993 sub GenerateImplementationNamedPropertyEnumerator
3994 { 3994 {
3995 my $interface = shift; 3995 my $interface = shift;
3996 my $implClassName = GetImplName($interface); 3996 my $implClassName = GetImplName($interface);
3997 my $v8ClassName = GetV8ClassName($interface); 3997 my $v8ClassName = GetV8ClassName($interface);
3998 3998
3999 $implementation{nameSpaceInternal}->add(<<END); 3999 $implementation{nameSpaceInternal}->add(<<END);
4000 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo) 4000 static void namedPropertyEnumerator(const v8::PropertyCallbackInfo<v8::Array>& i nfo)
4001 { 4001 {
4002 ExceptionState es(info.GetIsolate()); 4002 ExceptionState es(info.Holder(), info.GetIsolate());
4003 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 4003 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
4004 Vector<String> names; 4004 Vector<String> names;
4005 collection->namedPropertyEnumerator(names, es); 4005 collection->namedPropertyEnumerator(names, es);
4006 if (es.throwIfNeeded()) 4006 if (es.throwIfNeeded())
4007 return; 4007 return;
4008 v8::Handle<v8::Array> v8names = v8::Array::New(names.size()); 4008 v8::Handle<v8::Array> v8names = v8::Array::New(names.size());
4009 for (size_t i = 0; i < names.size(); ++i) 4009 for (size_t i = 0; i < names.size(); ++i)
4010 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate())); 4010 v8names->Set(v8::Integer::New(i, info.GetIsolate()), v8String(names[i], info.GetIsolate()));
4011 v8SetReturnValue(info, v8names); 4011 v8SetReturnValue(info, v8names);
4012 } 4012 }
4013 4013
4014 END 4014 END
4015 } 4015 }
4016 4016
4017 sub GenerateImplementationNamedPropertyQuery 4017 sub GenerateImplementationNamedPropertyQuery
4018 { 4018 {
4019 my $interface = shift; 4019 my $interface = shift;
4020 my $implClassName = GetImplName($interface); 4020 my $implClassName = GetImplName($interface);
4021 my $v8ClassName = GetV8ClassName($interface); 4021 my $v8ClassName = GetV8ClassName($interface);
4022 4022
4023 $implementation{nameSpaceInternal}->add(<<END); 4023 $implementation{nameSpaceInternal}->add(<<END);
4024 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info) 4024 static void namedPropertyQuery(v8::Local<v8::String> name, const v8::PropertyCal lbackInfo<v8::Integer>& info)
4025 { 4025 {
4026 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder()); 4026 ${implClassName}* collection = ${v8ClassName}::toNative(info.Holder());
4027 AtomicString propertyName = toWebCoreAtomicString(name); 4027 AtomicString propertyName = toWebCoreAtomicString(name);
4028 ExceptionState es(info.GetIsolate()); 4028 ExceptionState es(info.Holder(), info.GetIsolate());
4029 bool result = collection->namedPropertyQuery(propertyName, es); 4029 bool result = collection->namedPropertyQuery(propertyName, es);
4030 if (es.throwIfNeeded()) 4030 if (es.throwIfNeeded())
4031 return; 4031 return;
4032 if (!result) 4032 if (!result)
4033 return; 4033 return;
4034 v8SetReturnValueInt(info, v8::None); 4034 v8SetReturnValueInt(info, v8::None);
4035 } 4035 }
4036 4036
4037 END 4037 END
4038 } 4038 }
(...skipping 2251 matching lines...) Expand 10 before | Expand all | Expand 10 after
6290 6290
6291 return 1 if $interface->extendedAttributes->{"CustomToV8"}; 6291 return 1 if $interface->extendedAttributes->{"CustomToV8"};
6292 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; 6292 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"};
6293 return 1 if InheritsInterface($interface, "Document"); 6293 return 1 if InheritsInterface($interface, "Document");
6294 return 1 if SVGTypeNeedsToHoldContextElement($interface->name); 6294 return 1 if SVGTypeNeedsToHoldContextElement($interface->name);
6295 6295
6296 return 0; 6296 return 0;
6297 } 6297 }
6298 6298
6299 1; 6299 1;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698