Chromium Code Reviews| 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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 355 { | 355 { |
| 356 ASSERT(isolate); | 356 ASSERT(isolate); |
| 357 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString , length); | 357 return v8::String::NewFromUtf8(isolate, str, v8::String::kInternalizedString , length); |
| 358 } | 358 } |
| 359 | 359 |
| 360 inline v8::Handle<v8::Value> v8Undefined() | 360 inline v8::Handle<v8::Value> v8Undefined() |
| 361 { | 361 { |
| 362 return v8::Handle<v8::Value>(); | 362 return v8::Handle<v8::Value>(); |
| 363 } | 363 } |
| 364 | 364 |
| 365 // Used in generated code as e.g. | |
| 366 // | |
| 367 // if (!convertAndThrow(target = toInt32(..., exceptionState), exceptionState) ) | |
| 368 // return; | |
| 369 // | |
| 370 // for conversion to types where the conversion function returns the converted | |
| 371 // value (except via a macro that just expects an expression returning false in | |
| 372 // case of an error.) | |
| 373 template <typename T> | |
| 374 bool convertAndCheck(T, ExceptionState& exceptionState) | |
| 375 { | |
| 376 return !exceptionState.hadException(); | |
| 377 } | |
| 378 template <typename T> | |
| 379 bool convertAndThrow(T, ExceptionState& exceptionState) | |
|
bashi
2015/02/23 23:44:06
convertOrThrow?
| |
| 380 { | |
| 381 return !exceptionState.throwIfNeeded(); | |
| 382 } | |
| 383 | |
| 365 // Conversion flags, used in toIntXX/toUIntXX. | 384 // Conversion flags, used in toIntXX/toUIntXX. |
| 366 enum IntegerConversionConfiguration { | 385 enum IntegerConversionConfiguration { |
| 367 NormalConversion, | 386 NormalConversion, |
| 368 EnforceRange, | 387 EnforceRange, |
| 369 Clamp | 388 Clamp |
| 370 }; | 389 }; |
| 371 | 390 |
| 372 // Convert a value to a 8-bit signed integer. The conversion fails if the | 391 // Convert a value to a 8-bit signed integer. The conversion fails if the |
| 373 // value cannot be converted to a number or the range violated per WebIDL: | 392 // value cannot be converted to a number or the range violated per WebIDL: |
| 374 // http://www.w3.org/TR/WebIDL/#es-byte | 393 // http://www.w3.org/TR/WebIDL/#es-byte |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 | 1030 |
| 1012 private: | 1031 private: |
| 1013 v8::TryCatch& m_block; | 1032 v8::TryCatch& m_block; |
| 1014 }; | 1033 }; |
| 1015 | 1034 |
| 1016 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); | 1035 typedef void (*InstallTemplateFunction)(v8::Local<v8::FunctionTemplate>, v8::Iso late*); |
| 1017 | 1036 |
| 1018 } // namespace blink | 1037 } // namespace blink |
| 1019 | 1038 |
| 1020 #endif // V8Binding_h | 1039 #endif // V8Binding_h |
| OLD | NEW |