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 2535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2546 $parameterCheckString .= <<END; | 2546 $parameterCheckString .= <<END; |
| 2547 return; | 2547 return; |
| 2548 } | 2548 } |
| 2549 END | 2549 END |
| 2550 } | 2550 } |
| 2551 | 2551 |
| 2552 my $parameterName = $parameter->name; | 2552 my $parameterName = $parameter->name; |
| 2553 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); | 2553 AddToImplIncludes("bindings/v8/ExceptionMessages.h"); |
| 2554 AddToImplIncludes("bindings/v8/ExceptionState.h"); | 2554 AddToImplIncludes("bindings/v8/ExceptionState.h"); |
| 2555 if (IsCallbackInterface($parameter->type)) { | 2555 if (IsCallbackInterface($parameter->type)) { |
| 2556 my $ptrType = IsLegacyRefCountedCallback($parameter->type) ? "Ref" : "Own"; | |
| 2556 my $v8ClassName = "V8" . $parameter->type; | 2557 my $v8ClassName = "V8" . $parameter->type; |
| 2557 AddToImplIncludes("$v8ClassName.h"); | 2558 AddToImplIncludes("$v8ClassName.h"); |
| 2558 if ($parameter->isOptional) { | 2559 if ($parameter->isOptional) { |
| 2559 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName;\n"; | 2560 $parameterCheckString .= " ${ptrType}Ptr<" . $parameter->type . "> $parameterName;\n"; |
| 2560 $parameterCheckString .= " if (info.Length() > $paramIndex && !info[$paramIndex]->IsNull() && !info[$paramIndex]->IsUndefined()) {\n"; | 2561 $parameterCheckString .= " if (info.Length() > $paramIndex && !info[$paramIndex]->IsNull() && !info[$paramIndex]->IsUndefined()) {\n"; |
| 2561 $parameterCheckString .= " if (!info[$paramIndex]->IsFunc tion()) {\n"; | 2562 $parameterCheckString .= " if (!info[$paramIndex]->IsFunc tion()) {\n"; |
| 2562 $parameterCheckString .= " throwTypeError(ExceptionMe ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback pr ovided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate() );\n"; | 2563 $parameterCheckString .= " throwTypeError(ExceptionMe ssages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback pr ovided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate() );\n"; |
| 2563 $parameterCheckString .= " return;\n"; | 2564 $parameterCheckString .= " return;\n"; |
| 2564 $parameterCheckString .= " }\n"; | 2565 $parameterCheckString .= " }\n"; |
| 2565 $parameterCheckString .= " $parameterName = ${v8ClassName }::create(info[$paramIndex], getExecutionContext());\n"; | 2566 $parameterCheckString .= " $parameterName = ${v8ClassName }::create(info[$paramIndex], getExecutionContext());\n"; |
| 2566 $parameterCheckString .= " }\n"; | 2567 $parameterCheckString .= " }\n"; |
| 2567 } else { | 2568 } else { |
| 2568 $parameterCheckString .= " if (info.Length() <= $paramIndex | | "; | 2569 $parameterCheckString .= " if (info.Length() <= $paramIndex | | "; |
| 2569 if ($parameter->isNullable) { | 2570 if ($parameter->isNullable) { |
| 2570 $parameterCheckString .= "!(info[$paramIndex]->IsFunction() || info[$paramIndex]->IsNull())"; | 2571 $parameterCheckString .= "!(info[$paramIndex]->IsFunction() || info[$paramIndex]->IsNull())"; |
| 2571 } else { | 2572 } else { |
| 2572 $parameterCheckString .= "!info[$paramIndex]->IsFunction()"; | 2573 $parameterCheckString .= "!info[$paramIndex]->IsFunction()"; |
| 2573 } | 2574 } |
| 2574 $parameterCheckString .= ") {\n"; | 2575 $parameterCheckString .= ") {\n"; |
| 2575 $parameterCheckString .= " throwTypeError(ExceptionMessag es::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provid ed as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n "; | 2576 $parameterCheckString .= " throwTypeError(ExceptionMessag es::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provid ed as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n "; |
| 2576 $parameterCheckString .= " return;\n"; | 2577 $parameterCheckString .= " return;\n"; |
| 2577 $parameterCheckString .= " }\n"; | 2578 $parameterCheckString .= " }\n"; |
| 2578 $parameterCheckString .= " RefPtr<" . $parameter->type . "> $ parameterName = "; | 2579 $parameterCheckString .= " ${ptrType}Ptr<" . $parameter->type . "> $parameterName = "; |
| 2579 $parameterCheckString .= "info[$paramIndex]->IsNull() ? 0 : " if $parameter->isNullable; | 2580 $parameterCheckString .= "info[$paramIndex]->IsNull() ? nullptr : " if $parameter->isNullable; |
| 2580 $parameterCheckString .= "${v8ClassName}::create(info[$paramInde x], getExecutionContext());\n"; | 2581 $parameterCheckString .= "${v8ClassName}::create(info[$paramInde x], getExecutionContext());\n"; |
| 2581 } | 2582 } |
| 2582 } elsif ($parameter->extendedAttributes->{"Clamp"}) { | 2583 } elsif ($parameter->extendedAttributes->{"Clamp"}) { |
| 2583 my $nativeValue = "${parameterName}NativeValue"; | 2584 my $nativeValue = "${parameterName}NativeValue"; |
| 2584 my $idlType = $parameter->type; | 2585 my $idlType = $parameter->type; |
| 2585 $parameterCheckString .= " $nativeType $parameterName = 0;\n" ; | 2586 $parameterCheckString .= " $nativeType $parameterName = 0;\n" ; |
| 2586 $parameterCheckString .= " V8TRYCATCH_VOID(double, $nativeVal ue, info[$paramIndex]->NumberValue());\n"; | 2587 $parameterCheckString .= " V8TRYCATCH_VOID(double, $nativeVal ue, info[$paramIndex]->NumberValue());\n"; |
| 2587 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; | 2588 $parameterCheckString .= " if (!std::isnan($nativeValue))\n"; |
| 2588 $parameterCheckString .= " $parameterName = clampTo<$idlT ype>($nativeValue);\n"; | 2589 $parameterCheckString .= " $parameterName = clampTo<$idlT ype>($nativeValue);\n"; |
| 2589 } elsif ($parameter->type eq "SerializedScriptValue") { | 2590 } elsif ($parameter->type eq "SerializedScriptValue") { |
| (...skipping 2181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4771 } | 4772 } |
| 4772 | 4773 |
| 4773 sub GenerateCallbackHeader | 4774 sub GenerateCallbackHeader |
| 4774 { | 4775 { |
| 4775 my $object = shift; | 4776 my $object = shift; |
| 4776 my $interface = shift; | 4777 my $interface = shift; |
| 4777 | 4778 |
| 4778 my $interfaceName = $interface->name; | 4779 my $interfaceName = $interface->name; |
| 4779 my $implClassName = GetImplName($interface); | 4780 my $implClassName = GetImplName($interface); |
| 4780 my $v8ClassName = GetV8ClassName($interface); | 4781 my $v8ClassName = GetV8ClassName($interface); |
| 4782 my $refCounted = IsLegacyRefCountedCallback($interfaceName); | |
| 4783 my $ptrType = $refCounted ? "Ref" : "Own"; | |
| 4784 my $adoptType = $refCounted ? "Ref" : "Ptr"; | |
| 4781 | 4785 |
| 4782 my @includes = (); | 4786 my @includes = (); |
| 4783 push(@includes, "bindings/v8/ActiveDOMCallback.h"); | 4787 push(@includes, "bindings/v8/ActiveDOMCallback.h"); |
| 4784 push(@includes, "bindings/v8/DOMWrapperWorld.h"); | 4788 push(@includes, "bindings/v8/DOMWrapperWorld.h"); |
| 4785 push(@includes, "bindings/v8/ScopedPersistent.h"); | 4789 push(@includes, "bindings/v8/ScopedPersistent.h"); |
| 4786 push(@includes, HeaderFilesForInterface($interfaceName, $implClassName)); | 4790 push(@includes, HeaderFilesForInterface($interfaceName, $implClassName)); |
| 4787 for my $include (sort @includes) { | 4791 for my $include (sort @includes) { |
| 4788 $header{includes}->add("#include \"$include\"\n"); | 4792 $header{includes}->add("#include \"$include\"\n"); |
| 4789 } | 4793 } |
| 4790 $header{nameSpaceWebCore}->addHeader("\nclass ExecutionContext;\n"); | 4794 $header{nameSpaceWebCore}->addHeader("\nclass ExecutionContext;\n"); |
| 4791 $header{class}->addHeader("class $v8ClassName : public $implClassName, publi c ActiveDOMCallback {"); | 4795 $header{class}->addHeader("class $v8ClassName : public $implClassName, publi c ActiveDOMCallback {"); |
| 4792 $header{class}->addFooter("};\n"); | 4796 $header{class}->addFooter("};\n"); |
| 4793 | 4797 |
| 4794 $header{classPublic}->add(<<END); | 4798 $header{classPublic}->add(<<END); |
| 4795 static PassRefPtr<${v8ClassName}> create(v8::Handle<v8::Value> jsValue, Exec utionContext* context) | 4799 static Pass${ptrType}Ptr<${v8ClassName}> create(v8::Handle<v8::Value> jsValu e, ExecutionContext* context) |
| 4796 { | 4800 { |
| 4797 ASSERT(jsValue->IsObject()); | 4801 ASSERT(jsValue->IsObject()); |
| 4798 ASSERT(context); | 4802 ASSERT(context); |
| 4799 return adoptRef(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(jsValue) , context)); | 4803 return adopt${adoptType}(new ${v8ClassName}(v8::Handle<v8::Object>::Cast (jsValue), context)); |
| 4800 } | 4804 } |
| 4801 | 4805 |
| 4802 virtual ~${v8ClassName}(); | 4806 virtual ~${v8ClassName}(); |
| 4803 | 4807 |
| 4804 END | 4808 END |
| 4805 | 4809 |
| 4806 # Functions | 4810 # Functions |
| 4807 my $numFunctions = @{$interface->functions}; | 4811 my $numFunctions = @{$interface->functions}; |
| 4808 if ($numFunctions > 0) { | 4812 if ($numFunctions > 0) { |
| 4809 foreach my $function (@{$interface->functions}) { | 4813 foreach my $function (@{$interface->functions}) { |
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6345 my $interface = shift; | 6349 my $interface = shift; |
| 6346 | 6350 |
| 6347 return 1 if $interface->extendedAttributes->{"CustomToV8"}; | 6351 return 1 if $interface->extendedAttributes->{"CustomToV8"}; |
| 6348 return 1 if $interface->extendedAttributes->{"CustomWrap"}; | 6352 return 1 if $interface->extendedAttributes->{"CustomWrap"}; |
| 6349 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; | 6353 return 1 if $interface->extendedAttributes->{"SpecialWrapFor"}; |
| 6350 return 1 if InheritsInterface($interface, "Document"); | 6354 return 1 if InheritsInterface($interface, "Document"); |
| 6351 | 6355 |
| 6352 return 0; | 6356 return 0; |
| 6353 } | 6357 } |
| 6354 | 6358 |
| 6359 sub IsLegacyRefCountedCallback | |
|
abarth-chromium
2013/11/26 21:50:16
Should this be an IDL attribute instead of hard-co
adamk
2013/11/26 21:54:28
That would require having the attributes of an int
haraken
2013/11/27 00:37:11
Yeah.
Shall we add a FIXME that IsLegacyRefCounte
| |
| 6360 { | |
| 6361 my $name = shift; | |
| 6362 # WebSQL | |
| 6363 return 1 if $name eq "DatabaseCallback"; | |
| 6364 return 1 if $name eq "SQLTransactionCallback"; | |
| 6365 return 1 if $name eq "SQLTransactionErrorCallback"; | |
| 6366 return 1 if $name eq "SQLTransactionSyncCallback"; | |
| 6367 return 1 if $name eq "SQLStatementCallback"; | |
| 6368 return 1 if $name eq "SQLStatementErrorCallback"; | |
| 6369 # Filesystem | |
| 6370 return 1 if $name eq "EntryCallback"; | |
| 6371 return 1 if $name eq "EntriesCallback"; | |
| 6372 return 1 if $name eq "ErrorCallback"; | |
| 6373 return 1 if $name eq "FileCallback"; | |
| 6374 return 1 if $name eq "FileSystemCallback"; | |
| 6375 return 1 if $name eq "FileWriterCallback"; | |
| 6376 return 1 if $name eq "MetadataCallback"; | |
| 6377 # requestAnimationFrame | |
| 6378 return 1 if $name eq "RequestAnimationFrameCallback"; | |
| 6379 # Used everywhere | |
| 6380 return 1 if $name eq "VoidCallback"; | |
| 6381 return 0; | |
| 6382 } | |
| 6383 | |
| 6355 1; | 6384 1; |
| OLD | NEW |