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

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

Issue 234403004: Rename V8TRYCATCH_* macros in v8/V8BindingMacros.h (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: BOOL*_BOOL -> BOOL* Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/V8Binding.cpp ('k') | Source/bindings/v8/V8Initializer.cpp » ('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 15 matching lines...) Expand all
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 // Naming scheme:
37 type var; \ 37 // TO*_RETURNTYPE[_ARGTYPE]...
38 { \ 38 // ...removing RETURNTYPE/ARGTYPE duplicate if an argument is simply returned
39 v8::TryCatch block; \ 39
40 var = (value); \ 40 #define TONATIVE_EXCEPTION(type, var, value) \
41 if (UNLIKELY(block.HasCaught())) \ 41 type var; \
42 return block.ReThrow(); \ 42 { \
43 v8::TryCatch block; \
44 var = (value); \
45 if (UNLIKELY(block.HasCaught())) \
46 return block.ReThrow(); \
43 } 47 }
44 48
45 #define V8TRYCATCH_RETURN(type, var, value, retVal) \ 49 #define TONATIVE_VOID(type, var, value) \
46 type var; \
47 { \
48 v8::TryCatch block; \
49 var = (value); \
50 if (UNLIKELY(block.HasCaught())) { \
51 block.ReThrow(); \
52 return retVal; \
53 } \
54 }
55
56 #define V8TRYCATCH_EXCEPTION_RETURN(type, var, value, exceptionState, retVal) \
57 type var; \
58 { \
59 v8::TryCatch block; \
60 var = (value); \
61 if (UNLIKELY(block.HasCaught())) \
62 exceptionState.rethrowV8Exception(block.Exception()); \
63 if (UNLIKELY(exceptionState.throwIfNeeded())) \
64 return retVal; \
65 }
66
67 #define V8TRYCATCH_VOID(type, var, value) \
68 type var; \ 50 type var; \
69 { \ 51 { \
70 v8::TryCatch block; \ 52 v8::TryCatch block; \
71 var = (value); \ 53 var = (value); \
72 if (UNLIKELY(block.HasCaught())) { \ 54 if (UNLIKELY(block.HasCaught())) { \
73 block.ReThrow(); \ 55 block.ReThrow(); \
74 return; \ 56 return; \
75 } \ 57 } \
76 } 58 }
77 59
78 #define V8TRYCATCH_EXCEPTION_VOID(type, var, value, exceptionState) \ 60 #define TONATIVE_BOOL(type, var, value, retVal) \
79 type var; \ 61 type var; \
80 { \ 62 { \
81 v8::TryCatch block; \ 63 v8::TryCatch block; \
82 var = (value); \ 64 var = (value); \
83 if (UNLIKELY(block.HasCaught())) \ 65 if (UNLIKELY(block.HasCaught())) { \
84 exceptionState.rethrowV8Exception(block.Exception()); \ 66 block.ReThrow(); \
85 if (UNLIKELY(exceptionState.throwIfNeeded())) \ 67 return retVal; \
86 return; \ 68 } \
87 } 69 }
88 70
89 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_RETURN(type, var, value, retVal) \ 71 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \
90 type var(value); \ 72 type var; \
91 if (UNLIKELY(!var.prepare())) \ 73 { \
74 v8::TryCatch block; \
75 var = (value); \
76 if (UNLIKELY(block.HasCaught())) \
77 exceptionState.rethrowV8Exception(block.Exception()); \
78 if (UNLIKELY(exceptionState.throwIfNeeded())) \
79 return; \
80 }
81
82 #define TONATIVE_BOOL_EXCEPTIONSTATE(type, var, value, exceptionState, retVal) \
83 type var; \
84 { \
85 v8::TryCatch block; \
86 var = (value); \
87 if (UNLIKELY(block.HasCaught())) \
88 exceptionState.rethrowV8Exception(block.Exception()); \
89 if (UNLIKELY(exceptionState.throwIfNeeded())) \
90 return retVal; \
91 }
92
93 // type is an instance of class template V8StringResource<>,
94 // but Mode argument varies; using type (not Mode) for consistency
95 // with other macros and ease of code generation
96 #define TOSTRING_VOID(type, var, value) \
97 type var(value); \
98 if (UNLIKELY(!var.prepare())) \
99 return;
100
101 #define TOSTRING_BOOL(type, var, value, retVal) \
102 type var(value); \
103 if (UNLIKELY(!var.prepare())) \
92 return retVal; 104 return retVal;
93 105
94 #define V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(type, var, value) \
95 type var(value); \
96 if (UNLIKELY(!var.prepare())) \
97 return;
98
99 } // namespace WebCore 106 } // namespace WebCore
100 107
101 #endif // V8BindingMacros_h 108 #endif // V8BindingMacros_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/V8Binding.cpp ('k') | Source/bindings/v8/V8Initializer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698