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 #define TONATIVE_VOID_ASYNC_INTERNAL(var, value, info)
\ |
| 74 var = (value);
\ |
| 75 if (UNLIKELY(block.HasCaught())) {
\ |
| 76 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block
.Exception())); \ |
| 77 rethrow.cancel();
\ |
| 78 return;
\ |
| 79 } |
| 80 |
| 81 #define TONATIVE_VOID_ASYNC(type, var, value, info) \ |
| 82 type var; \ |
| 83 { \ |
| 84 v8::TryCatch block; \ |
| 85 V8RethrowTryCatchScope rethrow(block); \ |
| 86 TONATIVE_VOID_ASYNC_INTERNAL(var, value, info); \ |
| 87 } |
| 88 |
| 89 |
73 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ | 90 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ |
74 var = (value); \ | 91 var = (value); \ |
75 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ | 92 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ |
76 return; \ | 93 return; \ |
77 | 94 |
78 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ | 95 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ |
79 type var; \ | 96 type var; \ |
80 { \ | 97 { \ |
81 v8::TryCatch block; \ | 98 v8::TryCatch block; \ |
82 V8RethrowTryCatchScope rethrow(block); \ | 99 V8RethrowTryCatchScope rethrow(block); \ |
83 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState); \ | 100 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState); \ |
84 } | 101 } |
85 | 102 |
86 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal
) \ | 103 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal
) \ |
87 type var;
\ | 104 type var;
\ |
88 {
\ | 105 {
\ |
89 v8::TryCatch block;
\ | 106 v8::TryCatch block;
\ |
90 V8RethrowTryCatchScope rethrow(block);
\ | 107 V8RethrowTryCatchScope rethrow(block);
\ |
91 var = (value);
\ | 108 var = (value);
\ |
92 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded()))
\ | 109 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded()))
\ |
93 return retVal;
\ | 110 return retVal;
\ |
94 } | 111 } |
95 | 112 |
| 113 #define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC_INTERNAL(scriptState, var, value, exc
eptionState, info) \ |
| 114 var = (value);
\ |
| 115 if (UNLIKELY(block.HasCaught())) {
\ |
| 116 v8SetReturnValue(info, ScriptPromise::rejectRaw(info.GetIsolate(), block
.Exception())); \ |
| 117 rethrow.cancel();
\ |
| 118 return;
\ |
| 119 }
\ |
| 120 if (UNLIKELY(exceptionState.throwIfNeeded())) {
\ |
| 121 v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value());
\ |
| 122 rethrow.cancel();
\ |
| 123 return;
\ |
| 124 } |
| 125 |
| 126 #define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC(scriptState, type, var, value, except
ionState, info) \ |
| 127 type var;
\ |
| 128 {
\ |
| 129 v8::TryCatch block;
\ |
| 130 V8RethrowTryCatchScope rethrow(block);
\ |
| 131 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(scriptState, var, value, exception
State, info); \ |
| 132 } |
| 133 |
96 // type is an instance of class template V8StringResource<>, | 134 // type is an instance of class template V8StringResource<>, |
97 // but Mode argument varies; using type (not Mode) for consistency | 135 // but Mode argument varies; using type (not Mode) for consistency |
98 // with other macros and ease of code generation | 136 // with other macros and ease of code generation |
99 #define TOSTRING_VOID(type, var, value) \ | 137 #define TOSTRING_VOID(type, var, value) \ |
100 type var(value); \ | 138 type var(value); \ |
101 if (UNLIKELY(!var.prepare())) \ | 139 if (UNLIKELY(!var.prepare())) \ |
102 return; | 140 return; |
103 | 141 |
104 #define TOSTRING_VOID_INTERNAL(var, value) \ | 142 #define TOSTRING_VOID_INTERNAL(var, value) \ |
105 var = (value); \ | 143 var = (value); \ |
106 if (UNLIKELY(!var.prepare())) \ | 144 if (UNLIKELY(!var.prepare())) \ |
107 return; | 145 return; |
108 | 146 |
109 #define TOSTRING_DEFAULT(type, var, value, retVal) \ | 147 #define TOSTRING_DEFAULT(type, var, value, retVal) \ |
110 type var(value); \ | 148 type var(value); \ |
111 if (UNLIKELY(!var.prepare())) \ | 149 if (UNLIKELY(!var.prepare())) \ |
112 return retVal; | 150 return retVal; |
113 | 151 |
| 152 #define TOSTRING_VOID_ASYNC_INTERNAL(var, value, info)
\ |
| 153 var = (value);
\ |
| 154 if (UNLIKELY(!var.prepare())) {
\ |
| 155 rethrow.cancel();
\ |
| 156 info.GetReturnValue().Set(ScriptPromise::rejectRaw(info.GetIsolate(), bl
ock.Exception())); \ |
| 157 return;
\ |
| 158 } |
| 159 |
| 160 #define TOSTRING_VOID_ASYNC(type, var, value, info) \ |
| 161 type var; \ |
| 162 { \ |
| 163 v8::TryCatch block; \ |
| 164 V8RethrowTryCatchScope rethrow(block); \ |
| 165 TOSTRING_VOID_ASYNC_INTERNAL(type, var, value, info); \ |
| 166 } |
| 167 |
114 } // namespace blink | 168 } // namespace blink |
115 | 169 |
116 #endif // V8BindingMacros_h | 170 #endif // V8BindingMacros_h |
OLD | NEW |