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 Promis e. | |
74 #define TONATIVE_VOID_ASYNC_INTERNAL(var, value, info) \ | |
haraken
2014/08/01 17:04:24
Given that this logic is specific to Promise, shal
yhirano
2014/08/04 01:42:08
Done.
| |
75 var = (value); \ | |
76 if (UNLIKELY(block.HasCaught())) { \ | |
77 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block .Exception())); \ | |
78 rethrow.cancel(); \ | |
79 return; \ | |
80 } | |
81 | |
82 #define TONATIVE_VOID_ASYNC(type, var, value, info) \ | |
83 type var; \ | |
84 { \ | |
85 v8::TryCatch block; \ | |
86 V8RethrowTryCatchScope rethrow(block); \ | |
87 TONATIVE_VOID_ASYNC_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 Promis e. | |
115 #define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC_INTERNAL(var, value, exceptionState, info, scriptState) \ | |
116 var = (value); \ | |
117 if (UNLIKELY(block.HasCaught())) { \ | |
118 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block .Exception())); \ | |
119 rethrow.cancel(); \ | |
120 return; \ | |
121 } \ | |
122 if (UNLIKELY(exceptionState.hadException())) { \ | |
123 v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value()); \ | |
124 return; \ | |
125 } | |
126 | |
127 #define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC(type, var, value, exceptionState, inf o, scriptState) \ | |
128 type var; \ | |
129 { \ | |
130 v8::TryCatch block; \ | |
131 V8RethrowTryCatchScope rethrow(block); \ | |
132 TONATIVE_VOID_EXCEPTIONSTATE_ASYNC_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 Promis e. | |
154 #define TOSTRING_VOID_ASYNC_INTERNAL(var, value, info) \ | |
155 var = (value); \ | |
156 if (UNLIKELY(!var.prepare())) { \ | |
157 info.GetReturnValue().Set(ScriptPromise::rejectRaw(info.GetIsolate(), bl ock.Exception())); \ | |
158 rethrow.cancel(); \ | |
159 return; \ | |
160 } | |
161 | |
162 #define TOSTRING_VOID_ASYNC(type, var, value, info) \ | |
163 type var; \ | |
164 { \ | |
165 v8::TryCatch block; \ | |
166 V8RethrowTryCatchScope rethrow(block); \ | |
167 TOSTRING_VOID_ASYNC_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 |