https://bugs.webkit.org/show_bug.cgi?id=80696
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 18:26:51 +0000 (18:26 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 20 Mar 2012 18:26:51 +0000 (18:26 +0000)
Remove custom bindings for attribute type Array.

Patch by Vineet Chaudhary <rgf748@motorola.com> on 2012-03-20
Reviewed by Kentaro Hara.

No new tests.

* bindings/js/JSConsoleCustom.cpp: Removed custom function.
(WebCore):
* bindings/js/JSDOMBinding.h: Added template jsArray and toNativeArray.
(WebCore):
(WebCore::jsArray):
(WebCore::toNativeArray):
* bindings/scripts/CodeGenerator.pm: Modified codegenerators to generate appropriate code.
(GetArrayType): Added GetArrayType to get return type of attribute interface.
* bindings/scripts/CodeGeneratorGObject.pm: Modified codegenerators to generate appropriate code.
(SkipAttribute):
* bindings/scripts/CodeGeneratorJS.pm: Modified codegenerators to generate appropriate code.
(AddIncludesForType):
(JSValueToNative):
(NativeToJSValue):
* bindings/scripts/CodeGeneratorV8.pm: Modified codegenerators to generate appropriate code.
(GenerateNormalAttrGetter):
(GenerateNormalAttrSetter):
(JSValueToNative):
(NativeToJSValue):
* bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Updated results from running binding tests.
(webkit_dom_test_obj_get_property):
(webkit_dom_test_obj_class_init):
* bindings/scripts/test/GObject/WebKitDOMTestObj.h: Ditto.
* bindings/scripts/test/JS/JSTestObj.cpp: Ditto.
(WebCore::jsTestObjSequenceAttr):
(WebCore::setJSTestObjSequenceAttr):
(WebCore::jsTestObjPrototypeFunctionMethodReturningSequence):
* bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
(WebCore::TestObjInternal::sequenceAttrAttrGetter):
(WebCore::TestObjInternal::sequenceAttrAttrSetter):
(WebCore::TestObjInternal::methodReturningSequenceCallback):
* bindings/v8/V8Binding.h: Added template v8Array and toNativeArray.
(WebCore):
(WebCore::v8Array):
(WebCore::toNativeArray):
* bindings/v8/custom/V8ConsoleCustom.cpp: Removed custom function.
(WebCore):
* page/Console.idl: Replaced attribute type Array to sequence<SriptProfile> to remove
  custom bindings.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@111416 268f45cc-cd09-0410-ab3c-d52691b4dbfc

14 files changed:
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSConsoleCustom.cpp
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorGObject.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.cpp
Source/WebCore/bindings/scripts/test/GObject/WebKitDOMTestObj.h
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/bindings/v8/V8Binding.h
Source/WebCore/bindings/v8/custom/V8ConsoleCustom.cpp
Source/WebCore/page/Console.idl

index d6d5e27fecd1d0c63f1e28aa1af02ef4ec4b1566..1991970abe476391dc0c3c55432665c79de0b34d 100644 (file)
@@ -1,3 +1,52 @@
+2012-03-20  Vineet Chaudhary  <rgf748@motorola.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=80696
+        Remove custom bindings for attribute type Array.
+
+        Reviewed by Kentaro Hara.
+
+        No new tests.
+
+        * bindings/js/JSConsoleCustom.cpp: Removed custom function.
+        (WebCore):
+        * bindings/js/JSDOMBinding.h: Added template jsArray and toNativeArray.
+        (WebCore):
+        (WebCore::jsArray):
+        (WebCore::toNativeArray):
+        * bindings/scripts/CodeGenerator.pm: Modified codegenerators to generate appropriate code.
+        (GetArrayType): Added GetArrayType to get return type of attribute interface.
+        * bindings/scripts/CodeGeneratorGObject.pm: Modified codegenerators to generate appropriate code.
+        (SkipAttribute):
+        * bindings/scripts/CodeGeneratorJS.pm: Modified codegenerators to generate appropriate code.
+        (AddIncludesForType):
+        (JSValueToNative):
+        (NativeToJSValue):
+        * bindings/scripts/CodeGeneratorV8.pm: Modified codegenerators to generate appropriate code.
+        (GenerateNormalAttrGetter):
+        (GenerateNormalAttrSetter):
+        (JSValueToNative):
+        (NativeToJSValue):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.cpp: Updated results from running binding tests.
+        (webkit_dom_test_obj_get_property):
+        (webkit_dom_test_obj_class_init):
+        * bindings/scripts/test/GObject/WebKitDOMTestObj.h: Ditto.
+        * bindings/scripts/test/JS/JSTestObj.cpp: Ditto.
+        (WebCore::jsTestObjSequenceAttr):
+        (WebCore::setJSTestObjSequenceAttr):
+        (WebCore::jsTestObjPrototypeFunctionMethodReturningSequence):
+        * bindings/scripts/test/V8/V8TestObj.cpp: Ditto.
+        (WebCore::TestObjInternal::sequenceAttrAttrGetter):
+        (WebCore::TestObjInternal::sequenceAttrAttrSetter):
+        (WebCore::TestObjInternal::methodReturningSequenceCallback):
+        * bindings/v8/V8Binding.h: Added template v8Array and toNativeArray.
+        (WebCore):
+        (WebCore::v8Array):
+        (WebCore::toNativeArray):
+        * bindings/v8/custom/V8ConsoleCustom.cpp: Removed custom function.
+        (WebCore):
+        * page/Console.idl: Replaced attribute type Array to sequence<SriptProfile> to remove
+          custom bindings.
+
 2012-03-20  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r111310.
index f1d1fe990d608738df84129cbc1de5cbdd83fb45..b049f83e2de901cf32f215675d865ed3433d5925 100644 (file)
 #include "JSConsole.h"
 
 #include "Console.h"
-#include "JSScriptProfile.h"
 #include "ScriptCallStack.h"
 #include "ScriptCallStackFactory.h"
-#include "ScriptProfile.h"
-#include <runtime/JSArray.h>
 #include <wtf/OwnPtr.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
-typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;
-
-JSValue JSConsole::profiles(ExecState* exec) const
-{
-    const ProfilesArray& profiles = impl()->profiles();
-    MarkedArgumentBuffer list;
-
-    ProfilesArray::const_iterator end = profiles.end();
-    for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter)
-        list.append(toJS(exec, globalObject(), iter->get()));
-
-    return constructArray(exec, globalObject(), list);
-}
-
 JSValue JSConsole::profile(ExecState* exec)
 {
     RefPtr<ScriptCallStack> callStack(createScriptCallStack(exec, 1));
index 0eb3d9cf523e6421dce4842c6dd3acdfcc0e7acf..20a450be827aa6485e76dc360f46c7cb76cb3819 100644 (file)
@@ -35,6 +35,7 @@
 #include "StyledElement.h"
 #include <heap/Weak.h>
 #include <runtime/FunctionPrototype.h>
+#include <runtime/JSArray.h>
 #include <runtime/Lookup.h>
 #include <runtime/ObjectPrototype.h>
 #include <wtf/Forward.h>
@@ -278,6 +279,34 @@ enum ParameterDefaultPolicy {
         return toJS(exec, globalObject, ptr.get());
     }
 
+    template <typename Iterable>
+    JSC::JSValue jsArray(JSC::ExecState* exec, JSDOMGlobalObject* globalObject, const Iterable& iterator)
+    {
+        JSC::MarkedArgumentBuffer list;
+        typename Iterable::const_iterator end = iterator.end();
+
+        for (typename Iterable::const_iterator iter = iterator.begin(); iter != end; ++iter)
+            list.append(toJS(exec, globalObject, WTF::getPtr(*iter)));
+
+        return JSC::constructArray(exec, list);
+    }
+
+    template <class T>
+    Vector<T> toNativeArray(JSC::ExecState* exec, JSC::JSValue value)
+    {
+        if (!isJSArray(value))
+            return Vector<T>();
+
+        Vector<T> result;
+        JSC::JSArray* array = asArray(value);
+
+        for (unsigned i = 0; i < array->length(); ++i) {
+            String indexedValue = ustringToString(array->getIndex(i).toString(exec)->value(exec));
+            result.append(indexedValue);
+        }
+        return result;
+    }
+
     // Validates that the passed object is a sequence type per section 4.1.13 of the WebIDL spec.
     JSC::JSObject* toJSSequence(JSC::ExecState*, JSC::JSValue, unsigned&);
 
index ea5835996718c118bc2801f7f0e0c023a2553a9e..524b158f86c0d91452fbe38e89b1ef9317e32f6f 100644 (file)
@@ -445,6 +445,15 @@ sub IsSVGAnimatedType
     return 0;
 }
 
