Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 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 15 matching lines...) Expand all Loading... | |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef V8BindingMacros_h | 31 #ifndef V8BindingMacros_h |
| 32 #define V8BindingMacros_h | 32 #define V8BindingMacros_h |
| 33 | 33 |
| 34 namespace WebCore { | 34 namespace WebCore { |
| 35 | 35 |
| 36 #define V8TRYCATCH(type, var, value) \ | 36 // Naming scheme: |
| 37 type var; \ | 37 // TO*_RETURNTYPE[_ARGTYPE]... |
| 38 { \ | 38 |
| 39 v8::TryCatch block; \ | 39 #define TONATIVE_EXCEPTION(type, var, value) \ |
| 40 var = (value); \ | 40 type var; \ |
| 41 if (UNLIKELY(block.HasCaught())) \ | 41 { \ |
| 42 return block.ReThrow(); \ | 42 v8::TryCatch block; \ |
| 43 var = (value); \ | |
| 44 if (UNLIKELY(block.HasCaught())) \ | |
| 45 return block.ReThrow(); \ | |
| 43 } | 46 } |
| 44 | 47 |
| 45 #define V8TRYCATCH_RETURN(type, var, value, retVal) \ | 48 #define TONATIVE_VOID(type, var, value) \ |
| 46 type var; \ | |
| 47 { \ | |
| 48 v8::TryCatch block; \ | |
| 49 var = (value); \ | |
| 50 if (UNLIKELY(block.HasCaught())) { \ | |
| 51 block.ReThrow(); \ | |
| 52 return retVal; \ | |
| 53 } \ | |
| 54 } | |
| 55 | |
| 56 #define V8TRYCATCH_EXCEPTION_RETURN(type, var, value, exceptionState, retVal) \ | |
| 57 type var; \ | |
| 58 { \ | |
| 59 v8::TryCatch block; \ | |
| 60 var = (value); \ | |
| 61 if (UNLIKELY(block.HasCaught())) \ | |
| 62 exceptionState.rethrowV8Exception(block.Exception()); \ | |
| 63 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | |
| 64 return retVal; \ | |
| 65 } | |
| 66 | |
| 67 #define V8TRYCATCH_VOID(type, var, value) \ | |
| 68 type var; \ | 49 type var; \ |
| 69 { \ | 50 { \ |
| 70 v8::TryCatch block; \ | 51 v8::TryCatch block; \ |
| 71 var = (value); \ | 52 var = (value); \ |
| 72 if (UNLIKELY(block.HasCaught())) { \ | 53 if (UNLIKELY(block.HasCaught())) { \ |
| 73 block.ReThrow(); \ | 54 block.ReThrow(); \ |
| 74 return; \ | 55 return; \ |
| 75 } \ | 56 } \ |
| 76 } | 57 } |
| 77 | 58 |
| 78 #define V8TRYCATCH_EXCEPTION_VOID(type, var, value, exceptionState) \ | 59 #define TONATIVE_BOOL(type, var, value, retVal) \ |
| 79 type var; \ | 60 type var; \ |
| 80 { \ | 61 { \ |
| 81 v8::TryCatch block; \ | 62 v8::TryCatch block; \ |
| 82 var = (value); \ | 63 var = (value); \ |
| 83 if (UNLIKELY(block.HasCaught())) \ | 64 if (UNLIKELY(block.HasCaught())) { \ |
| 84 exceptionState.rethrowV8Exception(block.Exception()); \ | 65 block.ReThrow(); \ |
| 85 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 66 return retVal; \ |
| 86 return; \ | 67 } \ |
| 87 } | 68 } |
| 88 | 69 |
| 89 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(type, var, value, retVal) \ | 70 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ |
| 90 type var(value); \ | 71 type var; \ |
| 91 if (UNLIKELY(!var.prepare())) \ | 72 { \ |
| 73 v8::TryCatch block; \ | |
| 74 var = (value); \ | |
| 75 if (UNLIKELY(block.HasCaught())) \ | |
| 76 exceptionState.rethrowV8Exception(block.Exception()); \ | |
| 77 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | |
| 78 return; \ | |
| 79 } | |
| 80 | |
| 81 #define TONATIVE_BOOL_EXCEPTIONSTATE_BOOL(type, var, value, exceptionState, retV al) \ | |
|
haraken
2014/04/11 06:09:26
TONATIVE_BOOL_EXCEPTIONSTATE ?
I understand that
Nils Barth (inactive)
2014/04/11 07:40:16
Agreed, this is clearer (I was thinking the same t
| |
| 82 type var; \ | |
| 83 { \ | |
| 84 v8::TryCatch block; \ | |
| 85 var = (value); \ | |
| 86 if (UNLIKELY(block.HasCaught())) \ | |
| 87 exceptionState.rethrowV8Exception(block.Exception()); \ | |
| 88 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | |
| 89 return retVal; \ | |
| 90 } | |
| 91 | |
| 92 // type is an instance of class template V8StringResource<>, | |
| 93 // but Mode argument varies; using type (not Mode) for consistency | |
| 94 // with other macros and ease of code generation | |
| 95 #define TOSTRING_VOID(type, var, value) \ | |
| 96 type var(value); \ | |
| 97 if (UNLIKELY(!var.prepare())) \ | |
| 98 return; | |
| 99 | |
| 100 #define TOSTRING_BOOL_BOOL(type, var, value, retVal) \ | |
|
haraken
2014/04/11 06:09:26
TOSTRING_BOOL ?
If you want to call this TOSTRING
| |
| 101 type var(value); \ | |
| 102 if (UNLIKELY(!var.prepare())) \ | |
| 92 return retVal; | 103 return retVal; |
| 93 | 104 |
| 94 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(type, var, value) \ | |
| 95 type var(value); \ | |
| 96 if (UNLIKELY(!var.prepare())) \ | |
| 97 return; | |
| 98 | |
| 99 } // namespace WebCore | 105 } // namespace WebCore |
| 100 | 106 |
| 101 #endif // V8BindingMacros_h | 107 #endif // V8BindingMacros_h |
| OLD | NEW |