OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 } | 475 } |
476 | 476 |
477 uint64_t toUInt64(v8::Handle<v8::Value> value) | 477 uint64_t toUInt64(v8::Handle<v8::Value> value) |
478 { | 478 { |
479 NonThrowableExceptionState exceptionState; | 479 NonThrowableExceptionState exceptionState; |
480 return toUInt64(value, NormalConversion, exceptionState); | 480 return toUInt64(value, NormalConversion, exceptionState); |
481 } | 481 } |
482 | 482 |
483 float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) | 483 float toFloat(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
484 { | 484 { |
| 485 return static_cast<float>(toDouble(value, exceptionState)); |
| 486 } |
| 487 |
| 488 double toDouble(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
| 489 { |
| 490 if (value->IsNumber()) |
| 491 return value->NumberValue(); |
| 492 |
485 v8::TryCatch block; | 493 v8::TryCatch block; |
486 v8::Local<v8::Number> numberObject(value->ToNumber()); | 494 v8::Local<v8::Number> numberObject(value->ToNumber()); |
487 if (block.HasCaught()) { | 495 if (block.HasCaught()) { |
488 exceptionState.rethrowV8Exception(block.Exception()); | 496 exceptionState.rethrowV8Exception(block.Exception()); |
489 return 0; | 497 return 0; |
490 } | 498 } |
| 499 |
491 return numberObject->NumberValue(); | 500 return numberObject->NumberValue(); |
492 } | 501 } |
493 | 502 |
494 String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) | 503 String toByteString(v8::Handle<v8::Value> value, ExceptionState& exceptionState) |
495 { | 504 { |
496 // Handle null default value. | 505 // Handle null default value. |
497 if (value.IsEmpty()) | 506 if (value.IsEmpty()) |
498 return String(); | 507 return String(); |
499 | 508 |
500 // From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString | 509 // From the Web IDL spec: http://heycam.github.io/webidl/#es-ByteString |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 | 962 |
954 v8::Local<v8::Value> v8IteratorResult(v8::Isolate* isolate, v8::Handle<v8::Value
> value) | 963 v8::Local<v8::Value> v8IteratorResult(v8::Isolate* isolate, v8::Handle<v8::Value
> value) |
955 { | 964 { |
956 v8::Local<v8::Object> result = v8::Object::New(isolate); | 965 v8::Local<v8::Object> result = v8::Object::New(isolate); |
957 result->Set(v8String(isolate, "value"), value); | 966 result->Set(v8String(isolate, "value"), value); |
958 result->Set(v8String(isolate, "done"), v8Boolean(false, isolate)); | 967 result->Set(v8String(isolate, "done"), v8Boolean(false, isolate)); |
959 return result; | 968 return result; |
960 } | 969 } |
961 | 970 |
962 } // namespace blink | 971 } // namespace blink |
OLD | NEW |