Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(199)

Side by Side Diff: Source/bindings/core/v8/V8Binding.h

Issue 567503002: Add toDouble() helper, and use toFloat()/toDouble() for conversions (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 528
529 // Convert a value to a single precision float, which might fail. 529 // Convert a value to a single precision float, which might fail.
530 float toFloat(v8::Handle<v8::Value>, ExceptionState&); 530 float toFloat(v8::Handle<v8::Value>, ExceptionState&);
531 531
532 // Convert a value to a single precision float assuming the conversion cannot fa il. 532 // Convert a value to a single precision float assuming the conversion cannot fa il.
533 inline float toFloat(v8::Local<v8::Value> value) 533 inline float toFloat(v8::Local<v8::Value> value)
534 { 534 {
535 return static_cast<float>(value->NumberValue()); 535 return static_cast<float>(value->NumberValue());
536 } 536 }
537 537
538 // Convert a value to a double precision float, which might fail.
539 double toDouble(v8::Handle<v8::Value>, ExceptionState&);
540
538 // Converts a value to a String, throwing if any code unit is outside 0-255. 541 // Converts a value to a String, throwing if any code unit is outside 0-255.
539 String toByteString(v8::Handle<v8::Value>, ExceptionState&); 542 String toByteString(v8::Handle<v8::Value>, ExceptionState&);
540 543
541 // Converts a value to a String, replacing unmatched UTF-16 surrogates with repl acement characters. 544 // Converts a value to a String, replacing unmatched UTF-16 surrogates with repl acement characters.
542 String toScalarValueString(v8::Handle<v8::Value>, ExceptionState&); 545 String toScalarValueString(v8::Handle<v8::Value>, ExceptionState&);
543 546
544 inline v8::Handle<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate) 547 inline v8::Handle<v8::Boolean> v8Boolean(bool value, v8::Isolate* isolate)
545 { 548 {
546 return value ? v8::True(isolate) : v8::False(isolate); 549 return value ? v8::True(isolate) : v8::False(isolate);
547 } 550 }
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
971 v8::Local<v8::Value> v8IteratorResult(v8::Isolate*, v8::Handle<v8::Value>); 974 v8::Local<v8::Value> v8IteratorResult(v8::Isolate*, v8::Handle<v8::Value>);
972 template <typename T> 975 template <typename T>
973 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value) 976 v8::Local<v8::Value> v8IteratorResult(ScriptState* scriptState, const T& value)
974 { 977 {
975 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value( value, scriptState->context()->Global(), scriptState->isolate())); 978 return v8IteratorResult(scriptState->isolate(), V8ValueTraits<T>::toV8Value( value, scriptState->context()->Global(), scriptState->isolate()));
976 } 979 }
977 980
978 } // namespace blink 981 } // namespace blink
979 982
980 #endif // V8Binding_h 983 #endif // V8Binding_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/core/v8/V8Binding.cpp » ('j') | Source/bindings/templates/interface.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698