Chromium Code Reviews| 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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 "short" => 1, | 162 "short" => 1, |
| 163 "long" => 1, | 163 "long" => 1, |
| 164 "long long" => 1, | 164 "long long" => 1, |
| 165 "unsigned short" => 1, | 165 "unsigned short" => 1, |
| 166 "unsigned long" => 1, | 166 "unsigned long" => 1, |
| 167 "unsigned long long" => 1, | 167 "unsigned long long" => 1, |
| 168 "float" => 1, | 168 "float" => 1, |
| 169 "double" => 1, | 169 "double" => 1, |
| 170 ); | 170 ); |
| 171 | 171 |
| 172 my %integerTypeHash = ("byte" => 1, | 172 # NOTE: For the unsigned types, the "UI" prefix is used (and not |
| 173 "octet" => 1, | 173 # "Ui"), so as to match onto the naming of V8Binding conversion |
| 174 "short" => 1, | 174 # methods (and not the Typed Array naming scheme for unsigned types.) |
| 175 "long" => 1, | 175 my %integerTypeHash = ("byte" => "Int8", |
| 176 "long long" => 1, | 176 "octet" => "UInt8", |
| 177 "unsigned short" => 1, | 177 "short" => "Int16", |
| 178 "unsigned long" => 1, | 178 "long" => "Int32", |
| 179 "unsigned long long" => 1, | 179 "long long" => "Int64", |
| 180 "unsigned short" => "UInt16", | |
| 181 "unsigned long" => "UInt32", | |
| 182 "unsigned long long" => "UInt64" | |
| 180 ); | 183 ); |
| 181 | 184 |
| 182 my %nonWrapperTypes = ("CompareHow" => 1, | 185 my %nonWrapperTypes = ("CompareHow" => 1, |
| 183 "Dictionary" => 1, | 186 "Dictionary" => 1, |
| 184 "EventListener" => 1, | 187 "EventListener" => 1, |
| 185 "EventHandler" => 1, | 188 "EventHandler" => 1, |
| 186 "MediaQueryListListener" => 1, | 189 "MediaQueryListListener" => 1, |
| 187 "NodeFilter" => 1, | 190 "NodeFilter" => 1, |
| 188 "SerializedScriptValue" => 1, | 191 "SerializedScriptValue" => 1, |
| 189 "any" => 1, | 192 "any" => 1, |
| (...skipping 1732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1922 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info)\n"; | 1925 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::FunctionCallbackInfo<v8::Value>& info)\n"; |
| 1923 } else { | 1926 } else { |
| 1924 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n"; | 1927 $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8 ::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n"; |
| 1925 } | 1928 } |
| 1926 $code .= "{\n"; | 1929 $code .= "{\n"; |
| 1927 | 1930 |
| 1928 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; | 1931 my $raisesException = $attribute->extendedAttributes->{"RaisesException"}; |
| 1929 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Setter"); | 1932 my $useExceptions = 1 if $raisesException && ($raisesException eq "VALUE_IS_ MISSING" or $raisesException eq "Setter"); |
| 1930 my $hasStrictTypeChecking = 1 if $attribute->extendedAttributes->{"StrictTyp eChecking"} && IsWrapperType($attrType); # Currently only actually check interf ace types | 1933 my $hasStrictTypeChecking = 1 if $attribute->extendedAttributes->{"StrictTyp eChecking"} && IsWrapperType($attrType); # Currently only actually check interf ace types |
| 1931 | 1934 |
| 1935 # Can throw exceptions from accessors or during type conversion. | |
| 1936 my $isNumberType = IsIntegerType($attribute->type); | |
| 1937 | |
| 1932 # We throw exceptions using 'ExceptionState' if the attribute explicitly | 1938 # We throw exceptions using 'ExceptionState' if the attribute explicitly |
| 1933 # claims that exceptions may be raised, or if a strict type check might | 1939 # claims that exceptions may be raised, or if a strict type check might |
| 1934 # fail, or if we're dealing with SVG, which does strange things with | 1940 # fail, or if we're dealing with SVG, which does strange things with |
| 1935 # tearoffs and read-only wrappers. | 1941 # tearoffs and read-only wrappers. |
| 1936 if ($useExceptions or $hasStrictTypeChecking or GetSVGTypeNeedingTearOff($in terfaceName) or GetSVGTypeNeedingTearOff($attrType)) { | 1942 if ($useExceptions or $hasStrictTypeChecking or GetSVGTypeNeedingTearOff($in terfaceName) or GetSVGTypeNeedingTearOff($attrType) or $isNumberType) { |
| 1937 $code .= " ExceptionState exceptionState(ExceptionState::SetterContex t, \"${attrName}\", \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; | 1943 $code .= " ExceptionState exceptionState(ExceptionState::SetterContex t, \"${attrName}\", \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
| 1938 } | 1944 } |
| 1939 | 1945 |
| 1940 # If the "StrictTypeChecking" extended attribute is present, and the | 1946 # If the "StrictTypeChecking" extended attribute is present, and the |
| 1941 # attribute's type is an interface type, then if the incoming value does not | 1947 # attribute's type is an interface type, then if the incoming value does not |
| 1942 # implement that interface, a TypeError is thrown rather than silently | 1948 # implement that interface, a TypeError is thrown rather than silently |
| 1943 # passing NULL to the C++ code. | 1949 # passing NULL to the C++ code. |
| 1944 # Per the Web IDL and ECMAScript specifications, incoming values can always | 1950 # Per the Web IDL and ECMAScript specifications, incoming values can always |
| 1945 # be converted to both strings and numbers, so do not throw TypeError if the | 1951 # be converted to both strings and numbers, so do not throw TypeError if the |
| 1946 # attribute is of these types. | 1952 # attribute is of these types. |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2353 # Append a number to an overloaded method's name to make it unique: | 2359 # Append a number to an overloaded method's name to make it unique: |
| 2354 $name = $name . $function->{overloadIndex}; | 2360 $name = $name . $function->{overloadIndex}; |
| 2355 } | 2361 } |
| 2356 | 2362 |
| 2357 my $conditionalString = GenerateConditionalString($function); | 2363 my $conditionalString = GenerateConditionalString($function); |
| 2358 my $code = ""; | 2364 my $code = ""; |
| 2359 $code .= "#if ${conditionalString}\n" if $conditionalString; | 2365 $code .= "#if ${conditionalString}\n" if $conditionalString; |
| 2360 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC allbackInfo<v8::Value>& info)\n"; | 2366 $code .= "static void ${name}Method${forMainWorldSuffix}(const v8::FunctionC allbackInfo<v8::Value>& info)\n"; |
| 2361 $code .= "{\n"; | 2367 $code .= "{\n"; |
| 2362 | 2368 |
| 2363 # We throw exceptions using 'ExceptionState' if the function explicitly clai ms that exceptions | 2369 # We throw exceptions using 'ExceptionState' for a function if: |
| 2364 # may be raised, or for event listeners, or for security-checking, and for w eird SVG stuff. | 2370 # - it explicitly claims that exceptions may be raised (or should be if ty pe checks fail.) |
| 2371 # - event listeners | |
| 2372 # - security-checking | |
| 2373 # - weird SVG stuff. | |
|
jsbell
2014/01/02 18:03:23
nit: inconsistent punctuation in the list
| |
| 2374 # - takes a parameter that might raise an exception on conversion. | |
| 2375 # | |
| 2365 my $isEventListener = $name eq "addEventListener" || $name eq "removeEventLi stener"; | 2376 my $isEventListener = $name eq "addEventListener" || $name eq "removeEventLi stener"; |
| 2366 my $isSecurityCheckNecessary = $interface->extendedAttributes->{"CheckSecuri ty"} && !$function->extendedAttributes->{"DoNotCheckSecurity"}; | 2377 my $isSecurityCheckNecessary = $interface->extendedAttributes->{"CheckSecuri ty"} && !$function->extendedAttributes->{"DoNotCheckSecurity"}; |
| 2367 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; | 2378 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"}; |
| 2379 my $hasStrictTypeChecking = $function->extendedAttributes->{"StrictTypeCheck ing"}; | |
| 2368 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); | 2380 my ($svgPropertyType, $svgListPropertyType, $svgNativeType) = GetSVGProperty Types($interfaceName); |
| 2369 my $isNonListSVGType = $svgNativeType && !($interfaceName =~ /List$/); | 2381 my $isNonListSVGType = $svgNativeType && !($interfaceName =~ /List$/); |
| 2370 | 2382 |
| 2371 my $hasExceptionState = 0; | 2383 my $hasExceptionState = $raisesExceptions || $isEventListener || $isSecurity CheckNecessary || $isNonListSVGType || HasExceptionRaisingParameter($function); |
| 2372 if ($raisesExceptions || $isEventListener || $isSecurityCheckNecessary || $i sNonListSVGType || HasSerializedScriptValueParameter($function)) { | 2384 if ($hasExceptionState) { |
| 2373 $code .= " ExceptionState exceptionState(ExceptionState::ExecutionCon text, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsol ate());\n"; | 2385 $code .= " ExceptionState exceptionState(ExceptionState::ExecutionCon text, \"${unoverloadedName}\", \"${interfaceName}\", info.Holder(), info.GetIsol ate());\n"; |
| 2374 $hasExceptionState = 1; | |
| 2375 } | 2386 } |
| 2376 | 2387 |
| 2377 if ($isEventListener) { | 2388 if ($isEventListener) { |
| 2378 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; | 2389 my $lookupType = ($name eq "addEventListener") ? "OrCreate" : "Only"; |
| 2379 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; | 2390 my $passRefPtrHandling = ($name eq "addEventListener") ? "" : ".get()"; |
| 2380 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove"; | 2391 my $hiddenDependencyAction = ($name eq "addEventListener") ? "create" : "remove"; |
| 2381 | 2392 |
| 2382 AddToImplIncludes("bindings/v8/BindingSecurity.h"); | 2393 AddToImplIncludes("bindings/v8/BindingSecurity.h"); |
| 2383 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); | 2394 AddToImplIncludes("bindings/v8/V8EventListenerList.h"); |
| 2384 AddToImplIncludes("core/frame/DOMWindow.h"); | 2395 AddToImplIncludes("core/frame/DOMWindow.h"); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2452 $code .= " exceptionState.throwIfNeeded();\n"; | 2463 $code .= " exceptionState.throwIfNeeded();\n"; |
| 2453 $code .= " return;\n"; | 2464 $code .= " return;\n"; |
| 2454 $code .= " }\n"; | 2465 $code .= " }\n"; |
| 2455 END | 2466 END |
| 2456 } | 2467 } |
| 2457 | 2468 |
| 2458 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix, $hasExceptionState); | 2469 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, $forMainWorldSuffix, $hasExceptionState); |
| 2459 $code .= $parameterCheckString; | 2470 $code .= $parameterCheckString; |
| 2460 | 2471 |
| 2461 # Build the function call string. | 2472 # Build the function call string. |
| 2462 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, %replacements); | 2473 $code .= GenerateFunctionCallString($function, $paramIndex, " ", $interfa ce, $forMainWorldSuffix, $hasExceptionState, %replacements); |
| 2463 $code .= "}\n"; | 2474 $code .= "}\n"; |
| 2464 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 2475 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 2465 $code .= "\n"; | 2476 $code .= "\n"; |
| 2466 $implementation{nameSpaceInternal}->add($code); | 2477 $implementation{nameSpaceInternal}->add($code); |
| 2467 } | 2478 } |
| 2468 | 2479 |
| 2469 sub GenerateCallWith | 2480 sub GenerateCallWith |
| 2470 { | 2481 { |
| 2471 my $callWith = shift; | 2482 my $callWith = shift; |
| 2472 return ([], "") unless $callWith; | 2483 return ([], "") unless $callWith; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2560 foreach my $parameter (@{$function->parameters}) { | 2571 foreach my $parameter (@{$function->parameters}) { |
| 2561 my $humanFriendlyIndex = $paramIndex + 1; | 2572 my $humanFriendlyIndex = $paramIndex + 1; |
| 2562 my $nativeType = GetNativeType($parameter->type, $parameter->extendedAtt ributes, "parameter"); | 2573 my $nativeType = GetNativeType($parameter->type, $parameter->extendedAtt ributes, "parameter"); |
| 2563 | 2574 |
| 2564 # Optional arguments without [Default=...] should generate an early call with fewer arguments. | 2575 # Optional arguments without [Default=...] should generate an early call with fewer arguments. |
| 2565 # Optional Dictionary arguments always considered to have default of emp ty dictionary. | 2576 # Optional Dictionary arguments always considered to have default of emp ty dictionary. |
| 2566 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default "} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { | 2577 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default "} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { |
| 2567 $parameterCheckString .= <<END; | 2578 $parameterCheckString .= <<END; |
| 2568 if (UNLIKELY(info.Length() <= $paramIndex)) { | 2579 if (UNLIKELY(info.Length() <= $paramIndex)) { |
| 2569 END | 2580 END |
| 2570 $parameterCheckString .= GenerateFunctionCallString($function, $para mIndex, " " x 2, $interface, $forMainWorldSuffix, %replacements); | 2581 $parameterCheckString .= GenerateFunctionCallString($function, $para mIndex, " " x 2, $interface, $forMainWorldSuffix, $hasExceptionState, %replac ements); |
| 2571 $parameterCheckString .= <<END; | 2582 $parameterCheckString .= <<END; |
| 2572 return; | 2583 return; |
| 2573 } | 2584 } |
| 2574 END | 2585 END |
| 2575 } | 2586 } |
| 2576 | 2587 |
| 2577 my $parameterName = $parameter->name; | 2588 my $parameterName = $parameter->name; |
| 2578 if (IsCallbackInterface($parameter->type)) { | 2589 if (IsCallbackInterface($parameter->type)) { |
| 2579 my $v8ClassName = "V8" . $parameter->type; | 2590 my $v8ClassName = "V8" . $parameter->type; |
| 2580 AddToImplIncludes("$v8ClassName.h"); | 2591 AddToImplIncludes("$v8ClassName.h"); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2771 | 2782 |
| 2772 my $interfaceName = $interface->name; | 2783 my $interfaceName = $interface->name; |
| 2773 my $implClassName = GetImplName($interface); | 2784 my $implClassName = GetImplName($interface); |
| 2774 my $v8ClassName = GetV8ClassName($interface); | 2785 my $v8ClassName = GetV8ClassName($interface); |
| 2775 my $overloadedIndexString = ""; | 2786 my $overloadedIndexString = ""; |
| 2776 if ($function->overloadedIndex > 0) { | 2787 if ($function->overloadedIndex > 0) { |
| 2777 $overloadedIndexString .= $function->overloadedIndex; | 2788 $overloadedIndexString .= $function->overloadedIndex; |
| 2778 } | 2789 } |
| 2779 | 2790 |
| 2780 my $constructorRaisesException = $interface->extendedAttributes->{"RaisesExc eption"} && $interface->extendedAttributes->{"RaisesException"} eq "Constructor" ; | 2791 my $constructorRaisesException = $interface->extendedAttributes->{"RaisesExc eption"} && $interface->extendedAttributes->{"RaisesException"} eq "Constructor" ; |
| 2781 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} || $constructorRaisesException || HasSerializedScriptValueParameter($function); | 2792 my $hasExceptionState = $function->extendedAttributes->{"RaisesException"} | | $constructorRaisesException || HasExceptionRaisingParameter($function); |
| 2782 | 2793 |
| 2783 my @beforeArgumentList; | 2794 my @beforeArgumentList; |
| 2784 my @afterArgumentList; | 2795 my @afterArgumentList; |
| 2785 my $code = ""; | 2796 my $code = ""; |
| 2786 $code .= <<END; | 2797 $code .= <<END; |
| 2787 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& info) | 2798 static void constructor${overloadedIndexString}(const v8::FunctionCallbackInfo<v 8::Value>& info) |
| 2788 { | 2799 { |
| 2789 END | 2800 END |
| 2790 | 2801 |
| 2802 if ($hasExceptionState) { | |
| 2803 $code .= " ExceptionState exceptionState(ExceptionState::Construction Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; | |
| 2804 } | |
| 2791 if ($function->overloadedIndex == 0) { | 2805 if ($function->overloadedIndex == 0) { |
| 2792 my $hasExceptionState = 0; | |
| 2793 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptio nState); | 2806 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptio nState); |
| 2794 } | 2807 } |
| 2795 | 2808 |
| 2796 if ($raisesExceptions) { | |
| 2797 $code .= " ExceptionState exceptionState(ExceptionState::Construction Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; | |
| 2798 } | |
| 2799 | |
| 2800 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] | 2809 # FIXME: Currently [Constructor(...)] does not yet support optional argument s without [Default=...] |
| 2801 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "", $raisesExceptions); | 2810 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "", $hasExceptionState); |
| 2802 $code .= $parameterCheckString; | 2811 $code .= $parameterCheckString; |
| 2803 | 2812 |
| 2804 if ($interface->extendedAttributes->{"ConstructorCallWith"}) { | 2813 if ($interface->extendedAttributes->{"ConstructorCallWith"}) { |
| 2805 if (ExtendedAttributeContains($interface->extendedAttributes->{"Construc torCallWith"}, "ExecutionContext")) { | 2814 if (ExtendedAttributeContains($interface->extendedAttributes->{"Construc torCallWith"}, "ExecutionContext")) { |
| 2806 push(@beforeArgumentList, "context"); | 2815 push(@beforeArgumentList, "context"); |
| 2807 $code .= " ExecutionContext* context = getExecutionContext();\n"; | 2816 $code .= " ExecutionContext* context = getExecutionContext();\n"; |
| 2808 } | 2817 } |
| 2809 if (ExtendedAttributeContains($interface->extendedAttributes->{"Construc torCallWith"}, "Document")) { | 2818 if (ExtendedAttributeContains($interface->extendedAttributes->{"Construc torCallWith"}, "Document")) { |
| 2810 push(@beforeArgumentList, "document"); | 2819 push(@beforeArgumentList, "document"); |
| 2811 $code .= " Document& document = *toDocument(getExecutionContext() );\n"; | 2820 $code .= " Document& document = *toDocument(getExecutionContext() );\n"; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3065 | 3074 |
| 3066 sub GenerateNamedConstructor | 3075 sub GenerateNamedConstructor |
| 3067 { | 3076 { |
| 3068 my $function = shift; | 3077 my $function = shift; |
| 3069 my $interface = shift; | 3078 my $interface = shift; |
| 3070 | 3079 |
| 3071 my $interfaceName = $interface->name; | 3080 my $interfaceName = $interface->name; |
| 3072 my $implClassName = GetImplName($interface); | 3081 my $implClassName = GetImplName($interface); |
| 3073 my $v8ClassName = GetV8ClassName($interface); | 3082 my $v8ClassName = GetV8ClassName($interface); |
| 3074 my $constructorRaisesException = $interface->extendedAttributes->{"RaisesExc eption"} && $interface->extendedAttributes->{"RaisesException"} eq "Constructor" ; | 3083 my $constructorRaisesException = $interface->extendedAttributes->{"RaisesExc eption"} && $interface->extendedAttributes->{"RaisesException"} eq "Constructor" ; |
| 3075 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} || $constructorRaisesException || HasSerializedScriptValueParameter($function); | 3084 my $raisesExceptions = $function->extendedAttributes->{"RaisesException"} || $constructorRaisesException || HasExceptionRaisingParameter($function); |
| 3076 | 3085 |
| 3077 my $maybeObserveFeature = GenerateFeatureObservation($function->extendedAttr ibutes->{"MeasureAs"}); | 3086 my $maybeObserveFeature = GenerateFeatureObservation($function->extendedAttr ibutes->{"MeasureAs"}); |
| 3078 my $maybeDeprecateFeature = GenerateDeprecationNotification($function->exten dedAttributes->{"DeprecateAs"}); | 3087 my $maybeDeprecateFeature = GenerateDeprecationNotification($function->exten dedAttributes->{"DeprecateAs"}); |
| 3079 | 3088 |
| 3080 my @beforeArgumentList; | 3089 my @beforeArgumentList; |
| 3081 my @afterArgumentList; | 3090 my @afterArgumentList; |
| 3082 | 3091 |
| 3083 my $toActiveDOMObject = "0"; | 3092 my $toActiveDOMObject = "0"; |
| 3084 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { | 3093 if (InheritsExtendedAttribute($interface, "ActiveDOMObject")) { |
| 3085 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject"; | 3094 $toActiveDOMObject = "${v8ClassName}::toActiveDOMObject"; |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 3106 $code .= <<END; | 3115 $code .= <<END; |
| 3107 Document* document = currentDocument(); | 3116 Document* document = currentDocument(); |
| 3108 ASSERT(document); | 3117 ASSERT(document); |
| 3109 | 3118 |
| 3110 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance | 3119 // Make sure the document is added to the DOM Node map. Otherwise, the ${imp lClassName} instance |
| 3111 // may end up being the only node in the map and get garbage-collected prema turely. | 3120 // may end up being the only node in the map and get garbage-collected prema turely. |
| 3112 toV8(document, info.Holder(), info.GetIsolate()); | 3121 toV8(document, info.Holder(), info.GetIsolate()); |
| 3113 | 3122 |
| 3114 END | 3123 END |
| 3115 | 3124 |
| 3116 if ($raisesExceptions) { | 3125 my $hasExceptionState = $raisesExceptions; |
| 3126 if ($hasExceptionState) { | |
| 3117 $code .= " ExceptionState exceptionState(ExceptionState::Construction Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; | 3127 $code .= " ExceptionState exceptionState(ExceptionState::Construction Context, \"${interfaceName}\", info.Holder(), info.GetIsolate());\n"; |
| 3118 } | 3128 } |
| 3119 | |
| 3120 my $hasExceptionState = $raisesExceptions; | |
| 3121 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionSta te); | 3129 $code .= GenerateArgumentsCountCheck($function, $interface, $hasExceptionSta te); |
| 3122 | 3130 |
| 3123 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "", $raisesExceptions); | 3131 my ($parameterCheckString, $paramIndex, %replacements) = GenerateParametersC heck($function, $interface, "", $hasExceptionState); |
| 3124 $code .= $parameterCheckString; | 3132 $code .= $parameterCheckString; |
| 3125 | 3133 |
| 3126 push(@beforeArgumentList, "*document"); | 3134 push(@beforeArgumentList, "*document"); |
| 3127 | 3135 |
| 3128 if ($constructorRaisesException) { | 3136 if ($constructorRaisesException) { |
| 3129 push(@afterArgumentList, "exceptionState"); | 3137 push(@afterArgumentList, "exceptionState"); |
| 3130 } | 3138 } |
| 3131 | 3139 |
| 3132 my @argumentList; | 3140 my @argumentList; |
| 3133 my $index = 0; | 3141 my $index = 0; |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3700 $implementation{nameSpaceInternal}->add($code); | 3708 $implementation{nameSpaceInternal}->add($code); |
| 3701 } | 3709 } |
| 3702 | 3710 |
| 3703 sub GenerateImplementationIndexedPropertySetter | 3711 sub GenerateImplementationIndexedPropertySetter |
| 3704 { | 3712 { |
| 3705 my $interface = shift; | 3713 my $interface = shift; |
| 3706 my $indexedSetterFunction = shift; | 3714 my $indexedSetterFunction = shift; |
| 3707 my $implClassName = GetImplName($interface); | 3715 my $implClassName = GetImplName($interface); |
| 3708 my $v8ClassName = GetV8ClassName($interface); | 3716 my $v8ClassName = GetV8ClassName($interface); |
| 3709 my $methodName = GetImplName($indexedSetterFunction); | 3717 my $methodName = GetImplName($indexedSetterFunction); |
| 3718 my $interfaceName = $interface->name; | |
| 3710 | 3719 |
| 3711 my $type = $indexedSetterFunction->parameters->[1]->type; | 3720 my $type = $indexedSetterFunction->parameters->[1]->type; |
| 3712 my $raisesExceptions = $indexedSetterFunction->extendedAttributes->{"RaisesE xception"}; | 3721 my $raisesExceptions = $indexedSetterFunction->extendedAttributes->{"RaisesE xception"}; |
| 3713 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"}; | 3722 my $treatNullAs = $indexedSetterFunction->parameters->[1]->extendedAttribute s->{"TreatNullAs"}; |
| 3714 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"}; | 3723 my $treatUndefinedAs = $indexedSetterFunction->parameters->[1]->extendedAttr ibutes->{"TreatUndefinedAs"}; |
| 3715 my $asSetterValue = 0; | |
| 3716 | 3724 |
| 3717 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; | 3725 my $code = "static void indexedPropertySetter(uint32_t index, v8::Local<v8:: Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; |
| 3718 $code .= "{\n"; | 3726 $code .= "{\n"; |
| 3727 | |
| 3728 my $extraArguments = ""; | |
| 3729 if ($raisesExceptions || IsIntegerType($type)) { | |
| 3730 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola te());\n"; | |
| 3731 if ($raisesExceptions) { | |
| 3732 $extraArguments = ", exceptionState"; | |
| 3733 } | |
| 3734 } | |
| 3735 | |
| 3736 my $asSetterValue = 0; | |
| 3719 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; | 3737 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; |
| 3720 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "pro pertyValue", " ", "info.GetIsolate()"); | 3738 $code .= JSValueToNativeStatement($indexedSetterFunction->parameters->[1]->t ype, $indexedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "pro pertyValue", " ", "info.GetIsolate()"); |
| 3721 | 3739 |
| 3722 my $extraArguments = ""; | |
| 3723 if ($raisesExceptions) { | |
| 3724 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola te());\n"; | |
| 3725 $extraArguments = ", exceptionState"; | |
| 3726 } | |
| 3727 my @conditions = (); | 3740 my @conditions = (); |
| 3728 my @statements = (); | 3741 my @statements = (); |
| 3729 if ($treatNullAs && $treatNullAs ne "NullString") { | 3742 if ($treatNullAs && $treatNullAs ne "NullString") { |
| 3730 push @conditions, "jsValue->IsNull()"; | 3743 push @conditions, "jsValue->IsNull()"; |
| 3731 push @statements, "collection->${treatNullAs}(index$extraArguments);"; | 3744 push @statements, "collection->${treatNullAs}(index$extraArguments);"; |
| 3732 } | 3745 } |
| 3733 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { | 3746 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { |
| 3734 push @conditions, "jsValue->IsUndefined()"; | 3747 push @conditions, "jsValue->IsUndefined()"; |
| 3735 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;"; | 3748 push @statements, "collection->${treatUndefinedAs}(index$extraArguments) ;"; |
| 3736 } | 3749 } |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4005 $implementation{nameSpaceInternal}->add($code); | 4018 $implementation{nameSpaceInternal}->add($code); |
| 4006 } | 4019 } |
| 4007 | 4020 |
| 4008 sub GenerateImplementationNamedPropertySetter | 4021 sub GenerateImplementationNamedPropertySetter |
| 4009 { | 4022 { |
| 4010 my $interface = shift; | 4023 my $interface = shift; |
| 4011 my $namedSetterFunction = shift; | 4024 my $namedSetterFunction = shift; |
| 4012 my $implClassName = GetImplName($interface); | 4025 my $implClassName = GetImplName($interface); |
| 4013 my $v8ClassName = GetV8ClassName($interface); | 4026 my $v8ClassName = GetV8ClassName($interface); |
| 4014 my $methodName = GetImplName($namedSetterFunction); | 4027 my $methodName = GetImplName($namedSetterFunction); |
| 4028 my $interfaceName = $interface->name; | |
| 4015 | 4029 |
| 4030 my $type = $namedSetterFunction->parameters->[1]->type; | |
| 4016 my $raisesExceptions = $namedSetterFunction->extendedAttributes->{"RaisesExc eption"}; | 4031 my $raisesExceptions = $namedSetterFunction->extendedAttributes->{"RaisesExc eption"}; |
| 4017 my $treatNullAs = $namedSetterFunction->parameters->[1]->extendedAttributes- >{"TreatNullAs"}; | 4032 my $treatNullAs = $namedSetterFunction->parameters->[1]->extendedAttributes- >{"TreatNullAs"}; |
| 4018 my $treatUndefinedAs = $namedSetterFunction->parameters->[1]->extendedAttrib utes->{"TreatUndefinedAs"}; | 4033 my $treatUndefinedAs = $namedSetterFunction->parameters->[1]->extendedAttrib utes->{"TreatUndefinedAs"}; |
| 4019 my $asSetterValue = 0; | |
| 4020 | 4034 |
| 4021 my $code = "static void namedPropertySetter(v8::Local<v8::String> name, v8:: Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; | 4035 my $code = "static void namedPropertySetter(v8::Local<v8::String> name, v8:: Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<v8::Value>& info)\n"; |
| 4022 $code .= "{\n"; | 4036 $code .= "{\n"; |
| 4023 if (!$namedSetterFunction->extendedAttributes->{"OverrideBuiltins"}) { | 4037 if (!$namedSetterFunction->extendedAttributes->{"OverrideBuiltins"}) { |
| 4024 $code .= " if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(n ame).IsEmpty())\n"; | 4038 $code .= " if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(n ame).IsEmpty())\n"; |
| 4025 $code .= " return;\n"; | 4039 $code .= " return;\n"; |
| 4026 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; | 4040 $code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n"; |
| 4027 $code .= " return;\n"; | 4041 $code .= " return;\n"; |
| 4028 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; | 4042 $code .= " if (info.Holder()->HasRealNamedProperty(name))\n"; |
| 4029 $code .= " return;\n"; | 4043 $code .= " return;\n"; |
| 4030 } | 4044 } |
| 4045 | |
| 4046 my $extraArguments = ""; | |
| 4047 if ($raisesExceptions || IsIntegerType($type)) { | |
| 4048 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola te());\n"; | |
| 4049 if ($raisesExceptions) { | |
| 4050 $extraArguments = ", exceptionState"; | |
| 4051 } | |
| 4052 } | |
| 4053 | |
| 4054 my $asSetterValue = 0; | |
| 4031 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; | 4055 $code .= " ${implClassName}* collection = ${v8ClassName}::toNative(info.H older());\n"; |
| 4032 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "name", "propertyNa me", " ", "info.GetIsolate()"); | 4056 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[0]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "name", "propertyNa me", " ", "info.GetIsolate()"); |
| 4033 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "propert yValue", " ", "info.GetIsolate()"); | 4057 $code .= JSValueToNativeStatement($namedSetterFunction->parameters->[1]->typ e, $namedSetterFunction->extendedAttributes, $asSetterValue, "jsValue", "propert yValue", " ", "info.GetIsolate()"); |
| 4034 my $extraArguments = ""; | |
| 4035 if ($raisesExceptions) { | |
| 4036 $code .= " ExceptionState exceptionState(info.Holder(), info.GetIsola te());\n"; | |
| 4037 $extraArguments = ", exceptionState"; | |
| 4038 } | |
| 4039 | 4058 |
| 4040 my @conditions = (); | 4059 my @conditions = (); |
| 4041 my @statements = (); | 4060 my @statements = (); |
| 4042 if ($treatNullAs && $treatNullAs ne "NullString") { | 4061 if ($treatNullAs && $treatNullAs ne "NullString") { |
| 4043 push @conditions, "jsValue->IsNull()"; | 4062 push @conditions, "jsValue->IsNull()"; |
| 4044 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);"; | 4063 push @statements, "collection->${treatNullAs}(propertyName$extraArgument s);"; |
| 4045 } | 4064 } |
| 4046 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { | 4065 if ($treatUndefinedAs && $treatUndefinedAs ne "NullString") { |
| 4047 push @conditions, "jsValue->IsUndefined()"; | 4066 push @conditions, "jsValue->IsUndefined()"; |
| 4048 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);"; | 4067 push @statements, "collection->${treatUndefinedAs}(propertyName$extraArg uments);"; |
| (...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5180 return "WebCore"; | 5199 return "WebCore"; |
| 5181 } | 5200 } |
| 5182 | 5201 |
| 5183 sub GenerateFunctionCallString | 5202 sub GenerateFunctionCallString |
| 5184 { | 5203 { |
| 5185 my $function = shift; | 5204 my $function = shift; |
| 5186 my $numberOfParameters = shift; | 5205 my $numberOfParameters = shift; |
| 5187 my $indent = shift; | 5206 my $indent = shift; |
| 5188 my $interface = shift; | 5207 my $interface = shift; |
| 5189 my $forMainWorldSuffix = shift; | 5208 my $forMainWorldSuffix = shift; |
| 5209 my $hasExceptionState = shift; | |
| 5190 my %replacements = @_; | 5210 my %replacements = @_; |
| 5191 | 5211 |
| 5192 my $interfaceName = $interface->name; | 5212 my $interfaceName = $interface->name; |
| 5193 my $implClassName = GetImplName($interface); | 5213 my $implClassName = GetImplName($interface); |
| 5194 my $name = GetImplName($function); | 5214 my $name = GetImplName($function); |
| 5195 my $returnType = $function->type; | 5215 my $returnType = $function->type; |
| 5196 my $nativeReturnType = GetNativeType($returnType, {}, ""); | 5216 my $nativeReturnType = GetNativeType($returnType, {}, ""); |
| 5197 my $code = ""; | 5217 my $code = ""; |
| 5198 | 5218 |
| 5199 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf aceName =~ /List$/); | 5219 my $isSVGTearOffType = (IsSVGTypeNeedingTearOff($returnType) and not $interf aceName =~ /List$/); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 5229 if ($index eq $numberOfParameters) { | 5249 if ($index eq $numberOfParameters) { |
| 5230 last; | 5250 last; |
| 5231 } | 5251 } |
| 5232 my $paramName = $parameter->name; | 5252 my $paramName = $parameter->name; |
| 5233 my $paramType = $parameter->type; | 5253 my $paramType = $parameter->type; |
| 5234 | 5254 |
| 5235 if ($replacements{$paramName}) { | 5255 if ($replacements{$paramName}) { |
| 5236 push @arguments, $replacements{$paramName}; | 5256 push @arguments, $replacements{$paramName}; |
| 5237 } elsif (IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceNam e =~ /List$/) { | 5257 } elsif (IsSVGTypeNeedingTearOff($parameter->type) and not $interfaceNam e =~ /List$/) { |
| 5238 push @arguments, "$paramName->propertyReference()"; | 5258 push @arguments, "$paramName->propertyReference()"; |
| 5239 $code .= <<END; | 5259 if ($hasExceptionState) { |
| 5260 $code .= <<END; | |
| 5261 if (!$paramName) { | |
| 5262 exceptionState.throwTypeError(\"parameter $humanFriendlyIndex is not of type '${ \$parameter->type }'.\"); | |
| 5263 exceptionState.throwIfNeeded(); | |
| 5264 return; | |
| 5265 } | |
| 5266 END | |
| 5267 } else { | |
| 5268 $code .= <<END; | |
| 5240 if (!$paramName) { | 5269 if (!$paramName) { |
| 5241 throwTypeError(ExceptionMessages::failedToExecute(\"$name\", \"$interfac eName\", \"parameter $humanFriendlyIndex is not of type '${ \$parameter->type }' .\"), info.GetIsolate()); | 5270 throwTypeError(ExceptionMessages::failedToExecute(\"$name\", \"$interfac eName\", \"parameter $humanFriendlyIndex is not of type '${ \$parameter->type }' .\"), info.GetIsolate()); |
| 5242 return; | 5271 return; |
| 5243 } | 5272 } |
| 5244 END | 5273 END |
| 5274 } | |
| 5245 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") { | 5275 } elsif ($parameter->type eq "SVGMatrix" and $interfaceName eq "SVGTrans formList") { |
| 5246 push @arguments, "$paramName.get()"; | 5276 push @arguments, "$paramName.get()"; |
| 5247 } elsif (IsNullableParameter($parameter)) { | 5277 } elsif (IsNullableParameter($parameter)) { |
| 5248 push @arguments, "${paramName}IsNull ? 0 : &$paramName"; | 5278 push @arguments, "${paramName}IsNull ? 0 : &$paramName"; |
| 5249 } elsif (IsCallbackInterface($paramType) or $paramType eq "NodeFilter" o r $paramType eq "XPathNSResolver") { | 5279 } elsif (IsCallbackInterface($paramType) or $paramType eq "NodeFilter" o r $paramType eq "XPathNSResolver") { |
| 5250 push @arguments, "$paramName.release()"; | 5280 push @arguments, "$paramName.release()"; |
| 5251 } else { | 5281 } else { |
| 5252 push @arguments, $paramName; | 5282 push @arguments, $paramName; |
| 5253 } | 5283 } |
| 5254 $index++; | 5284 $index++; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5423 my $nativeType = GetNativeType($type, $extendedAttributes, "parameter"); | 5453 my $nativeType = GetNativeType($type, $extendedAttributes, "parameter"); |
| 5424 my $native_value = JSValueToNative($type, $extendedAttributes, $argIndexOrZe ro, $jsValue, $getIsolate); | 5454 my $native_value = JSValueToNative($type, $extendedAttributes, $argIndexOrZe ro, $jsValue, $getIsolate); |
| 5425 my $code = ""; | 5455 my $code = ""; |
| 5426 if ($type eq "DOMString" || IsEnumType($type)) { | 5456 if ($type eq "DOMString" || IsEnumType($type)) { |
| 5427 die "Wrong native type passed: $nativeType" unless $nativeType =~ /^V8St ringResource/; | 5457 die "Wrong native type passed: $nativeType" unless $nativeType =~ /^V8St ringResource/; |
| 5428 if ($type eq "DOMString" or IsEnumType($type)) { | 5458 if ($type eq "DOMString" or IsEnumType($type)) { |
| 5429 $code .= $indent . "V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID($nativeType , $variableName, $native_value);\n" | 5459 $code .= $indent . "V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID($nativeType , $variableName, $native_value);\n" |
| 5430 } else { | 5460 } else { |
| 5431 $code .= $indent . "$nativeType $variableName($native_value, true);\ n"; | 5461 $code .= $indent . "$nativeType $variableName($native_value, true);\ n"; |
| 5432 } | 5462 } |
| 5433 } elsif ($extendedAttributes->{"EnforceRange"}) { | 5463 } elsif (IsIntegerType($type)) { |
| 5434 $code .= $indent . "V8TRYCATCH_WITH_TYPECHECK_VOID($nativeType, $variabl eName, $native_value, $getIsolate);\n"; | 5464 $code .= $indent . "V8TRYCATCH_EXCEPTION_VOID($nativeType, $variableName , $native_value, exceptionState);\n"; |
| 5435 } else { | 5465 } else { |
| 5436 $code .= $indent . "V8TRYCATCH_VOID($nativeType, $variableName, $native_ value);\n"; | 5466 $code .= $indent . "V8TRYCATCH_VOID($nativeType, $variableName, $native_ value);\n"; |
| 5437 } | 5467 } |
| 5438 return $code; | 5468 return $code; |
| 5439 } | 5469 } |
| 5440 | 5470 |
| 5441 | 5471 |
| 5442 sub JSValueToNative | 5472 sub JSValueToNative |
| 5443 { | 5473 { |
| 5444 my $type = shift; | 5474 my $type = shift; |
| 5445 my $extendedAttributes = shift; | 5475 my $extendedAttributes = shift; |
| 5446 # Argument position (1-indexed) or 0 if for a setter's value. | 5476 # Argument position (1-indexed) or 0 if for a setter's value. |
| 5447 my $argIndexOrZero = shift; | 5477 my $argIndexOrZero = shift; |
| 5448 my $value = shift; | 5478 my $value = shift; |
| 5449 my $getIsolate = shift; | 5479 my $getIsolate = shift; |
| 5450 | 5480 |
| 5451 my $intConversion = $extendedAttributes->{"EnforceRange"} ? "EnforceRange" : "NormalConversion"; | |
| 5452 | |
| 5453 return "$value->BooleanValue()" if $type eq "boolean"; | 5481 return "$value->BooleanValue()" if $type eq "boolean"; |
| 5454 return "static_cast<$type>($value->NumberValue())" if $type eq "float" or $t ype eq "double"; | 5482 return "static_cast<$type>($value->NumberValue())" if $type eq "float" or $t ype eq "double"; |
| 5455 | 5483 |
| 5456 if ($intConversion ne "NormalConversion") { | 5484 if (IsIntegerType($type)) { |
| 5457 return "toInt8($value, $intConversion, ok)" if $type eq "byte"; | 5485 my $conversion = "to" . $integerTypeHash{$type} . "($value"; |
| 5458 return "toUInt8($value, $intConversion, ok)" if $type eq "octet"; | 5486 if ($extendedAttributes->{"EnforceRange"}) { |
| 5459 return "toInt16($value, $intConversion, ok)" if $type eq "short"; | 5487 return "${conversion}, EnforceRange, exceptionState)"; |
| 5460 return "toUInt16($value, $intConversion, ok)" if $type eq "unsigned shor t"; | 5488 } else { |
| 5461 return "toInt32($value, $intConversion, ok)" if $type eq "long"; | 5489 return "${conversion}, exceptionState)"; |
| 5462 return "toUInt32($value, $intConversion, ok)" if $type eq "unsigned long "; | 5490 } |
| 5463 return "toInt64($value, $intConversion, ok)" if $type eq "long long"; | |
| 5464 return "toUInt64($value, $intConversion, ok)" if $type eq "unsigned long long"; | |
| 5465 } else { | |
| 5466 return "toInt8($value)" if $type eq "byte"; | |
| 5467 return "toUInt8($value)" if $type eq "octet"; | |
| 5468 return "toInt16($value)" if $type eq "short"; | |
| 5469 return "toUInt16($value)" if $type eq "unsigned short"; | |
| 5470 return "toInt32($value)" if $type eq "long"; | |
| 5471 return "toUInt32($value)" if $type eq "unsigned long"; | |
| 5472 return "toInt64($value)" if $type eq "long long"; | |
| 5473 return "toUInt64($value)" if $type eq "unsigned long long"; | |
| 5474 } | 5491 } |
| 5475 return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "C ompareHow"; | 5492 return "static_cast<Range::CompareHow>($value->Int32Value())" if $type eq "C ompareHow"; |
| 5476 return "toWebCoreDate($value)" if $type eq "Date"; | 5493 return "toWebCoreDate($value)" if $type eq "Date"; |
| 5477 | 5494 |
| 5478 if ($type eq "DOMString" or IsEnumType($type)) { | 5495 if ($type eq "DOMString" or IsEnumType($type)) { |
| 5479 return $value; | 5496 return $value; |
| 5480 } | 5497 } |
| 5481 | 5498 |
| 5482 if ($type eq "SerializedScriptValue") { | 5499 if ($type eq "SerializedScriptValue") { |
| 5483 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); | 5500 AddToImplIncludes("bindings/v8/SerializedScriptValue.h"); |
| (...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6369 my $interface = shift; | 6386 my $interface = shift; |
| 6370 | 6387 |
| 6371 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "ToV8"); | 6388 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "ToV8"); |
| 6372 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "Wrap"); | 6389 return 1 if ExtendedAttributeContains($interface->extendedAttributes->{"Cust om"}, "Wrap"); |
| 6373 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6390 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
| 6374 return 1 if InheritsInterface($interface, "Document"); | 6391 return 1 if InheritsInterface($interface, "Document"); |
| 6375 | 6392 |
| 6376 return 0; | 6393 return 0; |
| 6377 } | 6394 } |
| 6378 | 6395 |
| 6379 sub HasSerializedScriptValueParameter | 6396 sub HasExceptionRaisingParameter |
| 6380 { | 6397 { |
| 6381 my $function = shift; | 6398 my $function = shift; |
| 6382 | 6399 |
| 6383 foreach my $parameter (@{$function->parameters}) { | 6400 foreach my $parameter (@{$function->parameters}) { |
| 6384 if ($parameter->type eq "SerializedScriptValue") { | 6401 if ($parameter->type eq "SerializedScriptValue") { |
| 6385 return 1; | 6402 return 1; |
| 6403 } elsif (IsIntegerType($parameter->type)) { | |
| 6404 return 1; | |
| 6386 } | 6405 } |
| 6387 } | 6406 } |
| 6388 return 0; | 6407 return 0; |
| 6389 } | 6408 } |
| 6390 | 6409 |
| 6391 1; | 6410 1; |
| OLD | NEW |