+sub GetArrayType
+{
+    my $object = shift;
+    my $type = shift;
+
+    return $1 if $type =~ /^sequence<([\w\d_]+)>.*/;
+    return "";
+}
+
 # Uppercase the first letter while respecting WebKit style guidelines.
 # E.g., xmlEncoding becomes XMLEncoding, but xmlllang becomes Xmllang.
 sub WK_ucfirst
index e10d011c3d4fd9daab279cc22d087d306d36464e..6c11926cb1b8d2bc45327be7179cb226d45b9030 100644 (file)
@@ -164,6 +164,10 @@ sub SkipAttribute {
         return 1;
     }
 
+    if ($codeGenerator->GetArrayType($propType)) {
+        return 1;
+    }
+
     # This is for DOMWindow.idl location attribute
     if ($attribute->signature->name eq "location") {
         return 1;
index b6c1cbaba1a99b46bf315e9af8dadd2108f975b6..267a6e092d360a1fbdb3168bb8997eb2afab2552 100644 (file)
@@ -266,6 +266,7 @@ sub AddIncludesForType
         $includesRef->{"JS${type}.h"} = 1;
     } elsif (IsTypedArrayType($type)) {
         $includesRef->{"<wtf/${type}.h>"} = 1;
+    } elsif ($codeGenerator->GetArrayType($type)) {
     } else {
         # default, include the same named file
         $includesRef->{"${type}.h"} = 1;
@@ -2945,6 +2946,10 @@ sub JSValueToNative
     AddToImplIncludes("JSCustomVoidCallback.h", $conditional) if $type eq "VoidCallback";
     AddToImplIncludes("Event.h", $conditional) if $type eq "Event";
 
+    if ($codeGenerator->GetArrayType($type)) {
+        return "toNativeArray(exec, $value)";
+    }
+
     # Default, assume autogenerated type conversion routines
     AddToImplIncludes("JS$type.h", $conditional);
     return "to$type($value)";
@@ -3004,6 +3009,14 @@ sub NativeToJSValue
         AddToImplIncludes("NameNodeList.h", $conditional);
     }
 
