| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 | 275 |
| 276 v8::Handle<v8::Value> v8Array(PassRefPtr<DOMStringList>, v8::Isolate*); | 276 v8::Handle<v8::Value> v8Array(PassRefPtr<DOMStringList>, v8::Isolate*); |
| 277 | 277 |
| 278 // Conversion flags, used in toIntXX/toUIntXX. | 278 // Conversion flags, used in toIntXX/toUIntXX. |
| 279 enum IntegerConversionConfiguration { | 279 enum IntegerConversionConfiguration { |
| 280 NormalConversion, | 280 NormalConversion, |
| 281 EnforceRange, | 281 EnforceRange, |
| 282 // FIXME: Implement Clamp | 282 // FIXME: Implement Clamp |
| 283 }; | 283 }; |
| 284 | 284 |
| 285 // Convert a value to a 8-bit signed integer. The conversion fails if the |
| 286 // value cannot be converted to a number or the range violated per WebIDL: |
| 287 // http://www.w3.org/TR/WebIDL/#es-byte |
| 288 int8_t toInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool& o
k); |
| 289 inline int8_t toInt8(v8::Handle<v8::Value> value, bool& ok) { return toInt8(
value, NormalConversion, ok); } |
| 290 |
| 291 // Convert a value to a 8-bit integer assuming the conversion cannot fail. |
| 292 inline int8_t toInt8(v8::Handle<v8::Value> value) |
| 293 { |
| 294 bool ok; |
| 295 return toInt8(value, NormalConversion, ok); |
| 296 } |
| 297 |
| 298 // Convert a value to a 8-bit unsigned integer. The conversion fails if the |
| 299 // value cannot be converted to a number or the range violated per WebIDL: |
| 300 // http://www.w3.org/TR/WebIDL/#es-octet |
| 301 uint8_t toUInt8(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); |
| 302 inline uint8_t toUInt8(v8::Handle<v8::Value> value, bool& ok) { return toUIn
t8(value, NormalConversion, ok); } |
| 303 |
| 304 // Convert a value to a 8-bit unsigned integer assuming the conversion canno
t fail. |
| 305 inline uint8_t toUInt8(v8::Handle<v8::Value> value) |
| 306 { |
| 307 bool ok; |
| 308 return toUInt8(value, NormalConversion, ok); |
| 309 } |
| 310 |
| 285 // Convert a value to a 32-bit signed integer. The conversion fails if the | 311 // Convert a value to a 32-bit signed integer. The conversion fails if the |
| 286 // value cannot be converted to a number or the range violated per WebIDL: | 312 // value cannot be converted to a number or the range violated per WebIDL: |
| 287 // http://www.w3.org/TR/WebIDL/#es-long | 313 // http://www.w3.org/TR/WebIDL/#es-long |
| 288 int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); | 314 int32_t toInt32(v8::Handle<v8::Value>, IntegerConversionConfiguration, bool&
ok); |
| 289 inline int32_t toInt32(v8::Handle<v8::Value> value, bool& ok) { return toInt
32(value, NormalConversion, ok); } | 315 inline int32_t toInt32(v8::Handle<v8::Value> value, bool& ok) { return toInt
32(value, NormalConversion, ok); } |
| 290 | 316 |
| 291 // Convert a value to a 32-bit integer assuming the conversion cannot fail. | 317 // Convert a value to a 32-bit integer assuming the conversion cannot fail. |
| 292 inline int32_t toInt32(v8::Handle<v8::Value> value) | 318 inline int32_t toInt32(v8::Handle<v8::Value> value) |
| 293 { | 319 { |
| 294 bool ok; | 320 bool ok; |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 template <class T> | 566 template <class T> |
| 541 v8::Handle<T> unsafeHandleFromRawValue(const T* value) | 567 v8::Handle<T> unsafeHandleFromRawValue(const T* value) |
| 542 { | 568 { |
| 543 const v8::Handle<T>* handle = reinterpret_cast<const v8::Handle<T>*>(&va
lue); | 569 const v8::Handle<T>* handle = reinterpret_cast<const v8::Handle<T>*>(&va
lue); |
| 544 return *handle; | 570 return *handle; |
| 545 } | 571 } |
| 546 | 572 |
| 547 } // namespace WebCore | 573 } // namespace WebCore |
| 548 | 574 |
| 549 #endif // V8Binding_h | 575 #endif // V8Binding_h |
| OLD | NEW |