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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 uint16_t toUInt16(v8::Isolate*, v8::Handle<v8::Value>, IntegerConversionConfigur
ation, ExceptionState&); | 390 uint16_t toUInt16(v8::Isolate*, v8::Handle<v8::Value>, IntegerConversionConfigur
ation, ExceptionState&); |
391 | 391 |
392 // Convert a value to a 32-bit signed integer. The conversion fails if the | 392 // Convert a value to a 32-bit signed integer. The conversion fails if the |
393 // value cannot be converted to a number or the range violated per WebIDL: | 393 // value cannot be converted to a number or the range violated per WebIDL: |
394 // http://www.w3.org/TR/WebIDL/#es-long | 394 // http://www.w3.org/TR/WebIDL/#es-long |
395 CORE_EXPORT int32_t toInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
ersionConfiguration, ExceptionState&); | 395 CORE_EXPORT int32_t toInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
ersionConfiguration, ExceptionState&); |
396 inline int32_t toInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
rConversionConfiguration configuration, ExceptionState& exceptionState) | 396 inline int32_t toInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
rConversionConfiguration configuration, ExceptionState& exceptionState) |
397 { | 397 { |
398 // Fast case. The value is already a 32-bit integer. | 398 // Fast case. The value is already a 32-bit integer. |
399 if (value->IsInt32()) | 399 if (value->IsInt32()) |
400 return value->Int32Value(); | 400 return value.As<v8::Int32>()->Value(); |
401 return toInt32Slow(isolate, value, configuration, exceptionState); | 401 return toInt32Slow(isolate, value, configuration, exceptionState); |
402 } | 402 } |
403 | 403 |
404 // Convert a value to a 32-bit unsigned integer. The conversion fails if the | 404 // Convert a value to a 32-bit unsigned integer. The conversion fails if the |
405 // value cannot be converted to a number or the range violated per WebIDL: | 405 // value cannot be converted to a number or the range violated per WebIDL: |
406 // http://www.w3.org/TR/WebIDL/#es-unsigned-long | 406 // http://www.w3.org/TR/WebIDL/#es-unsigned-long |
407 CORE_EXPORT uint32_t toUInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
nversionConfiguration, ExceptionState&); | 407 CORE_EXPORT uint32_t toUInt32Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
nversionConfiguration, ExceptionState&); |
408 inline uint32_t toUInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
gerConversionConfiguration configuration, ExceptionState& exceptionState) | 408 inline uint32_t toUInt32(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
gerConversionConfiguration configuration, ExceptionState& exceptionState) |
409 { | 409 { |
410 // Fast case. The value is already a 32-bit unsigned integer. | 410 // Fast case. The value is already a 32-bit unsigned integer. |
411 if (value->IsUint32()) | 411 if (value->IsUint32()) |
412 return value->Uint32Value(); | 412 return value.As<v8::Uint32>()->Value(); |
413 | 413 |
414 // Fast case. The value is a 32-bit signed integer with NormalConversion con
figuration. | 414 // Fast case. The value is a 32-bit signed integer with NormalConversion con
figuration. |
415 if (value->IsInt32() && configuration == NormalConversion) | 415 if (value->IsInt32() && configuration == NormalConversion) |
416 return value->Int32Value(); | 416 return value.As<v8::Int32>()->Value(); |
417 | 417 |
418 return toUInt32Slow(isolate, value, configuration, exceptionState); | 418 return toUInt32Slow(isolate, value, configuration, exceptionState); |
419 } | 419 } |
420 | 420 |
421 // Convert a value to a 64-bit signed integer. The conversion fails if the | 421 // Convert a value to a 64-bit signed integer. The conversion fails if the |
422 // value cannot be converted to a number or the range violated per WebIDL: | 422 // value cannot be converted to a number or the range violated per WebIDL: |
423 // http://www.w3.org/TR/WebIDL/#es-long-long | 423 // http://www.w3.org/TR/WebIDL/#es-long-long |
424 CORE_EXPORT int64_t toInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
ersionConfiguration, ExceptionState&); | 424 CORE_EXPORT int64_t toInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerConv
ersionConfiguration, ExceptionState&); |
425 inline int64_t toInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
rConversionConfiguration configuration, ExceptionState& exceptionState) | 425 inline int64_t toInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Intege
rConversionConfiguration configuration, ExceptionState& exceptionState) |
426 { | 426 { |
427 // Clamping not supported for int64_t/long long int. See Source/wtf/MathExtr
as.h. | 427 // Clamping not supported for int64_t/long long int. See Source/wtf/MathExtr
as.h. |
428 ASSERT(configuration != Clamp); | 428 ASSERT(configuration != Clamp); |
429 | 429 |
430 // Fast case. The value is a 32-bit integer. | 430 // Fast case. The value is a 32-bit integer. |
431 if (value->IsInt32()) | 431 if (value->IsInt32()) |
432 return value->Int32Value(); | 432 return value.As<v8::Int32>()->Value(); |
433 | 433 |
434 return toInt64Slow(isolate, value, configuration, exceptionState); | 434 return toInt64Slow(isolate, value, configuration, exceptionState); |
435 } | 435 } |
436 | 436 |
437 // Convert a value to a 64-bit unsigned integer. The conversion fails if the | 437 // Convert a value to a 64-bit unsigned integer. The conversion fails if the |
438 // value cannot be converted to a number or the range violated per WebIDL: | 438 // value cannot be converted to a number or the range violated per WebIDL: |
439 // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long | 439 // http://www.w3.org/TR/WebIDL/#es-unsigned-long-long |
440 CORE_EXPORT uint64_t toUInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
nversionConfiguration, ExceptionState&); | 440 CORE_EXPORT uint64_t toUInt64Slow(v8::Isolate*, v8::Handle<v8::Value>, IntegerCo
nversionConfiguration, ExceptionState&); |
441 inline uint64_t toUInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
gerConversionConfiguration configuration, ExceptionState& exceptionState) | 441 inline uint64_t toUInt64(v8::Isolate* isolate, v8::Handle<v8::Value> value, Inte
gerConversionConfiguration configuration, ExceptionState& exceptionState) |
442 { | 442 { |
443 // Fast case. The value is a 32-bit unsigned integer. | 443 // Fast case. The value is a 32-bit unsigned integer. |
444 if (value->IsUint32()) | 444 if (value->IsUint32()) |
445 return value->Uint32Value(); | 445 return value.As<v8::Uint32>()->Value(); |
446 | 446 |
447 if (value->IsInt32() && configuration == NormalConversion) | 447 if (value->IsInt32() && configuration == NormalConversion) |
448 return value->Int32Value(); | 448 return value.As<v8::Int32>()->Value(); |
449 | 449 |
450 return toUInt64Slow(isolate, value, configuration, exceptionState); | 450 return toUInt64Slow(isolate, value, configuration, exceptionState); |
451 } | 451 } |
452 | 452 |
453 // Convert a value to a double precision float, which might fail. | 453 // Convert a value to a double precision float, which might fail. |
454 CORE_EXPORT double toDoubleSlow(v8::Isolate*, v8::Handle<v8::Value>, ExceptionSt
ate&); | 454 CORE_EXPORT double toDoubleSlow(v8::Isolate*, v8::Handle<v8::Value>, ExceptionSt
ate&); |
455 inline double toDouble(v8::Isolate* isolate, v8::Handle<v8::Value> value, Except
ionState& exceptionState) | 455 inline double toDouble(v8::Isolate* isolate, v8::Handle<v8::Value> value, Except
ionState& exceptionState) |
456 { | 456 { |
457 if (value->IsNumber()) | 457 if (value->IsNumber()) |
458 return value->NumberValue(); | 458 return value.As<v8::Number>()->Value(); |
459 return toDoubleSlow(isolate, value, exceptionState); | 459 return toDoubleSlow(isolate, value, exceptionState); |
460 } | 460 } |
461 | 461 |
462 // Convert a value to a double precision float, throwing on non-finite values. | 462 // Convert a value to a double precision float, throwing on non-finite values. |
463 CORE_EXPORT double toRestrictedDouble(v8::Isolate*, v8::Handle<v8::Value>, Excep
tionState&); | 463 CORE_EXPORT double toRestrictedDouble(v8::Isolate*, v8::Handle<v8::Value>, Excep
tionState&); |
464 | 464 |
465 // Convert a value to a single precision float, which might fail. | 465 // Convert a value to a single precision float, which might fail. |
466 inline float toFloat(v8::Isolate* isolate, v8::Handle<v8::Value> value, Exceptio
nState& exceptionState) | 466 inline float toFloat(v8::Isolate* isolate, v8::Handle<v8::Value> value, Exceptio
nState& exceptionState) |
467 { | 467 { |
468 return static_cast<float>(toDouble(isolate, value, exceptionState)); | 468 return static_cast<float>(toDouble(isolate, value, exceptionState)); |
469 } | 469 } |
470 | 470 |
471 // Convert a value to a single precision float, throwing on non-finite values. | 471 // Convert a value to a single precision float, throwing on non-finite values. |
472 CORE_EXPORT float toRestrictedFloat(v8::Isolate*, v8::Handle<v8::Value>, Excepti
onState&); | 472 CORE_EXPORT float toRestrictedFloat(v8::Isolate*, v8::Handle<v8::Value>, Excepti
onState&); |
473 | 473 |
474 // Converts a value to a String, throwing if any code unit is outside 0-255. | 474 // Converts a value to a String, throwing if any code unit is outside 0-255. |
475 CORE_EXPORT String toByteString(v8::Isolate*, v8::Handle<v8::Value>, ExceptionSt
ate&); | 475 CORE_EXPORT String toByteString(v8::Isolate*, v8::Handle<v8::Value>, ExceptionSt
ate&); |
476 | 476 |
477 // Converts a value to a String, replacing unmatched UTF-16 surrogates with repl
acement characters. | 477 // Converts a value to a String, replacing unmatched UTF-16 surrogates with repl
acement characters. |
478 CORE_EXPORT String toUSVString(v8::Isolate*, v8::Handle<v8::Value>, ExceptionSta
te&); | 478 CORE_EXPORT String toUSVString(v8::Isolate*, v8::Handle<v8::Value>, ExceptionSta
te&); |
479 | 479 |
480 inline v8::Handle<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) | 480 inline v8::Handle<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) |
481 { | 481 { |
482 return value ? v8::True(isolate) : v8::False(isolate); | 482 return value ? v8::True(isolate) : v8::False(isolate); |
483 } | 483 } |
484 | 484 |
485 inline double toCoreDate(v8::Isolate* isolate, v8::Handle<v8::Value> object) | 485 inline double toCoreDate(v8::Isolate* isolate, v8::Handle<v8::Value> object) |
486 { | 486 { |
487 if (object->IsDate()) | 487 if (object->IsDate()) |
488 return v8::Handle<v8::Date>::Cast(object)->ValueOf(); | 488 return object.As<v8::Date>()->ValueOf(); |
489 if (object->IsNumber()) | 489 if (object->IsNumber()) |
490 return object->NumberValue(); | 490 return object.As<v8::Number>()->Value(); |
491 return std::numeric_limits<double>::quiet_NaN(); | 491 return std::numeric_limits<double>::quiet_NaN(); |
492 } | 492 } |
493 | 493 |
494 inline v8::Handle<v8::Value> v8DateOrNaN(double value, v8::Isolate* isolate) | 494 inline v8::Handle<v8::Value> v8DateOrNaN(double value, v8::Isolate* isolate) |
495 { | 495 { |
496 ASSERT(isolate); | 496 ASSERT(isolate); |
497 return v8::Date::New(isolate, std::isfinite(value) ? value : std::numeric_li
mits<double>::quiet_NaN()); | 497 return v8::Date::New(isolate, std::isfinite(value) ? value : std::numeric_li
mits<double>::quiet_NaN()); |
498 } | 498 } |
499 | 499 |
500 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. | 500 // FIXME: Remove the special casing for NodeFilter and XPathNSResolver. |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol
ate*, ExecutionContext*, v8::Handle<v8::Function>); | 969 PassRefPtr<TraceEvent::ConvertableToTraceFormat> devToolsTraceEventData(v8::Isol
ate*, ExecutionContext*, v8::Handle<v8::Function>); |
970 | 970 |
971 // Callback functions used by generated code. | 971 // Callback functions used by generated code. |
972 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName,
const v8::PropertyCallbackInfo<v8::Value>&); | 972 CORE_EXPORT void v8ConstructorAttributeGetter(v8::Local<v8::Name> propertyName,
const v8::PropertyCallbackInfo<v8::Value>&); |
973 | 973 |
974 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso
late*); | 974 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso
late*); |
975 | 975 |
976 } // namespace blink | 976 } // namespace blink |
977 | 977 |
978 #endif // V8Binding_h | 978 #endif // V8Binding_h |
OLD | NEW |