[V8] Add an optional 'isolate' argument to throwTypeError()
authorharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 08:38:34 +0000 (08:38 +0000)
committerharaken@chromium.org <haraken@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 May 2012 08:38:34 +0000 (08:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=87070

Reviewed by Adam Barth.

The objective is to pass Isolate around in V8 bindings.
This patch adds an optional 'isolate' argument to throwTypeError(),
and passes Isolate to throwTypeError()s. In a following patch,
I'll pass Isolate to all throwTypeError("message")s.

No tests. No change in behavior.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNormalAttrSetter):
(GenerateOverloadedFunctionCallback):
(GenerateParametersCheck):
* bindings/scripts/test/V8/V8TestObj.cpp:
(WebCore::TestObjV8Internal::overloadedMethodCallback):
(WebCore::TestObjV8Internal::overloadedMethod1Callback):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::throwTypeError):
* bindings/v8/V8Proxy.h:
(V8Proxy):
* bindings/v8/custom/V8ArrayBufferViewCustom.h:
(WebCore::constructWebGLArray):
* bindings/v8/custom/V8DataViewCustom.cpp:
(WebCore::V8DataView::constructorCallback):
* bindings/v8/custom/V8SVGLengthCustom.cpp:
(WebCore::V8SVGLength::valueAccessorSetter):
* bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
(WebCore::V8WebGLRenderingContext::getAttachedShadersCallback):
(WebCore::V8WebGLRenderingContext::getProgramParameterCallback):
(WebCore::V8WebGLRenderingContext::getShaderParameterCallback):
(WebCore::V8WebGLRenderingContext::getUniformCallback):
(WebCore::vertexAttribAndUniformHelperf):
(WebCore::uniformHelperi):
(WebCore::uniformMatrixHelper):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@117933 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/V8Proxy.cpp
Source/WebCore/bindings/v8/V8Proxy.h
Source/WebCore/bindings/v8/custom/V8ArrayBufferViewCustom.h
Source/WebCore/bindings/v8/custom/V8DataViewCustom.cpp
Source/WebCore/bindings/v8/custom/V8SVGLengthCustom.cpp
Source/WebCore/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp

index 4265c1d..13efd92 100644 (file)
@@ -1,3 +1,43 @@
+2012-05-22  Kentaro Hara  <haraken@chromium.org>
+
+        [V8] Add an optional 'isolate' argument to throwTypeError()
+        https://bugs.webkit.org/show_bug.cgi?id=87070
+
+        Reviewed by Adam Barth.
+
+        The objective is to pass Isolate around in V8 bindings.
+        This patch adds an optional 'isolate' argument to throwTypeError(),
+        and passes Isolate to throwTypeError()s. In a following patch,
+        I'll pass Isolate to all throwTypeError("message")s.
+
+        No tests. No change in behavior.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateNormalAttrSetter):
+        (GenerateOverloadedFunctionCallback):
+        (GenerateParametersCheck):
+        * bindings/scripts/test/V8/V8TestObj.cpp:
+        (WebCore::TestObjV8Internal::overloadedMethodCallback):
+        (WebCore::TestObjV8Internal::overloadedMethod1Callback):
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::throwTypeError):
+        * bindings/v8/V8Proxy.h:
+        (V8Proxy):
+        * bindings/v8/custom/V8ArrayBufferViewCustom.h:
+        (WebCore::constructWebGLArray):
+        * bindings/v8/custom/V8DataViewCustom.cpp:
+        (WebCore::V8DataView::constructorCallback):
+        * bindings/v8/custom/V8SVGLengthCustom.cpp:
+        (WebCore::V8SVGLength::valueAccessorSetter):
+        * bindings/v8/custom/V8WebGLRenderingContextCustom.cpp:
+        (WebCore::V8WebGLRenderingContext::getAttachedShadersCallback):
+        (WebCore::V8WebGLRenderingContext::getProgramParameterCallback):
+        (WebCore::V8WebGLRenderingContext::getShaderParameterCallback):
+        (WebCore::V8WebGLRenderingContext::getUniformCallback):
+        (WebCore::vertexAttribAndUniformHelperf):
+        (WebCore::uniformHelperi):
+        (WebCore::uniformMatrixHelper):
+
 2012-05-22  Yoshifumi Inoue  <yosin@chromium.org>
 
         [Forms][Meter][Progress] Change function signature of parseToDoubleForNumberType
