Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. | 3 * Copyright (C) 2012 Ericsson AB. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 { | 425 { |
| 426 return toInt32(value, NormalConversion, exceptionState); | 426 return toInt32(value, NormalConversion, exceptionState); |
| 427 } | 427 } |
| 428 | 428 |
| 429 // Convert a value to a 32-bit integer assuming the conversion cannot fail. | 429 // Convert a value to a 32-bit integer assuming the conversion cannot fail. |
| 430 int32_t toInt32(v8::Handle<v8::Value>); | 430 int32_t toInt32(v8::Handle<v8::Value>); |
| 431 | 431 |
| 432 // Convert a value to a 32-bit unsigned integer. The conversion fails if the | 432 // Convert a value to a 32-bit unsigned integer. The conversion fails if the |
| 433 // value cannot be converted to a number or the range violated per WebIDL: | 433 // value cannot be converted to a number or the range violated per WebIDL: |
| 434 // http://www.w3.org/TR/WebIDL/#es-unsigned-long | 434 // http://www.w3.org/TR/WebIDL/#es-unsigned-long |
| 435 uint32_t toUInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, Excepti onState&); | 435 uint32_t toUInt32Slow(v8::Handle<v8::Value>, IntegerConversionConfiguration, Exc eptionState&); |
| 436 inline uint32_t toUInt32(v8::Handle<v8::Value> value, IntegerConversionConfigura tion configuration, ExceptionState& exceptionState) | |
| 437 { | |
| 438 // Fast case. The value is already a 32-bit unsigned integer. | |
| 439 if (value->IsUint32()) | |
| 440 return value->Uint32Value(); | |
| 441 | |
| 442 // Fast case. The value is a 32-bit signed integer - possibly positive? | |
| 443 if (value->IsInt32()) { | |
| 444 int32_t result = value->Int32Value(); | |
| 445 if (result >= 0) | |
| 446 return result; | |
| 447 if (configuration == EnforceRange) { | |
|
Jens Widell
2015/02/23 11:41:56
I think in principle that we're inlining too much
| |
| 448 exceptionState.throwTypeError("Value is outside the 'unsigned long' value range."); | |
| 449 return 0; | |
| 450 } | |
| 451 if (configuration == Clamp) | |
| 452 return clampTo<uint32_t>(result); | |
| 453 return result; | |
| 454 } | |
| 455 return toUInt32Slow(value, configuration, exceptionState); | |
| 456 } | |
| 457 | |
| 436 inline uint32_t toUInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionS tate) | 458 inline uint32_t toUInt32(v8::Handle<v8::Value> value, ExceptionState& exceptionS tate) |
| 437 { | 459 { |
| 438 return toUInt32(value, NormalConversion, exceptionState); | 460 return toUInt32(value, NormalConversion, exceptionState); |
| 439 } | 461 } |
| 440 | 462 |
| 441 // Convert a value to a 32-bit unsigned integer assuming the conversion cannot f ail. | 463 // Convert a value to a 32-bit unsigned integer assuming the conversion cannot f ail. |
| 442 uint32_t toUInt32(v8::Handle<v8::Value>); | 464 uint32_t toUInt32(v8::Handle<v8::Value>); |
| 443 | 465 |
| 444 // Convert a value to a 64-bit signed integer. The conversion fails if the | 466 // Convert a value to a 64-bit signed integer. The conversion fails if the |
| 445 // value cannot be converted to a number or the range violated per WebIDL: | 467 // value cannot be converted to a number or the range violated per WebIDL: |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 | 1033 |
| 1012 private: | 1034 private: |
| 1013 v8::TryCatch& m_block; | 1035 v8::TryCatch& m_block; |
| 1014 }; | 1036 }; |
| 1015 | 1037 |
| 1016 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); | 1038 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); |
| 1017 | 1039 |
| 1018 } // namespace blink | 1040 } // namespace blink |
| 1019 | 1041 |
| 1020 #endif // V8Binding_h | 1042 #endif // V8Binding_h |
| OLD | NEW |