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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 type var; \ | 63 type var; \ |
64 { \ | 64 { \ |
65 v8::TryCatch block; \ | 65 v8::TryCatch block; \ |
66 var = (value); \ | 66 var = (value); \ |
67 if (UNLIKELY(block.HasCaught())) { \ | 67 if (UNLIKELY(block.HasCaught())) { \ |
68 block.ReThrow(); \ | 68 block.ReThrow(); \ |
69 return retVal; \ | 69 return retVal; \ |
70 } \ | 70 } \ |
71 } | 71 } |
72 | 72 |
| 73 // We need to cancel the exception propergation when we return a rejected |
| 74 // Promise. |
| 75 #define TONATIVE_VOID_PROMISE_INTERNAL(var, value, info)
\ |
| 76 var = (value);
\ |
| 77 if (UNLIKELY(block.HasCaught())) {
\ |
| 78 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block
.Exception())); \ |
| 79 block.Reset();
\ |
| 80 return;
\ |
| 81 } |
| 82 |
| 83 #define TONATIVE_VOID_PROMISE(type, var, value, info) \ |
| 84 type var; \ |
| 85 { \ |
| 86 v8::TryCatch block; \ |
| 87 TONATIVE_VOID_PROMISE_INTERNAL(var, value, info); \ |
| 88 } |
| 89 |
| 90 |
73 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ | 91 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ |
74 var = (value); \ | 92 var = (value); \ |
75 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ | 93 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ |
76 return; \ | 94 return; \ |
77 | 95 |
78 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | 96 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ |
79 type var; \ | 97 type var; \ |
80 { \ | 98 { \ |
81 v8::TryCatch block; \ | 99 v8::TryCatch block; \ |
82 V8RethrowTryCatchScope rethrow(block); \ | 100 V8RethrowTryCatchScope rethrow(block); \ |
83 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState); \ | 101 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState); \ |
84 } | 102 } |
85 | 103 |
86 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal
) \ | 104 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal
) \ |
87 type var;
\ | 105 type var;
\ |
88 {
\ | 106 {
\ |
89 v8::TryCatch block;
\ | 107 v8::TryCatch block;
\ |
90 V8RethrowTryCatchScope rethrow(block);
\ | 108 V8RethrowTryCatchScope rethrow(block);
\ |
91 var = (value);
\ | 109 var = (value);
\ |
92 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded()))
\ | 110 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded()))
\ |
93 return retVal;
\ | 111 return retVal;
\ |
94 } | 112 } |
95 | 113 |
| 114 // We need to cancel the exception propergation when we return a rejected |
| 115 // Promise. |
| 116 #define TONATIVE_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState
, info, scriptState) \ |
| 117 var = (value);
\ |
| 118 if (UNLIKELY(block.HasCaught())) {
\ |
| 119 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block
.Exception())); \ |
| 120 block.Reset();
\ |
| 121 return;
\ |
| 122 }
\ |
| 123 if (UNLIKELY(exceptionState.hadException())) {
\ |
| 124 v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value());
\ |
| 125 return;
\ |
| 126 } |
| 127 |
| 128 #define TONATIVE_VOID_EXCEPTIONSTATE_PROMISE(type, var, value, exceptionState, i
nfo, scriptState) \ |
| 129 type var;
\ |
| 130 {
\ |
| 131 v8::TryCatch block;
\ |
| 132 TONATIVE_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState
, info, scriptState); \ |
| 133 } |
| 134 |
96 // type is an instance of class template V8StringResource<>, | 135 // type is an instance of class template V8StringResource<>, |
97 // but Mode argument varies; using type (not Mode) for consistency | 136 // but Mode argument varies; using type (not Mode) for consistency |
98 // with other macros and ease of code generation | 137 // with other macros and ease of code generation |
99 #define TOSTRING_VOID(type, var, value) \ | 138 #define TOSTRING_VOID(type, var, value) \ |
100 type var(value); \ | 139 type var(value); \ |
101 if (UNLIKELY(!var.prepare())) \ | 140 if (UNLIKELY(!var.prepare())) \ |
102 return; | 141 return; |
103 | 142 |
104 #define TOSTRING_VOID_INTERNAL(var, value) \ | 143 #define TOSTRING_VOID_INTERNAL(var, value) \ |
105 var = (value); \ | 144 var = (value); \ |
106 if (UNLIKELY(!var.prepare())) \ | 145 if (UNLIKELY(!var.prepare())) \ |
107 return; | 146 return; |
108 | 147 |
109 #define TOSTRING_DEFAULT(type, var, value, retVal) \ | 148 #define TOSTRING_DEFAULT(type, var, value, retVal) \ |
110 type var(value); \ | 149 type var(value); \ |
111 if (UNLIKELY(!var.prepare())) \ | 150 if (UNLIKELY(!var.prepare())) \ |
112 return retVal; | 151 return retVal; |
113 | 152 |
| 153 // We need to cancel the exception propergation when we return a rejected |
| 154 // Promise. |
| 155 #define TOSTRING_VOID_PROMISE_INTERNAL(var, value, info)
\ |
| 156 var = (value);
\ |
| 157 if (UNLIKELY(!var.prepare())) {
\ |
| 158 info.GetReturnValue().Set(ScriptPromise::rejectRaw(info.GetIsolate(), bl
ock.Exception())); \ |
| 159 block.Reset();
\ |
| 160 return;
\ |
| 161 } |
| 162 |
| 163 #define TOSTRING_VOID_PROMISE(type, var, value, info) \ |
| 164 type var; \ |
| 165 { \ |
| 166 v8::TryCatch block; \ |
| 167 TOSTRING_VOID_PROMISE_INTERNAL(type, var, value, info); \ |
| 168 } |
| 169 |
114 } // namespace blink | 170 } // namespace blink |
115 | 171 |
116 #endif // V8BindingMacros_h | 172 #endif // V8BindingMacros_h |
OLD | NEW |