[V8] Pass Isolate to v8Array()
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 05:12:14 +0000 (05:12 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Apr 2012 05:12:14 +0000 (05:12 +0000)
https://bugs.webkit.org/show_bug.cgi?id=84295

Reviewed by Nate Chapin.

The final objective is to pass Isolate around in V8 bindings.
This patch passes the Isolate to v8Array().

(GenerateNormalAttrGetter):
(NativeToJSValue):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::sequenceAttrAttrGetter):
(WebCore::TestObjV8Internal::methodReturningSequenceCallback):
* bindings/v8/V8Binding.h:
(WebCore::v8Array):

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

Source/WebCore/ChangeLog
Source/WebCore/bindings/scripts/CodeGeneratorV8.pm
Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp
Source/WebCore/bindings/v8/V8Binding.h

index 3f91f89..3908ef1 100644 (file)
@@ -1,5 +1,23 @@
 2012-04-23  Kentaro Hara  <haraken@chromium.org>
 
+        [V8] Pass Isolate to v8Array()
+        https://bugs.webkit.org/show_bug.cgi?id=84295
+
+        Reviewed by Nate Chapin.
+
+        The final objective is to pass Isolate around in V8 bindings.
+        This patch passes the Isolate to v8Array().
+
+        (GenerateNormalAttrGetter):
+        (NativeToJSValue):
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjV8Internal::sequenceAttrAttrGetter):
+        (WebCore::TestObjV8Internal::methodReturningSequenceCallback):
+        * bindings/v8/V8Binding.h:
+        (WebCore::v8Array):
+
+2012-04-23  Kentaro Hara  <haraken@chromium.org>
+
         [V8] Pass Isolate to GetNamedProperty()
         https://bugs.webkit.org/show_bug.cgi?id=84277
 
index 42baa4f..1b843ae 100644 (file)
@@ -919,7 +919,7 @@ END
                 AddToImplIncludes("V8$arrayType.h");
                 AddToImplIncludes("$arrayType.h");
             }
-            push(@implContentDecls, "    return v8Array(${getterString});\n");
+            push(@implContentDecls, "    return v8Array(${getterString}, info.GetIsolate());\n");
             push(@implContentDecls, "}\n\n");
             return;
         }
@@ -3808,7 +3808,7 @@ sub NativeToJSValue
             AddToImplIncludes("V8$arrayType.h");
             AddToImplIncludes("$arrayType.h");
         }
-        return "v8Array($value)";
+        return "v8Array($value, $getIsolate)";
     }
 
     AddIncludesForType($type);
index fa3caee..0943d7d 100644 (file)
@@ -223,7 +223,7 @@ static v8::Handle<v8::Value> sequenceAttrAttrGetter(v8::Local<v8::String> name,
 {
     INC_STATS("DOM.TestObj.sequenceAttr._get");
     TestObj* imp = V8TestObj::toNative(info.Holder());
-    return v8Array(imp->sequenceAttr());
+    return v8Array(imp->sequenceAttr(), info.GetIsolate());
 }
 
 static void sequenceAttrAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
@@ -1295,7 +1295,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 v8Array(imp->methodReturningSequence(intArg));
+    return v8Array(imp->methodReturningSequence(intArg), args.GetIsolate());
 }
 
 static v8::Handle<v8::Value> methodThatRequiresAllArgsAndThrowsCallback(const v8::Arguments& args)
index 91412a1..d409634 100644 (file)
@@ -261,24 +261,24 @@ namespace WebCore {
     }
 
     template<typename T>
-    v8::Handle<v8::Value> v8Array(const Vector<T>& iterator)
+    v8::Handle<v8::Value> v8Array(const Vector<T>& iterator, v8::Isolate* isolate)
     {
         v8::Local<v8::Array> result = v8::Array::New(iterator.size());
         int index = 0;
         typename Vector<T>::const_iterator end = iterator.end();
         for (typename Vector<T>::const_iterator iter = iterator.begin(); iter != end; ++iter)
-            result->Set(v8::Integer::New(index++), toV8(WTF::getPtr(*iter)));
+            result->Set(v8::Integer::New(index++), toV8(WTF::getPtr(*iter), isolate));
         return result;
     }
 
     template<>
-    inline v8::Handle<v8::Value> v8Array(const Vector<String>& iterator)
+    inline v8::Handle<v8::Value> v8Array(const Vector<String>& iterator, v8::Isolate* isolate)
     {
         v8::Local<v8::Array> array = v8::Array::New(iterator.size());
         Vector<String>::const_iterator end = iterator.end();
         int index = 0;
         for (Vector<String>::const_iterator iter = iterator.begin(); iter != end; ++iter)
-            array->Set(v8::Integer::New(index++), v8String(*iter));
+            array->Set(v8::Integer::New(index++), v8String(*iter, isolate));
         return array;
     }