+    my $arrayType = $codeGenerator->GetArrayType($type);
+    if ($arrayType) {
+        AddToImplIncludes("<runtime/JSArray.h>", $conditional);
+        AddToImplIncludes("JS$arrayType.h", $conditional);
+        AddToImplIncludes("$arrayType.h", $conditional);
+        return "jsArray(exec, $thisValue->globalObject(), $value)";
+    }
+
     if ($type eq "DOMObject") {
         if ($implClassName eq "Document") {
             AddToImplIncludes("JSCanvasRenderingContext2D.h", $conditional);
index 234b1bb1426ccc45ebd484340c03f9e6a7dba077..bb2268ce2a917fb1687c544b7137c4cf8ddc963d 100644 (file)
@@ -923,6 +923,17 @@ END
     if (!IsNodeSubType($dataNode) && $attrName ne "self" && (IsWrapperType($returnType) && ($attribute->type =~ /^readonly/ || $attribute->signature->extendedAttributes->{"Replaceable"})
         && $returnType ne "EventTarget" && $returnType ne "SerializedScriptValue" && $returnType ne "DOMWindow" 
         && $returnType !~ /SVG/ && $returnType !~ /HTML/ && !IsDOMNodeType($returnType))) {
+
+        my $arrayType = $codeGenerator->GetArrayType($returnType);
+        if ($arrayType) {
+            AddToImplIncludes("V8$arrayType.h");
+            AddToImplIncludes("$arrayType.h");
+            push(@implContentDecls, "    const Vector<RefPtr<$arrayType> > vector = ${getterString};\n");
+            push(@implContentDecls, "    return v8Array(vector);\n");
+            push(@implContentDecls, "}\n\n");
+            return;
+        }
+
         AddIncludesForType($returnType);
         # Check for a wrapper in the wrapper cache. If there is one, we know that a hidden reference has already
         # been created. If we don't find a wrapper, we create both a wrapper and a hidden reference.
@@ -1097,16 +1108,20 @@ END
         }
     } else {
         my $value = JSValueToNative($attribute->signature, "value");
+        my $arrayType = $codeGenerator->GetArrayType($nativeType);
+
         if ($nativeType =~ /^V8Parameter/) {
-          push(@implContentDecls, "    " . ConvertToV8Parameter($attribute->signature, $nativeType, "v", $value, "VOID") . "\n");
+            push(@implContentDecls, "    " . ConvertToV8Parameter($attribute->signature, $nativeType, "v", $value, "VOID") . "\n");
+        } elsif ($arrayType) {
+            push(@implContentDecls, "    Vector<$arrayType> v = $value;\n");
         } else {
-          push(@implContentDecls, "    $nativeType v = $value;\n");
+            push(@implContentDecls, "    $nativeType v = $value;\n");
         }
     }
 
     my $result = "v";
     my $returnType = GetTypeFromSignature($attribute->signature);
-    if (IsRefPtrType($returnType)) {
+    if (IsRefPtrType($returnType) && !$codeGenerator->GetArrayType($returnType)) {
         $result = "WTF::getPtr(" . $result . ")";
     }
 
@@ -3554,6 +3569,10 @@ sub JSValueToNative
         return "V8DOMWrapper::getXPathNSResolver($value)";
     }
 
+    if ($codeGenerator->GetArrayType($type)) {
+        return "toNativeArray($value)";
+    }
+
     AddIncludesForType($type);
 
     if (IsDOMNodeType($type)) {
@@ -3767,6 +3786,13 @@ sub NativeToJSValue
         return "v8String($value)";
     }
 
+    my $arrayType = $codeGenerator->GetArrayType($type);
+    if ($arrayType) {
+        AddToImplIncludes("V8$arrayType.h");
+        AddToImplIncludes("$arrayType.h");
+        return "v8Array($value)";
+    }
+
     AddIncludesForType($type);
 
     # special case for non-DOM node interfaces
index ab3a9bdcec5f9a89ddfdb23aa3d8e7ca9be3218d..80693d4add5e31aeaf606977fa249d6fa2ee0460 100644 (file)
@@ -810,32 +810,6 @@ webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj*
     item->setTestObjAttr(converted_value);
 }
 
