Chromium Code Reviews| Index: Source/bindings/core/v8/V8Binding.cpp |
| diff --git a/Source/bindings/core/v8/V8Binding.cpp b/Source/bindings/core/v8/V8Binding.cpp |
| index b1e36c0770e75469d2b5ca77c8109eb2dabbcc69..5069c3412b168a6a1aa1a2f3d0a77bd29640510a 100644 |
| --- a/Source/bindings/core/v8/V8Binding.cpp |
| +++ b/Source/bindings/core/v8/V8Binding.cpp |
| @@ -202,7 +202,13 @@ static inline T toSmallerInt(v8::Handle<v8::Value> value, IntegerConversionConfi |
| } |
| // Can the value be converted to a number? |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value->ToNumber(), exceptionState, 0); |
| + v8::TryCatch block; |
| + v8::Local<v8::Number> numberObject(value->ToNumber()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return 0; |
| + } |
| + |
| if (numberObject.IsEmpty()) { |
|
Jens Widell
2014/09/09 15:06:38
Question: Can this be true? It would be if value->
haraken
2014/09/10 01:09:23
You're right. This should be ASSERT(!numberObject.
Jens Widell
2014/09/10 05:33:57
Done.
|
| exceptionState.throwTypeError("Not convertible to a number value (of type '" + String(typeName) + "'."); |
|
haraken
2014/09/10 01:09:23
Do we want to put this message into the exceptionS
Jens Widell
2014/09/10 04:42:27
Don't know if I understand what you mean. Elaborat
haraken
2014/09/10 04:49:49
Sorry for not being clear.
There are two ways to
|
| return 0; |
| @@ -239,7 +245,13 @@ static inline T toSmallerUInt(v8::Handle<v8::Value> value, IntegerConversionConf |
| } |
| // Can the value be converted to a number? |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value->ToNumber(), exceptionState, 0); |
| + v8::TryCatch block; |
| + v8::Local<v8::Number> numberObject(value->ToNumber()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return 0; |
| + } |
| + |
| if (numberObject.IsEmpty()) { |
| exceptionState.throwTypeError("Not convertible to a number value (of type '" + String(typeName) + "'."); |
| return 0; |
| @@ -311,7 +323,13 @@ int32_t toInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration conf |
| return value->Int32Value(); |
| // Can the value be converted to a number? |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value->ToNumber(), exceptionState, 0); |
| + v8::TryCatch block; |
| + v8::Local<v8::Number> numberObject(value->ToNumber()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return 0; |
| + } |
| + |
| if (numberObject.IsEmpty()) { |
| exceptionState.throwTypeError("Not convertible to a number value (of type 'long'.)"); |
| return 0; |
| @@ -328,8 +346,7 @@ int32_t toInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration conf |
| if (configuration == Clamp) |
| return clampTo<int32_t>(numberObject->Value()); |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(int32_t, result, numberObject->Int32Value(), exceptionState, 0); |
|
Jens Widell
2014/09/09 15:06:38
I assumed here that since numberObject is a number
|
| - return result; |
| + return numberObject->Int32Value(); |
| } |
| int32_t toInt32(v8::Handle<v8::Value> value) |
| @@ -357,7 +374,13 @@ uint32_t toUInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration co |
| } |
| // Can the value be converted to a number? |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value->ToNumber(), exceptionState, 0); |
| + v8::TryCatch block; |
| + v8::Local<v8::Number> numberObject(value->ToNumber()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return 0; |
| + } |
| + |
| if (numberObject.IsEmpty()) { |
| exceptionState.throwTypeError("Not convertible to a number value (of type 'unsigned long'.)"); |
| return 0; |
| @@ -374,8 +397,7 @@ uint32_t toUInt32(v8::Handle<v8::Value> value, IntegerConversionConfiguration co |
| if (configuration == Clamp) |
| return clampTo<uint32_t>(numberObject->Value()); |
| - TONATIVE_DEFAULT(uint32_t, result, numberObject->Uint32Value(), 0); |
| - return result; |
| + return numberObject->Uint32Value(); |
| } |
| uint32_t toUInt32(v8::Handle<v8::Value> value) |
| @@ -391,7 +413,13 @@ int64_t toInt64(v8::Handle<v8::Value> value, IntegerConversionConfiguration conf |
| return value->Int32Value(); |
| // Can the value be converted to a number? |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value->ToNumber(), exceptionState, 0); |
| + v8::TryCatch block; |
| + v8::Local<v8::Number> numberObject(value->ToNumber()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return 0; |
| + } |
| + |
| if (numberObject.IsEmpty()) { |
| exceptionState.throwTypeError("Not convertible to a number value (of type 'long long'.)"); |
| return 0; |
| @@ -437,7 +465,13 @@ uint64_t toUInt64(v8::Handle<v8::Value> value, IntegerConversionConfiguration co |
| } |
| // Can the value be converted to a number? |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value->ToNumber(), exceptionState, 0); |
| + v8::TryCatch block; |
| + v8::Local<v8::Number> numberObject(value->ToNumber()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return 0; |
| + } |
| + |
| if (numberObject.IsEmpty()) { |
| exceptionState.throwTypeError("Not convertible to a number value (of type 'unsigned long long'.)"); |
| return 0; |
| @@ -466,7 +500,12 @@ uint64_t toUInt64(v8::Handle<v8::Value> value) |
| float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| { |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::Number>, numberObject, value->ToNumber(), exceptionState, 0); |
| + v8::TryCatch block; |
| + v8::Local<v8::Number> numberObject(value->ToNumber()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return 0; |
| + } |
| return numberObject->NumberValue(); |
| } |
| @@ -481,7 +520,13 @@ String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| return String(); |
| // 1. Let x be ToString(v) |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::String>, stringObject, value->ToString(), exceptionState, String()); |
| + v8::TryCatch block; |
| + v8::Local<v8::String> stringObject(value->ToString()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return String(); |
| + } |
| + |
| String x = toCoreString(stringObject); |
| // 2. If the value of any element of x is greater than 255, then throw a TypeError. |
| @@ -605,7 +650,13 @@ String toScalarValueString(v8::Handle<v8::Value> value, ExceptionState& exceptio |
| // http://encoding.spec.whatwg.org/#type-scalarvaluestring |
| if (value.IsEmpty()) |
| return String(); |
| - TONATIVE_DEFAULT_EXCEPTIONSTATE(v8::Local<v8::String>, stringObject, value->ToString(), exceptionState, String()); |
| + |
| + v8::TryCatch block; |
| + v8::Local<v8::String> stringObject(value->ToString()); |
| + if (block.HasCaught()) { |
| + exceptionState.rethrowV8Exception(block.Exception()); |
| + return String(); |
| + } |
| // ScalarValueString is identical to DOMString except that "convert a |
| // DOMString to a sequence of Unicode characters" is used subsequently |