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

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

Issue 23797002: Hack to add accessors for WebIDL attributes. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 2 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
« no previous file with comments | « Source/bindings/scripts/IDLAttributes.txt ('k') | Source/bindings/v8/V8DOMConfiguration.h » ('j') | no next file with comments »
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 6030b45d5b750c3c22d52a75b8d8ab5994d59718..c58ca980f589218a868ca85ef2fcf2691f154fa2 100644
--- a/Source/bindings/scripts/code_generator_v8.pm
+++ b/Source/bindings/scripts/code_generator_v8.pm
@@ -1294,10 +1294,12 @@ END
} elsif ($accessType eq "Setter") {
$code .= <<END;
V8PerContextData* contextData = V8PerContextData::from(info.GetIsolate()->GetCurrentContext());
+/*
if (contextData && contextData->activityLogger()) {
v8::Handle<v8::Value> loggerArg[] = { jsValue };
contextData->activityLogger()->log("${interfaceName}.${propertyName}", 1, &loggerArg[0], "${accessType}");
}
+*/
END
} elsif ($accessType eq "Getter") {
$code .= <<END;
@@ -1317,6 +1319,7 @@ sub GenerateNormalAttributeGetterCallback
my $attribute = shift;
my $interface = shift;
my $forMainWorldSuffix = shift;
+ my $isAccessor = shift;
my $implClassName = GetImplName($interface);
my $v8ClassName = GetV8ClassName($interface);
@@ -1327,7 +1330,11 @@ sub GenerateNormalAttributeGetterCallback
my $code = "";
$code .= "#if ${conditionalString}\n" if $conditionalString;
- $code .= "static void ${attrName}AttributeGetterCallback${forMainWorldSuffix}(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
+ if ($isAccessor) {
+ $code .= "static void ${attrName}AttributeGetterCallback${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8::Value>& info)\n";
+ } else {
+ $code .= "static void ${attrName}AttributeGetterCallback${forMainWorldSuffix}(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
+ }
$code .= "{\n";
$code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMGetter\");\n";
$code .= GenerateFeatureObservation($attrExt->{"MeasureAs"});
@@ -1336,9 +1343,17 @@ sub GenerateNormalAttributeGetterCallback
$code .= GenerateActivityLogging("Getter", $interface, "${attrName}");
}
if (HasCustomGetter($attrExt)) {
- $code .= " ${v8ClassName}::${attrName}AttributeGetterCustom(name, info);\n";
+ if ($isAccessor) {
+ $code .= " ${v8ClassName}::${attrName}AttributeGetterCustom(info);\n";
+ } else {
+ $code .= " ${v8ClassName}::${attrName}AttributeGetterCustom(name, info);\n";
+ }
} else {
- $code .= " ${implClassName}V8Internal::${attrName}AttributeGetter${forMainWorldSuffix}(name, info);\n";
+ if ($isAccessor) {
+ $code .= " ${implClassName}V8Internal::${attrName}AttributeGetter${forMainWorldSuffix}(info);\n";
+ } else {
+ $code .= " ${implClassName}V8Internal::${attrName}AttributeGetter${forMainWorldSuffix}(name, info);\n";
+ }
}
$code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n";
$code .= "}\n";
@@ -1363,6 +1378,7 @@ sub GenerateNormalAttributeGetter
my $attribute = shift;
my $interface = shift;
my $forMainWorldSuffix = shift;
+ my $isAccessor = shift;
my $interfaceName = $interface->name;
my $implClassName = GetImplName($interface);
@@ -1383,10 +1399,13 @@ sub GenerateNormalAttributeGetter
my $conditionalString = GenerateConditionalString($attribute);
my $code = "";
$code .= "#if ${conditionalString}\n" if $conditionalString;
- $code .= <<END;
-static void ${attrName}AttributeGetter${forMainWorldSuffix}(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)
-{
-END
+ if ($isAccessor) {
+ $code .= "static void ${attrName}AttributeGetter${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8::Value>& info)\n";
+ $code .= "{\n";
+ } else {
+ $code .= "static void ${attrName}AttributeGetter${forMainWorldSuffix}(v8::Local<v8::String> name, const v8::PropertyCallbackInfo<v8::Value>& info)\n";
+ $code .= "{\n";
+ }
if ($svgNativeType) {
my $svgWrappedNativeType = GetSVGWrappedTypeNeedingTearOff($interfaceName);
if ($svgWrappedNativeType =~ /List/) {
@@ -1754,6 +1773,7 @@ sub GenerateNormalAttributeSetterCallback
my $attribute = shift;
my $interface = shift;
my $forMainWorldSuffix = shift;
+ my $isAccessor = shift;
my $implClassName = GetImplName($interface);
my $v8ClassName = GetV8ClassName($interface);
@@ -1764,7 +1784,11 @@ sub GenerateNormalAttributeSetterCallback
my $code = "";
$code .= "#if ${conditionalString}\n" if $conditionalString;
- $code .= "static void ${attrName}AttributeSetterCallback${forMainWorldSuffix}(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n";
+ if ($isAccessor) {
+ $code .= "static void ${attrName}AttributeSetterCallback${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8::Value>& info)\n";
+ } else {
+ $code .= "static void ${attrName}AttributeSetterCallback${forMainWorldSuffix}(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n";
+ }
$code .= "{\n";
$code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"Blink\", \"DOMSetter\");\n";
$code .= GenerateFeatureObservation($attrExt->{"MeasureAs"});
@@ -1774,9 +1798,17 @@ sub GenerateNormalAttributeSetterCallback
}
$code .= GenerateCustomElementInvocationScopeIfNeeded($attrExt);
if (HasCustomSetter($attribute)) {
- $code .= " ${v8ClassName}::${attrName}AttributeSetterCustom(name, jsValue, info);\n";
+ if ($isAccessor) {
+ $code .= " ${v8ClassName}::${attrName}AttributeSetterCustom(info);\n";
+ } else {
+ $code .= " ${v8ClassName}::${attrName}AttributeSetterCustom(name, jsValue, info);\n";
+ }
} else {
- $code .= " ${implClassName}V8Internal::${attrName}AttributeSetter${forMainWorldSuffix}(name, jsValue, info);\n";
+ if ($isAccessor) {
+ $code .= " ${implClassName}V8Internal::${attrName}AttributeSetter${forMainWorldSuffix}(info);\n";
+ } else {
+ $code .= " ${implClassName}V8Internal::${attrName}AttributeSetter${forMainWorldSuffix}(name, jsValue, info);\n";
+ }
}
$code .= " TRACE_EVENT_SET_SAMPLING_STATE(\"V8\", \"Execution\");\n";
$code .= "}\n";
@@ -1802,6 +1834,7 @@ sub GenerateNormalAttributeSetter
my $attribute = shift;
my $interface = shift;
my $forMainWorldSuffix = shift;
+ my $isAccessor = shift;
my $interfaceName = $interface->name;
my $implClassName = GetImplName($interface);
@@ -1818,8 +1851,14 @@ sub GenerateNormalAttributeSetter
my $conditionalString = GenerateConditionalString($attribute);
my $code = "";
$code .= "#if ${conditionalString}\n" if $conditionalString;
- $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n";
- $code .= "{\n";
+ if ($isAccessor) {
+ $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(const v8::FunctionCallbackInfo<v8::Value>& info)\n";
+ $code .= "{\n";
+ $code .= " v8::Local<v8::Value> jsValue = info[0];\n";
+ } else {
+ $code .= "static void ${attrName}AttributeSetter${forMainWorldSuffix}(v8::Local<v8::String> name, v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)\n";
+ $code .= "{\n";
+ }
# If the "StrictTypeChecking" extended attribute is present, and the attribute's type is an
# interface type, then if the incoming value does not implement that interface, a TypeError is
@@ -3015,13 +3054,14 @@ sub GenerateAttributeConfigurationArray
{
my $interface = shift;
my $attributes = shift;
+ my $isAccessor = shift;
my $code = "";
foreach my $attribute (@$attributes) {
my $conditionalString = GenerateConditionalString($attribute);
my $subCode = "";
$subCode .= "#if ${conditionalString}\n" if $conditionalString;
- $subCode .= GenerateAttributeConfiguration($interface, $attribute, ",", "");
+ $subCode .= GenerateAttributeConfiguration($interface, $attribute, ",", "", $isAccessor);
$subCode .= "#endif // ${conditionalString}\n" if $conditionalString;
$code .= $subCode;
}
@@ -3032,6 +3072,7 @@ sub GenerateAttributeConfigurationParameters
{
my $interface = shift;
my $attribute = shift;
+ my $isAccessor = shift;
my $attrName = $attribute->name;
my $attrExt = $attribute->extendedAttributes;
my $implClassName = GetImplName($interface);
@@ -3079,7 +3120,7 @@ sub GenerateAttributeConfigurationParameters
@propAttributeList = ("v8::None") unless @propAttributeList;
my $propAttribute = join(" | ", @propAttributeList);
- my $on_proto = "0 /* on instance */";
+ my $onPrototype = "0 /* on instance */";
my $data = "0"; # no data
# Constructor
@@ -3118,7 +3159,7 @@ sub GenerateAttributeConfigurationParameters
# An accessor can be installed on the proto
if ($attrExt->{"OnProto"}) {
- $on_proto = "1 /* on proto */";
+ $onPrototype = "1 /* on proto */";
}
if (!$attrExt->{"PerWorldBindings"}) {
@@ -3126,7 +3167,7 @@ sub GenerateAttributeConfigurationParameters
$setterForMainWorld = "0";
}
- return ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, "static_cast<v8::PropertyAttribute>($propAttribute)", $on_proto);
+ return ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, "static_cast<v8::PropertyAttribute>($propAttribute)", $onPrototype);
}
sub GenerateAttributeConfiguration
@@ -3135,11 +3176,16 @@ sub GenerateAttributeConfiguration
my $attribute = shift;
my $delimiter = shift;
my $indent = shift;
+ my $isAccessor = shift;
my $code = "";
- my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, $propAttribute, $on_proto) = GenerateAttributeConfigurationParameters($interface, $attribute);
+ my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, $propAttribute, $onPrototype) = GenerateAttributeConfigurationParameters($interface, $attribute, $isAccessor);
- $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, $propAttribute, $on_proto}" . $delimiter . "\n";
+ if ($isAccessor) {
+ $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, $propAttribute}" . $delimiter . "\n";
+ } else {
+ $code .= $indent . " {\"$attrName\", $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, $propAttribute, $onPrototype}" . $delimiter . "\n";
+ }
return $code;
}
@@ -3150,7 +3196,7 @@ sub GenerateStaticAttribute
my $attrExt = $attribute->extendedAttributes;
my $code = "";
- my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, $propAttribute, $on_proto) = GenerateAttributeConfigurationParameters($interface, $attribute);
+ my ($attrName, $getter, $setter, $getterForMainWorld, $setterForMainWorld, $data, $accessControl, $propAttribute, $onPrototype) = GenerateAttributeConfigurationParameters($interface, $attribute);
die "Static attributes do not support optimized getters or setters for the main world" if $getterForMainWorld || $setterForMainWorld;
@@ -4082,16 +4128,17 @@ END
$hasReplaceable = 1;
}
+ my $isAccessor = $attrExt->{"ExposeV8GetterAndSetter"};
my @worldSuffixes = ("");
if ($attrExt->{"PerWorldBindings"}) {
push(@worldSuffixes, "ForMainWorld");
}
foreach my $worldSuffix (@worldSuffixes) {
- GenerateNormalAttributeGetter($attribute, $interface, $worldSuffix);
- GenerateNormalAttributeGetterCallback($attribute, $interface, $worldSuffix);
+ GenerateNormalAttributeGetter($attribute, $interface, $worldSuffix, $isAccessor);
+ GenerateNormalAttributeGetterCallback($attribute, $interface, $worldSuffix, $isAccessor);
if (!$isReplaceable && !IsReadonly($attribute)) {
- GenerateNormalAttributeSetter($attribute, $interface, $worldSuffix);
- GenerateNormalAttributeSetterCallback($attribute, $interface, $worldSuffix);
+ GenerateNormalAttributeSetter($attribute, $interface, $worldSuffix, $isAccessor);
+ GenerateNormalAttributeSetterCallback($attribute, $interface, $worldSuffix, $isAccessor);
}
}
}
@@ -4185,17 +4232,22 @@ END
my @runtimeEnabledAttributes;
my @perContextEnabledAttributes;
my @normalAttributes;
+ my @normalAccessors;
my @staticAttributes;
foreach my $attribute (@$attributes) {
-
if ($attribute->isStatic) {
push(@staticAttributes, $attribute);
} elsif ($interfaceName eq "Window" && $attribute->extendedAttributes->{"Unforgeable"}) {
push(@disallowsShadowing, $attribute);
- } elsif ($attribute->extendedAttributes->{"PerContextEnabled"}) {
- push(@perContextEnabledAttributes, $attribute);
- } elsif ($attribute->extendedAttributes->{"RuntimeEnabled"}) {
- push(@runtimeEnabledAttributes, $attribute);
+ } elsif ($attribute->extendedAttributes->{"RuntimeEnabled"} || $attribute->extendedAttributes->{"PerContextEnabled"}) {
+ if ($attribute->extendedAttributes->{"PerContextEnabled"}) {
+ push(@perContextEnabledAttributes, $attribute);
+ }
+ if ($attribute->extendedAttributes->{"RuntimeEnabled"}) {
+ push(@runtimeEnabledAttributes, $attribute);
+ }
+ } elsif ($attribute->extendedAttributes->{"ExposeV8GetterAndSetter"}) {
+ push(@normalAccessors, $attribute);
} else {
push(@normalAttributes, $attribute);
}
@@ -4210,9 +4262,9 @@ END
$implementation{nameSpaceWebCore}->add($code);
}
- my $has_attributes = 0;
+ my $hasAttributes = 0;
if (@normalAttributes) {
- $has_attributes = 1;
+ $hasAttributes = 1;
my $code = "";
$code .= "static const V8DOMConfiguration::AttributeConfiguration ${v8ClassName}Attributes[] = {\n";
$code .= GenerateAttributeConfigurationArray($interface, \@normalAttributes);
@@ -4220,9 +4272,18 @@ END
$implementation{nameSpaceWebCore}->add($code);
}
+ my $hasAccessors = 0;
+ if (@normalAccessors) {
+ $hasAccessors = 1;
+ my $code = "";
+ $code .= "static const V8DOMConfiguration::AccessorConfiguration ${v8ClassName}Accessors[] = {\n";
+ $code .= GenerateAttributeConfigurationArray($interface, \@normalAccessors, "accessor");
+ $code .= "};\n\n";
+ $implementation{nameSpaceWebCore}->add($code);
+ }
+
# Setup table of standard callback functions
- my $num_callbacks = 0;
- my $has_callbacks = 0;
+ my $hasMethods = 0;
$code = "";
foreach my $function (@normalFunctions) {
# Only one table entry is needed for overloaded methods:
@@ -4230,8 +4291,8 @@ END
# Don't put any nonstandard functions into this table:
next if !IsStandardFunction($interface, $function);
next if $function->name eq "";
- if (!$has_callbacks) {
- $has_callbacks = 1;
+ if (!$hasMethods) {
+ $hasMethods = 1;
$code .= "static const V8DOMConfiguration::MethodConfiguration ${v8ClassName}Methods[] = {\n";
}
my $name = $function->name;
@@ -4246,14 +4307,13 @@ END
{"$name", ${implClassName}V8Internal::${name}MethodCallback, ${methodForMainWorld}, ${functionLength}},
END
$code .= "#endif // ${conditionalString}\n" if $conditionalString;
- $num_callbacks++;
}
- $code .= "};\n\n" if $has_callbacks;
+ $code .= "};\n\n" if $hasMethods;
$implementation{nameSpaceWebCore}->add($code);
- my $has_constants = 0;
+ my $hasConstants = 0;
if (@{$interface->constants}) {
- $has_constants = 1;
+ $hasConstants = 1;
}
if (!HasCustomConstructor($interface)) {
@@ -4269,9 +4329,9 @@ END
GenerateConstructorCallback($interface);
}
- my $access_check = "";
+ my $accessCheck = "";
if ($interface->extendedAttributes->{"CheckSecurity"} && $interfaceName ne "Window") {
- $access_check = "instance->SetAccessCheckCallbacks(${implClassName}V8Internal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8::External::New(const_cast<WrapperTypeInfo*>(&${v8ClassName}::wrapperTypeInfo)));";
+ $accessCheck = "instance->SetAccessCheckCallbacks(${implClassName}V8Internal::namedSecurityCheck, ${implClassName}V8Internal::indexedSecurityCheck, v8::External::New(const_cast<WrapperTypeInfo*>(&${v8ClassName}::wrapperTypeInfo)));";
}
# For the Window interface, generate the shadow object template
@@ -4301,37 +4361,22 @@ static v8::Handle<v8::FunctionTemplate> Configure${v8ClassName}Template(v8::Hand
v8::Local<v8::Signature> defaultSignature;
END
+
+ # Define constants, attributes, accessors and methods.
if ($interface->extendedAttributes->{"RuntimeEnabled"}) {
my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($interface);
$code .= <<END;
if (!${runtimeEnabledFunction}())
- defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"\", $parentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, isolate, currentWorldType);
+ defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"\", $parentClassTemplate, ${v8ClassName}::internalFieldCount, 0, 0, 0, 0, 0, 0, isolate, currentWorldType);
else
END
}
- $code .= <<END;
- defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"${interfaceName}\", $parentClassTemplate, ${v8ClassName}::internalFieldCount,
-END
- # Set up our attributes if we have them
- if ($has_attributes) {
- $code .= <<END;
- ${v8ClassName}Attributes, WTF_ARRAY_LENGTH(${v8ClassName}Attributes),
-END
- } else {
- $code .= <<END;
- 0, 0,
-END
- }
+ $code .= " defaultSignature = V8DOMConfiguration::installDOMClassTemplate(desc, \"${interfaceName}\", $parentClassTemplate, ${v8ClassName}::internalFieldCount, ";
- if ($has_callbacks) {
- $code .= <<END;
- ${v8ClassName}Methods, WTF_ARRAY_LENGTH(${v8ClassName}Methods), isolate, currentWorldType);
-END
- } else {
- $code .= <<END;
- 0, 0, isolate, currentWorldType);
-END
- }
+ $code .= $hasAttributes ? "${v8ClassName}Attributes, WTF_ARRAY_LENGTH(${v8ClassName}Attributes), " : "0, 0, ";
+ $code .= $hasAccessors ? "${v8ClassName}Accessors, WTF_ARRAY_LENGTH(${v8ClassName}Accessors), " : "0, 0, ";
+ $code .= $hasMethods ? "${v8ClassName}Methods, WTF_ARRAY_LENGTH(${v8ClassName}Methods), " : "0, 0, ";
+ $code .= "isolate, currentWorldType);\n";
AddToImplIncludes("wtf/UnusedParam.h");
$code .= <<END;
@@ -4344,7 +4389,7 @@ END
$code .= " desc->SetLength(${interfaceLength});\n";
}
- if ($access_check or @runtimeEnabledAttributes or @normalFunctions or $has_constants) {
+ if ($accessCheck or @runtimeEnabledAttributes or @normalFunctions or $hasConstants) {
$code .= <<END;
v8::Local<v8::ObjectTemplate> instance = desc->InstanceTemplate();
v8::Local<v8::ObjectTemplate> proto = desc->PrototypeTemplate();
@@ -4353,18 +4398,18 @@ END
END
}
- if ($access_check) {
- $code .= " $access_check\n";
+ if ($accessCheck) {
+ $code .= " $accessCheck\n";
}
- # Setup the enable-at-runtime attributes if we have them
- foreach my $runtime_attr (@runtimeEnabledAttributes) {
- my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtime_attr);
- my $conditionalString = GenerateConditionalString($runtime_attr);
- $code .= "#if ${conditionalString}\n" if $conditionalString;
+ # Define enable-at-runtime attributes.
+ foreach my $runtimeAttribute (@runtimeEnabledAttributes) {
+ my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtimeAttribute);
+ my $conditionalString = GenerateConditionalString($runtimeAttribute);
+ $code .= "\n#if ${conditionalString}\n" if $conditionalString;
$code .= " if (${runtimeEnabledFunction}()) {\n";
$code .= " static const V8DOMConfiguration::AttributeConfiguration attributeConfiguration =\\\n";
- $code .= GenerateAttributeConfiguration($interface, $runtime_attr, ";", " ");
+ $code .= GenerateAttributeConfiguration($interface, $runtimeAttribute, ";", " ");
$code .= <<END;
V8DOMConfiguration::installAttribute(instance, proto, attributeConfiguration, isolate, currentWorldType);
}
@@ -4373,7 +4418,8 @@ END
}
my @constantsEnabledAtRuntime;
- if ($has_constants) {
+ if ($hasConstants) {
+ # Define constants.
$code .= " static const V8DOMConfiguration::ConstantConfiguration ${v8ClassName}Constants[] = {\n";
foreach my $constant (@{$interface->constants}) {
my $name = $constant->name;
@@ -4396,11 +4442,11 @@ END
$code .= <<END;
V8DOMConfiguration::installConstants(desc, proto, ${v8ClassName}Constants, WTF_ARRAY_LENGTH(${v8ClassName}Constants), isolate);
END
- # Setup the enable-at-runtime constants if we have them
- foreach my $runtime_const (@constantsEnabledAtRuntime) {
- my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtime_const);
- my $name = $runtime_const->name;
- my $value = $runtime_const->value;
+ # Define enable-at-runtime constants.
+ foreach my $runtimeConstant (@constantsEnabledAtRuntime) {
+ my $runtimeEnabledFunction = GetRuntimeEnabledFunctionName($runtimeConstant);
+ my $name = $runtimeConstant->name;
+ my $value = $runtimeConstant->value;
$code .= " if (${runtimeEnabledFunction}()) {\n";
$code .= <<END;
static const V8DOMConfiguration::ConstantConfiguration constantConfiguration = {"${name}", static_cast<signed int>(${value})};
@@ -4416,21 +4462,16 @@ END
$code .= GenerateImplementationLegacyCall($interface);
$code .= GenerateImplementationMasqueradesAsUndefined($interface);
- # Define our functions with Set() or SetAccessor()
- my $total_functions = 0;
+ # Define methods.
foreach my $function (@normalFunctions) {
# Only one accessor is needed for overloaded methods:
next if $function->{overloadIndex} > 1;
next if $function->name eq "";
- $total_functions++;
next if IsStandardFunction($interface, $function);
$code .= GenerateNonStandardFunction($interface, $function);
- $num_callbacks++;
}
- die "Wrong number of callbacks generated for $interfaceName ($num_callbacks, should be $total_functions)" if $num_callbacks != $total_functions;
-
# Define static attributes.
foreach my $attribute (@staticAttributes) {
$code .= GenerateStaticAttribute($interface, $attribute);
@@ -4507,7 +4548,7 @@ void ${v8ClassName}::installPerContextEnabledProperties(v8::Handle<v8::Object> i
v8::Local<v8::Object> proto = v8::Local<v8::Object>::Cast(instance->GetPrototype());
END
- # Setup the enable-by-settings attributes if we have them
+ # Define the enable-per-context attributes.
foreach my $perContextEnabledAttribute (@perContextEnabledAttributes) {
my $contextEnabledFunction = GetContextEnabledFunctionName($perContextEnabledAttribute);
$code .= " if (${contextEnabledFunction}(impl->document())) {\n";
@@ -4533,7 +4574,7 @@ void ${v8ClassName}::installPerContextEnabledPrototypeProperties(v8::Handle<v8::
{
UNUSED_PARAM(proto);
END
- # Setup the enable-by-settings functions if we have them
+ # Define enable-per-context methods.
$code .= <<END;
v8::Local<v8::Signature> defaultSignature = v8::Signature::New(GetTemplate(isolate, worldType(isolate)));
UNUSED_PARAM(defaultSignature);
« no previous file with comments | « Source/bindings/scripts/IDLAttributes.txt ('k') | Source/bindings/v8/V8DOMConfiguration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698