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

Unified Diff: Source/bindings/tests/results/modules/V8TestInterface5.cpp

Issue 567503002: Add toDouble() helper, and use toFloat()/toDouble() for conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 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
Index: Source/bindings/tests/results/modules/V8TestInterface5.cpp
diff --git a/Source/bindings/tests/results/modules/V8TestInterface5.cpp b/Source/bindings/tests/results/modules/V8TestInterface5.cpp
index 51bf8e52b7817adcdcadbf1bdf71a258cf68c3a1..a3cff6ebd3fa583e86106a48ece0e3ca12df92f5 100644
--- a/Source/bindings/tests/results/modules/V8TestInterface5.cpp
+++ b/Source/bindings/tests/results/modules/V8TestInterface5.cpp
@@ -90,7 +90,7 @@ static void doubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v
v8::Handle<v8::Object> holder = info.Holder();
ExceptionState exceptionState(ExceptionState::SetterContext, "doubleAttribute", "TestInterface5", holder, info.GetIsolate());
TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
- TONATIVE_VOID(double, cppValue, static_cast<double>(v8Value->NumberValue()));
+ TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState);
if (!std::isfinite(cppValue)) {
exceptionState.throwTypeError("The provided double value is non-finite.");
exceptionState.throwIfNeeded();
@@ -125,7 +125,7 @@ static void floatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8
v8::Handle<v8::Object> holder = info.Holder();
ExceptionState exceptionState(ExceptionState::SetterContext, "floatAttribute", "TestInterface5", holder, info.GetIsolate());
TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
- TONATIVE_VOID(float, cppValue, static_cast<float>(v8Value->NumberValue()));
+ TONATIVE_VOID_EXCEPTIONSTATE(float, cppValue, toFloat(v8Value, exceptionState), exceptionState);
if (!std::isfinite(cppValue)) {
exceptionState.throwTypeError("The provided float value is non-finite.");
exceptionState.throwIfNeeded();
@@ -158,8 +158,9 @@ static void unrestrictedDoubleAttributeAttributeGetterCallback(v8::Local<v8::Str
static void unrestrictedDoubleAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
+ ExceptionState exceptionState(ExceptionState::SetterContext, "unrestrictedDoubleAttribute", "TestInterface5", holder, info.GetIsolate());
TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
- TONATIVE_VOID(double, cppValue, static_cast<double>(v8Value->NumberValue()));
+ TONATIVE_VOID_EXCEPTIONSTATE(double, cppValue, toDouble(v8Value, exceptionState), exceptionState);
impl->setUnrestrictedDoubleAttribute(cppValue);
}
@@ -187,8 +188,9 @@ static void unrestrictedFloatAttributeAttributeGetterCallback(v8::Local<v8::Stri
static void unrestrictedFloatAttributeAttributeSetter(v8::Local<v8::Value> v8Value, const v8::PropertyCallbackInfo<void>& info)
{
v8::Handle<v8::Object> holder = info.Holder();
+ ExceptionState exceptionState(ExceptionState::SetterContext, "unrestrictedFloatAttribute", "TestInterface5", holder, info.GetIsolate());
TestInterface5Implementation* impl = V8TestInterface5::toImpl(holder);
- TONATIVE_VOID(float, cppValue, static_cast<float>(v8Value->NumberValue()));
+ TONATIVE_VOID_EXCEPTIONSTATE(float, cppValue, toFloat(v8Value, exceptionState), exceptionState);
impl->setUnrestrictedFloatAttribute(cppValue);
}
@@ -364,24 +366,26 @@ static void voidMethodTestInterfaceEmptyArgMethodCallback(const v8::FunctionCall
static void voidMethodDoubleArgFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDoubleArgFloatArg", "TestInterface5", info.Holder(), info.GetIsolate());
if (UNLIKELY(info.Length() < 2)) {
- V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("voidMethodDoubleArgFloatArg", "TestInterface5", 2, info.Length(), info.GetIsolate()), info.GetIsolate());
+ setMinimumArityTypeError(exceptionState, 2, info.Length());
+ exceptionState.throwIfNeeded();
return;
}
TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
double doubleArg;
float floatArg;
{
- v8::TryCatch block;
- V8RethrowTryCatchScope rethrow(block);
- TONATIVE_VOID_INTERNAL(doubleArg, static_cast<double>(info[0]->NumberValue()));
+ TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(doubleArg, toDouble(info[0], exceptionState), exceptionState);
if (!std::isfinite(doubleArg)) {
- V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute("voidMethodDoubleArgFloatArg", "TestInterface5", "double parameter 1 is non-finite."), info.GetIsolate());
+ exceptionState.throwTypeError("double parameter 1 is non-finite.");
+ exceptionState.throwIfNeeded();
return;
}
- TONATIVE_VOID_INTERNAL(floatArg, static_cast<float>(info[1]->NumberValue()));
+ TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(floatArg, toFloat(info[1], exceptionState), exceptionState);
if (!std::isfinite(floatArg)) {
- V8ThrowException::throwTypeError(ExceptionMessages::failedToExecute("voidMethodDoubleArgFloatArg", "TestInterface5", "float parameter 2 is non-finite."), info.GetIsolate());
+ exceptionState.throwTypeError("float parameter 2 is non-finite.");
+ exceptionState.throwIfNeeded();
return;
}
}
@@ -397,18 +401,18 @@ static void voidMethodDoubleArgFloatArgMethodCallback(const v8::FunctionCallback
static void voidMethodUnrestrictedDoubleArgUnrestrictedFloatArgMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
+ ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", "TestInterface5", info.Holder(), info.GetIsolate());
if (UNLIKELY(info.Length() < 2)) {
- V8ThrowException::throwException(createMinimumArityTypeErrorForMethod("voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg", "TestInterface5", 2, info.Length(), info.GetIsolate()), info.GetIsolate());
+ setMinimumArityTypeError(exceptionState, 2, info.Length());
+ exceptionState.throwIfNeeded();
return;
}
TestInterface5Implementation* impl = V8TestInterface5::toImpl(info.Holder());
double unrestrictedDoubleArg;
float unrestrictedFloatArg;
{
- v8::TryCatch block;
- V8RethrowTryCatchScope rethrow(block);
- TONATIVE_VOID_INTERNAL(unrestrictedDoubleArg, static_cast<double>(info[0]->NumberValue()));
- TONATIVE_VOID_INTERNAL(unrestrictedFloatArg, static_cast<float>(info[1]->NumberValue()));
+ TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(unrestrictedDoubleArg, toDouble(info[0], exceptionState), exceptionState);
+ TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(unrestrictedFloatArg, toFloat(info[1], exceptionState), exceptionState);
}
impl->voidMethodUnrestrictedDoubleArgUnrestrictedFloatArg(unrestrictedDoubleArg, unrestrictedFloatArg);
}

Powered by Google App Engine
This is Rietveld 408576698