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 // Naming scheme: | |
| 37 // COMMAND[_VOID][_ARG]... | |
|
haraken
2014/04/11 02:33:20
COMMAND[_RETURNTYPE][_ARGUMENTTYPE]... ?
Currentl
Nils Barth (inactive)
2014/04/11 03:00:56
How about
TONATIVE[_TYPE][_ARGUMENTTYPE]...
That w
haraken
2014/04/11 03:28:59
Actually, TONATIVE_BOOL and TONATIVE_STRING are di
| |
| 38 | |
| 36 #define V8TRYCATCH(type, var, value) \ | 39 #define V8TRYCATCH(type, var, value) \ |
|
haraken
2014/04/11 02:33:20
V8TRYCATCH_EXCEPTION ?
| |
| 37 type var; \ | 40 type var; \ |
| 38 { \ | 41 { \ |
| 39 v8::TryCatch block; \ | 42 v8::TryCatch block; \ |
| 40 var = (value); \ | 43 var = (value); \ |
| 41 if (UNLIKELY(block.HasCaught())) \ | 44 if (UNLIKELY(block.HasCaught())) \ |
| 42 return block.ReThrow(); \ | 45 return block.ReThrow(); \ |
| 43 } | 46 } |
| 44 | 47 |
| 48 #define V8TRYCATCH_VOID(type, var, value) \ | |
| 49 type var; \ | |
| 50 { \ | |
| 51 v8::TryCatch block; \ | |
| 52 var = (value); \ | |
| 53 if (UNLIKELY(block.HasCaught())) { \ | |
| 54 block.ReThrow(); \ | |
| 55 return; \ | |
| 56 } \ | |
| 57 } | |
| 58 | |
| 45 #define V8TRYCATCH_RETURN(type, var, value, retVal) \ | 59 #define V8TRYCATCH_RETURN(type, var, value, retVal) \ |
|
haraken
2014/04/11 02:33:20
V8TRYCATCH_BOOL ?
| |
| 46 type var; \ | 60 type var; \ |
| 47 { \ | 61 { \ |
| 48 v8::TryCatch block; \ | 62 v8::TryCatch block; \ |
| 49 var = (value); \ | 63 var = (value); \ |
| 50 if (UNLIKELY(block.HasCaught())) { \ | 64 if (UNLIKELY(block.HasCaught())) { \ |
| 51 block.ReThrow(); \ | 65 block.ReThrow(); \ |
| 52 return retVal; \ | 66 return retVal; \ |
| 53 } \ | 67 } \ |
| 54 } | 68 } |
| 55 | 69 |
| 70 #define V8TRYCATCH_VOID_EXCEPTION(type, var, value, exceptionState) \ | |
|
haraken
2014/04/11 02:33:20
V8TRYCATCH_VOID_EXCEPTIONSTATE ?
| |
| 71 type var; \ | |
| 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 | |
| 56 #define V8TRYCATCH_EXCEPTION_RETURN(type, var, value, exceptionState, retVal) \ | 81 #define V8TRYCATCH_EXCEPTION_RETURN(type, var, value, exceptionState, retVal) \ |
|
haraken
2014/04/11 02:33:20
V8TRYCATCH_BOOL_EXCEPTIONSTATE ?
| |
| 57 type var; \ | 82 type var; \ |
| 58 { \ | 83 { \ |
| 59 v8::TryCatch block; \ | 84 v8::TryCatch block; \ |
| 60 var = (value); \ | 85 var = (value); \ |
| 61 if (UNLIKELY(block.HasCaught())) \ | 86 if (UNLIKELY(block.HasCaught())) \ |
| 62 exceptionState.rethrowV8Exception(block.Exception()); \ | 87 exceptionState.rethrowV8Exception(block.Exception()); \ |
| 63 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | 88 if (UNLIKELY(exceptionState.throwIfNeeded())) \ |
| 64 return retVal; \ | 89 return retVal; \ |
| 65 } | 90 } |
| 66 | 91 |
| 67 #define V8TRYCATCH_VOID(type, var, value) \ | 92 #define V8STRINGRESOURCE_PREPARE_VOID(type, var, value) \ |
| 68 type var; \ | 93 type var(value); \ |
|
haraken
2014/04/11 02:33:20
You can drop the |type| parameter, because |type|
Nils Barth (inactive)
2014/04/11 03:00:56
V8StringResource<> is a class template, and is ins
haraken
2014/04/11 03:28:59
Makes sense.
Nils Barth (inactive)
2014/04/11 06:01:38
Anyway, added a comment about usage.
| |
| 69 { \ | 94 if (UNLIKELY(!var.prepare())) \ |
| 70 v8::TryCatch block; \ | 95 return; |
| 71 var = (value); \ | |
| 72 if (UNLIKELY(block.HasCaught())) { \ | |
| 73 block.ReThrow(); \ | |
| 74 return; \ | |
| 75 } \ | |
| 76 } | |
| 77 | 96 |
| 78 #define V8TRYCATCH_EXCEPTION_VOID(type, var, value, exceptionState) \ | 97 #define V8STRINGRESOURCE_PREPARE_RETURN(type, var, value, retVal) \ |
| 79 type var; \ | 98 type var(value); \ |
|
haraken
2014/04/11 02:33:20
Ditto.
| |
| 80 { \ | 99 if (UNLIKELY(!var.prepare())) \ |
| 81 v8::TryCatch block; \ | |
| 82 var = (value); \ | |
| 83 if (UNLIKELY(block.HasCaught())) \ | |
| 84 exceptionState.rethrowV8Exception(block.Exception()); \ | |
| 85 if (UNLIKELY(exceptionState.throwIfNeeded())) \ | |
| 86 return; \ | |
| 87 } | |
| 88 | |
| 89 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(type, var, value, retVal) \ | |
| 90 type var(value); \ | |
| 91 if (UNLIKELY(!var.prepare())) \ | |
| 92 return retVal; | 100 return retVal; |
| 93 | 101 |
| 94 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(type, var, value) \ | |
| 95 type var(value); \ | |
| 96 if (UNLIKELY(!var.prepare())) \ | |
| 97 return; | |
| 98 | |
| 99 } // namespace WebCore | 102 } // namespace WebCore |
| 100 | 103 |
| 101 #endif // V8BindingMacros_h | 104 #endif // V8BindingMacros_h |
| OLD | NEW |