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 1539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1550 $code .= " return v8Array(${getterString}, info.GetIsolate());\n" ; | 1550 $code .= " return v8Array(${getterString}, info.GetIsolate());\n" ; |
| 1551 $code .= "}\n\n"; | 1551 $code .= "}\n\n"; |
| 1552 $implementation{nameSpaceInternal}->add($code); | 1552 $implementation{nameSpaceInternal}->add($code); |
| 1553 return; | 1553 return; |
| 1554 } | 1554 } |
| 1555 | 1555 |
| 1556 AddIncludesForType($returnType); | 1556 AddIncludesForType($returnType); |
| 1557 AddToImplIncludes("bindings/v8/V8HiddenPropertyName.h"); | 1557 AddToImplIncludes("bindings/v8/V8HiddenPropertyName.h"); |
| 1558 # Check for a wrapper in the wrapper cache. If there is one, we know tha t a hidden reference has already | 1558 # Check for a wrapper in the wrapper cache. If there is one, we know tha t a hidden reference has already |
| 1559 # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. | 1559 # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference. |
| 1560 $code .= " RefPtr<$returnType> result = ${getterString};\n"; | 1560 my $nativeReturnType = GetNativeType($returnType); |
| 1561 $code .= " $nativeReturnType result = ${getterString};\n"; | |
| 1561 if ($forMainWorldSuffix) { | 1562 if ($forMainWorldSuffix) { |
| 1562 $code .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper${forMainWorldSuffix}(result.get())) : v8Un defined();\n"; | 1563 $code .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper${forMainWorldSuffix}(result.get())) : v8Un defined();\n"; |
| 1563 } else { | 1564 } else { |
| 1564 $code .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Unde fined();\n"; | 1565 $code .= " v8::Handle<v8::Value> wrapper = result.get() ? v8::Handl e<v8::Value>(DOMDataStore::getWrapper(result.get(), info.GetIsolate())) : v8Unde fined();\n"; |
| 1565 } | 1566 } |
| 1566 $code .= " if (wrapper.IsEmpty()) {\n"; | 1567 $code .= " if (wrapper.IsEmpty()) {\n"; |
| 1567 $code .= " wrapper = toV8(result.get(), info.Holder(), info.GetIs olate());\n"; # FIXME: Could use wrap here since the wrapper is empty. | 1568 $code .= " wrapper = toV8(result.get(), info.Holder(), info.GetIs olate());\n"; # FIXME: Could use wrap here since the wrapper is empty. |
| 1568 $code .= " if (!wrapper.IsEmpty())\n"; | 1569 $code .= " if (!wrapper.IsEmpty())\n"; |
| 1569 $code .= " V8HiddenPropertyName::setNamedHiddenReference(info .Holder(), \"${attrName}\", wrapper);\n"; | 1570 $code .= " V8HiddenPropertyName::setNamedHiddenReference(info .Holder(), \"${attrName}\", wrapper);\n"; |
| 1570 $code .= " }\n"; | 1571 $code .= " }\n"; |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2378 my $paramIndex = 0; | 2379 my $paramIndex = 0; |
| 2379 my %replacements = (); | 2380 my %replacements = (); |
| 2380 | 2381 |
| 2381 foreach my $parameter (@{$function->parameters}) { | 2382 foreach my $parameter (@{$function->parameters}) { |
| 2382 my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); | 2383 my $nativeType = GetNativeTypeFromSignature($parameter, $paramIndex); |
| 2383 | 2384 |
| 2384 # Optional arguments without [Default=...] should generate an early call with fewer arguments. | 2385 # Optional arguments without [Default=...] should generate an early call with fewer arguments. |
| 2385 # Optional arguments with [Optional=...] should not generate the early c all. | 2386 # Optional arguments with [Optional=...] should not generate the early c all. |
| 2386 # Optional Dictionary arguments always considered to have default of emp ty dictionary. | 2387 # Optional Dictionary arguments always considered to have default of emp ty dictionary. |
| 2387 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default "} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { | 2388 if ($parameter->isOptional && !$parameter->extendedAttributes->{"Default "} && $nativeType ne "Dictionary" && !IsCallbackInterface($parameter->type)) { |
| 2388 $parameterCheckString .= " if (args.Length() <= $paramIndex) {\n" ; | 2389 $parameterCheckString .= " if (args.Length() <= $paramIndex)"; |
| 2389 my $functionCall = GenerateFunctionCallString($function, $paramIndex , " " x 2, $interface, $forMainWorldSuffix, %replacements); | 2390 my $functionCall = GenerateFunctionCallString($function, $paramIndex , " " x 2, $interface, $forMainWorldSuffix, %replacements); |
| 2391 my $multiLine = ($functionCall =~ tr/\n//) > 1; | |
|
haraken
2013/05/13 13:53:28
Actually I don't want to mess up the code generato
| |
| 2392 $parameterCheckString .= $multiLine ? " {\n" : "\n"; | |
| 2390 $parameterCheckString .= $functionCall; | 2393 $parameterCheckString .= $functionCall; |
| 2391 $parameterCheckString .= " }\n"; | 2394 $parameterCheckString .= $multiLine ? " }\n" : "\n"; |
| 2392 } | 2395 } |
| 2393 | 2396 |
| 2394 my $parameterDefaultPolicy = "DefaultIsUndefined"; | 2397 my $parameterDefaultPolicy = "DefaultIsUndefined"; |
| 2395 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par ameter->extendedAttributes->{"Default"} : ""; | 2398 my $default = defined $parameter->extendedAttributes->{"Default"} ? $par ameter->extendedAttributes->{"Default"} : ""; |
| 2396 if ($parameter->isOptional and $default eq "NullString") { | 2399 if ($parameter->isOptional and $default eq "NullString") { |
| 2397 $parameterDefaultPolicy = "DefaultIsNullString"; | 2400 $parameterDefaultPolicy = "DefaultIsNullString"; |
| 2398 } | 2401 } |
| 2399 | 2402 |
| 2400 my $parameterName = $parameter->name; | 2403 my $parameterName = $parameter->name; |
| 2401 AddToImplIncludes("core/dom/ExceptionCode.h"); | 2404 AddToImplIncludes("core/dom/ExceptionCode.h"); |
| (...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3954 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. | 3957 UNUSED_PARAM(defaultSignature); // In some cases, it will not be used. |
| 3955 | 3958 |
| 3956 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo ntext()); | 3959 ScriptExecutionContext* context = toScriptExecutionContext(proto->CreationCo ntext()); |
| 3957 END | 3960 END |
| 3958 | 3961 |
| 3959 foreach my $runtimeFunc (@enabledPerContextFunctions) { | 3962 foreach my $runtimeFunc (@enabledPerContextFunctions) { |
| 3960 my $enableFunction = GetContextEnableFunction($runtimeFunc->signatur e); | 3963 my $enableFunction = GetContextEnableFunction($runtimeFunc->signatur e); |
| 3961 my $functionLength = GetFunctionLength($runtimeFunc); | 3964 my $functionLength = GetFunctionLength($runtimeFunc); |
| 3962 my $conditionalString = GenerateConditionalString($runtimeFunc->sign ature); | 3965 my $conditionalString = GenerateConditionalString($runtimeFunc->sign ature); |
| 3963 $code .= "\n#if ${conditionalString}\n" if $conditionalString; | 3966 $code .= "\n#if ${conditionalString}\n" if $conditionalString; |
| 3964 $code .= " if (context && context->isDocument() && ${enableFuncti on}(toDocument(context))) {\n"; | 3967 $code .= " if (context && context->isDocument() && ${enableFuncti on}(toDocument(context)))\n"; |
| 3965 my $name = $runtimeFunc->signature->name; | 3968 my $name = $runtimeFunc->signature->name; |
| 3966 $code .= <<END; | 3969 $code .= <<END; |
| 3967 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($ {implClassName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur e, $functionLength)->GetFunction()); | 3970 proto->Set(v8::String::NewSymbol("${name}"), v8::FunctionTemplate::New($ {implClassName}V8Internal::${name}MethodCallback, v8Undefined(), defaultSignatur e, $functionLength)->GetFunction()); |
| 3968 END | 3971 END |
| 3969 $code .= " }\n"; | |
| 3970 $code .= "#endif // ${conditionalString}\n" if $conditionalString; | 3972 $code .= "#endif // ${conditionalString}\n" if $conditionalString; |
| 3971 } | 3973 } |
| 3972 | 3974 |
| 3973 $code .= <<END; | 3975 $code .= <<END; |
| 3974 } | 3976 } |
| 3975 | 3977 |
| 3976 END | 3978 END |
| 3977 $implementation{nameSpaceWebCore}->add($code); | 3979 $implementation{nameSpaceWebCore}->add($code); |
| 3978 } | 3980 } |
| 3979 | 3981 |
| (...skipping 1694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5674 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { | 5676 if ($currentInterface->extendedAttributes->{$extendedAttribute}) { |
| 5675 $found = 1; | 5677 $found = 1; |
| 5676 } | 5678 } |
| 5677 return 1 if $found; | 5679 return 1 if $found; |
| 5678 }, 0); | 5680 }, 0); |
| 5679 | 5681 |
| 5680 return $found; | 5682 return $found; |
| 5681 } | 5683 } |
| 5682 | 5684 |
| 5683 1; | 5685 1; |
| OLD | NEW |