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

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

Issue 265293004: Create fewer local v8::TryCatch objects in generated bindings code (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: added comment Created 6 years, 7 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 | « Source/bindings/tests/results/V8TestTypedefs.cpp ('k') | Source/bindings/v8/V8StringResource.h » ('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 28 matching lines...) Expand all
39 39
40 #define TONATIVE_EXCEPTION(type, var, value) \ 40 #define TONATIVE_EXCEPTION(type, var, value) \
41 type var; \ 41 type var; \
42 { \ 42 { \
43 v8::TryCatch block; \ 43 v8::TryCatch block; \
44 var = (value); \ 44 var = (value); \
45 if (UNLIKELY(block.HasCaught())) \ 45 if (UNLIKELY(block.HasCaught())) \
46 return block.ReThrow(); \ 46 return block.ReThrow(); \
47 } 47 }
48 48
49 #define TONATIVE_VOID_INTERNAL(var, value) \
50 var = (value); \
51 if (UNLIKELY(block.HasCaught())) { \
52 block.ReThrow(); \
53 return; \
54 }
55
49 #define TONATIVE_VOID(type, var, value) \ 56 #define TONATIVE_VOID(type, var, value) \
50 type var; \ 57 type var; \
51 { \ 58 { \
52 v8::TryCatch block; \ 59 v8::TryCatch block; \
53 var = (value); \ 60 TONATIVE_VOID_INTERNAL(var, value); \
54 if (UNLIKELY(block.HasCaught())) { \
55 block.ReThrow(); \
56 return; \
57 } \
58 } 61 }
59 62
60 #define TONATIVE_DEFAULT(type, var, value, retVal) \ 63 #define TONATIVE_DEFAULT(type, var, value, retVal) \
61 type var; \ 64 type var; \
62 { \ 65 { \
63 v8::TryCatch block; \ 66 v8::TryCatch block; \
64 var = (value); \ 67 var = (value); \
65 if (UNLIKELY(block.HasCaught())) { \ 68 if (UNLIKELY(block.HasCaught())) { \
66 block.ReThrow(); \ 69 block.ReThrow(); \
67 return retVal; \ 70 return retVal; \
68 } \ 71 } \
69 } 72 }
70 73
71 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \ 74 #define TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState) \
72 type var; \ 75 var = (value); \
73 { \ 76 if (UNLIKELY(block.HasCaught())) \
74 v8::TryCatch block; \ 77 exceptionState.rethrowV8Exception(block.Exception()); \
75 var = (value); \ 78 if (UNLIKELY(exceptionState.throwIfNeeded())) \
76 if (UNLIKELY(block.HasCaught())) \ 79 return;
77 exceptionState.rethrowV8Exception(block.Exception()); \ 80
78 if (UNLIKELY(exceptionState.throwIfNeeded())) \ 81 #define TONATIVE_VOID_EXCEPTIONSTATE(type, var, value, exceptionState) \
79 return; \ 82 type var; \
83 { \
84 v8::TryCatch block; \
85 TONATIVE_VOID_EXCEPTIONSTATE_INTERNAL(var, value, exceptionState); \
80 } 86 }
81 87
82 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal ) \ 88 #define TONATIVE_DEFAULT_EXCEPTIONSTATE(type, var, value, exceptionState, retVal ) \
83 type var; \ 89 type var; \
84 { \ 90 { \
85 v8::TryCatch block; \ 91 v8::TryCatch block; \
86 var = (value); \ 92 var = (value); \
87 if (UNLIKELY(block.HasCaught())) \ 93 if (UNLIKELY(block.HasCaught())) \
88 exceptionState.rethrowV8Exception(block.Exception()); \ 94 exceptionState.rethrowV8Exception(block.Exception()); \
89 if (UNLIKELY(exceptionState.throwIfNeeded())) \ 95 if (UNLIKELY(exceptionState.throwIfNeeded())) \
90 return retVal; \ 96 return retVal; \
91 } 97 }
92 98
93 // type is an instance of class template V8StringResource<>, 99 // type is an instance of class template V8StringResource<>,
94 // but Mode argument varies; using type (not Mode) for consistency 100 // but Mode argument varies; using type (not Mode) for consistency
95 // with other macros and ease of code generation 101 // with other macros and ease of code generation
96 #define TOSTRING_VOID(type, var, value) \ 102 #define TOSTRING_VOID(type, var, value) \
97 type var(value); \ 103 type var(value); \
98 if (UNLIKELY(!var.prepare())) \ 104 if (UNLIKELY(!var.prepare())) \
99 return; 105 return;
100 106
107 #define TOSTRING_VOID_INTERNAL(var, value) \
108 var = (value); \
109 if (UNLIKELY(!var.prepare())) \
110 return;
111
112 #define TOSTRING_VOID_INTERNAL_RETHROW(var, value, block) \
113 var = (value); \
114 if (UNLIKELY(!var.prepare())) { \
115 block.ReThrow(); \
116 return; \
117 }
118
101 #define TOSTRING_DEFAULT(type, var, value, retVal) \ 119 #define TOSTRING_DEFAULT(type, var, value, retVal) \
102 type var(value); \ 120 type var(value); \
103 if (UNLIKELY(!var.prepare())) \ 121 if (UNLIKELY(!var.prepare())) \
104 return retVal; 122 return retVal;
105 123
106 } // namespace WebCore 124 } // namespace WebCore
107 125
108 #endif // V8BindingMacros_h 126 #endif // V8BindingMacros_h
OLDNEW
« no previous file with comments | « Source/bindings/tests/results/V8TestTypedefs.cpp ('k') | Source/bindings/v8/V8StringResource.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698