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

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

Issue 13933014: Gen index getter by unified way instead of using several helper function in some special cases. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: removed debug printf Created 7 years, 8 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/WebCore/html/HTMLSelectElement.idl ('k') | Source/bindings/tests/results/V8TestEventTarget.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/CodeGeneratorV8.pm
diff --git a/Source/bindings/scripts/CodeGeneratorV8.pm b/Source/bindings/scripts/CodeGeneratorV8.pm
index 2cf402511932ae937a5765e4f3873c619feef350..2d95af19fdbc9382123508e80f79c746c26be88b 100644
--- a/Source/bindings/scripts/CodeGeneratorV8.pm
+++ b/Source/bindings/scripts/CodeGeneratorV8.pm
@@ -698,7 +698,7 @@ sub GenerateHeaderNamedAndIndexedPropertyAccessors
{
my $interface = shift;
my $interfaceName = $interface->name;
- my $hasCustomIndexedGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"};
+ my $hasCustomIndexedGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomIndexedGetter"};
my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexedSetter"} && !$interface->extendedAttributes->{"NumericIndexedGetter"};
my $hasCustomNamedGetter = $interface->extendedAttributes->{"NamedGetter"} || $interface->extendedAttributes->{"CustomNamedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"};
my $hasCustomNamedSetter = $interface->extendedAttributes->{"CustomNamedSetter"};
@@ -2610,7 +2610,7 @@ END
push(@implContent, "#endif // ${conditionalString}\n") if $conditionalString;
}
-sub GenerateImplementationIndexer
+sub GenerateImplementationIndexedProperty
{
my $interface = shift;
my $indexer = shift;
@@ -2618,30 +2618,31 @@ sub GenerateImplementationIndexer
my $v8InterfaceName = "V8$interfaceName";
# FIXME: Figure out what NumericIndexedGetter is really supposed to do. Right now, it's only set on WebGL-related files.
- my $hasCustomSetter = $interface->extendedAttributes->{"CustomIndexedSetter"} && !$interface->extendedAttributes->{"NumericIndexedGetter"};
- my $hasGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomGetOwnPropertySlot"};
+ my $hasCustomIndexedSetter = $interface->extendedAttributes->{"CustomIndexedSetter"} && !$interface->extendedAttributes->{"NumericIndexedGetter"};
+ my $hasIndexedGetter = $interface->extendedAttributes->{"IndexedGetter"} || $interface->extendedAttributes->{"CustomIndexedGetter"};
# FIXME: Investigate and remove this nastinesss. In V8, named property handling and indexer handling are apparently decoupled,
# which means that object[X] where X is a number doesn't reach named property indexer. So we need to provide
# simplistic, mirrored indexer handling in addition to named property handling.
my $isSpecialCase = exists $indexerSpecialCases{$interfaceName};
if ($isSpecialCase) {
- $hasGetter = 1;
+ $hasIndexedGetter = 1;
if ($interface->extendedAttributes->{"CustomNamedSetter"}) {
- $hasCustomSetter = 1;
+ $hasCustomIndexedSetter = 1;
}
}
+ # FIXME: Remove the special cases. Interfaces that have indexedPropertyGetter should have indexedPropertyEnumerator.
my $hasEnumerator = !$isSpecialCase && $codeGenerator->InheritsInterface($interface, "Node");
# FIXME: Find a way to not have to special-case HTMLOptionsCollection.
if ($interfaceName eq "HTMLOptionsCollection") {
$hasEnumerator = 1;
- $hasGetter = 1;
+ $hasIndexedGetter = 1;
}
- if (!$hasGetter) {
- return;
+ if (!$hasIndexedGetter) {
+ return "";
}
AddToImplIncludes("V8Collection.h");
@@ -2652,32 +2653,8 @@ sub GenerateImplementationIndexer
my $indexerType = $indexer ? $indexer->type : 0;
- # FIXME: Remove this once toV8 helper methods are implemented (see https://bugs.webkit.org/show_bug.cgi?id=32563).
- if ($interfaceName eq "WebKitCSSKeyframesRule") {
- $indexerType = "WebKitCSSKeyframeRule";
- }
-
- if ($indexerType && !$hasCustomSetter) {
- if ($indexerType eq "DOMString") {
- my $conversion = $indexer->extendedAttributes->{"TreatReturnedNullStringAs"};
- if ($conversion && $conversion eq "Null") {
- push(@implContent, <<END);
- setCollectionStringOrUndefinedIndexedGetter<${interfaceName}>(desc);
-END
- } else {
- push(@implContent, <<END);
- setCollectionStringIndexedGetter<${interfaceName}>(desc);
-END
- }
- } else {
- push(@implContent, <<END);
- setCollectionIndexedGetter<${interfaceName}, ${indexerType}>(desc);
-END
- # Include the header for this indexer type, because setCollectionIndexedGetter() requires toV8() for this type.
- AddToImplIncludes("V8${indexerType}.h");
- }
-
- return;
+ if ($indexerType && !$hasCustomIndexedSetter) {
+ $hasEnumerator = 1;
}
my $hasDeleter = $interface->extendedAttributes->{"CustomDeleteProperty"};
@@ -2691,13 +2668,53 @@ END
$setOn = "Prototype";
$hasDeleter = 0;
}
+ # FIXME: Implement V8DataTransferItemList::indexedPropertyDeleter
+ if ($interfaceName eq "DataTransferItemList") {
+ $hasDeleter = 0;
+ }
push(@implContent, " desc->${setOn}Template()->SetIndexedPropertyHandler(${v8InterfaceName}::indexedPropertyGetter");
- push(@implContent, $hasCustomSetter ? ", ${v8InterfaceName}::indexedPropertySetter" : ", 0");
+ push(@implContent, $hasCustomIndexedSetter ? ", ${v8InterfaceName}::indexedPropertySetter" : ", 0");
push(@implContent, ", 0"); # IndexedPropertyQuery -- not being used at the moment.
push(@implContent, $hasDeleter ? ", ${v8InterfaceName}::indexedPropertyDeleter" : ", 0");
push(@implContent, ", nodeCollectionIndexedPropertyEnumerator<${interfaceName}>") if $hasEnumerator;
push(@implContent, ");\n");
+
+ if($interface->extendedAttributes->{"IndexedGetter"}) {
+ # FIXME: add item() method to WebKitCSSKeyframesRule.idl or remove [IndexedGetter] from WebKitCSSKeyframesRule.idl
+ # Currently indexer type is hard coded because it can not be obtained from IDL.
+ if ($interfaceName eq "WebKitCSSKeyframesRule") {
+ $indexerType = "WebKitCSSKeyframeRule";
+ }
+ my $jsValue = "";
+ my $elementType = GetNativeType($indexerType);
haraken 2013/04/17 10:29:52 $elementType => $nativeType
+ my $isNull = "";
+
+ if ($indexerType eq "DOMString") {
haraken 2013/04/17 10:29:52 Shall we use $codeGenerator->IsRefPtrType($indexer
+ $isNull = "element.isNull()";
+ $jsValue = NativeToJSValue($indexer, "element", "info.Holder()", "info.GetIsolate()");
+ } else {
+ $isNull = "!element";
+ if ($interfaceName eq "WebKitCSSKeyframesRule") {
+ $jsValue = "toV8(element.release(), info.Holder(), info.GetIsolate())";
+ } else {
+ $jsValue = NativeToJSValue($indexer, "element.release()", "info.Holder()", "info.GetIsolate()");
+ }
+ }
+
+ return <<END;
+v8::Handle<v8::Value> ${v8InterfaceName}::indexedPropertyGetter(uint32_t index, const v8::AccessorInfo& info)
+{
+ ASSERT(V8DOMWrapper::maybeDOMWrapper(info.Holder()));
+ ${interfaceName}* collection = toNative(info.Holder());
+ $elementType element = collection->item(index);
+ if ($isNull)
+ return v8Undefined();
+ return $jsValue;
+}
+END
+ }
+ return "";
}
sub GenerateImplementationNamedPropertyGetter
@@ -3225,7 +3242,7 @@ END
push(@implContent, "\n#endif // ${conditionalString}\n") if $conditionalString;
}
- GenerateImplementationIndexer($interface, $indexer);
+ my $indexPropertyGetterCode = GenerateImplementationIndexedProperty($interface, $indexer);
GenerateImplementationNamedPropertyGetter($interface, $namedPropertyGetter);
GenerateImplementationCustomCall($interface);
GenerateImplementationMasqueradesAsUndefined($interface);
@@ -3314,6 +3331,8 @@ bool ${v8InterfaceName}::HasInstanceInAnyWorld(v8::Handle<v8::Value> value, v8::
END
+ push(@implContent, $indexPropertyGetterCode);
+
if (@enabledPerContextAttributes) {
push(@implContent, <<END);
void ${v8InterfaceName}::installPerContextProperties(v8::Handle<v8::Object> instance, ${nativeType}* impl, v8::Isolate* isolate)
« no previous file with comments | « Source/WebCore/html/HTMLSelectElement.idl ('k') | Source/bindings/tests/results/V8TestEventTarget.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698