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

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

Issue 15724005: [Binding] Support primitive type for union member (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: do not inherit getter. rename DoNotCheckJSProperty to OverrideBuiltins Created 7 years, 7 months 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
Index: Source/bindings/scripts/CodeGeneratorV8.pm
diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm
index 6ad557e388ebc718b0d9dba46808821378e181e8..2eed11ad2034cfe546a28b0f084fb3134c00ab49 100644
--- a/Source/bindings/scripts/CodeGeneratorV8.pm
+++ b/Source/bindings/scripts/CodeGeneratorV8.pm
@@ -564,20 +564,12 @@ sub GetSpecialAccessorFunctionForType
my $special = shift;
my $type = shift;
kojih 2013/05/23 05:14:26 quit searching all parents for special method
- my @interfaces = ($interface);
- ForAllParents($interface, sub {
- my $currentInterface = shift;
- push(@interfaces, $currentInterface);
- });
-
- foreach my $currentInterface (@interfaces) {
- foreach my $function (@{$currentInterface->functions}) {
- my $specials = $function->signature->specials;
- my $specialExists = grep { $_ eq $special } @$specials;
- my $parameters = $function->parameters;
- if ($specialExists and scalar(@$parameters) == 1 and $parameters->[0]->type eq $type) {
- return $function;
- }
+ foreach my $function (@{$interface->functions}) {
+ my $specials = $function->signature->specials;
+ my $specialExists = grep { $_ eq $special } @$specials;
+ my $parameters = $function->parameters;
+ if ($specialExists and scalar(@$parameters) == 1 and $parameters->[0]->type eq $type) {
+ return $function;
}
}
@@ -3039,8 +3031,10 @@ sub GenerateIsNullExpression
}
if (IsRefPtrType($type)) {
return "!${variableName}";
- } else {
+ } elsif ($type eq "DOMString") {
return "${variableName}.isNull()";
+ } else {
+ return "";
kojih 2013/05/23 05:14:26 primitive case
}
}
@@ -3206,7 +3200,10 @@ sub GenerateMethodCall
my $unionMemberType = $returnType->unionMemberTypes->[$i];
my $nativeType = GetNativeType($unionMemberType);
my $unionMemberVariable = $returnName . $i;
+ my $unionMemberEnabledVariable = $returnName . $i . "Enabled";
+ $code .= " bool ${unionMemberEnabledVariable} = false;\n";
$code .= " ${nativeType} ${unionMemberVariable};\n";
+ push @extraArguments, $unionMemberEnabledVariable;
push @extraArguments, $unionMemberVariable;
}
push @arguments, @extraArguments;
@@ -3237,7 +3234,7 @@ sub GenerateImplementationNamedPropertyGetter
my $code = "v8::Handle<v8::Value> ${v8ClassName}::namedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)\n";
$code .= "{\n";
- if (!$namedGetterFunction->signature->extendedAttributes->{"DoNotCheckJSProperty"}) {
+ if (!$namedGetterFunction->signature->extendedAttributes->{"OverrideBuiltins"}) {
$code .= " if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())\n";
$code .= " return v8Undefined();\n";
$code .= " if (info.Holder()->HasRealNamedCallbackProperty(name))\n";
@@ -4739,12 +4736,14 @@ sub NativeToJSValue
my $unionMemberType = $types->[$i];
my $unionMemberNumber = $i + 1;
my $unionMemberVariable = $nativeValue . $i;
+ my $unionMemberEnabledVariable = $nativeValue . $i . "Enabled";
my $unionMemberNativeValue = $unionMemberVariable;
$unionMemberNativeValue .= ".release()" if (IsRefPtrType($unionMemberType));
my $returnJSValueCode = NativeToJSValue($unionMemberType, $extendedAttributes, $unionMemberNativeValue, $indent . " ", $receiver, $getCreationContext, $getIsolate, $getHolderContainer, $getScriptWrappable, $returnHandleType, $forMainWorldSuffix);
- my $isNotNull = "!" . GenerateIsNullExpression($unionMemberType, $unionMemberVariable);
+ my $isNotNull = GenerateIsNullExpression($unionMemberType, $unionMemberVariable);
+ $isNotNull = " && !" . $isNotNull if $isNotNull;
my $code = "";
- $code .= "${indent}if (${isNotNull})\n";
+ $code .= "${indent}if (${unionMemberEnabledVariable}${isNotNull})\n";
$code .= "${returnJSValueCode}";
push @codes, $code;
}
« no previous file with comments | « no previous file | Source/bindings/scripts/IDLAttributes.txt » ('j') | Source/bindings/tests/results/V8TestInterface.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698