Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(121)

Side by Side Diff: Source/bindings/core/v8/V8BindingMacros.h

Issue 552143004: Simplify TONATIVE_*_EXCEPTIONSTATE* macros (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@bindings-conversion-ExceptionState
Patch Set: rebased Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 #define TONATIVE_VOID_PROMISE(type, var, value, info) \ 83 #define TONATIVE_VOID_PROMISE(type, var, value, info) \
84 type var; \ 84 type var; \
85 { \ 85 { \
86 v8::TryCatch block; \ 86 v8::TryCatch block; \
87 TONATIVE_VOID_PROMISE_INTERNAL(var, value, info); \ 87 TONATIVE_VOID_PROMISE_INTERNAL(var, value, info); \
88 } 88 }
89 89
90 90
91 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \ 91 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \
92 var = (value); \ 92 var = (value); \
93 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \ 93 if (UNLIKELY(exceptionState.throwIfNeeded())) \
94 return; \ 94 return; \
95 95
96 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ 96 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \
97 type var; \ 97 type var; \
98 { \ 98 var = (value); \
99 v8::TryCatch block; \ 99 if (UNLIKELY(exceptionState.throwIfNeeded())) \
100 V8RethrowTryCatchScope rethrow(block); \ 100 return;
101 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState); \
102 }
103 101
104 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal ) \ 102 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal ) \
105 type var; \ 103 type var = (value); \
106 { \ 104 if (UNLIKELY(exceptionState.throwIfNeeded())) \
107 v8::TryCatch block; \ 105 return retVal;
108 V8RethrowTryCatchScope rethrow(block); \
109 var = (value); \
110 if (UNLIKELY(block.HasCaught() || exceptionState.throwIfNeeded())) \
111 return retVal; \
112 }
113 106
114 // We need to cancel the exception propergation when we return a rejected 107 // We need to cancel the exception propergation when we return a rejected
115 // Promise. 108 // Promise.
116 #define TONATIVE_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState , info, scriptState) \ 109 #define TONATIVE_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState , info, scriptState) \
117 var = (value); \ 110 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())) { \ 111 if (UNLIKELY(exceptionState.hadException())) { \
124 v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value()); \ 112 v8SetReturnValue(info, exceptionState.reject(scriptState).v8Value()); \
125 return; \ 113 return; \
126 } 114 }
127 115
128 #define TONATIVE_VOID_EXCEPTIONSTATE_PROMISE(type, var, value, exceptionState, i nfo, scriptState) \ 116 #define TONATIVE_VOID_EXCEPTIONSTATE_PROMISE(type, var, value, exceptionState, i nfo, scriptState) \
129 type var; \ 117 type var; \
130 { \ 118 TONATIVE_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState, in fo, scriptState);
131 v8::TryCatch block; \
132 TONATIVE_VOID_EXCEPTIONSTATE_PROMISE_INTERNAL(var, value, exceptionState , info, scriptState); \
133 }
134 119
135 // type is an instance of class template V8StringResource<>, 120 // type is an instance of class template V8StringResource<>,
136 // but Mode argument varies; using type (not Mode) for consistency 121 // but Mode argument varies; using type (not Mode) for consistency
137 // with other macros and ease of code generation 122 // with other macros and ease of code generation
138 #define TOSTRING_VOID(type, var, value) \ 123 #define TOSTRING_VOID(type, var, value) \
139 type var(value); \ 124 type var(value); \
140 if (UNLIKELY(!var.prepare())) \ 125 if (UNLIKELY(!var.prepare())) \
141 return; 126 return;
142 127
143 #define TOSTRING_VOID_INTERNAL(var, value) \ 128 #define TOSTRING_VOID_INTERNAL(var, value) \
(...skipping 19 matching lines...) Expand all
163 #define TOSTRING_VOID_PROMISE(type, var, value, info) \ 148 #define TOSTRING_VOID_PROMISE(type, var, value, info) \
164 type var; \ 149 type var; \
165 { \ 150 { \
166 v8::TryCatch block; \ 151 v8::TryCatch block; \
167 TOSTRING_VOID_PROMISE_INTERNAL(type, var, value, info); \ 152 TOSTRING_VOID_PROMISE_INTERNAL(type, var, value, info); \
168 } 153 }
169 154
170 } // namespace blink 155 } // namespace blink
171 156
172 #endif // V8BindingMacros_h 157 #endif // V8BindingMacros_h
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698