index a97a434..f3bed83 100644 (file)
@@ -1054,7 +1054,7 @@ sub GenerateNormalAttrSetter
         my $argType = GetTypeFromSignature($attribute->signature);
         if (IsWrapperType($argType)) {
             push(@implContentDecls, "    if (!isUndefinedOrNull(value) && !V8${argType}::HasInstance(value)) {\n");
-            push(@implContentDecls, "        V8Proxy::throwTypeError();\n");
+            push(@implContentDecls, "        V8Proxy::throwTypeError(0, info.GetIsolate());\n");
             push(@implContentDecls, "        return;\n");
             push(@implContentDecls, "    }\n");
         }
@@ -1354,7 +1354,7 @@ END
         push(@implContentDecls, "        return ${name}$overload->{overloadIndex}Callback(args);\n");
     }
     push(@implContentDecls, <<END);
-    V8Proxy::throwTypeError();
+    V8Proxy::throwTypeError(0, args.GetIsolate());
     return v8::Handle<v8::Value>();
 END
     push(@implContentDecls, "}\n\n");
@@ -1663,7 +1663,7 @@ sub GenerateParametersCheck
                 my $argType = GetTypeFromSignature($parameter);
                 if (IsWrapperType($argType)) {
                     $parameterCheckString .= "    if (args.Length() > $paramIndex && !isUndefinedOrNull($argValue) && !V8${argType}::HasInstance($argValue)) {\n";
-                    $parameterCheckString .= "        V8Proxy::throwTypeError();\n";
+                    $parameterCheckString .= "        V8Proxy::throwTypeError(0, args.GetIsolate());\n";
                     $parameterCheckString .= "        return v8::Handle<v8::Value>();\n";
                     $parameterCheckString .= "    }\n";
                 }
index 509044f..6ec3bb1 100644 (file)
@@ -1813,7 +1813,7 @@ static v8::Handle<v8::Value> overloadedMethodCallback(const v8::Arguments& args)
         return overloadedMethod6Callback(args);
     if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsArray())))
         return overloadedMethod7Callback(args);
-    V8Proxy::throwTypeError();
+    V8Proxy::throwTypeError(0, args.GetIsolate());
     return v8::Handle<v8::Value>();
 }
 
@@ -1871,7 +1871,7 @@ static v8::Handle<v8::Value> overloadedMethod1Callback(const v8::Arguments& args
         return overloadedMethod11Callback(args);
     if ((args.Length() == 1 && (args[0]->IsNull() || args[0]->IsUndefined() || args[0]->IsString() || args[0]->IsObject())))
         return overloadedMethod12Callback(args);
-    V8Proxy::throwTypeError();
+    V8Proxy::throwTypeError(0, args.GetIsolate());
     return v8::Handle<v8::Value>();
 }
 
index 67d528f..c53b7a0 100644 (file)
@@ -631,9 +631,9 @@ v8::Handle<v8::Value> V8Proxy::throwError(ErrorType type, const char* message, v
     }
 }
 
-v8::Handle<v8::Value> V8Proxy::throwTypeError(const char* message)
+v8::Handle<v8::Value> V8Proxy::throwTypeError(const char* message, v8::Isolate* isolate)
 {
-    return throwError(TypeError, (message ? message : "Type error"));
+    return throwError(TypeError, (message ? message : "Type error"), isolate);
 }
 
 v8::Handle<v8::Value> V8Proxy::throwNotEnoughArgumentsError(v8::Isolate* isolate)
index 1718bc8..fbf9594 100644 (file)
@@ -240,7 +240,7 @@ namespace WebCore {
         static v8::Handle<v8::Value> throwError(ErrorType, const char* message, v8::Isolate* = 0);
 
         // Helpers for throwing syntax and type errors with predefined messages.
-        static v8::Handle<v8::Value> throwTypeError(const char* = 0);
+        static v8::Handle<v8::Value> throwTypeError(const char* = 0, v8::Isolate* = 0);
         static v8::Handle<v8::Value> throwNotEnoughArgumentsError(v8::Isolate*);
 
         v8::Local<v8::Context> context();
index 2395f24..a2fd69d 100644 (file)
@@ -138,8 +138,7 @@ v8::Handle<v8::Value> constructWebGLArray(const v8::Arguments& args, WrapperType
 
     if (args[0]->IsNull()) {
         // Invalid first argument
-        // FIXME: use forthcoming V8Proxy::throwTypeError().
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     }
 
     // See whether the first argument is a ArrayBuffer.
index 954188e..f1c9d27 100755 (executable)
@@ -53,7 +53,7 @@ v8::Handle<v8::Value> V8DataView::constructorCallback(const v8::Arguments& args)
         return args.Holder();
     }
     if (args[0]->IsNull() || !V8ArrayBuffer::HasInstance(args[0]))
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     return constructWebGLArrayWithArrayBufferArgument<DataView, char>(args, &info, v8::kExternalByteArray, false);
 }
 
