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

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

Issue 1492763002: Add a utility class to call stream methods implemented with v8 extras. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@v8-extra-switch
Patch Set: Created 5 years 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
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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 71
72 template <typename T> 72 template <typename T>
73 inline bool v8Call(v8::Maybe<T> maybe, T& outVariable, v8::TryCatch& tryCatch) 73 inline bool v8Call(v8::Maybe<T> maybe, T& outVariable, v8::TryCatch& tryCatch)
74 { 74 {
75 bool success = v8Call(maybe, outVariable); 75 bool success = v8Call(maybe, outVariable);
76 ASSERT(success || tryCatch.HasCaught()); 76 ASSERT(success || tryCatch.HasCaught());
77 return success; 77 return success;
78 } 78 }
79 79
80 template <typename T> 80 template <typename T>
81 inline bool v8Call(v8::MaybeLocal<T> maybeLocal, v8::Local<T>& outVariable)
82 {
83 return maybeLocal.ToLocal(&outVariable);
84 }
85
86 template <typename T>
81 inline bool v8Call(v8::MaybeLocal<T> maybeLocal, v8::Local<T>& outVariable, v8:: TryCatch& tryCatch) 87 inline bool v8Call(v8::MaybeLocal<T> maybeLocal, v8::Local<T>& outVariable, v8:: TryCatch& tryCatch)
82 { 88 {
83 bool success = maybeLocal.ToLocal(&outVariable); 89 bool success = maybeLocal.ToLocal(&outVariable);
84 ASSERT(success || tryCatch.HasCaught()); 90 ASSERT(success || tryCatch.HasCaught());
85 return success; 91 return success;
86 } 92 }
87 93
88 template <typename T> 94 template <typename T>
89 inline T v8CallOrCrash(v8::Maybe<T> maybe) 95 inline T v8CallOrCrash(v8::Maybe<T> maybe)
90 { 96 {
91 return maybe.FromJust(); 97 return maybe.FromJust();
92 } 98 }
93 99
94 template <typename T> 100 template <typename T>
95 inline v8::Local<T> v8CallOrCrash(v8::MaybeLocal<T> maybeLocal) 101 inline v8::Local<T> v8CallOrCrash(v8::MaybeLocal<T> maybeLocal)
96 { 102 {
97 return maybeLocal.ToLocalChecked(); 103 return maybeLocal.ToLocalChecked();
98 } 104 }
99 105
100 // The last "else" is to avoid dangling else problem. 106 // The last "else" is to avoid dangling else problem.
101 #define V8_CALL(outVariable, handle, methodCall, failureExpression) \ 107 #define V8_CALL(outVariable, handle, methodCall, failureExpression) \
102 if (handle.IsEmpty() || !v8Call(handle->methodCall, outVariable)) { \ 108 if (handle.IsEmpty() || !v8Call(handle->methodCall, outVariable)) { \
103 failureExpression; \ 109 failureExpression; \
104 } else 110 } else
105 111
106 } // namespace blink 112 } // namespace blink
107 113
108 #endif // V8BindingMacros_h 114 #endif // V8BindingMacros_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/core/v8/ScriptState.cpp ('k') | third_party/WebKit/Source/bindings/core/v8/v8.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698