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 #define V8TRYCATCH(type, var, value) \ |
37 type var; \ | 37 type var; \ |
38 { \ | 38 { \ |
39 v8::TryCatch block; \ | 39 v8::TryCatch block; \ |
40 var = (value); \ | 40 var = (value); \ |
41 if (block.HasCaught()) \ | 41 if (UNLIKELY(block.HasCaught())) \ |
42 return block.ReThrow(); \ | 42 return block.ReThrow(); \ |
43 } | 43 } |
44 | 44 |
45 #define V8TRYCATCH_RETURN(type, var, value, retVal) \ | 45 #define V8TRYCATCH_RETURN(type, var, value, retVal) \ |
46 type var; \ | 46 type var; \ |
47 { \ | 47 { \ |
48 v8::TryCatch block; \ | 48 v8::TryCatch block; \ |
49 var = (value); \ | 49 var = (value); \ |
50 if (block.HasCaught()) { \ | 50 if (UNLIKELY(block.HasCaught())) { \ |
51 block.ReThrow(); \ | 51 block.ReThrow(); \ |
52 return retVal; \ | 52 return retVal; \ |
53 } \ | 53 } \ |
54 } | 54 } |
55 | 55 |
56 #define V8TRYCATCH_VOID(type, var, value) \ | 56 #define V8TRYCATCH_EXCEPTION_RETURN(type, var, value, exceptionState, retVal) \ |
57 type var; \ | 57 type var; \ |
58 { \ | 58 { \ |
59 v8::TryCatch block; \ | 59 v8::TryCatch block; \ |
60 var = (value); \ | 60 var = (value); \ |
61 if (block.HasCaught()) { \ | 61 if (UNLIKELY(block.HasCaught())) \ |
62 block.ReThrow(); \ | 62 exceptionState.rethrowV8Exception(block.Exception()); \ |
63 return; \ | 63 if (UNLIKELY(exceptionState.throwIfNeeded())) \ |
64 } \ | 64 return retVal; \ |
65 } | 65 } |
66 | 66 |
67 #define V8TRYCATCH_WITH_TYPECHECK_VOID(type, var, value, isolate) \ | 67 #define V8TRYCATCH_VOID(type, var, value) \ |
68 type var; \ | 68 type var; \ |
69 { \ | 69 { \ |
70 bool ok = true; \ | 70 v8::TryCatch block; \ |
71 { \ | 71 var = (value); \ |
72 v8::TryCatch block; \ | 72 if (UNLIKELY(block.HasCaught())) { \ |
73 var = (value); \ | 73 block.ReThrow(); \ |
74 if (block.HasCaught()) { \ | 74 return; \ |
75 block.ReThrow(); \ | 75 } \ |
76 return; \ | 76 } |
77 } \ | 77 |
78 } \ | 78 #define V8TRYCATCH_EXCEPTION_VOID(type, var, value, exceptionState) \ |
79 if (UNLIKELY(!ok)) { \ | 79 type var; \ |
80 throwUninformativeAndGenericTypeError(isolate); \ | 80 { \ |
81 return; \ | 81 v8::TryCatch block; \ |
82 } \ | 82 var = (value); \ |
| 83 if (UNLIKELY(block.HasCaught())) \ |
| 84 exceptionState.rethrowV8Exception(block.Exception()); \ |
| 85 if (UNLIKELY(exceptionState.throwIfNeeded())) \ |
| 86 return; \ |
83 } | 87 } |
84 | 88 |
85 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(type, var, value, retVal) \ | 89 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(type, var, value, retVal) \ |
86 type var(value); \ | 90 type var(value); \ |
87 if (!var.prepare()) \ | 91 if (UNLIKELY(!var.prepare())) \ |
88 return retVal; | 92 return retVal; |
89 | 93 |
90 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(type, var, value) \ | 94 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(type, var, value) \ |
91 type var(value); \ | 95 type var(value); \ |
92 if (!var.prepare()) \ | 96 if (UNLIKELY(!var.prepare())) \ |
93 return; | 97 return; |
94 | 98 |
95 } // namespace WebCore | 99 } // namespace WebCore |
96 | 100 |
97 #endif // V8BindingMacros_h | 101 #endif // V8BindingMacros_h |
OLD | NEW |