index 10a0735..f7da9bf 100644 (file)
@@ -66,7 +66,7 @@ void V8SVGLength::valueAccessorSetter(v8::Local<v8::String> name, v8::Local<v8::
     }
 
     if (!isUndefinedOrNull(value) && !value->IsNumber() && !value->IsBoolean()) {
-        V8Proxy::throwTypeError();
+        V8Proxy::throwTypeError(0, info.GetIsolate());
         return;
     }
 
index ee9d1a7..072daea 100644 (file)
@@ -274,7 +274,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getAttachedShadersCallback(const
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
     if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0]))
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     Vector<RefPtr<WebGLShader> > shaders;
     bool succeed = context->getAttachedShaders(program, shaders, ec);
@@ -355,7 +355,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getProgramParameterCallback(const
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
     if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0]))
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     unsigned pname = toInt32(args[1]);
     WebGLGetInfo info = context->getProgramParameter(program, pname, ec);
@@ -382,7 +382,7 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getShaderParameterCallback(const
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
     if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLShader::HasInstance(args[0]))
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     WebGLShader* shader = V8WebGLShader::HasInstance(args[0]) ? V8WebGLShader::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
     unsigned pname = toInt32(args[1]);
     WebGLGetInfo info = context->getShaderParameter(shader, pname, ec);
@@ -423,11 +423,11 @@ v8::Handle<v8::Value> V8WebGLRenderingContext::getUniformCallback(const v8::Argu
     ExceptionCode ec = 0;
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
     if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLProgram::HasInstance(args[0]))
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     WebGLProgram* program = V8WebGLProgram::HasInstance(args[0]) ? V8WebGLProgram::toNative(v8::Handle<v8::Object>::Cast(args[0])) : 0;
 
     if (args.Length() > 1 && !isUndefinedOrNull(args[1]) && !V8WebGLUniformLocation::HasInstance(args[1]))
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     bool ok = false;
     WebGLUniformLocation* location = toWebGLUniformLocation(args[1], ok);
 
@@ -495,7 +495,7 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments&
         index = toInt32(args[0]);
     else {
         if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0]))
-            return V8Proxy::throwTypeError();
+            return V8Proxy::throwTypeError(0, args.GetIsolate());
         location = toWebGLUniformLocation(args[0], ok);
     }
 
@@ -522,7 +522,7 @@ static v8::Handle<v8::Value> vertexAttribAndUniformHelperf(const v8::Arguments&
     }
 
     if (args[1].IsEmpty() || !args[1]->IsArray())
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     v8::Handle<v8::Array> array =
       v8::Local<v8::Array>::Cast(args[1]);
     uint32_t len = array->Length();
@@ -567,7 +567,7 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args,
 
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
     if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0]))
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     bool ok = false;
     WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok);
 
@@ -588,7 +588,7 @@ static v8::Handle<v8::Value> uniformHelperi(const v8::Arguments& args,
     }
 
     if (args[1].IsEmpty() || !args[1]->IsArray())
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     v8::Handle<v8::Array> array =
       v8::Local<v8::Array>::Cast(args[1]);
     uint32_t len = array->Length();
@@ -678,7 +678,7 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args,
     WebGLRenderingContext* context = V8WebGLRenderingContext::toNative(args.Holder());
 
     if (args.Length() > 0 && !isUndefinedOrNull(args[0]) && !V8WebGLUniformLocation::HasInstance(args[0]))
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     bool ok = false;
     WebGLUniformLocation* location = toWebGLUniformLocation(args[0], ok);
     
@@ -699,7 +699,7 @@ static v8::Handle<v8::Value> uniformMatrixHelper(const v8::Arguments& args,
     }
 
     if (args[2].IsEmpty() || !args[2]->IsArray())
-        return V8Proxy::throwTypeError();
+        return V8Proxy::throwTypeError(0, args.GetIsolate());
     v8::Handle<v8::Array> array =
       v8::Local<v8::Array>::Cast(args[2]);
     uint32_t len = array->Length();