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 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 // http://www.w3.org/TR/WebIDL/#es-unsigned-short | 407 // http://www.w3.org/TR/WebIDL/#es-unsigned-short |
408 CORE_EXPORT uint16_t toUInt16(v8::Isolate*, v8::Handle<v8::Value>, IntegerConver
sionConfiguration, ExceptionState&); | 408 CORE_EXPORT uint16_t toUInt16(v8::Isolate*, v8::Handle<v8::Value>, IntegerConver
sionConfiguration, ExceptionState&); |
409 | 409 |
410 // Convert a value to a 32-bit signed integer. The conversion fails if the | 410 // Convert a value to a 32-bit signed integer. The conversion fails if the |
411 // value cannot be converted to a number or the range violated per WebIDL: | 411 // value cannot be converted to a number or the range violated per WebIDL: |
412 // http://www.w3.org/TR/WebIDL/#es-long | 412 // http://www.w3.org/TR/WebIDL/#es-long |
413 CORE_EXPORT int32_t toInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
ersionConfiguration, ExceptionState&); | 413 CORE_EXPORT int32_t toInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
ersionConfiguration, ExceptionState&); |
414 inline int32_t toInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
rConversionConfiguration configuration, ExceptionState& exceptionState) | 414 inline int32_t toInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
rConversionConfiguration configuration, ExceptionState& exceptionState) |
415 { | 415 { |
416 // Fast case. The value is already a 32-bit integer. | 416 // Fast case. The value is already a 32-bit integer. |
417 if (value->IsInt32()) | 417 if (LIKELY(value->IsInt32())) |
418 return value.As<v8::Int32>()->Value(); | 418 return value.As<v8::Int32>()->Value(); |
419 return toInt32Slow(isolate, value, configuration, exceptionState); | 419 return toInt32Slow(isolate, value, configuration, exceptionState); |
420 } | 420 } |
421 | 421 |
422 // Convert a value to a 32-bit unsigned integer. The conversion fails if the | 422 // Convert a value to a 32-bit unsigned integer. The conversion fails if the |
423 // value cannot be converted to a number or the range violated per WebIDL: | 423 // value cannot be converted to a number or the range violated per WebIDL: |
424 // http://www.w3.org/TR/WebIDL/#es-unsigned-long | 424 // http://www.w3.org/TR/WebIDL/#es-unsigned-long |
425 CORE_EXPORT uint32_t toUInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
nversionConfiguration, ExceptionState&); | 425 CORE_EXPORT uint32_t toUInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
nversionConfiguration, ExceptionState&); |
426 inline uint32_t toUInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
gerConversionConfiguration configuration, ExceptionState& exceptionState) | 426 inline uint32_t toUInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
gerConversionConfiguration configuration, ExceptionState& exceptionState) |
427 { | 427 { |
428 // Fast case. The value is already a 32-bit unsigned integer. | 428 // Fast case. The value is already a 32-bit unsigned integer. |
429 if (value->IsUint32()) | 429 if (LIKELY(value->IsUint32())) |
430 return value.As<v8::Uint32>()->Value(); | 430 return value.As<v8::Uint32>()->Value(); |
431 | 431 |
432 // Fast case. The value is a 32-bit signed integer with NormalConversion con
figuration. | 432 // Fast case. The value is a 32-bit signed integer with NormalConversion con
figuration. |
433 if (value->IsInt32() && configuration == NormalConversion) | 433 if (LIKELY(value->IsInt32() && configuration == NormalConversion)) |
434 return value.As<v8::Int32>()->Value(); | 434 return value.As<v8::Int32>()->Value(); |
435 | 435 |
436 return toUInt32Slow(isolate, value, configuration, exceptionState); | 436 return toUInt32Slow(isolate, value, configuration, exceptionState); |
437 } | 437 } |
438 | 438 |
439 // Convert a value to a 64-bit signed integer. The conversion fails if the | 439 // Convert a value to a 64-bit signed integer. The conversion fails if the |
440 // value cannot be converted to a number or the range violated per WebIDL: | 440 // value cannot be converted to a number or the range violated per WebIDL: |
441 // http://www.w3.org/TR/WebIDL/#es-long-long | 441 // http://www.w3.org/TR/WebIDL/#es-long-long |
442 CORE_EXPORT int64_t toInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
ersionConfiguration, ExceptionState&); | 442 CORE_EXPORT int64_t toInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
ersionConfiguration, ExceptionState&); |
443 inline int64_t toInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
rConversionConfiguration configuration, ExceptionState& exceptionState) | 443 inline int64_t toInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
rConversionConfiguration configuration, ExceptionState& exceptionState) |
444 { | 444 { |
445 // Clamping not supported for int64_t/long long int. See Source/wtf/MathExtr
as.h. | 445 // Clamping not supported for int64_t/long long int. See Source/wtf/MathExtr
as.h. |
446 ASSERT(configuration != Clamp); | 446 ASSERT(configuration != Clamp); |
447 | 447 |
448 // Fast case. The value is a 32-bit integer. | 448 // Fast case. The value is a 32-bit integer. |
449 if (value->IsInt32()) | 449 if (LIKELY(value->IsInt32())) |
450 return value.As<v8::Int32>()->Value(); | 450 return value.As<v8::Int32>()->Value(); |
451 | 451 |
452 return toInt64Slow(isolate, value, configuration, exceptionState); | 452 return toInt64Slow(isolate, value, configuration, exceptionState); |
453 } | 453 } |
454 | 454 |
455 // Convert a value to a 64-bit unsigned integer. The conversion fails if the | 455 // Convert a value to a 64-bit unsigned integer. The conversion fails if the |
456 // value cannot be converted to a number or the range violated per WebIDL: | 456 // value cannot be converted to a number or the range violated per WebIDL: |
457 // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long | 457 // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long |
458 CORE_EXPORT uint64_t toUInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
nversionConfiguration, ExceptionState&); | 458 CORE_EXPORT uint64_t toUInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
nversionConfiguration, ExceptionState&); |
459 inline uint64_t toUInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
gerConversionConfiguration configuration, ExceptionState& exceptionState) | 459 inline uint64_t toUInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
gerConversionConfiguration configuration, ExceptionState& exceptionState) |
460 { | 460 { |
461 // Fast case. The value is a 32-bit unsigned integer. | 461 // Fast case. The value is a 32-bit unsigned integer. |
462 if (value->IsUint32()) | 462 if (LIKELY(value->IsUint32())) |
463 return value.As<v8::Uint32>()->Value(); | 463 return value.As<v8::Uint32>()->Value(); |
464 | 464 |
465 if (value->IsInt32() && configuration == NormalConversion) | 465 if (LIKELY(value->IsInt32() && configuration == NormalConversion)) |
466 return value.As<v8::Int32>()->Value(); | 466 return value.As<v8::Int32>()->Value(); |
467 | 467 |
468 return toUInt64Slow(isolate, value, configuration, exceptionState); | 468 return toUInt64Slow(isolate, value, configuration, exceptionState); |
469 } | 469 } |
470 | 470 |
471 // Convert a value to a double precision float, which might fail. | 471 // Convert a value to a double precision float, which might fail. |
472 CORE_EXPORT double toDoubleSlow(v8::Isolate*, v8::Handle<v8::Value>, ExceptionSt
ate&); | 472 CORE_EXPORT double toDoubleSlow(v8::Isolate*, v8::Handle<v8::Value>, ExceptionSt
ate&); |
473 inline double toDouble(v8::Isolate* isolate, v8::Handle<v8::Value> value, Except
ionState& exceptionState) | 473 inline double toDouble(v8::Isolate* isolate, v8::Handle<v8::Value> value, Except
ionState& exceptionState) |
474 { | 474 { |
475 if (value->IsNumber()) | 475 if (LIKELY(value->IsNumber())) |
476 return value.As<v8::Number>()->Value(); | 476 return value.As<v8::Number>()->Value(); |
477 return toDoubleSlow(isolate, value, exceptionState); | 477 return toDoubleSlow(isolate, value, exceptionState); |
478 } | 478 } |
479 | 479 |
480 // Convert a value to a double precision float, throwing on non-finite values. | 480 // Convert a value to a double precision float, throwing on non-finite values. |
481 CORE_EXPORT double toRestrictedDouble(v8::Isolate*, v8::Handle<v8::Value>, Excep
tionState&); | 481 CORE_EXPORT double toRestrictedDouble(v8::Isolate*, v8::Handle<v8::Value>, Excep
tionState&); |
482 | 482 |
483 // Convert a value to a single precision float, which might fail. | 483 // Convert a value to a single precision float, which might fail. |
484 inline float toFloat(v8::Isolate* isolate, v8::Handle<v8::Value> value, Exceptio
nState& exceptionState) | 484 inline float toFloat(v8::Isolate* isolate, v8::Handle<v8::Value> value, Exceptio
nState& exceptionState) |
485 { | 485 { |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol
ate*, ExecutionContext*, v8::Handle<v8::Function>); | 990 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol
ate*, ExecutionContext*, v8::Handle<v8::Function>); |
991 | 991 |
992 // Callback functions used by generated code. | 992 // Callback functions used by generated code. |
993 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName,
const v8::PropertyCallbackInfo<v8::Value>&); | 993 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName,
const v8::PropertyCallbackInfo<v8::Value>&); |
994 | 994 |
995 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso
late*); | 995 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso
late*); |
996 | 996 |
997 } // namespace blink | 997 } // namespace blink |
998 | 998 |
999 #endif // V8Binding_h | 999 #endif // V8Binding_h |
OLD | NEW |