| OLD | NEW |
| 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 2236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 # values passed in non-primitive argument slots. When more than a single | 2247 # values passed in non-primitive argument slots. When more than a single |
| 2248 # overload is applicable, precedence is given according to the order of | 2248 # overload is applicable, precedence is given according to the order of |
| 2249 # declaration in the IDL. | 2249 # declaration in the IDL. |
| 2250 | 2250 |
| 2251 my $name = $function->name; | 2251 my $name = $function->name; |
| 2252 my $interfaceName = $interface->name; | 2252 my $interfaceName = $interface->name; |
| 2253 my $implClassName = GetImplName($interface); | 2253 my $implClassName = GetImplName($interface); |
| 2254 | 2254 |
| 2255 my $conditionalString = GenerateConditionalString($function); | 2255 my $conditionalString = GenerateConditionalString($function); |
| 2256 my $leastNumMandatoryParams = 255; | 2256 my $leastNumMandatoryParams = 255; |
| 2257 my $code = ""; | 2257 |
| 2258 $code .= "#if ${conditionalString}\n\n" if $conditionalString; | 2258 my $hasExceptionState = 0; |
| 2259 $code .= <<END; | 2259 my $header = ""; |
| 2260 $header .= "#if ${conditionalString}\n\n" if $conditionalString; |
| 2261 $header .= <<END; |
| 2260 static void ${name}Method${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8
::Value>& info) | 2262 static void ${name}Method${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8
::Value>& info) |
| 2261 { | 2263 { |
| 2262 END | 2264 END |
| 2265 my $code = ""; |
| 2263 $code .= GenerateFeatureObservation($function->extendedAttributes->{"Measure
As"}); | 2266 $code .= GenerateFeatureObservation($function->extendedAttributes->{"Measure
As"}); |
| 2264 $code .= GenerateDeprecationNotification($function->extendedAttributes->{"De
precateAs"}); | 2267 $code .= GenerateDeprecationNotification($function->extendedAttributes->{"De
precateAs"}); |
| 2265 | 2268 |
| 2266 foreach my $overload (@{$function->{overloads}}) { | 2269 foreach my $overload (@{$function->{overloads}}) { |
| 2267 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($overload); | 2270 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($overload); |
| 2268 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); | 2271 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); |
| 2269 $code .= " if ($parametersCheck) {\n"; | 2272 $code .= " if ($parametersCheck) {\n"; |
| 2270 my $overloadedIndexString = $overload->{overloadIndex}; | 2273 my $overloadedIndexString = $overload->{overloadIndex}; |
| 2271 $code .= " ${name}${overloadedIndexString}Method${forMainWorldSuf
fix}(info);\n"; | 2274 $code .= " ${name}${overloadedIndexString}Method${forMainWorldSuf
fix}(info);\n"; |
| 2272 $code .= " return;\n"; | 2275 $code .= " return;\n"; |
| 2273 $code .= " }\n"; | 2276 $code .= " }\n"; |
| 2274 } | 2277 } |
| 2275 if ($leastNumMandatoryParams >= 1) { | 2278 if ($leastNumMandatoryParams >= 1) { |
| 2279 if (!$hasExceptionState) { |
| 2280 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2281 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2282 $header .= " ExceptionState exceptionState(ExceptionState::Execut
ionContext, \"${name}\", \"${interfaceName}\", info.Holder(), info.GetIsolate())
;\n"; |
| 2283 $hasExceptionState = 1; |
| 2284 } |
| 2276 $code .= " if (UNLIKELY(info.Length() < $leastNumMandatoryParams)) {\
n"; | 2285 $code .= " if (UNLIKELY(info.Length() < $leastNumMandatoryParams)) {\
n"; |
| 2277 $code .= " throwTypeError(ExceptionMessages::failedToExecute(\"$n
ame\", \"$interfaceName\", ExceptionMessages::notEnoughArguments($leastNumMandat
oryParams, info.Length())), info.GetIsolate());\n"; | 2286 $code .= " exceptionState.throwTypeError(ExceptionMessages::notEn
oughArguments($leastNumMandatoryParams, info.Length()));\n"; |
| 2287 $code .= " exceptionState.throwIfNeeded();\n"; |
| 2278 $code .= " return;\n"; | 2288 $code .= " return;\n"; |
| 2279 $code .= " }\n"; | 2289 $code .= " }\n"; |
| 2280 } | 2290 } |
| 2281 $code .= <<END; | 2291 if ($hasExceptionState) { |
| 2282 throwTypeError(ExceptionMessages::failedToExecute(\"$name\", \"$interfaceNam
e\", \"No function was found that matched the signature provided.\"), info.GetIs
olate()); | 2292 $code .= <<END; |
| 2293 exceptionState.throwTypeError(\"No function was found that matched the signa
ture provided.\"); |
| 2294 exceptionState.throwIfNeeded(); |
| 2283 END | 2295 END |
| 2296 } else { |
| 2297 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2298 $code .=<<END; |
| 2299 throwTypeError(ExceptionMessages::failedToExecute(\"${name}\", \"${interface
Name}\", \"No function was found that matched the signature provided.\"), info.G
etIsolate()); |
| 2300 END |
| 2301 } |
| 2284 $code .= "}\n\n"; | 2302 $code .= "}\n\n"; |
| 2285 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; | 2303 $code .= "#endif // ${conditionalString}\n\n" if $conditionalString; |
| 2286 $implementation{nameSpaceInternal}->add($code); | 2304 $implementation{nameSpaceInternal}->add($header . $code); |
| 2287 } | 2305 } |
| 2288 | 2306 |
| 2289 sub GenerateFunctionCallback | 2307 sub GenerateFunctionCallback |
| 2290 { | 2308 { |
| 2291 my $function = shift; | 2309 my $function = shift; |
| 2292 my $interface = shift; | 2310 my $interface = shift; |
| 2293 my $forMainWorldSuffix = shift; | 2311 my $forMainWorldSuffix = shift; |
| 2294 | 2312 |
| 2295 my $implClassName = GetImplName($interface); | 2313 my $implClassName = GetImplName($interface); |
| 2296 my $v8ClassName = GetV8ClassName($interface); | 2314 my $v8ClassName = GetV8ClassName($interface); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2355 $code .= "{\n"; | 2373 $code .= "{\n"; |
| 2356 | 2374 |
| 2357 # We throw exceptions using 'ExceptionState' if the function explicitly clai
ms that exceptions | 2375 # We throw exceptions using 'ExceptionState' if the function explicitly clai
ms that exceptions |
| 2358 # may be raised, or for event listeners, or for security-checking, and for w
eird SVG stuff. | 2376 # may be raised, or for event listeners, or for security-checking, and for w
eird SVG stuff. |
| 2359 my $isEventListener = $name eq "addEventListener" || $name eq "removeEventLi
stener"; | 2377 my $isEventListener = $name eq "addEventListener" || $name eq "removeEventLi
stener"; |
| 2360 my $isSecurityCheckNecessary = $interface->extendedAttributes->{"CheckSecuri
ty"} && !$function->extendedAttributes->{"DoNotCheckSecurity"}; | 2378 my $isSecurityCheckNecessary = $interface->extendedAttributes->{"CheckSecuri
ty"} && !$function->extendedAttributes->{"DoNotCheckSecurity"}; |
| 2361 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; | 2379 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; |
| 2362 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); | 2380 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty
Types($interfaceName); |
| 2363 my $isNonListSVGType = $svgNativeType && !($interfaceName =~ /List$/); | 2381 my $isNonListSVGType = $svgNativeType && !($interfaceName =~ /List$/); |
| 2364 | 2382 |
| 2383 my $hasExceptionState = 0; |
| 2365 if ($raisesExceptions || $isEventListener || $isSecurityCheckNecessary || $i
sNonListSVGType) { | 2384 if ($raisesExceptions || $isEventListener || $isSecurityCheckNecessary || $i
sNonListSVGType) { |
| 2366 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2385 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2367 $code .= " ExceptionState exceptionState(ExceptionState::ExecutionCon
text, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsol
ate());\n"; | 2386 $code .= " ExceptionState exceptionState(ExceptionState::ExecutionCon
text, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsol
ate());\n"; |
| 2387 $hasExceptionState = 1; |
| 2368 } | 2388 } |
| 2369 | 2389 |
| 2370 if ($isEventListener) { | 2390 if ($isEventListener) { |
| 2371 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; | 2391 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; |
| 2372 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; | 2392 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; |
| 2373 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" :
"remove"; | 2393 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" :
"remove"; |
| 2374 | 2394 |
| 2375 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2395 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 2376 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); | 2396 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
| 2377 AddToImplIncludes("core/frame/DOMWindow.h"); | 2397 AddToImplIncludes("core/frame/DOMWindow.h"); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 2393 ${hiddenDependencyAction}HiddenDependency(info.Holder(), info[1], ${
v8ClassName}::eventListenerCacheIndex, info.GetIsolate()); | 2413 ${hiddenDependencyAction}HiddenDependency(info.Holder(), info[1], ${
v8ClassName}::eventListenerCacheIndex, info.GetIsolate()); |
| 2394 } | 2414 } |
| 2395 } | 2415 } |
| 2396 END | 2416 END |
| 2397 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 2417 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 2398 $code .= "\n"; | 2418 $code .= "\n"; |
| 2399 $implementation{nameSpaceInternal}->add($code); | 2419 $implementation{nameSpaceInternal}->add($code); |
| 2400 return; | 2420 return; |
| 2401 } | 2421 } |
| 2402 | 2422 |
| 2403 $code .= GenerateArgumentsCountCheck($function, $interface); | 2423 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionSta
te); |
| 2404 | 2424 |
| 2405 if ($svgNativeType) { | 2425 if ($svgNativeType) { |
| 2406 my $nativeClassName = GetNativeType($interfaceName); | 2426 my $nativeClassName = GetNativeType($interfaceName); |
| 2407 if ($interfaceName =~ /List$/) { | 2427 if ($interfaceName =~ /List$/) { |
| 2408 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(info.H
older());\n"; | 2428 $code .= " $nativeClassName imp = ${v8ClassName}::toNative(info.H
older());\n"; |
| 2409 } else { | 2429 } else { |
| 2410 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2430 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| 2411 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(in
fo.Holder());\n"; | 2431 $code .= " $nativeClassName wrapper = ${v8ClassName}::toNative(in
fo.Holder());\n"; |
| 2412 $code .= " if (wrapper->isReadOnly()) {\n"; | 2432 $code .= " if (wrapper->isReadOnly()) {\n"; |
| 2413 $code .= " exceptionState.throwDOMException(NoModificationAll
owedError, \"The object is read-only.\");\n"; | 2433 $code .= " exceptionState.throwDOMException(NoModificationAll
owedError, \"The object is read-only.\");\n"; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 if (ExtendedAttributeContains($callWith, "FirstWindow")) { | 2513 if (ExtendedAttributeContains($callWith, "FirstWindow")) { |
| 2494 push(@callWithArgs, "firstDOMWindow()"); | 2514 push(@callWithArgs, "firstDOMWindow()"); |
| 2495 } | 2515 } |
| 2496 return ([@callWithArgs], $code); | 2516 return ([@callWithArgs], $code); |
| 2497 } | 2517 } |
| 2498 | 2518 |
| 2499 sub GenerateArgumentsCountCheck | 2519 sub GenerateArgumentsCountCheck |
| 2500 { | 2520 { |
| 2501 my $function = shift; | 2521 my $function = shift; |
| 2502 my $interface = shift; | 2522 my $interface = shift; |
| 2523 my $hasExceptionState = shift; |
| 2503 | 2524 |
| 2504 my $functionName = $function->name; | 2525 my $functionName = $function->name; |
| 2505 my $interfaceName = $interface->name; | 2526 my $interfaceName = $interface->name; |
| 2506 my $implClassName = GetImplName($interface); | 2527 my $implClassName = GetImplName($interface); |
| 2507 | 2528 |
| 2508 my $numMandatoryParams = 0; | 2529 my $numMandatoryParams = 0; |
| 2509 my $allowNonOptional = 1; | 2530 my $allowNonOptional = 1; |
| 2510 foreach my $param (@{$function->parameters}) { | 2531 foreach my $param (@{$function->parameters}) { |
| 2511 if ($param->isOptional or $param->isVariadic) { | 2532 if ($param->isOptional or $param->isVariadic) { |
| 2512 $allowNonOptional = 0; | 2533 $allowNonOptional = 0; |
| 2513 } else { | 2534 } else { |
| 2514 die "An argument must not be declared to be optional unless all subs
equent arguments to the operation are also optional." if !$allowNonOptional; | 2535 die "An argument must not be declared to be optional unless all subs
equent arguments to the operation are also optional." if !$allowNonOptional; |
| 2515 $numMandatoryParams++; | 2536 $numMandatoryParams++; |
| 2516 } | 2537 } |
| 2517 } | 2538 } |
| 2518 | 2539 |
| 2519 my $argumentsCountCheckString = ""; | 2540 my $argumentsCountCheckString = ""; |
| 2520 if ($numMandatoryParams >= 1) { | 2541 if ($numMandatoryParams >= 1) { |
| 2521 $argumentsCountCheckString .= " if (UNLIKELY(info.Length() < $numMand
atoryParams)) {\n"; | 2542 $argumentsCountCheckString .= " if (UNLIKELY(info.Length() < $numMand
atoryParams)) {\n"; |
| 2522 $argumentsCountCheckString .= " throwTypeError(ExceptionMessages:
:failedToExecute(\"$functionName\", \"$interfaceName\", ExceptionMessages::notEn
oughArguments($numMandatoryParams, info.Length())), info.GetIsolate());\n"; | 2543 if ($hasExceptionState) { |
| 2544 $argumentsCountCheckString .= " exceptionState.throwTypeError
(ExceptionMessages::notEnoughArguments($numMandatoryParams, info.Length()));\n"; |
| 2545 $argumentsCountCheckString .= " exceptionState.throwIfNeeded(
);\n"; |
| 2546 } else { |
| 2547 $argumentsCountCheckString .= " throwTypeError(ExceptionMessa
ges::failedToExecute(\"$functionName\", \"$interfaceName\", ExceptionMessages::n
otEnoughArguments($numMandatoryParams, info.Length())), info.GetIsolate());\n"; |
| 2548 } |
| 2523 $argumentsCountCheckString .= " return;\n"; | 2549 $argumentsCountCheckString .= " return;\n"; |
| 2524 $argumentsCountCheckString .= " }\n"; | 2550 $argumentsCountCheckString .= " }\n"; |
| 2525 } | 2551 } |
| 2526 return $argumentsCountCheckString; | 2552 return $argumentsCountCheckString; |
| 2527 } | 2553 } |
| 2528 | 2554 |
| 2529 sub GenerateParametersCheck | 2555 sub GenerateParametersCheck |
| 2530 { | 2556 { |
| 2531 my $function = shift; | 2557 my $function = shift; |
| 2532 my $interface = shift; | 2558 my $interface = shift; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2681 } | 2707 } |
| 2682 return ($parameterCheckString, $paramIndex, %replacements); | 2708 return ($parameterCheckString, $paramIndex, %replacements); |
| 2683 } | 2709 } |
| 2684 | 2710 |
| 2685 sub GenerateOverloadedConstructorCallback | 2711 sub GenerateOverloadedConstructorCallback |
| 2686 { | 2712 { |
| 2687 my $interface = shift; | 2713 my $interface = shift; |
| 2688 my $interfaceName = $interface->name; | 2714 my $interfaceName = $interface->name; |
| 2689 my $implClassName = GetImplName($interface); | 2715 my $implClassName = GetImplName($interface); |
| 2690 | 2716 |
| 2691 my $code = ""; | 2717 my $hasExceptionState = 0; |
| 2692 $code .= <<END; | 2718 my $header = ""; |
| 2719 $header .= <<END; |
| 2693 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) | 2720 static void constructor(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 2694 { | 2721 { |
| 2695 END | 2722 END |
| 2723 my $code = ""; |
| 2696 my $leastNumMandatoryParams = 255; | 2724 my $leastNumMandatoryParams = 255; |
| 2697 foreach my $constructor (@{$interface->constructors}) { | 2725 foreach my $constructor (@{$interface->constructors}) { |
| 2698 my $name = "constructor" . $constructor->overloadedIndex; | 2726 my $name = "constructor" . $constructor->overloadedIndex; |
| 2699 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($constructor); | 2727 my ($numMandatoryParams, $parametersCheck) = GenerateFunctionParametersC
heck($constructor); |
| 2700 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); | 2728 $leastNumMandatoryParams = $numMandatoryParams if ($numMandatoryParams <
$leastNumMandatoryParams); |
| 2701 $code .= " if ($parametersCheck) {\n"; | 2729 $code .= " if ($parametersCheck) {\n"; |
| 2702 $code .= " ${implClassName}V8Internal::${name}(info);\n"; | 2730 $code .= " ${implClassName}V8Internal::${name}(info);\n"; |
| 2703 $code .= " return;\n"; | 2731 $code .= " return;\n"; |
| 2704 $code .= " }\n"; | 2732 $code .= " }\n"; |
| 2705 } | 2733 } |
| 2706 if ($leastNumMandatoryParams >= 1) { | 2734 if ($leastNumMandatoryParams >= 1) { |
| 2735 if (!$hasExceptionState) { |
| 2736 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2737 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2738 $header .= " ExceptionState exceptionState(ExceptionState::Constr
uctionContext, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
| 2739 $hasExceptionState = 1; |
| 2740 } |
| 2707 $code .= " if (UNLIKELY(info.Length() < $leastNumMandatoryParams)) {\
n"; | 2741 $code .= " if (UNLIKELY(info.Length() < $leastNumMandatoryParams)) {\
n"; |
| 2708 | 2742 $code .= " exceptionState.throwTypeError(ExceptionMessages::notEn
oughArguments($leastNumMandatoryParams, info.Length()));\n"; |
| 2709 $code .= " throwTypeError(ExceptionMessages::failedToConstruct(\"
$interfaceName\", ExceptionMessages::notEnoughArguments($leastNumMandatoryParams
, info.Length())), info.GetIsolate());\n"; | 2743 $code .= " exceptionState.throwIfNeeded();\n"; |
| 2710 $code .= " return;\n"; | 2744 $code .= " return;\n"; |
| 2711 $code .= " }\n"; | 2745 $code .= " }\n"; |
| 2712 } | 2746 } |
| 2713 $code .= <<END; | 2747 if ($hasExceptionState) { |
| 2714 throwTypeError(ExceptionMessages::failedToConstruct(\"$interfaceName\", \"No
matching constructor signature.\"), info.GetIsolate()); | 2748 $code .= <<END; |
| 2715 return; | 2749 exceptionState.throwTypeError(\"No matching constructor signature.\"); |
| 2750 exceptionState.throwIfNeeded(); |
| 2716 END | 2751 END |
| 2752 } else { |
| 2753 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2754 $code .= <<END; |
| 2755 throwTypeError(ExceptionMessages::failedToConstruct(\"${interfaceName}\", \"
No matching constructor signature.\"), info.GetIsolate()); |
| 2756 END |
| 2757 } |
| 2717 $code .= "}\n\n"; | 2758 $code .= "}\n\n"; |
| 2718 $implementation{nameSpaceInternal}->add($code); | 2759 $implementation{nameSpaceInternal}->add($header . $code); |
| 2719 } | 2760 } |
| 2720 | 2761 |
| 2721 sub GenerateSingleConstructorCallback | 2762 sub GenerateSingleConstructorCallback |
| 2722 { | 2763 { |
| 2723 my $interface = shift; | 2764 my $interface = shift; |
| 2724 my $function = shift; | 2765 my $function = shift; |
| 2725 | 2766 |
| 2726 my $implClassName = GetImplName($interface); | 2767 my $implClassName = GetImplName($interface); |
| 2727 my $v8ClassName = GetV8ClassName($interface); | 2768 my $v8ClassName = GetV8ClassName($interface); |
| 2728 my $overloadedIndexString = ""; | 2769 my $overloadedIndexString = ""; |
| 2729 if ($function->overloadedIndex > 0) { | 2770 if ($function->overloadedIndex > 0) { |
| 2730 $overloadedIndexString .= $function->overloadedIndex; | 2771 $overloadedIndexString .= $function->overloadedIndex; |
| 2731 } | 2772 } |
| 2732 | 2773 |
| 2733 my $constructorRaisesException = $interface->extendedAttributes->{"RaisesExc
eption"} && $interface->extendedAttributes->{"RaisesException"} eq "Constructor"
; | 2774 my $constructorRaisesException = $interface->extendedAttributes->{"RaisesExc
eption"} && $interface->extendedAttributes->{"RaisesException"} eq "Constructor"
; |
| 2734 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} ||
$constructorRaisesException; | 2775 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} ||
$constructorRaisesException; |
| 2735 | 2776 |
| 2736 my @beforeArgumentList; | 2777 my @beforeArgumentList; |
| 2737 my @afterArgumentList; | 2778 my @afterArgumentList; |
| 2738 my $code = ""; | 2779 my $code = ""; |
| 2739 $code .= <<END; | 2780 $code .= <<END; |
| 2740 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v
8::Value>& info) | 2781 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v
8::Value>& info) |
| 2741 { | 2782 { |
| 2742 END | 2783 END |
| 2743 | 2784 |
| 2744 if ($function->overloadedIndex == 0) { | 2785 if ($function->overloadedIndex == 0) { |
| 2745 $code .= GenerateArgumentsCountCheck($function, $interface); | 2786 my $hasExceptionState = 0; |
| 2787 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptio
nState); |
| 2746 } | 2788 } |
| 2747 | 2789 |
| 2748 if ($raisesExceptions) { | 2790 if ($raisesExceptions) { |
| 2749 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2791 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2750 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola
te());\n"; | 2792 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola
te());\n"; |
| 2751 } | 2793 } |
| 2752 | 2794 |
| 2753 # FIXME: Currently [Constructor(...)] does not yet support optional argument
s without [Default=...] | 2795 # FIXME: Currently [Constructor(...)] does not yet support optional argument
s without [Default=...] |
| 2754 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, ""); | 2796 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface, ""); |
| 2755 $code .= $parameterCheckString; | 2797 $code .= $parameterCheckString; |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3075 $code .= <<END; | 3117 $code .= <<END; |
| 3076 Document* document = currentDocument(); | 3118 Document* document = currentDocument(); |
| 3077 ASSERT(document); | 3119 ASSERT(document); |
| 3078 | 3120 |
| 3079 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp
lClassName} instance | 3121 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp
lClassName} instance |
| 3080 // may end up being the only node in the map and get garbage-collected prema
turely. | 3122 // may end up being the only node in the map and get garbage-collected prema
turely. |
| 3081 toV8(document, info.Holder(), info.GetIsolate()); | 3123 toV8(document, info.Holder(), info.GetIsolate()); |
| 3082 | 3124 |
| 3083 END | 3125 END |
| 3084 | 3126 |
| 3085 $code .= GenerateArgumentsCountCheck($function, $interface); | |
| 3086 | |
| 3087 if ($raisesExceptions) { | 3127 if ($raisesExceptions) { |
| 3088 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 3128 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 3089 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola
te());\n"; | 3129 my $interfaceName = $interface->name; |
| 3130 $code .= " ExceptionState exceptionState(ExceptionState::Construction
Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
| 3090 } | 3131 } |
| 3091 | 3132 |
| 3133 my $hasExceptionState = $raisesExceptions; |
| 3134 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionSta
te); |
| 3135 |
| 3092 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface); | 3136 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC
heck($function, $interface); |
| 3093 $code .= $parameterCheckString; | 3137 $code .= $parameterCheckString; |
| 3094 | 3138 |
| 3095 push(@beforeArgumentList, "*document"); | 3139 push(@beforeArgumentList, "*document"); |
| 3096 | 3140 |
| 3097 if ($constructorRaisesException) { | 3141 if ($constructorRaisesException) { |
| 3098 push(@afterArgumentList, "exceptionState"); | 3142 push(@afterArgumentList, "exceptionState"); |
| 3099 } | 3143 } |
| 3100 | 3144 |
| 3101 my @argumentList; | 3145 my @argumentList; |
| (...skipping 3245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6347 | 6391 |
| 6348 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust
om"}, "ToV8"); | 6392 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust
om"}, "ToV8"); |
| 6349 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust
om"}, "Wrap"); | 6393 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust
om"}, "Wrap"); |
| 6350 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6394 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
| 6351 return 1 if InheritsInterface($interface, "Document"); | 6395 return 1 if InheritsInterface($interface, "Document"); |
| 6352 | 6396 |
| 6353 return 0; | 6397 return 0; |
| 6354 } | 6398 } |
| 6355 | 6399 |
| 6356 1; | 6400 1; |
| OLD | NEW |