-WebKitDOMsequence<ScriptProfile>*
-webkit_dom_test_obj_get_sequence_attr(WebKitDOMTestObj* self)
-{
-    g_return_val_if_fail(self, 0);
-    WebCore::JSMainThreadNullState state;
-    WebCore::TestObj * item = WebKit::core(self);
-    PassRefPtr<WebCore::sequence<ScriptProfile>> g_res = WTF::getPtr(item->sequenceAttr());
-    WebKitDOMsequence<ScriptProfile>* res = WebKit::kit(g_res.get());
-    return res;
-}
-
-void
-webkit_dom_test_obj_set_sequence_attr(WebKitDOMTestObj* self, WebKitDOMsequence<ScriptProfile>* value)
-{
-    g_return_if_fail(self);
-    WebCore::JSMainThreadNullState state;
-    WebCore::TestObj * item = WebKit::core(self);
-    g_return_if_fail(value);
-    WebCore::sequence<ScriptProfile> * converted_value = NULL;
-    if (value != NULL) {
-        converted_value = WebKit::core(value);
-        g_return_if_fail(converted_value);
-    }
-    item->setSequenceAttr(converted_value);
-}
-
 WebKitDOMTestObj*
 webkit_dom_test_obj_get_xml_obj_attr(WebKitDOMTestObj* self)
 {
@@ -1595,7 +1569,6 @@ enum {
     PROP_UNSIGNED_LONG_LONG_ATTR,
     PROP_STRING_ATTR,
     PROP_TEST_OBJ_ATTR,
-    PROP_SEQUENCE_ATTR,
     PROP_XML_OBJ_ATTR,
     PROP_CREATE,
     PROP_REFLECTED_STRING_ATTR,
@@ -1855,12 +1828,6 @@ static void webkit_dom_test_obj_get_property(GObject* object, guint prop_id, GVa
         g_value_set_object(value, WebKit::kit(ptr.get()));
         break;
     }
-    case PROP_SEQUENCE_ATTR:
-    {
-        RefPtr<WebCore::sequence<ScriptProfile>> ptr = coreSelf->sequenceAttr();
-        g_value_set_object(value, WebKit::kit(ptr.get()));
-        break;
-    }
     case PROP_XML_OBJ_ATTR:
     {
         RefPtr<WebCore::TestObj> ptr = coreSelf->xmlObjAttr();
@@ -2152,13 +2119,6 @@ G_MAXUINT64, /* min */
                                                            "read-write  WebKitDOMTestObj* TestObj.test-obj-attr", /* longer - could do with some extra doc stuff here */
                                                            WEBKIT_TYPE_DOM_TEST_OBJ, /* gobject type */
                                                            WEBKIT_PARAM_READWRITE));
-    g_object_class_install_property(gobjectClass,
-                                    PROP_SEQUENCE_ATTR,
-                                    g_param_spec_object("sequence-attr", /* name */
-                                                           "test_obj_sequence-attr", /* short description */
-                                                           "read-write  WebKitDOMsequence<ScriptProfile>* TestObj.sequence-attr", /* longer - could do with some extra doc stuff here */
-                                                           WEBKIT_TYPE_DOM_SEQUENCE<SCRIPT_PROFILE>, /* gobject type */
-                                                           WEBKIT_PARAM_READWRITE));
     g_object_class_install_property(gobjectClass,
                                     PROP_XML_OBJ_ATTR,
                                     g_param_spec_object("xml-obj-attr", /* name */
index bb36779218e5539def0884475dfa880bcad2a807..b94ebae2f8b3394bc1466d050b41de0a9a2c1109 100644 (file)
@@ -696,27 +696,6 @@ webkit_dom_test_obj_get_test_obj_attr(WebKitDOMTestObj* self);
 WEBKIT_API void
 webkit_dom_test_obj_set_test_obj_attr(WebKitDOMTestObj* self, WebKitDOMTestObj* value);
 
-/**
- * webkit_dom_test_obj_get_sequence_attr:
- * @self: A #WebKitDOMTestObj
- *
- * Returns: (transfer none):
- *
-**/
-WEBKIT_API WebKitDOMsequence<ScriptProfile>*
-webkit_dom_test_obj_get_sequence_attr(WebKitDOMTestObj* self);
-
-/**
- * webkit_dom_test_obj_set_sequence_attr:
- * @self: A #WebKitDOMTestObj
- * @value: A #WebKitDOMsequence<ScriptProfile>
- *
- * Returns: (transfer none):
- *
-**/
-WEBKIT_API void
-webkit_dom_test_obj_set_sequence_attr(WebKitDOMTestObj* self, WebKitDOMsequence<ScriptProfile>* value);
-
 /**
  * webkit_dom_test_obj_get_xml_obj_attr:
  * @self: A #WebKitDOMTestObj
index c051c25720d6178bf8bfd3320549dfd966d2b2e7..ef4309a754a8a818c34c521a0589fab71c640713 100644 (file)
@@ -33,6 +33,7 @@
 #include "JSEventListener.h"
 #include "JSSVGDocument.h"
 #include "JSSVGPoint.h"
+#include "JSScriptProfile.h"
 #include "JSTestCallback.h"
 #include "JSTestObj.h"
 #include "JSa.h"
 #include "JSe.h"
 #include "JSint.h"
 #include "JSsequence.h"
-#include "JSsequence<ScriptProfile>.h"
 #include "KURL.h"
 #include "SVGDocument.h"
 #include "SVGStaticPropertyTearOff.h"
 #include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptCallStackFactory.h"
+#include "ScriptProfile.h"
 #include "SerializedScriptValue.h"
 #include "TestObj.h"
 #include "bool.h"
-#include "sequence<ScriptProfile>.h"
 #include <runtime/Error.h>
+#include <runtime/JSArray.h>
 #include <runtime/JSString.h>
 #include <wtf/GetPtr.h>
 
@@ -477,7 +478,7 @@ JSValue jsTestObjSequenceAttr(ExecState* exec, JSValue slotBase, const Identifie
     JSTestObj* castedThis = static_cast<JSTestObj*>(asObject(slotBase));
     UNUSED_PARAM(exec);
     TestObj* impl = static_cast<TestObj*>(castedThis->impl());
-    JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->sequenceAttr()));
+    JSValue result = jsArray(exec, castedThis->globalObject(), impl->sequenceAttr());
     return result;
 }
 
@@ -965,7 +966,7 @@ void setJSTestObjSequenceAttr(ExecState* exec, JSObject* thisObject, JSValue val
 {
     JSTestObj* castedThis = static_cast<JSTestObj*>(thisObject);
     TestObj* impl = static_cast<TestObj*>(castedThis->impl());
-    impl->setSequenceAttr(tosequence<ScriptProfile>(value));
+    impl->setSequenceAttr(toNativeArray(exec, value));
 }
 
 
@@ -1423,7 +1424,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionMethodReturningSequence(E
     if (exec->hadException())
         return JSValue::encode(jsUndefined());
 
-    JSC::JSValue result = toJS(exec, castedThis->globalObject(), WTF::getPtr(impl->methodReturningSequence(intArg)));
+    JSC::JSValue result = jsArray(exec, castedThis->globalObject(), impl->methodReturningSequence(intArg));
     return JSValue::encode(result);
 }
 
index ab9cb06a837715350417e375b7d531fd758309ef..2deddbe9ea24c3f3001512cedb5e27b259d6e886 100644 (file)
@@ -32,6 +32,7 @@
 #include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptCallStackFactory.h"
+#include "ScriptProfile.h"
 #include "SerializedScriptValue.h"
 #include "V8Binding.h"
 #include "V8BindingMacros.h"
@@ -42,6 +43,7 @@
 #include "V8Proxy.h"
 #include "V8SVGDocument.h"
 #include "V8SVGPoint.h"
+#include "V8ScriptProfile.h"
 #include "V8TestCallback.h"
 #include "V8a.h"
 #include "V8any.h"
@@ -52,7 +54,6 @@
 #include "V8e.h"
 #include "V8int.h"
 #include "V8sequence.h"
-#include "V8sequence<ScriptProfile>.h"
 #include <wtf/GetPtr.h>
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
@@ -223,15 +224,15 @@ static v8::Handle<v8::Value> sequenceAttrAttrGetter(v8::Local<v8::String> name,
 {
     INC_STATS("DOM.TestObj.sequenceAttr._get");
     TestObj* imp = V8TestObj::toNative(info.Holder());
-    return toV8(imp->sequenceAttr());
+    return v8Array(imp->sequenceAttr());
 }
 
 static void sequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
 {
     INC_STATS("DOM.TestObj.sequenceAttr._set");
     TestObj* imp = V8TestObj::toNative(info.Holder());
-    sequence<ScriptProfile>* v = V8sequence<ScriptProfile>::HasInstance(value) ? V8sequence<ScriptProfile>::toNative(v8::Handle<v8::Object>::Cast(value)) : 0;
-    imp->setSequenceAttr(WTF::getPtr(v));
+    Vector<ScriptProfile> v = toNativeArray(value);
+    imp->setSequenceAttr(v);
     return;
 }
 
@@ -1071,7 +1072,7 @@ static v8::Handle<v8::Value> methodReturningSequenceCallback(const v8::Arguments
         return throwError("Not enough arguments", V8Proxy::TypeError);
     TestObj* imp = V8TestObj::toNative(args.Holder());
     EXCEPTION_BLOCK(int, intArg, toInt32(MAYBE_MISSING_PARAMETER(args, 0, DefaultIsUndefined)));
-    return toV8(imp->methodReturningSequence(intArg));
+    return v8Array(imp->methodReturningSequence(intArg));
 }
 
 static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8::Arguments& args)
index 369dd008813f2800ea606a00db47ecc705442acf..bacd7e9aa26f3f7486ce78bd18c0458e87a069f5 100644 (file)
@@ -286,6 +286,35 @@ namespace WebCore {
         return v8ExternalString(string);
     }
 
+    template<typename Iterable>
+    v8::Handle<v8::Value> v8Array(const Iterable& iterator)
+    {
+        v8::Local<v8::Array> result = v8::Array::New(iterator.size());
+        int index = 0;
+        typename Iterable::const_iterator end = iterator.end();
+        for (typename Iterable::const_iterator iter = iterator.begin(); iter != end; ++iter)
+            result->Set(v8::Integer::New(index++), toV8(WTF::getPtr(*iter)));
+        return result;
+    }
+
+    template <class T>
+    Vector<T> toNativeArray(v8::Handle<v8::Value> value)
+    {
+        if (!value->IsArray())
+            return Vector<T>();
+
+        Vector<T> result;
+        v8::Local<v8::Value> v8Value(v8::Local<v8::Value>::New(value));
+        v8::Local<v8::Array> array = v8::Local<v8::Array>::Cast(v8Value);
+        size_t length = array->Length();
+
+        for (size_t i = 0; i < length; ++i) {
+            String indexedValue = v8StringToWebCoreString(array->Get(i));
+            result.append(indexedValue);
+        }
+        return result;
+    }
+
     // Enables caching v8 wrappers created for WTF::StringImpl.  Currently this cache requires
     // all the calls (both to convert WTF::String to v8::String and to GC the handle)
     // to be performed on the main thread.
index 7ade8688d7b041a1fd2e8340cf1beb52de1f7242..dfce734b1eb0868f4199480aadcc7e7cac6d7430 100644 (file)
 #include "ScriptArguments.h"
 #include "ScriptCallStack.h"
 #include "ScriptCallStackFactory.h"
-#include "ScriptProfile.h"
 #include "V8Binding.h"
 #include "V8BindingMacros.h"
 #include "V8MemoryInfo.h"
 #include "V8Proxy.h"
-#include "V8ScriptProfile.h"
 
 namespace WebCore {
 
-typedef Vector<RefPtr<ScriptProfile> > ProfilesArray;
-
-#if ENABLE(JAVASCRIPT_DEBUGGER)
-v8::Handle<v8::Value> V8Console::profilesAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
-{
-    INC_STATS("DOM.Console.profilesAccessorGetter");
-    Console* imp = V8Console::toNative(info.Holder());
-    const ProfilesArray& profiles = imp->profiles();
-    v8::Handle<v8::Array> result = v8::Array::New(profiles.size());
-    int index = 0;
-    ProfilesArray::const_iterator end = profiles.end();
-    for (ProfilesArray::const_iterator iter = profiles.begin(); iter != end; ++iter)
-        result->Set(v8::Integer::New(index++), toV8(iter->get()));
-    return result;
-}
-#endif
-
 v8::Handle<v8::Value> V8Console::traceCallback(const v8::Arguments& args)
 {
     INC_STATS("DOM.Console.traceCallback");
index 2defe3213bd48f0288baf49d4955bbe16da78c13..5f215e89b8e5116b81d894982838a5ef88308d5e 100644 (file)
@@ -46,7 +46,7 @@ module window {
         [CallWith=ScriptArguments|CallStack] void markTimeline();
 
 #if defined(ENABLE_JAVASCRIPT_DEBUGGER) && ENABLE_JAVASCRIPT_DEBUGGER
-        readonly attribute [CustomGetter] Array profiles;
+        readonly attribute sequence<ScriptProfile> profiles;
         [Custom] void profile(in DOMString title);
         [Custom] void profileEnd(in DOMString title);
 #endif