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

Unified Diff: Source/bindings/scripts/code_generator_v8.pm

Issue 85263006: Make IDL Callbacks non-refcounted by default (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Refinements Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestCallback.h » ('j') | Source/bindings/v8/V8Callback.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/code_generator_v8.pm
diff --git a/Source/bindings/scripts/code_generator_v8.pm b/Source/bindings/scripts/code_generator_v8.pm
index 86495c8223dcc36a3c089548bbe258939f3e0ebe..0e86ae99b7aae40ad72e81c2b3e8deb4a16033a3 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -2553,10 +2553,11 @@ END
AddToImplIncludes("bindings/v8/ExceptionMessages.h");
AddToImplIncludes("bindings/v8/ExceptionState.h");
if (IsCallbackInterface($parameter->type)) {
+ my $ptrType = IsLegacyRefCountedCallback($parameter->type) ? "Ref" : "Own";
my $v8ClassName = "V8" . $parameter->type;
AddToImplIncludes("$v8ClassName.h");
if ($parameter->isOptional) {
- $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName;\n";
+ $parameterCheckString .= " ${ptrType}Ptr<" . $parameter->type . "> $parameterName;\n";
$parameterCheckString .= " if (info.Length() > $paramIndex && !info[$paramIndex]->IsNull() && !info[$paramIndex]->IsUndefined()) {\n";
$parameterCheckString .= " if (!info[$paramIndex]->IsFunction()) {\n";
$parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n";
@@ -2575,8 +2576,8 @@ END
$parameterCheckString .= " throwTypeError(ExceptionMessages::failedToExecute(\"$functionName\", \"$interfaceName\", \"The callback provided as parameter $humanFriendlyIndex is not a function.\"), info.GetIsolate());\n";
$parameterCheckString .= " return;\n";
$parameterCheckString .= " }\n";
- $parameterCheckString .= " RefPtr<" . $parameter->type . "> $parameterName = ";
- $parameterCheckString .= "info[$paramIndex]->IsNull() ? 0 : " if $parameter->isNullable;
+ $parameterCheckString .= " ${ptrType}Ptr<" . $parameter->type . "> $parameterName = ";
+ $parameterCheckString .= "info[$paramIndex]->IsNull() ? nullptr : " if $parameter->isNullable;
$parameterCheckString .= "${v8ClassName}::create(info[$paramIndex], getExecutionContext());\n";
}
} elsif ($parameter->extendedAttributes->{"Clamp"}) {
@@ -4778,6 +4779,9 @@ sub GenerateCallbackHeader
my $interfaceName = $interface->name;
my $implClassName = GetImplName($interface);
my $v8ClassName = GetV8ClassName($interface);
+ my $refCounted = IsLegacyRefCountedCallback($interfaceName);
+ my $ptrType = $refCounted ? "Ref" : "Own";
+ my $adoptType = $refCounted ? "Ref" : "Ptr";
my @includes = ();
push(@includes, "bindings/v8/ActiveDOMCallback.h");
@@ -4792,11 +4796,11 @@ sub GenerateCallbackHeader
$header{class}->addFooter("};\n");
$header{classPublic}->add(<<END);
- static PassRefPtr<${v8ClassName}> create(v8::Handle<v8::Value> jsValue, ExecutionContext* context)
+ static Pass${ptrType}Ptr<${v8ClassName}> create(v8::Handle<v8::Value> jsValue, ExecutionContext* context)
{
ASSERT(jsValue->IsObject());
ASSERT(context);
- return adoptRef(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(jsValue), context));
+ return adopt${adoptType}(new ${v8ClassName}(v8::Handle<v8::Object>::Cast(jsValue), context));
}
virtual ~${v8ClassName}();
@@ -6352,4 +6356,29 @@ sub NeedsSpecialWrap
return 0;
}
+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
+{
+ my $name = shift;
+ # WebSQL
+ return 1 if $name eq "DatabaseCallback";
+ return 1 if $name eq "SQLTransactionCallback";
+ return 1 if $name eq "SQLTransactionErrorCallback";
+ return 1 if $name eq "SQLTransactionSyncCallback";
+ return 1 if $name eq "SQLStatementCallback";
+ return 1 if $name eq "SQLStatementErrorCallback";
+ # Filesystem
+ return 1 if $name eq "EntryCallback";
+ return 1 if $name eq "EntriesCallback";
+ return 1 if $name eq "ErrorCallback";
+ return 1 if $name eq "FileCallback";
+ return 1 if $name eq "FileSystemCallback";
+ return 1 if $name eq "FileWriterCallback";
+ return 1 if $name eq "MetadataCallback";
+ # requestAnimationFrame
+ return 1 if $name eq "RequestAnimationFrameCallback";
+ # Used everywhere
+ return 1 if $name eq "VoidCallback";
+ return 0;
+}
+
1;
« no previous file with comments | « no previous file | Source/bindings/tests/results/V8TestCallback.h » ('j') | Source/bindings/v8/V8Callback.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698